nirspipe.qc.figures.common.head_map#

The flat head every figure that draws a value per channel is built on.

One projection, one outline, two marks. Which mark is right depends on what the number is:

  • a bar along the source-to-detector path, for a value that is a claim about that path, such as a correlation between a seed and this channel. A short channel, too stubby to read as a path, becomes a single larger disc inside a grey ring.

  • a disc at the channel’s midpoint, for a value that is a property of one place, such as an amplitude. Bars are wrong for those: they meet end to end wherever two channels share an optode, so a montage of independent measurements reads as one connected polyline.

Two views built on it cannot drift into describing different heads.

Built on nirspipe.qc.figures.common.topomap’s projection, which is MNE’s own, so these heads and a real topomap put a channel in the same place. What varies between callers is the colour scale and which channels have a value; the geometry never does.

Module Contents#

Functions#

head_geometry

Glyph coordinates and the head outline for one recording, keyed by separation.

head_ground

The outline and the bare source-detector skeleton, under the glyphs.

head_glyph

One scope’s channels drawn on the head, coloured by values.

head_axes

One square, unlabelled panel per head, all sharing the widest outline’s bounds.

pair_values

One value per channel this head draws, NaN where by_pair has no such pair.

build_head_slider

A row of heads per member, or the one subject’s, the slider running the whole recording.

Data#

API#

nirspipe.qc.figures.common.head_map.logger = 'get_logger(...)'#
nirspipe.qc.figures.common.head_map.BLANK_COLOR = '#cfd6dc'#
nirspipe.qc.figures.common.head_map.DIM_OPACITY = 0.3#
nirspipe.qc.figures.common.head_map.head_geometry(raw: mne.io.Raw, pairs: list[str]) → dict | None#

Glyph coordinates and the head outline for one recording, keyed by separation.

pairs names the long source-detector pairs as "S1_D1"; everything else the montage carries is short. A caller that wants only the long channels drawn passes them here and then draws the "long" scope alone.

None when the montage has no usable optode positions.

nirspipe.qc.figures.common.head_map.head_ground(fig, geo: dict, row: int, col: int) → None#

The outline and the bare source-detector skeleton, under the glyphs.

nirspipe.qc.figures.common.head_map.head_glyph(fig, geo, scope, values, row, col, title, cmin, cmax, bar, colorscale, sid: str = '', dim=None, blank_color: str | None = None, fmt: str = '.3f', mark: str = 'bar', hover_tail: str = '', customdata=None) → int#

One scope’s channels drawn on the head, coloured by values.

values carries one number per channel in geo[scope]["names"] order, and every marker of a channel takes that channel’s colour.

mark is “bar” or “disc”; see this module’s own docstring for which a number wants. With bars, long and short stay on one colour scale and the shape separates them.

customdata gives one extra value per channel and hover_tail a template fragment to print it with, for a figure whose colour is a derived number and whose reader still wants the measured one.

bar is True for the trace that shows the colour bar, or a dict of colorbar settings where a grid needs one bar per panel rather than one for the whole figure.

Two optional states, both drawn under the coloured markers so a value is never hidden by a channel that has none:

  • blank_color draws the channels whose value is not finite in that flat colour. A caller with no number for a channel then gets a grey channel rather than a gap.

  • dim names the channels to draw at reduced opacity. They keep their colour, because they do carry a real value; what the dimming means is the caller’s to say.

Without either, every marker goes into one trace, non-finite ones included, so a caller that updates colours frame by frame can hand back an array of the same length it passed.

Returns the index of the coloured trace, which is what such a frame updates.

nirspipe.qc.figures.common.head_map.head_axes(fig, geo_by_sub: dict, n_rows: int, n_cols: int, row_labels: list[str] | None = None) → None#

One square, unlabelled panel per head, all sharing the widest outline’s bounds.

nirspipe.qc.figures.common.head_map.HEAD_SCALE = [[0.0, '#F8786E'], [0.5, '#FFD966'], [1.0, '#C5E0B3']]#
nirspipe.qc.figures.common.head_map.pair_values(geo, scope, by_pair: dict, reduce_fn) → numpy.ndarray#

One value per channel this head draws, NaN where by_pair has no such pair.

nirspipe.qc.figures.common.head_map.build_head_slider(geo_by_sub: dict, subject_ids: list[str], grid: dict, series_by_sub: dict, conditions: dict | list | None = None, cutoffs: dict[str, float] | None = None, step: int = 3) → plotly.graph_objects.Figure | None#

A row of heads per member, or the one subject’s, the slider running the whole recording.

The instantaneous view, in columns read left to right: whether the window passed, the mask the screening counts, then SCI and PSP, the numbers that build it, each on a scale centred on its line in cutoffs where it has one. Every frame names the block it lands in, so a position on the slider says what was being done and not only when. conditions is {name: (t0, t1)}, or a list of (name, (t0, t1)) where a condition recurs.

step decimates the frames. Each one carries a colour per marker per head, so the page grows with the frame count.