cedalion.geometry.segmentation
Funtionality to work with segmented MRI scans.
Functions
|
Generate cell coordinates from a 3D volume. |
|
Postprocessing of the segmented SPM12 MRI segmentation files. |
|
|
|
Create a surface from a segmentation mask. |
|
Generate voxels from a segmentation mask. |
- cedalion.geometry.segmentation.voxels_from_segmentation(
- segmentation_mask: DataArray,
- segmentation_types: List[str],
- isovalue=0.9,
- fill_holes_in_mask=False,
Generate voxels from a segmentation mask.
- Parameters:
segmentation_mask – xr.DataArray Segmentation mask.
segmentation_types – List[str] List of segmentation types.
isovalue – float, optional Isovalue for marching cubes, by default 0.9.
fill_holes_in_mask – bool, optional Fill holes in the mask, by default False.
- Returns:
- cdc.Voxels
Voxels in voxel space.
- cedalion.geometry.segmentation.surface_from_segmentation(
- segmentation_mask: DataArray,
- segmentation_types: List[str],
- isovalue=0.9,
- fill_holes_in_mask=False,
Create a surface from a segmentation mask.
- Parameters:
segmentation_mask (xr.DataArray) – Segmentation mask with dimensions segmentation type, i, j, k.
segmentation_types (List[str]) – A list of segmentation types to include in the surface.
isovalue (Float) – The isovalue to use for the marching cubes algorithm.
fill_holes_in_mask (Bool) – Whether to fill holes in the mask before creating the surface.
- Returns:
A cedalion.Surface object.
- cedalion.geometry.segmentation.cell_coordinates(volume, flat: bool = False)[source]
Generate cell coordinates from a 3D volume.
- Parameters:
volume (np.ndarray) – 3D volume.
flat (bool, optional) – If True, return coordinates as a flat array, by default False.
Returns
-------
xr.DataArray – Cell coordinates in voxel space.
- cedalion.geometry.segmentation.segmentation_postprocessing(
- segmentation_dir: str,
- mask_files: dict[str, str] = {'air': 'c6.nii', 'bone': 'c4.nii', 'csf': 'c3.nii', 'gray': 'c1.nii', 'skin': 'c5.nii', 'white': 'c2.nii'},
- isSmooth: bool = True,
- fixCSF: bool = True,
- removeDisconnected: bool = True,
- labelUnassigned: bool = True,
- removeAir: bool = True,
- subtractTissues: bool = True,
Postprocessing of the segmented SPM12 MRI segmentation files.
- Parameters:
segmentation_dir (str) – Directory where the segmented files are stored.
mask_files (dict[str, str], optional) – Dictionary containing the filenames of the segmented tissues.
isSmooth (bool, optional) – Smooth the segmented tissues using Gaussian filter.
fixCSF (bool, optional) – Fix the CSF continuity.
removeDisconnected (bool, optional) – Remove disconnected voxels.
labelUnassigned (bool, optional) – Label empty voxels to the nearest tissue type.
removeAir (bool, optional) – Remove air cavities.
subtractTissues (bool, optional) – Subtract tissues from each others
Returns:
- mask_filesdict
Dictionary containing the filenames of the postprocessed masks.
References:
This whole postprocessing is based on the following references: Huang et al. [HDS+13] Harmening and Miklody [HM22]