NIPY logo

Site Navigation

NIPY Community

Previous topic

nipy.labs.utils.mask.compute_mask_sessions

Next topic

nipy.labs.utils.mask.compute_mask_files

This Page

nipy.labs.utils.mask.compute_mask

nipy.labs.utils.mask.compute_mask(mean_volume, reference_volume=None, m=0.2, M=0.9, cc=True, opening=True)

Compute a mask file from fMRI data in 3D or 4D ndarrays.

Compute and write the mask of an image based on the grey level This is based on an heuristic proposed by T.Nichols: find the least dense point of the histogram, between fractions m and M of the total image histogram.

In case of failure, it is usually advisable to increase m.

Parameters :

mean_volume : 3D ndarray

mean EPI image, used to compute the threshold for the mask.

reference_volume: 3D ndarray, optional :

reference volume used to compute the mask. If none is give, the mean volume is used.

m : float, optional

lower fraction of the histogram to be discarded.

M: float, optional :

upper fraction of the histogram to be discarded.

cc: boolean, optional :

if cc is True, only the largest connect component is kept.

opening: boolean, optional :

if opening is True, an morphological opening is performed, to keep only large structures. This step is useful to remove parts of the skull that might have been included.

Returns :

mask : 3D boolean ndarray

The brain mask