nigsp.operations.nifti.apply_mask

nigsp.operations.nifti.apply_mask(data, mask)[source]

Reduce shape and size of data based on mask.

Uses the concept of “mask” as defined in neuroimaging, not in numpy: every voxel that is not 0 is kept, the 0 are excluded.

Parameters:
datanumpy.ndarray

Data to be masked.

masknumpy.ndarray

Mask to be applied - where all elements that are 0 are eliminated.

Returns:
numpy.ndarray

Masked (data.ndim-1 Dimensions) array.

Raises:
ValueError

If the first mask.ndim dimensions of data have a different shape from mask.