nirspipe.qc.figures.subject.sci_psp_panel#

Module Contents#

Functions#

channel_quality_heatmap

Square-marker grid: channels on x-axis, metrics on y-axis. Green=pass, red=fail, gray=missing.

condition_quality_heatmap

Every condition’s channel grid, regrouped: one block per metric, one row per condition.

member_condition_heatmap

A group’s channel status, one block per member: the run’s verdict, then each condition’s.

trial_quality_heatmap

Trial x metric heatmap: which trials stand out, on which metric.

lollipop_scores_figure

build_sci_psp_figure

Channel quality over time: one heatmap row per metric, its channel mean beside it.

Data#

API#

nirspipe.qc.figures.subject.sci_psp_panel.logger = 'get_logger(...)'#
nirspipe.qc.figures.subject.sci_psp_panel.channel_quality_heatmap(ch_names: list[str], is_bad: list[bool], sci_per_ch: dict[str, float], cv_per_ch: dict[str, float], snr_per_ch: dict[str, float], psp_per_ch: dict[str, float], good_frac_per_ch: dict[str, float] | None = None, *, sci_thresh: float, cv_thresh: float = CV_PASS, snr_thresh: float = SNR_PASS, psp_thresh: float | None = None, good_frac_thresh: float = GOOD_FRAC_PASS, split_at: int | None = None) → plotly.graph_objects.Figure#

Square-marker grid: channels on x-axis, metrics on y-axis. Green=pass, red=fail, gray=missing.

split_at is the index the short channels start at, given when the caller has already ordered ch_names long block first; it draws the divider and names the two blocks.

Status is the screening verdict and Passing is the row that produces it, which is why it sits directly under: a channel can fail on its passing-window share with every average below it comfortable. The rows under it are drawn against the cutoffs in nirspipe.qc.metrics._helpers and none of them prunes; PSP with psp_thresh None runs the same ramp from 0 to PSP_SCALE_MAX, higher better, with a colour bar.

nirspipe.qc.figures.subject.sci_psp_panel.condition_quality_heatmap(conditions: list[tuple[str, dict]], *, sci_thresh: float, cv_thresh: float = CV_PASS, snr_thresh: float = SNR_PASS, psp_thresh: float | None = None, good_frac_thresh: float = GOOD_FRAC_PASS, status_label: str = 'Status', status_words: tuple[str, str] = ('OK', 'BAD')) → plotly.graph_objects.Figure | None#

Every condition’s channel grid, regrouped: one block per metric, one row per condition.

conditions pairs each label with the heatmap_args() dict its own page draws from, and the pass rule is channel_quality_heatmap()’s, so a cell here is that page’s cell. Grouping by metric puts one channel’s conditions in a column, which is the comparison this figure exists for.

Example: [(“rest”, args_a), (“task”, args_b)] -> six blocks (Status … SNR), each two rows deep, channels across.

Columns follow the first condition’s order. Returns None under two conditions, where the run’s own grid already says everything.

nirspipe.qc.figures.subject.sci_psp_panel.member_condition_heatmap(pairs: list[str], status: dict[str, dict], subject_ids: list[str], labels: list[str], *, split_at: int | None = None, row_label: str | None = None) → plotly.graph_objects.Figure | None#

A group’s channel status, one block per member: the run’s verdict, then each condition’s.

status is condition_channel_status(). Each block is a Run row (kept / rejected) and one row per label (pass / fail); row_label names a lone condition row instead of the label, as a condition page does.

Example: two members, labels [“ca”, “cb”] -> two blocks of three rows, pairs across.

None when no member has a result in any of labels.

nirspipe.qc.figures.subject.sci_psp_panel.trial_quality_heatmap(trial_labels: list[str], trial_sqms: list[dict]) → plotly.graph_objects.Figure | None#

Trial x metric heatmap: which trials stand out, on which metric.

Each metric row is scaled to its own min-max across trials, because SCI (0 to 1) and SNR (tens to hundreds) share no range and one colour scale over both would flatten SCI to a single shade. Colour is therefore relative within a row: red marks the worse end of what this recording actually did, not a threshold anyone crossed. Hover carries the real value.

Example: 40 trials whose SCI holds near 0.9 except trials 12 and 13 gives a mostly uniform SCI row with two red cells.

Returns None when no metric survives on any trial (nothing to draw).

nirspipe.qc.figures.subject.sci_psp_panel.lollipop_scores_figure(ch_names: list[str], mean_scores: numpy.ndarray, colors: list[str], threshold: float | None, metric_label: str = 'Score') → plotly.graph_objects.Figure#
nirspipe.qc.figures.subject.sci_psp_panel.build_sci_psp_figure(sci_scores: dict[str, float], psp_per_channel: dict[str, float], bad_channels: set[str], sci_threshold: float, psp_threshold: float | None = None, sci_matrix: numpy.ndarray | None = None, sci_win_times: numpy.ndarray | None = None, psp_matrix: numpy.ndarray | None = None, psp_win_times: numpy.ndarray | None = None, cv_matrix: numpy.ndarray | None = None, cv_win_times: numpy.ndarray | None = None, cv_threshold: float = CV_PASS, window_s: float | None = None, warn: list[str] | None = None) → plotly.graph_objects.Figure#

Channel quality over time: one heatmap row per metric, its channel mean beside it.

Every row is measured on the uncorrected optical density and on one window grid, so a column in the CV row is the same stretch of recording as the column above it in SCI.

CV carries SNR rather than getting a row of its own: the record stores SNR as 1/CV exactly, so a second row would be the same numbers reflected, and the hover prints both. CV is also the one row where low is good, which is why it takes the reversed scale.

SCI and PSP get a row per source-detector pair, since both compare the pair’s two wavelengths; CV is measured on each wavelength and keeps a row for each. A pair whose two SCI or PSP rows disagree is drawn a row per wavelength and said so in warn.

The lollipop beside each row is that row averaged along time, so the dot and the strip are one measurement, rather than the record’s scalar of the same name -- which for SCI is the whole-run correlation and not the windowed one the strip draws.

psp_threshold None draws PSP with no line: the rows’ red-to-green scale from 0 to PSP_SCALE_MAX, higher better, and each dot in its value’s colour on that scale.

Without the windowed matrices this falls back to the lollipop-only pair.