laion_fmri.brain

Brain space mapping utilities.

Functions

get_voxel_coordinates(brain_mask_path, affine)

Compute MNI coordinates for brain voxels.

to_nifti(values, output_path, ...[, ...])

Map 1D voxel values back to a 3D NIfTI volume.

laion_fmri.brain.get_voxel_coordinates(brain_mask_path, affine, roi_mask=None, custom_mask=None)[source]

Compute MNI coordinates for brain voxels.

Parameters:
  • brain_mask_path (str or Path) – Path to the brain mask NIfTI.

  • affine (np.ndarray) – 4x4 affine matrix.

  • roi_mask (np.ndarray[bool] or None) – Boolean mask within brain voxels.

  • custom_mask (np.ndarray[bool] or None) – Custom boolean mask within brain voxels.

Returns:

Shape (n_voxels, 3) array of coordinates.

Return type:

np.ndarray

laion_fmri.brain.to_nifti(values, output_path, brain_mask_path, affine, roi_mask=None, custom_mask=None)[source]

Map 1D voxel values back to a 3D NIfTI volume.

Parameters:
  • values (np.ndarray) – 1D array of values to place in the volume.

  • output_path (str or Path) – Output NIfTI file path.

  • brain_mask_path (str or Path) – Path to the brain mask NIfTI.

  • affine (np.ndarray) – 4x4 affine matrix.

  • roi_mask (np.ndarray[bool] or None) – Boolean mask within brain voxels.

  • custom_mask (np.ndarray[bool] or None) – Custom boolean mask within brain voxels.

Raises:

ValueError – If values length does not match the expected voxel count.