Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

nilearn.image.threshold_img#

nilearn.image.threshold_img(img, threshold, cluster_threshold=0, two_sided=True, mask_img=None, copy=True)[source]#

Threshold the given input image, mostly statistical or atlas images.

Thresholding can be done based on direct image intensities or selection threshold with given percentile.

Changed in version 0.9.0: New cluster_threshold and two_sided parameters added.

New in version 0.2.

Parameters:
imga 3D/4D Niimg-like object

Image containing statistical or atlas maps which should be thresholded.

thresholdfloat or str

Voxels with intensities less than the requested threshold will be set to zero. Those with intensities greater or equal than the requested threshold will keep their original value. If float, we threshold the image based on image intensities. The given value should be within the range of minimum and maximum intensity of the input image. If string, it should finish with percent sign e.g. “80%” and we threshold based on the score obtained using this percentile on the image data. The given string should be within the range of “0%” to “100%”. The percentile rank is computed using scipy.stats.scoreatpercentile.

cluster_thresholdfloat, default=0

Cluster size threshold, in voxels. In the returned thresholded map, sets of connected voxels (clusters) with size smaller than this number will be removed.

New in version 0.9.0.

two_sidedbool, default=True

Whether the thresholding should yield both positive and negative part of the maps.

New in version 0.9.0.

mask_imgNiimg-like object, default=None

Mask image applied to mask the input data. If None, no masking will be applied.

copybool, default=True

If True, input array is not modified. True by default: the filtering is not performed in-place.

Returns:
Nifti1Image

Thresholded image of the given input image.

See also

nilearn.glm.threshold_stats_img

Threshold a statistical image using the alpha value, optionally with false positive control.

Examples using nilearn.image.threshold_img#

Encoding models for visual stimuli from Miyawaki et al. 2008

Encoding models for visual stimuli from Miyawaki et al. 2008

Statistical testing of a second-level analysis

Statistical testing of a second-level analysis

Region Extraction using a t-statistical map (3D)

Region Extraction using a t-statistical map (3D)