nirspipe.qc.boilerplate.vocabulary#
The bridge between the step names the pipeline records and the prose describing them. Two vocabularies exist and they sit at different granularities on purpose, so this maps rather than renames:
the pipeline records one
motion_correctionstep with the method as a parameter, whilesteps.tomlneeds one paragraph per method because the citations differthe pipeline records one
bandpassstep with two cutoffs, while the prose splits into bandpass / highpass / lowpass depending on which cutoff was givenglm_fitandglm_residualsare two files from one regression described in a single paragraph, a task GLM or a confound regression depending on the conditions they record
Steps with no paragraph are not omissions: reading a file or recording quality metrics is
bookkeeping, not method, and putting it in steps.toml would leak it into the Methods
section. Those get a plain one-liner here instead.
Module Contents#
Functions#
Section of steps.toml describing this step, or None when it has no method prose. |
|
Fill a section’s {slots} from a sidecar’s parameters. |
|
What a metric is, which way is good, and what stage it was measured on.
Returns ‘’ for an undescribed metric, so the report renders a bare number rather than
an empty tooltip. |
|
What one record key holds, or ‘’ when nothing describes it. |
|
|
|
The one grid every run was measured on, or None when they differ or one is unknown. |
|
A stored value in the unit its label names, for a figure that plots it. |
|
|
|
Three significant figures, never an exponent; thousands grouped above 1000. sig3(0.000151) -> “0.000151” sig3(13.59) -> “13.6” sig3(574812) -> “575,000” |
|
“higher”, “lower”, or None for a metric with no better end. |
|
The direction as a flag, for callers that scale a value within its own range. |
|
One metric as a panel prints it, or an em dash when the run did not measure it. |
|
CSS class for a metric’s value, or ‘’ when the metric has no established cutoff. |
|
A scalar panel’s rows, ready for whatever renders them. |
|
Sections a step’s |
|
Every method step the sidecars under |
|
The method steps behind one file, read up its chain of |
Data#
API#
- nirspipe.qc.boilerplate.vocabulary.boilerplate_key(step: str | None, params: dict[str, Any]) str | None#
Section of steps.toml describing this step, or None when it has no method prose.
- nirspipe.qc.boilerplate.vocabulary.template_slots(key: str, params: dict[str, Any]) dict[str, str]#
Fill a section’s {slots} from a sidecar’s parameters.
Note the naming: a sidecar’s
high_passis the lower edge of the band, which the filter templates calll_freq.
- nirspipe.qc.boilerplate.vocabulary.STEP_SUMMARY = None#
- nirspipe.qc.boilerplate.vocabulary.METRIC_SUMMARY = None#
- nirspipe.qc.boilerplate.vocabulary.KEY_METRICS = 'frozenset(...)'#
- nirspipe.qc.boilerplate.vocabulary.METRIC_STAGE = None#
- nirspipe.qc.boilerplate.vocabulary.metric_summary(metric: str, condition: bool = False) str#
What a metric is, which way is good, and what stage it was measured on. Returns ‘’ for an undescribed metric, so the report renders a bare number rather than an empty tooltip.
conditionis a condition page, whose GVTD numbers come from one file.
- nirspipe.qc.boilerplate.vocabulary.RECORD_SECTIONS = None#
- nirspipe.qc.boilerplate.vocabulary.RECORD_CHANNEL_METRICS = None#
- nirspipe.qc.boilerplate.vocabulary.RECORD_CHANNEL_COLUMNS = None#
- nirspipe.qc.boilerplate.vocabulary.CHANNEL_QC_COLUMNS = None#
- nirspipe.qc.boilerplate.vocabulary.RECORD_WINDOW_COLUMNS = None#
- nirspipe.qc.boilerplate.vocabulary.RECORD_EXTRA_KEYS = None#
- nirspipe.qc.boilerplate.vocabulary.RECORD_CV_BY_WAVELENGTH = 'cv_mean over the {nm} nm channels only.'#
- nirspipe.qc.boilerplate.vocabulary.COHORT_SECTIONS = None#
- nirspipe.qc.boilerplate.vocabulary.COHORT_ID_COLUMN = 'The run this row describes, by its BIDS entities.'#
- nirspipe.qc.boilerplate.vocabulary.CONDITION_COLUMNS = None#
- nirspipe.qc.boilerplate.vocabulary.CONDITION_METRICS = None#
- nirspipe.qc.boilerplate.vocabulary.CONDITION_WINDOW = "Measured over the condition's window."#
- nirspipe.qc.boilerplate.vocabulary.record_key_summary(key: str) str#
What one record key holds, or ‘’ when nothing describes it.
- nirspipe.qc.boilerplate.vocabulary.DISPLAY_UNITS = None#
- nirspipe.qc.boilerplate.vocabulary.METRIC_DISPLAY: dict[str, tuple[str, str, tuple[float, float] | None, str | None]] = None#
- nirspipe.qc.boilerplate.vocabulary.MISSING_VALUE = '—'#
- nirspipe.qc.boilerplate.vocabulary.grid_window_label(label: str, metric: str, window_s: float | None) str#
labelnaming the grid a condition value was sliced from:window_s, or “windowed” when the runs read together were measured on different grids.("SCI (10 s)", "sci_win_mean", 12.0) -> "SCI (12 s)"
The one grid every run was measured on, or None when they differ or one is unknown.
- nirspipe.qc.boilerplate.vocabulary.metric_label(metric: str, fallback: str | None = None, condition: bool = False) str#
- nirspipe.qc.boilerplate.vocabulary.display_value(metric: str, value: float) float#
A stored value in the unit its label names, for a figure that plots it.
- nirspipe.qc.boilerplate.vocabulary.with_unit(metric: str, label: str) str#
labelwith the metric’s display unit, folded into a trailing parenthesis.with_unit(“lowfreq_drift_amplitude_hbo”, “Low-freq drift (HbO)”) -> “Low-freq drift (HbO, µM)” with_unit(“gvtd_p95”, “GVTD p95”) -> “GVTD p95 (mOD/sample)” with_unit(“sci_mean”, “Mean SCI”) -> “Mean SCI”
- nirspipe.qc.boilerplate.vocabulary.sig3(value: float) str#
Three significant figures, never an exponent; thousands grouped above 1000. sig3(0.000151) -> “0.000151” sig3(13.59) -> “13.6” sig3(574812) -> “575,000”
- nirspipe.qc.boilerplate.vocabulary.metric_direction(metric: str) str | None#
“higher”, “lower”, or None for a metric with no better end.
None is a real answer and not a gap: mean amplitude, the separations and the GVTD threshold are descriptive, so ranking or colouring them would invent a verdict.
- nirspipe.qc.boilerplate.vocabulary.higher_is_better(metric: str) bool | None#
The direction as a flag, for callers that scale a value within its own range.
- nirspipe.qc.boilerplate.vocabulary.format_metric(metric: str, value: Any, fmt: str | None = None) str#
One metric as a panel prints it, or an em dash when the run did not measure it.
format_metric(“sci_mean”, 0.8132) -> “0.813” format_metric(“pct_data_retained”, 0.9241) -> “92.4%” format_metric(“spike_count”, None) -> “—”
fmtoverrides the registry for the rare caller that needs a different width; every other caller gets the format the metric is defined with, so one number does not print to three decimals in one view and two in the next.
- nirspipe.qc.boilerplate.vocabulary.metric_class(metric: str, value: Any) str#
CSS class for a metric’s value, or ‘’ when the metric has no established cutoff.
metric_class(“sci_mean”, 0.81) -> “qm-ok” metric_class(“psp_mean”, 0.81) -> “” (no published threshold) The empty string is deliberate and is not a passing verdict: a metric nobody has a cutoff for prints in the default colour rather than being called good.
- nirspipe.qc.boilerplate.vocabulary.metric_rows(scalars: dict[str, Any], keys: Sequence[str] | None = None, *, skip_missing: bool = False, condition: bool = False) list[dict[str, Any]]#
A scalar panel’s rows, ready for whatever renders them.
metric_rows({"sci_mean": 0.81}, ["sci_mean"]) -> [{"key": "sci_mean", "label": "Mean SCI", "value": "0.810", "cls": "qm-ok", "tip": "Scalp coupling: ...", "key_metric": True}]
Every view that prints these numbers goes through here, so a threshold or a label moves in one place instead of once per renderer.
keysis the print order and defaults to every described metric the dict carries;skip_missingdrops what the run did not measure rather than printing a row of dashes for it.
- nirspipe.qc.boilerplate.vocabulary.span_keys(step: str | None, params: dict[str, Any], spans: list) list[str]#
Sections a step’s
BAD_spans add beside its own sentence.sci_pruning with BAD_unselected and --gvtd-censor -> ["excluded_unselected", "gvtd_censoring"]
- nirspipe.qc.boilerplate.vocabulary.steps_from_sidecars(nirs_dir: pathlib.Path, label: str | None = None) list[tuple[str, dict[str, str]]]#
Every method step the sidecars under
nirs_dirrecord, ordered by graph depth.labelis a run stem (sub-01_task-rest) and keeps another run’s files out of the paragraph, the wayscan()scopes its graph.
- nirspipe.qc.boilerplate.vocabulary.steps_from_lineage(path: str | Path) list[tuple[str, dict[str, str]]] | None#
The method steps behind one file, read up its chain of
Sources..../sub-01_task-rest_desc-preproc_nirs.snirf -> od_conversion, sci_marking, motion_tddr, beer_lambert (no filter, no regression)
What a later stage did to the same recording is not in the chain, so a reader of an earlier stage is never described as having read the later one. None when the file’s own record cannot be found, which is a moved tree or an input this package did not write.