nirspipe.qc.figures.subject.group_figures#
Plotly figure builders for cohort-level QC reports (individual and hyper).
Module Contents#
Functions#
Recorded to be checked against, not shown: |
|
Split metric_cols into (groups, ordered_flat) following _METRIC_GROUPS; leftovers -> ‘Other’. |
|
The quantity a column measures, which the outlier score counts once. |
|
Per run, the mean over metric families of each family’s mean |
|
{bids_name: [worst metrics]} for runs whose |
|
One row per metric, one dot per run at its robust z, colour = channel set. |
|
Metric x channel-set grid over time: every run pale, the cohort’s band and median over. |
|
One colour per condition, by the rule the run report’s markers already follow. |
|
One run’s windowed metrics over time, the conditions shaded behind them. |
|
Conditions the cohort has, in the order the first run that carries them wrote them. |
|
One panel per metric: x is the condition, one line per run, the median over them. |
|
run x condition, one panel per metric, colour = robust z inside that condition. |
|
channel x condition for one run, the panels and order of |
|
Flow of small real-value charts, one per scale-homogeneous group. |
|
(bin centres, density) of |
|
Each run’s channel-pair r before and after the regression, pale, with the cohort median; a row per task and chromophore. |
|
The density r takes across |
|
Each connection’s r with movement: counted by r beside the spread with no relation, and against the channels’ distance; a row per task. |
Data#
API#
- nirspipe.qc.figures.subject.group_figures.check_only(col: str) bool#
Recorded to be checked against, not shown:
imu_gyro_speed_gvtd_rho-> True.
- nirspipe.qc.figures.subject.group_figures.group_metrics(metric_cols: list[str]) tuple[list[tuple[str, list[str]]], list[str]]#
Split metric_cols into (groups, ordered_flat) following _METRIC_GROUPS; leftovers -> ‘Other’.
Matching ignores the section prefix, so
raw_sci_meanandraw_long_sci_meanboth land in the coupling group while staying separate columns. Settings are dropped rather than grouped, so neither the ordering nor the charts carry them, and so are the metrics recorded only to be checked against.
- nirspipe.qc.figures.subject.group_figures.SCORE_THRESHOLD = 2.0#
- nirspipe.qc.figures.subject.group_figures.metric_family(col: str) str#
The quantity a column measures, which the outlier score counts once.
"raw_long_gvtd_filt_p95" -> "GVTD amplitude" "motion_post_gvtd_num_above_thresh" -> "Motion & spike fraction" "raw_heart_rate" -> "heart_rate"
- nirspipe.qc.figures.subject.group_figures.deviation_scores(df: pandas.DataFrame, metric_cols: list[str]) numpy.ndarray#
Per run, the mean over metric families of each family’s mean
|z|.A quantity the record holds under several stages and channel sets counts once, so a run is not called out for one quantity written down twelve times.
- nirspipe.qc.figures.subject.group_figures.detect_outliers(df: pandas.DataFrame, metric_cols: list[str], threshold: float = SCORE_THRESHOLD) dict[str, list[str]]#
{bids_name: [worst metrics]} for runs whose
deviation_scores()is past the threshold.The metric list is what put the run there, worst first and one column per family, so the reader gets the reason beside the verdict rather than one quantity under six names.
- nirspipe.qc.figures.subject.group_figures.build_deviation_strip(df: pandas.DataFrame, metric_cols: list[str]) tuple[go.Figure | None, list[str]]#
One row per metric, one dot per run at its robust z, colour = channel set.
This is the report’s overview. The metric names are horizontal, the cohort’s spread is the width of its dot cloud, and a run sitting apart is apart on the axis rather than a shade darker.
Returns (figure, dropped): a metric every run agreed on has no z to plot and is named in the report’s notes instead.
- nirspipe.qc.figures.subject.group_figures.SMOOTH_S = 60.0#
- nirspipe.qc.figures.subject.group_figures.build_window_grid(rows: list[dict], highlight: list[str] | None = None, metrics: tuple = ('sci', 'cv', 'gvtd')) plotly.graph_objects.Figure | None#
Metric x channel-set grid over time: every run pale, the cohort’s band and median over.
Rows are metrics and columns are channel sets, sharing the y axis along a row so the three sets are read against each other.
highlightnames runs that keep a line of their own, one colour each, the same colour in every cell.
- nirspipe.qc.figures.subject.group_figures.condition_colours(conditions: list[str]) dict[str, str]#
One colour per condition, by the rule the run report’s markers already follow.
raw_figures.condition_colorscyclesCONDITION_PALETTEover the descriptions in the order they first appear, and a condition keeps the colour it wears there, so a band on this page and a marker on the run report are the same colour for the same block.
- nirspipe.qc.figures.subject.group_figures.build_condition_timeline(row: dict, windows: list[tuple[str, float, float]], metrics: tuple = ('sci', 'cv', 'gvtd')) plotly.graph_objects.Figure | None#
One run’s windowed metrics over time, the conditions shaded behind them.
The channel sets share a panel, where the cohort’s
build_window_grid()gives each a column. Long and short only:allis a blend of the two and lands between them.Smoothed over
SMOOTH_Sand sampled at that step.Colours come from the run report rather than from
_SET_COLOURS, whose long-channel blue is the one_utils.HBR_COLORuses;LONG_COLORandSHORT_COLORare the separation split every raw-level view already wears.
- nirspipe.qc.figures.subject.group_figures.condition_names(rows: list[dict]) list[str]#
Conditions the cohort has, in the order the first run that carries them wrote them.
- nirspipe.qc.figures.subject.group_figures.build_condition_panels(rows: list[dict], highlight: list[str] | None = None) plotly.graph_objects.Figure | None#
One panel per metric: x is the condition, one line per run, the median over them.
The windows collapsed into the blocks the run was designed around.
- nirspipe.qc.figures.subject.group_figures.build_condition_matrix(rows: list[dict], order: list[str] | None = None) plotly.graph_objects.Figure | None#
run x condition, one panel per metric, colour = robust z inside that condition.
Sorted worst-first when an order is given, so the runs a reader is looking for are at the top.
- nirspipe.qc.figures.subject.group_figures.build_channel_condition_matrix(by_condition: dict, window_s: float | None = None) plotly.graph_objects.Figure | None#
channel x condition for one run, the panels and order of
build_condition_panels.The cohort’s matrix asks which run moved in a condition; a subject has one run per page, so the same question there is which channel moved. The panel list is derived from
_CONDITION_METRICSrather than written again, so the two cannot name different metrics under the same heading.Channels are ordered by how far they move across conditions on the first panel, worst first, and every panel keeps that order so one row reads across all of them.
- nirspipe.qc.figures.subject.group_figures.build_grouped_boxes(df: pandas.DataFrame, metric_cols: list[str]) list[tuple[str, plotly.graph_objects.Figure]]#
Flow of small real-value charts, one per scale-homogeneous group.
Each point carries its bids_name (customdata) so the report can link to it.
- nirspipe.qc.figures.subject.group_figures.FC_BIN = 0.02#
- nirspipe.qc.figures.subject.group_figures.FC_SMOOTH = 0.04#
- nirspipe.qc.figures.subject.group_figures.fc_density(values: numpy.ndarray) tuple[np.ndarray, np.ndarray]#
(bin centres, density) of
valuesover -1 to 1, binned atFC_BINand smoothed by a Gaussian ofFC_SMOOTH.
- nirspipe.qc.figures.subject.group_figures.build_fc_distributions(by_task: dict) plotly.graph_objects.Figure | None#
Each run’s channel-pair r before and after the regression, pale, with the cohort median; a row per task and chromophore.
by_taskisfc_distributions(). None when no task has a run with both matrices.
- nirspipe.qc.figures.subject.group_figures.FC_MOVEMENT_BIN = 0.05#
- nirspipe.qc.figures.subject.group_figures.no_relation_density(r: numpy.ndarray, n_runs: int) numpy.ndarray#
The density r takes across
n_runsruns when the two measures are unrelated (Fisher: arctanh r ~ N(0, 1/(n - 3))).
- nirspipe.qc.figures.subject.group_figures.build_fc_movement(table: pandas.DataFrame) plotly.graph_objects.Figure | None#
Each connection’s r with movement: counted by r beside the spread with no relation, and against the channels’ distance; a row per task.
tableisfc_against_movement(). None when it is empty.