check_spl#
- pypulseqpp.safety.check_spl()[source]#
Check the sound pressure level of the sequence’s loudest repetition, played without end.
The repetition is the one of
repetition(), counted from block 1, over which the squared gradient summed over the axes integrates to the most, the earliest on a tie. It is filtered byresponseas a periodic waveform, so the levels are those of the steady state it reaches when played back to back.- Parameters:
seq (Sequence) – Sequence to check.
response (AcousticResponse) – The gradient coil’s acoustic transfer function, on the physical axes; see
read_acoustic_response().rotation (array_like, default=None) – 3x3 prescription rotation from logical to physical axes, applied after each block’s own rotation; identity (axial) by default.
peak_limit (float, default=140.0) – Largest peak level allowed, in dB.
average_limit (float, default=99.0) – Largest A-weighted average level allowed, in dB(A).
system (pypulseqpp.Opts, default=None) – Source of the gyromagnetic ratio; the sequence’s own by default.
- Returns:
is_ok (bool) – True when neither level exceeds its limit.
report (SimpleNamespace) –
peak, the largest sound pressure in dB;average, the A-weighted RMS sound pressure in dB(A);average_unweighted, the RMS sound pressure in dB;peak_limitandaverage_limit;repetition, the 1-based first and last block of the repetition evaluated; and itsduration(s). A sequence without gradients reads-inf.
- Raises:
ValueError – If
rotationis not a 3x3 orthonormal matrix, orresponseis not three axes of bins.
Notes
The repetition is sampled at the centres of
nequal intervals,nthe smallest transform length with only small prime factors that reaches the highest frequencyresponsetabulates. Its harmonicsk / durationare weighted byresponse, linearly interpolated between bins and zero above them, and summed over the axes; the averages are taken over the harmonics (Parseval), the A-weighted one witha_weighting(). Levels are referred to 20 uPa.Examples
>>> import numpy as np >>> import pypulseqpp as pp >>> from pypulseqpp import safety >>> seq = pp.Sequence(pp.Opts()) >>> for _ in range(4): ... _ = seq.add_block(pp.make_trapezoid("x", amplitude=4e5, flat_time=1e-3)) >>> flat = safety.AcousticResponse(np.full((3, 2049), 0.5 + 0j), 5.0) >>> is_ok, report = safety.check_spl(seq, flat) >>> is_ok, report.repetition (True, (1, 1))