nirspipe.qc.figures.subject.correlation_panel#
HbO–HbR correlation panel.
- Top row: one channel × channel Pearson r heatmap per stage, before and after denoising,
on one colour scale so the pair subtracts by eye.
- Bottom row: per-pair HbO–HbR r as a dumbbell, before → after, grouped by source-detector
separation.
Both stages share one figure and one channel order, so a channel sits at the same height before and after and the change is the length of a connector.
Separation is what the grouping is for: a short channel only ever sees scalp, so it is not sorted among the long ones. The heatmap rows follow the same grouping, so the block dividers inside each chromophore mark the long/short boundary rather than wherever the acquisition order happened to switch.
Both panels read their colour off one reversed RdBu scale, so a shade means the same r whether it is a matrix cell or a dot. The panel carries no threshold: which side of a fixed cut a run lands on moves with the low-pass edge.
Module Contents#
Functions#
Return the correlation panel as a Plotly figure, or None on an empty montage. |
|
Script that re-fits the panel to the width the browser actually gives it. |
API#
- nirspipe.qc.figures.subject.correlation_panel.hbo_hbr_correlation_figure(raw_haemo: mne.io.Raw, title: str = 'HbO–HbR Signal Quality', sep_bands=None, raw_after: mne.io.Raw | None = None, task_modelled: bool = False, stage_labels: tuple[str, str] | None = None, bad_pairs: set[str] | None = None) plotly.graph_objects.Figure | None#
Return the correlation panel as a Plotly figure, or None on an empty montage.
raw_afteris the denoised recording. Given it, the panel carries both stages: two heatmaps on one colour scale and a dumbbell per pair. Left out, or not matching the before stage’s channels, it degrades to the one-stage panel: one heatmap and one dot per pair, which is what a run with no denoising and what a condition page both get.task_modelledsays the after stage is a GLM residual, with the task model taken out as well as the confounds, so the after column is labelled to say so.stage_labelsnames the two stages when the step between them is not denoising, as in the raw viewer, where it is motion correction.bad_pairsare ranked in a group of their own after the kept ones; None reads them offraw_haemo’s marks. A channel onlyraw_aftermarks bad is blank in the after stage.
- nirspipe.qc.figures.subject.correlation_panel.fit_js(fig: plotly.graph_objects.Figure) str#
Script that re-fits the panel to the width the browser actually gives it.
The height is written into the file and the width is the page’s, so one of the two always has slack and a square-constrained matrix cannot use it.
constrain="domain"moves that slack out from between the labels and the matrix, but it lands between the heatmap and the dumbbell instead, which is a hole in the middle of the figure. This is the only place the two can be reconciled: measure the column on load, set the height that makes the matrix square in it, and move the row domains so the dumbbell keeps its own height rather than scaling with the figure.Idempotent and re-run after every resize Plotly makes. A page where the width cannot be read leaves the written height alone.
Two Plotly behaviours shape it. A relayout that sets a height also pins the width the figure has at that moment, and a pinned width switches off its responsive resize, so the pin is dropped once the relayout lands. And the window resize event arrives before Plotly has redrawn, so the refit hangs off Plotly’s own autosize relayout instead.