nirspipe.qc.figures.common._surface_overlay#
Per-vertex colours for a map on a cortical surface: an activation drawn as stc.plot
does, or an unsigned amplitude.
A binary curvature layer in grey sits under the data layer, which for an activation is diverging and transparent near zero, and for an amplitude is as opaque as the channels cover the vertex; the two are composited into one RGBA per vertex, ready to hand to a mesh.
Module Contents#
Functions#
Unit normal per vertex: the normalised sum of the unit normals of the faces around it. |
|
Sparse |
|
|
|
Per-vertex RGBA: sulci and gyri in two greys, with |
|
Per-vertex RGBA for an unsigned map: its colour over the greys, as opaque as covered. |
API#
- nirspipe.qc.figures.common._surface_overlay.vertex_normals(coords: numpy.ndarray, faces: numpy.ndarray) numpy.ndarray#
Unit normal per vertex: the normalised sum of the unit normals of the faces around it.
- nirspipe.qc.figures.common._surface_overlay.smoothing_matrix(faces: numpy.ndarray, n_vertices: int, vertices_from: numpy.ndarray, steps: int) scipy.sparse.csr_array#
Sparse
(n_vertices, len(vertices_from))map spreading values from a vertex subset.Each step replaces every vertex reached so far, and every neighbour of one, by the mean of itself and its reached neighbours. One step from a single vertex of a triangle fan gives that vertex and its ring equal weight; later steps widen and flatten the patch.
- nirspipe.qc.figures.common._surface_overlay.diverging_lut(fmin: float, fmid: float, fmax: float, cmap: str = 'RdBu_r') numpy.ndarray#
(256, 4)uint8 RGBA table spanning [-fmax, fmax], transparent within ±fmin.Opacity rises linearly from 0 at ±fmin to full at ±fmid, so small values fade into the cortex instead of tinting it:
diverging_lut(0, 0.5, 1)[128, 3] -> 0 # zero is fully transparent diverging_lut(0, 0.5, 1)[0, 3] -> 255 # -fmax is opaque
- nirspipe.qc.figures.common._surface_overlay.activation_rgba(curvature: numpy.ndarray, values: numpy.ndarray, fmin: float, fmid: float, fmax: float) numpy.ndarray#
Per-vertex RGBA: sulci and gyri in two greys, with
valuesover them.
- nirspipe.qc.figures.common._surface_overlay.coverage_rgba(curvature: numpy.ndarray, weighted: numpy.ndarray, cover: numpy.ndarray, vmin: float, vmax: float, cmap: str = 'viridis') numpy.ndarray#
Per-vertex RGBA for an unsigned map: its colour over the greys, as opaque as covered.
weightedis the projected values andcoverthe projected ones, so their ratio is the channels’ weighted mean. Dividing keeps the edge of the covered patch at its value, where smoothing alone would pull it toward zero and read as a low one:coverage_rgba(curv, weighted=[0.25], cover=[0.5], 0, 1) # viridis(0.5), half opaque