cedalion.dot.head_model
Functions
|
Create a TwoSurfaceHeadmodel for common atlases. |
Classes
|
Head Model class to represent a segmented head. |
- class cedalion.dot.head_model.TwoSurfaceHeadModel(
- segmentation_masks: xr.DataArray,
- brain: cdc.Surface,
- scalp: cdc.Surface,
- landmarks: cdt.LabeledPointCloud,
- t_ijk2ras: cdt.AffineTransform,
- t_ras2ijk: cdt.AffineTransform,
- voxel_to_vertex_brain: scipy.sparse.spmatrix,
- voxel_to_vertex_scalp: scipy.sparse.spmatrix,
Bases:
objectHead Model class to represent a segmented head.
Its main functions are reduced to work on voxel projections to scalp and cortex surfaces.
- segmentation_masks[source]
xr.DataArray Segmentation masks of the head for each tissue type.
- Type:
xarray.core.dataarray.DataArray
- landmarks[source]
cdt.LabeledPointCloud Anatomical landmarks in RAS space.
- Type:
xarray.core.dataarray.DataArray
- t_ijk2ras[source]
cdt.AffineTransform Affine transformation from ijk to RAS space.
- Type:
xarray.core.dataarray.DataArray
- t_ras2ijk[source]
cdt.AffineTransform Affine transformation from RAS to ijk space.
- Type:
xarray.core.dataarray.DataArray
- voxel_to_vertex_brain[source]
scipy.sparse.spmatrix Mapping from voxel to brain vertices.
- Type:
scipy.sparse._matrix.spmatrix
- voxel_to_vertex_scalp[source]
scipy.sparse.spmatrix Mapping from voxel to scalp vertices.
- Type:
scipy.sparse._matrix.spmatrix
- from_segmentation(cls, segmentation_dir, mask_files, landmarks_ras_file,
brain_seg_types, scalp_seg_types, smoothing, brain_face_count, scalp_face_count): Construct instance from segmentation masks in NIfTI format.
- landmarks: Annotated[DataArray, DataArraySchema(dims='label', coords='label', 'label', 'type')][source]
- classmethod from_segmentation(
- segmentation_dir: str,
- mask_files: dict[str, str] = {'csf': 'csf.nii', 'gm': 'gm.nii', 'scalp': 'scalp.nii', 'skull': 'skull.nii', 'wm': 'wm.nii'},
- landmarks_ras_file: str | None = None,
- brain_seg_types: list[str] = ['gm', 'wm'],
- scalp_seg_types: list[str] = ['scalp'],
- smoothing: float = 0.5,
- brain_face_count: int | None = 180000,
- scalp_face_count: int | None = 60000,
- fill_holes: bool = True,
Constructor from binary masks as gained from segmented MRI scans.
- Parameters:
segmentation_dir – Folder containing the segmentation masks in NIFTI format.
mask_files – Dictionary mapping segmentation types to NIFTI filenames.
landmarks_ras_file – Filename of the landmarks in RAS space.
brain_seg_types – List of segmentation types to be included in the brain surface.
scalp_seg_types – List of segmentation types to be included in the scalp surface.
smoothing – Smoothing factor for the brain and scalp surfaces.
brain_face_count – Number of faces for the brain surface.
scalp_face_count – Number of faces for the scalp surface.
fill_holes – Whether to fill holes in the segmentation masks.
- classmethod from_surfaces(
- segmentation_dir: str,
- mask_files: dict[str, str] = {'csf': 'csf.nii', 'gm': 'gm.nii', 'scalp': 'scalp.nii', 'skull': 'skull.nii', 'wm': 'wm.nii'},
- brain_surface_file: str = None,
- scalp_surface_file: str = None,
- landmarks_ras_file: str | None = None,
- brain_seg_types: list[str] = ['gm', 'wm'],
- scalp_seg_types: list[str] = ['scalp'],
- smoothing: float = 0.5,
- brain_face_count: int | None = 180000,
- scalp_face_count: int | None = 60000,
- fill_holes: bool = False,
- parcel_file: Path | str | None = None,
Constructor from seg.masks, brain and head surfaces as gained from MRI scans.
- Parameters:
segmentation_dir – Folder containing the segmentation masks in NIFTI format.
mask_files – Dictionary mapping segmentation types to NIFTI filenames.
brain_surface_file – Path to the brain surface.
scalp_surface_file – Path to the scalp surface.
landmarks_ras_file – Filename of the landmarks in RAS space.
brain_seg_types – List of segmentation types to be included in the brain surface.
scalp_seg_types – List of segmentation types to be included in the scalp surface.
smoothing – Smoothing factor for the brain and scalp surfaces.
brain_face_count – Number of faces for the brain surface.
scalp_face_count – Number of faces for the scalp surface.
fill_holes – Whether to fill holes in the segmentation masks.
parcel_file – path to the json file mapping vertices to parcels.
- Returns:
An instance of the TwoSurfaceHeadModel class.
- Return type:
- apply_transform(
- transform: cdt.AffineTransform,
Apply a coordinate transformation to the head model.
- Parameters:
transform – Affine transformation matrix (4x4) to be applied.
- Returns:
Transformed head model.
- save(foldername: str)[source]
Save the head model to a folder.
- Parameters:
foldername (str) – Folder to save the head model into.
- Returns:
None
- classmethod load(foldername: str)[source]
Load the head model from a folder.
- Parameters:
foldername (str) – Folder to load the head model from.
- Returns:
Loaded head model.
- Return type:
- align_and_snap_to_scalp(
- points: cdt.LabeledPointCloud,
- mode: str = 'trans_rot_isoscale',
Align and snap optodes or points to the scalp surface.
- Parameters:
points (cdt.LabeledPointCloud) – Points to be aligned and snapped to the scalp surface.
mode – method to derive the affine transform. Could be either ‘trans_rot_isoscale’ or ‘general’. See cedalion.geometry.registraion for details.
- Returns:
Points aligned and snapped to the scalp surface.
- Return type:
cdt.LabeledPointCloud
- snap_to_scalp_voxels(
- points: cdt.LabeledPointCloud,
Snap optodes or points to the closest scalp voxel.
- Parameters:
points (cdt.LabeledPointCloud) – Points to be snapped to the closest scalp voxel.
- Returns:
- Points aligned and snapped to the closest scalp
voxel.
- Return type:
cdt.LabeledPointCloud
- scale_to_landmarks(
- target_landmarks: cdt.LabeledPointCloud,
- scale_to_headsize(
- circumference: cdt.QLength,
- nz_cz_iz: cdt.QLength,
- lpa_cz_rpa: cdt.QLength,
- cedalion.dot.head_model.get_standard_headmodel(model: str) TwoSurfaceHeadModel[source]
Create a TwoSurfaceHeadmodel for common atlases.
Onc created, this function caches a head model.
- Parameters:
model – either colin27 or icbm152
- Returns:
The loaded head model with 1010-landmarks and parcel labels assigned.