nipy.labs.utils.mask.compute_mask_files¶
- nipy.labs.utils.mask.compute_mask_files(input_filename, output_filename=None, return_mean=False, m=0.2, M=0.9, cc=1, exclude_zeros=False, opening=2)¶
Compute a mask file from fMRI nifti file(s)
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:
- input_filenamestring
nifti filename (4D) or list of filenames (3D).
- output_filenamestring or None, optional
path to save the output nifti image (if not None).
- return_meanboolean, optional
if True, and output_filename is None, return the mean image also, as a 3D array (2nd return argument).
- mfloat, 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.
- exclude_zeros: boolean, optional
Consider zeros as missing values for the computation of the threshold. This option is useful if the images have been resliced with a large padding of zeros.
- opening: int, optional
Size of the morphological opening performed as post-processing
- Returns:
- mask3D boolean array
The brain mask
- mean_image3d ndarray, optional
The main of all the images used to estimate the mask. Only provided if return_mean is True.