nirspipe.qc.figures.subject.rest_figures#

Resting-state QC figures.

rest_channel_panel(): the run’s channels in one panel, FC matrices over ALFF and fALFF. alff_brain_figure(): mALFF projected onto the cortex, as the GLM activation is. alff_flat_figure(): mALFF on the optode flat map, for optodes no reading placed. fc_roi_matrix_figure(): connectivity ROI by ROI instead of channel by channel. fc_seed_topo_figure(): seed-to-whole-brain correlations drawn on the optode flat map.

The panel answers how much and with whom, the brain and the flat map answer where. The seed map stays on the shared head in nirspipe.qc.figures.common.head_map, where each channel keeps its own place next to the seed’s.

Module Contents#

Functions#

rest_channel_panel

The run’s channels in one panel: FC on top, ALFF and fALFF below.

fc_roi_matrix_figure

The ROI x ROI FC heatmaps, or None if there is nothing to draw.

flat_value_maps

Channel values on the optode flat map, a row of heads per entry, or None without positions.

alff_flat_figure

mALFF on the optode flat map, a head per chromophore on its own range: the stand-in for alff_brain_figure() when the optodes could not be placed.

short_share_figure

Each long channel’s variance the short-channel regressors carried, a head per chromophore on one 0 to 1 scale.

fc_seed_topo_figure

One flat map per seed ROI and chromophore, or None if the montage has no positions.

alff_brain_figure

mALFF on the template’s cortex in four views, a block per chromophore the table holds, as a base64 PNG.

Data#

API#

nirspipe.qc.figures.subject.rest_figures.logger = 'get_logger(...)'#
nirspipe.qc.figures.subject.rest_figures.rest_channel_panel(fc: dict[str, pd.DataFrame], alff_df=None, raw=None, sep_bands=None, title: str = 'Resting state per channel: connectivity, amplitude, spectral share', roi_map: dict | None = None)#

The run’s channels in one panel: FC on top, ALFF and fALFF below.

Built in the shape of the HbO-HbR correlation panel: matrices side by side on one colour scale, and a per-pair strip under them. Here the matrices are the chromophores in fc ({chromophore: channel matrix}) rather than two stages, and the strips carry amplitude rather than a correlation.

The matrices are drawn whole, diagonal blank, on a scale symmetric about 0 that reaches the largest |r| any of them holds, so a run whose correlations are all positive still spans the red half.

The rows share one channel order and one set of blocks, so a channel is in the same relative place in all of them: by ROI when roi_map ({ROI: [channels]}) is given, with a rule between ROIs and a colour strip beside each matrix, and by separation otherwise. They do not share an x scale: the matrices are narrower than the strips, so a column and a position correspond as labels and as blocks, not pixel for pixel.

alff_df may be None, which is a run that computed no amplitude, and the panel is then the matrices alone. None overall when there is no FC to draw. A channel with no correlation in any matrix is left off every row (kept_axes()).

nirspipe.qc.figures.subject.rest_figures.fc_roi_matrix_figure(fc_roi: dict[str, pd.DataFrame], title: str = 'ROI-to-ROI Functional Connectivity (Pearson r)') → plotly.graph_objects.Figure | None#

The ROI x ROI FC heatmaps, or None if there is nothing to draw.

fc_roi is {chromophore: ROI x ROI frame}, as compute_fc_roi() returns it. The channel matrices’ rule in rest_channel_panel(): symmetric about 0, out to the largest |r| either panel holds. A handful of ROIs means every label fits, so unlike those this one labels and prints every cell. The diagonal is blanked: an ROI’s correlation with itself is 1 by construction and says nothing. An ROI with no value is left off both axes (kept_axes()).

nirspipe.qc.figures.subject.rest_figures.flat_value_maps(raw: mne.io.Raw, rows: list[dict], title: str, colorscale, sep_bands=None) → plotly.graph_objects.Figure | None#

Channel values on the optode flat map, a row of heads per entry, or None without positions.

Each row is {"panels": [(title, chromophore, {channel: value}), ...], "scale": (vmin, vmax) or None, "bar": label}: a scale is shared by the row under one bar, None gives every head its own range and bar. A channel with no value is grey, a rejected one faded.

nirspipe.qc.figures.subject.rest_figures.alff_flat_figure(raw: mne.io.Raw, alff_df: pandas.DataFrame, sep_bands=None) → plotly.graph_objects.Figure | None#

mALFF on the optode flat map, a head per chromophore on its own range: the stand-in for alff_brain_figure() when the optodes could not be placed.

nirspipe.qc.figures.subject.rest_figures.short_share_figure(raw: mne.io.Raw, shares: dict[str, float], sep_bands=None) → plotly.graph_objects.Figure | None#

Each long channel’s variance the short-channel regressors carried, a head per chromophore on one 0 to 1 scale.

nirspipe.qc.figures.subject.rest_figures.fc_seed_topo_figure(raw: mne.io.Raw, seeds: dict[str, pd.DataFrame], title: str = 'Seed-to-whole-brain connectivity (Pearson r)', sep_bands=None) → plotly.graph_objects.Figure | None#

One flat map per seed ROI and chromophore, or None if the montage has no positions.

compute_fc_seed returns an ROI x channel frame per chromophore, and seeds holds them as {chromophore: frame}. Each channel is a bar of discs along its source-to-detector path, coloured by that seed’s correlation with it, on the same reversed RdBu / +-1 scale fc_matrix_figure uses so the two figures can be read against each other.

Three states are distinguishable:

  • an ordinary channel, coloured by r;

  • a channel with no value, grey. That is a channel inside the seed, whose correlation is inflated by construction, and grey says “no claim made here” where a blue channel would say “no connection”;

  • a rejected channel, drawn faded. Whether it also has a value depends on the frame; either way the fading says the channel was excluded upstream.

nirspipe.qc.figures.subject.rest_figures.alff_brain_figure(raw: mne.io.Raw, alff_df: pandas.DataFrame, sep_bands=None) → str | None#

mALFF on the template’s cortex in four views, a block per chromophore the table holds, as a base64 PNG.

The long channels that were kept and carry a value are projected as the GLM activation is, and each block’s scale runs from its lowest value to its highest. None when no channel has one.