check_mech_resonance#
- pypulseqpp.safety.check_mech_resonance()[source]#
Check the gradient amplitude spectrum against forbidden gradient bands.
- Parameters:
seq (Sequence) – Sequence to check.
bands (iterable of ForbiddenBand, or path) – Bands as
(axis, f_min, f_max, tolerance), or a table forread_forbidden_bands().window_width (float, default=0.04) – Window length in seconds.
stride (float, default=None) – Step between window starts in seconds;
window_width / 2by default.frequency_oversampling (int, default=3) – Zero-padded transform length, in window lengths.
min_threshold (float, default=10.0) – Threshold in mT/m for a band whose tolerance is 0.
rotation (array_like, default=None) – 3x3 prescription rotation from logical to physical axes, applied after each block’s own rotation; identity (axial) by default.
system (pypulseqpp.Opts, default=None) – Source of the gyromagnetic ratio; the sequence’s own by default.
- Returns:
is_ok (bool) – True when no window exceeds any band’s threshold.
report (SimpleNamespace) –
window_width,stride(as sampled, s),frequency_step(Hz),windows, the FFTbackend, andbands: one entry per band, in the order given, with the band’saxis(None for every axis),f_min,f_max,toleranceand appliedthreshold(mT/m); the band’s worst window, kept whether or not it violates: its largestpeakamplitude (mT/m), onpeak_axisatfrequency, in the 0-basedwindowstarting atwindow_start(s);violations, the windows exceeding the threshold on any guarded axis; andaxes, the same reading for each guarded axis on its own.
- Raises:
ValueError – If a band’s frequency range is empty or negative, or a rotation is not a 3x3 matrix.
Notes
The gradient is sampled at the centres of the sequence’s own gradient raster, the one its definitions record. Each window is mean-subtracted, Hann-tapered and zero-padded before a real FFT, and a bin’s amplitude is
2 |X_k| / sum(w), so a sustained sinusoid of amplitude A at a bin frequency reads A. A band’s threshold is its tolerance where that is positive andmin_thresholdotherwise. The FFT is MKL’s when themklpackage is installed, and pocketfft otherwise.