vreg.read_nifti#

vreg.read_nifti(filepath: str, coords: ndarray | None = None, dims: list | None = None, prec: int | None = None)[source]#

Read volume from a NIfTI file on disk.

Parameters:
  • filepath (str) – filepath to the NIfTI file.

  • coords (np.ndarray) – For values with dimensions more than 3, provide an additional coordinate array for the locations of the replicated volumes. If not provided, index arrays are used for the coordinates of the extra dimensions.

  • dims (list) – Names of the extra dimensions for volumes with more than 3 dimensions.

  • prec (int) – internal precision to be used when comparing positions. If not provided, the exact floating point values of locations are used. Defaults to None.

Raises:

ImportError – Error raised if nibabel is not installed.

Returns:

the volume read from file.

Return type:

Volume3D

Note

This requires a separate installation of the optional nibabel package, either via ‘pip install nibabel’ or by installing vreg with the rw option ‘pip install vreg[rw]’.

Warning

For volumes with more than 3 dimensions, coordinates and dimensions need to be provided separately as nifti does not store those.