cedalion.imagereco package

Submodules

cedalion.imagereco.forward_model module

class cedalion.imagereco.forward_model.ForwardModel(head_model, geo3d, measurement_list)

Bases: object

Forward model for simulating light transport in the head.

head_model

Head model containing voxel projections to brain and scalp surfaces.

Type:

TwoSurfaceHeadModel

optode_pos

Optode positions.

Type:

cdt.LabeledPointCloud

optode_dir

Optode orientations (directions of light beams).

Type:

xr.DataArray

tissue_properties

Tissue properties for each tissue type.

Type:

xr.DataArray

volume

Voxelated head volume from segmentation masks.

Type:

xr.DataArray

unitinmm

Unit of head model, optodes expressed in mm.

Type:

float

measurement_list

List of measurements of experiment with source, detector, channel and wavelength.

Type:

pd.DataFrame

compute_fluence(nphoton)

Compute fluence for each channel and wavelength from photon simulation.

compute_sensitivity(fluence_all, fluence_at_optodes)

Compute sensitivity matrix from fluence.

compute_fluence(nphoton=100000000.0)

Compute fluence for each channel and wavelength from photon simulation.

Parameters:

nphoton (int) – Number of photons to simulate.

Returns:

Fluence in each voxel for each channel and wavelength.

Return type:

xr.DataArray

compute_sensitivity(fluence_all, fluence_at_optodes)

Compute sensitivity matrix from fluence.

Parameters:
  • fluence_all (xr.DataArray) – Fluence in each voxel for each wavelength.

  • fluence_at_optodes (xr.DataArray) – Fluence at all optode positions for each wavelength.

Returns:

Sensitivity matrix for each channel, vertex and wavelength.

Return type:

xr.DataArray

compute_sensitivity_all(fluence_all, fluence_at_optodes)

Compute sensitivity matrix from fluence.

Parameters:
  • fluence_all (xr.DataArray) – Fluence in each voxel for each wavelength.

  • fluence_at_optodes (xr.DataArray) – Fluence at all optode positions for each wavelength.

Returns:

Sensitivity matrix for each channel, vertex and wavelength.

Return type:

xr.DataArray

static compute_stacked_sensitivity(sensitivity)

Compute stacked HbO and HbR sensitivity matrices from fluence.

Parameters:

sensitivity (xr.DataArray) – Sensitivity matrix for each vertex and wavelength.

Returns:

Stacked sensitivity matrix for each channel and vertex.

Return type:

xr.DataArray

class cedalion.imagereco.forward_model.TwoSurfaceHeadModel(segmentation_masks, brain, scalp, landmarks, t_ijk2ras, t_ras2ijk, voxel_to_vertex_brain, voxel_to_vertex_scalp)

Bases: object

Head Model class to represent a segmented head. Its main functions are reduced to work on voxel projections to scalp and cortex surfaces.

segmentation_masks

Segmentation masks of the head for each tissue type.

Type:

xr.DataArray

brain

Surface of the brain.

Type:

cdc.Surface

scalp

Surface of the scalp.

Type:

cdc.Surface

landmarks

Anatomical landmarks in RAS space.

Type:

cdt.LabeledPointCloud

t_ijk2ras

Affine transformation from ijk to RAS space.

Type:

cdt.AffineTransform

t_ras2ijk

Affine transformation from RAS to ijk space.

Type:

cdt.AffineTransform

voxel_to_vertex_brain

Mapping from voxel to brain vertices.

Type:

scipy.sparse.spmatrix

voxel_to_vertex_scalp

Mapping from voxel to scalp vertices.

Type:

scipy.sparse.spmatrix

crs

Coordinate reference system of the head model.

Type:

str

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.

apply_transform(transform)

Apply a coordinate transformation to the head model.

save(foldername)

Save the head model to a folder.

load(foldername)

Load the head model from a folder.

align_and_snap_to_scalp(points)

Align and snap optodes or points to the scalp surface.

align_and_snap_to_scalp(points)

Align and snap optodes or points to the scalp surface.

Parameters:

points (cdt.LabeledPointCloud) – Points to be aligned and snapped to the scalp surface.

Returns:

Points aligned and snapped to the scalp surface.

Return type:

cdt.LabeledPointCloud

apply_transform(transform)

Apply a coordinate transformation to the head model.

Parameters:

transform (cdt.AffineTransform) – Affine transformation matrix (4x4) to be applied.

Returns:

Transformed head model.

Return type:

TwoSurfaceHeadModel

brain: Surface
property crs

Coordinate reference system of the head model.

classmethod from_segmentation(segmentation_dir, mask_files={'csf': 'csf.nii', 'gm': 'gm.nii', 'scalp': 'scalp.nii', 'skull': 'skull.nii', 'wm': 'wm.nii'}, landmarks_ras_file=None, brain_seg_types=['gm', 'wm'], scalp_seg_types=['scalp'], smoothing=0.5, brain_face_count=60000, scalp_face_count=60000, fill_holes=False)

Constructor from binary masks as gained from segmented MRI scans.

Parameters:
  • segmentation_dir (str) – Folder containing the segmentation masks in NIFTI format.

  • mask_files (dict[str, str]) – Dictionary mapping segmentation types to NIFTI filenames.

  • landmarks_ras_file (Optional[str]) – Filename of the landmarks in RAS space.

  • brain_seg_types (list[str]) – List of segmentation types to be included in the brain surface.

  • scalp_seg_types (list[str]) – List of segmentation types to be included in the scalp surface.

  • smoothing (float) – Smoothing factor for the brain and scalp surfaces.

  • brain_face_count (Optional[int]) – Number of faces for the brain surface.

Return type:

TwoSurfaceHeadModel

landmarks: Annotated[DataArray]
classmethod load(foldername)

Load the head model from a folder.

Parameters:

foldername (str) – Folder to load the head model from.

Returns:

Loaded head model.

Return type:

TwoSurfaceHeadModel

save(foldername)

Save the head model to a folder.

Parameters:

foldername (str) – Folder to save the head model into.

Return type:

None

scalp: Surface
segmentation_masks: DataArray
t_ijk2ras: DataArray
t_ras2ijk: DataArray
voxel_to_vertex_brain: spmatrix
voxel_to_vertex_scalp: spmatrix

cedalion.imagereco.solver module

cedalion.imagereco.solver.pseudo_inverse_stacked(Adot, alpha=0.01)

cedalion.imagereco.tissue_properties module

class cedalion.imagereco.tissue_properties.TissueType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

CSF = 4
DM = 3
GM = 5
OTHER = 7
SKIN = 1
SKULL = 2
WM = 6
cedalion.imagereco.tissue_properties.get_tissue_properties(segmentation_masks)

Return tissue properties for the given segmentation mask.

Return type:

ndarray

cedalion.imagereco.utils module

cedalion.imagereco.utils.create_mock_activation_below_point(head_model, point, time_length, sampling_rate, spatial_size, vmax)
cedalion.imagereco.utils.map_segmentation_mask_to_surface(segmentation_mask, transform_vox2ras, surface)

Find for each voxel the closest vertex on the surface.

cedalion.imagereco.utils.normal_hrf(t, t_peak, t_std, vmax)

Module contents