nigsp.io.load_nifti_get_mask

nigsp.io.load_nifti_get_mask(fname, is_mask=False, ndim=4)[source]

Load a nifti file and returns its data, its image, and a 3d mask.

Parameters:
fnamestr

The filename to read in

is_maskbool, optional

If the file contains a mask. Default: False

ndimint or None, optional

The number of dimensions expected in the data. If None (default), 4 dimensions are expected, unless is_mask=True. In the latter case, 3 dimensions will be checked.

Returns:
datanumpy.ndarray

Data from nifti file.

masknumpy.ndarray

If is_mask is False, numpy.ndarray of one dimension less than data, in which any element that has at least a value different from zero in the last dimension of data is True. If is_mask is True, mask is a boolean representation of data.

imgnib.img

Image object from nibabel.