check_pns

Contents

check_pns#

pypulseqpp.safety.check_pns()[source]#

Check peripheral nerve stimulation against a SAFE or chronaxie model.

Parameters:
  • seq (Sequence) – Sequence to check.

  • model (ChronaxieModel, mapping, SAFE description, or path) – A ChronaxieModel or a mapping of its fields; a SAFE description shaped like upstream’s safe_example_hw(); or a .asc file for read_safe_model().

  • 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.

  • trace (bool, default=False) – Also return the response over time, which a diagnostic plot draws. The trace is one value per gradient raster interval over the whole sequence, so it costs four arrays of samples each.

Returns:

  • is_ok (bool) – True when the axis-combined response, as a fraction of the model’s threshold, stays below 1 at every sample.

  • report (SimpleNamespace) – model ("safe" or "chronaxie"), raster (s), samples, peak, the largest root-sum-square response, and axes, the largest response of each of x, y and z. A peak carries value as a fraction of threshold, the sample time (s) and the 1-based block that plays it. Under trace, time (s), response – the root-sum-square, as a fraction of threshold – and each axis’s own response, all of length samples.

Notes

The gradient is sampled at the centres of the sequence’s own gradient raster, from rest, and its slew is the difference between neighbouring samples; this and the SAFE model are upstream PyPulseq’s calc_pns. The response is evaluated over the whole sequence in one pass, carrying each model’s memory, in bounded storage.