nirspipe.qc.metrics#
Compute signal quality metrics (SQM) for fNIRS data.
Established metrics: SCI, PSP, CV, SNR, GVTD. Experimental (may change or be removed): Cardiac Power (CP), per-chromophore gcor, spike and motion-correction footprint, low-frequency drift.
One module per metric family, layered so the imports run one way:
_helpers shared plumbing: _safe_metrics, _mask_to_segments, long_short_channels
gvtd the global motion index, its threshold, and BAD_gvtd censoring
coupling SCI, PSP, CV, SNR, amplitude, channel distance, CP
motion per-channel spikes and the motion-correction footprint
haemo HbO-HbR correlation, CNR, band powers, gcor, drift, retention
windowed the same questions per window, on one shared grid
imu head movement from the IMU: its summaries and its agreement with GVTD
aggregate the dicts a run stores, assembled from the families above
hyper the dyad-level questions: the shared screening grid and its scalars
Every name is re-exported here, so from nirspipe.qc.metrics import X reaches any of
them and a caller need not know which module X is in.
Each compute_* function returns a flat dict and does no I/O. Assembling them into a per-run record on disk is qc/sqm_record.py’s job, not this package’s.
Bad channels are handled by signal domain, not per function. The Beer-Lambert conversion is the line:
- intensity / OD (compute_raw_sqm and its helpers, motion_correction_metrics)
aggregates cover every channel, rejected ones included. A rejected channel is still part of what the machine recorded, and this is the archival view.
- haemoglobin (compute_haemo_sqm, compute_prep_haemo_sqm)
aggregates exclude them, which is what mne.pick_types does by default. By this stage the channel is out of the analysis.
Do not “fix” an intensity/OD function to exclude bads. Doing so to _sci_metrics in particular makes sci_mean an average over channels chosen for having good SCI, which cannot fall below the threshold no matter how bad the recording is.
Per-channel dicts always list every channel, in both domains.