nirspipe.io.head_template#

The head a run’s optodes are placed on and drawn over: fsaverage, or one of MNE’s infant templates.

Each infant template (2 weeks to 2 years) has its own scalp, cortex, fiducials and 10-10 positions. It is fetched on first use into the folder fsaverage lives in, so every renderer finds both under one subjects_dir.

Module Contents#

Functions#

template_for_age

The template an age takes: the infant template nearest in age, or fsaverage from 18.

resolve_template

The template a participant runs on: the one given, else by age, else fsaverage.

space_of

The BIDS space label: fsaverage, or the MNE subject name with its hyphen as p.

space_of_subject

The space label of a template’s folder name: ANTS4-5Months3T -> ANTS4p5Months3T.

template_of_space

The --template value a space label names; ValueError for any other label.

subject_of

The template’s folder name under subjects_dir: ANTS4p5Months3T -> ANTS4-5Months3T.

describe

One phrase naming the template, for the coordinate sidecar and the page notes.

subjects_dir

The folder fsaverage is in, fetching it on first use; the infant templates go beside it.

template_dir

The template’s FreeSurfer folder, fetched on first use.

source_space_path

The cortical source space a projection spreads channel values over.

head_to_mri

The template’s head frame to its surface RAS, as a 4x4 in metres.

scalp

The template’s scalp surface, in mm, for nearest-point queries.

cortex_atlases

The annotations a template’s channels are labelled from: aparc on every template, Brodmann on fsaverage, which alone ships it.

nearest_cortex_regions

Each point’s region in every atlas the template ships, read at the pial vertex nearest it.

reference_points

10-10 (fsaverage: 10-5) positions and the three fiducials on the template, in mm, by lower-case label.

from_fsaverage

fsaverage surface RAS (mm) to the template’s, the affine that best carries their shared 10-10 points.

linear_scale

How much smaller or larger the template’s head is than fsaverage’s, as one length ratio.

head_sphere

The sphere a head map projects onto, in the template’s head frame (m); None keeps MNE’s default.

Data#

API#

nirspipe.io.head_template.FSAVERAGE = 'fsaverage'#
nirspipe.io.head_template.INFANT = None#
nirspipe.io.head_template.CHOICES = ()#
nirspipe.io.head_template.ADULT_AGE = 18.0#
nirspipe.io.head_template.template_for_age(age_years: float) → str#

The template an age takes: the infant template nearest in age, or fsaverage from 18.

0.33 -> "4.5mo"; 30 -> "fsaverage"; 5 -> ValueError

nirspipe.io.head_template.resolve_template(template: str | None, age: float | None) → str#

The template a participant runs on: the one given, else by age, else fsaverage.

age is the participant’s age when --dpf age reads it, None otherwise.

nirspipe.io.head_template.space_of(template: str) → str#

The BIDS space label: fsaverage, or the MNE subject name with its hyphen as p.

"4.5mo" -> "ANTS4p5Months3T"; a BIDS label is alphanumeric

nirspipe.io.head_template.space_of_subject(subject: str) → str#

The space label of a template’s folder name: ANTS4-5Months3T -> ANTS4p5Months3T.

nirspipe.io.head_template.template_of_space(space: str) → str#

The --template value a space label names; ValueError for any other label.

nirspipe.io.head_template.subject_of(space: str) → str#

The template’s folder name under subjects_dir: ANTS4p5Months3T -> ANTS4-5Months3T.

nirspipe.io.head_template.describe(space: str) → str#

One phrase naming the template, for the coordinate sidecar and the page notes.

nirspipe.io.head_template.subjects_dir() → pathlib.Path#

The folder fsaverage is in, fetching it on first use; the infant templates go beside it.

nirspipe.io.head_template.template_dir(space: str) → pathlib.Path#

The template’s FreeSurfer folder, fetched on first use.

nirspipe.io.head_template.source_space_path(space: str) → pathlib.Path#

The cortical source space a projection spreads channel values over.

nirspipe.io.head_template.head_to_mri(space: str = FSAVERAGE) → numpy.ndarray#

The template’s head frame to its surface RAS, as a 4x4 in metres.

fsaverage ships its own; an infant template’s follows from its fiducials, which define the head frame.

nirspipe.io.head_template.scalp(space: str) → scipy.spatial.cKDTree#

The template’s scalp surface, in mm, for nearest-point queries.

nirspipe.io.head_template.CORTEX_ATLASES = None#
nirspipe.io.head_template.cortex_atlases(space: str) → list[str]#

The annotations a template’s channels are labelled from: aparc on every template, Brodmann on fsaverage, which alone ships it.

nirspipe.io.head_template.nearest_cortex_regions(space: str, points_mm: numpy.ndarray) → dict[str, list]#

Each point’s region in every atlas the template ships, read at the pial vertex nearest it.

{"aparc": ["precentral-lh", None], "brodmann": ["Brodmann.4-lh", None]} for a point over the left motor strip and one with no position (NaN).

nirspipe.io.head_template.reference_points(space: str) → dict[str, numpy.ndarray]#

10-10 (fsaverage: 10-5) positions and the three fiducials on the template, in mm, by lower-case label.

nirspipe.io.head_template.from_fsaverage(space: str) → numpy.ndarray#

fsaverage surface RAS (mm) to the template’s, the affine that best carries their shared 10-10 points.

The identity for fsaverage. A cap stored on an adult head reaches an infant template this way, by where its optodes sit in the 10-10 system rather than by their distance in mm.

nirspipe.io.head_template.linear_scale(space: str) → float#

How much smaller or larger the template’s head is than fsaverage’s, as one length ratio.

nirspipe.io.head_template.head_sphere(space: str) → numpy.ndarray | None#

The sphere a head map projects onto, in the template’s head frame (m); None keeps MNE’s default.

MNE’s default is sized for an adult head; an infant template’s is shrunk by the template’s size, so a cap sits inside its head outline as it does on fsaverage.