cedalion.imagereco.utils

Utility functions for image reconstruction.

Functions

create_mock_activation_below_point(...)

Create a mock activation below a point.

map_segmentation_mask_to_surface(...)

Find for each voxel the closest vertex on the surface.

normal_hrf(t, t_peak, t_std, vmax)

Create a normal hrf.

cedalion.imagereco.utils.map_segmentation_mask_to_surface(
segmentation_mask: DataArray,
transform_vox2ras: DataArray,
surface: Surface,
)[source]

Find for each voxel the closest vertex on the surface.

Parameters:
  • segmentation_mask (xr.DataArray) – A binary mask of shape (segmentation_type, i, j, k).

  • transform_vox2ras (xr.DataArray) – The affine transformation from voxel to RAS space.

  • surface (cedalion.dataclasses.Surface) – The surface to map the voxels to.

Returns:

A sparse matrix of shape (ncells, nvertices) that maps voxels to

cells.

Return type:

coo_array

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

Create a normal hrf.

Parameters:
  • t (np.ndarray) – The time points.

  • t_peak (float) – The peak time.

  • t_std (float) – The standard deviation.

  • vmax (float) – The maximum value of the HRF.

Returns:

The HRF.

Return type:

np.ndarray

cedalion.imagereco.utils.create_mock_activation_below_point(
head_model: TwoSurfaceHeadModel,
point: Annotated[DataArray, DataArraySchema(dims='label', coords='label', 'label', 'type')],
time_length: Quantity,
sampling_rate: Quantity,
spatial_size: Quantity,
vmax: Quantity,
)[source]

Create a mock activation below a point.

Parameters:
  • head_model (cedalion.imagereco.forward_model.TwoSurfaceHeadModel) – The head model.

  • point (cdt.LabeledPointCloud) – The point below which to create the activation.

  • time_length (units.Quantity) – The length of the activation.

  • sampling_rate (units.Quantity) – The sampling rate.

  • spatial_size (units.Quantity) – The spatial size of the activation.

  • vmax (units.Quantity) – The maximum value of the activation.

Returns:

The activation.

Return type:

xr.DataArray