laion_fmri.io¶
Low-level file loaders for laion_fmri.
Functions
|
Load a FreeSurfer |
|
Load a |
|
Load a 4-D NIfTI's values within a brain mask. |
|
Load a 3-D NIfTI's values within a brain mask. |
|
Load a NIfTI mask as a flat 1-D boolean array. |
|
Load a NIfTI's data and 4×4 affine. |
|
Load a TSV file as a pandas DataFrame. |
- laion_fmri.io.load_freesurfer_label(path)[source]¶
Load a FreeSurfer
.labelfile’s vertex indices.- Parameters:
path (str or Path)
- Returns:
Shape
(n_label_vertices,), dtype int.- Return type:
np.ndarray
- laion_fmri.io.load_gifti_mask(path)[source]¶
Load a
.func.giisurface mask as a 1-D boolean array.- Parameters:
path (str or Path)
- Returns:
Shape
(n_vertices,), dtype bool.- Return type:
np.ndarray
- laion_fmri.io.load_nifti_4d(path, mask_path, streaming=False)[source]¶
Load a 4-D NIfTI’s values within a brain mask.
Returns each volume as a row of voxel values.
- Parameters:
path (str or Path)
mask_path (str or Path)
streaming (bool) – If False (default), materialize the full 4-D array up front, then mask per volume. Decompresses any
.nii.gzonce and is the right choice for the bucket’s compressed files; peak memory is the full 4-D file plus the masked output, so a real session is ~12 GB. If True, read one volume at a time – peak memory stays at one volume plus the masked output. Streaming is only fast on raw uncompressed ``.nii`` (or with the file already in OS cache); on.nii.gznibabel re-decompresses up to the offset on every slice, so streaming becomes effectively quadratic in the number of volumes.
- Returns:
Shape
(n_volumes, n_brain_voxels), dtype float32, C-contiguous so row indexing is cheap.- Return type:
np.ndarray
- laion_fmri.io.load_nifti_data(path, mask_path)[source]¶
Load a 3-D NIfTI’s values within a brain mask.
- laion_fmri.io.load_nifti_mask(path)[source]¶
Load a NIfTI mask as a flat 1-D boolean array.
- Parameters:
path (str or Path)
- Returns:
Shape
(n_total_voxels,), dtype bool.- Return type:
np.ndarray