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.glm.threshold_stats_img

nilearn.glm.threshold_stats_img(stat_img=None, mask_img=None, alpha=0.001, threshold=3.0, height_control='fpr', cluster_threshold=0, two_sided=True)[source]

Compute the required threshold level and return the thresholded map.

Parameters:
stat_imgNiimg-like object, or a SurfaceImage or None, default=None

Statistical image (presumably in z scale) whenever height_control is ‘fpr’ or None, stat_img=None is acceptable. If it is ‘fdr’ or ‘bonferroni’, an error is raised if stat_img is None.

mask_imgNiimg-like object, default=None

Mask image

alphafloat or list, default=0.001

Number controlling the thresholding (either a p-value or q-value). Its actual meaning depends on the height_control parameter. This function translates alpha to a z-scale threshold.

thresholdfloat, default=3.0

Desired threshold in z-scale. This is used only if height_control is None.

Note

  • When two_sided is True:

    'threshold' cannot be negative.

    The given value should be within the range of minimum and maximum intensity of the input image. All intensities in the interval [-threshold, threshold] will be set to zero.

  • When two_sided is False:

    • If the threshold is negative:

      It should be greater than the minimum intensity of the input data. All intensities greater than or equal to the specified threshold will be set to zero. All other intensities keep their original values.

    • If the threshold is positive:

      It should be less than the maximum intensity of the input data. All intensities less than or equal to the specified threshold will be set to zero. All other intensities keep their original values.

height_controlstr, or None, default=’fpr’

False positive control meaning of cluster forming threshold: None|’fpr’|’fdr’|’bonferroni’

cluster_thresholdfloat, default=0

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

two_sidedbool, default=True

Whether the thresholding should yield both positive and negative part of the maps. In that case, alpha is corrected by a factor of 2.

Returns:
thresholded_mapNifti1Image,

The stat_map thresholded at the prescribed voxel- and cluster-level.

thresholdfloat

The voxel-level threshold used actually.

See also

nilearn.image.threshold_img

Apply an explicit voxel-level (and optionally cluster-level) threshold without correction.

Notes

If the input image is not z-scaled (i.e. some z-transformed statistic) the computed threshold is not rigorous and likely meaningless

Examples using nilearn.glm.threshold_stats_img

Intro to GLM Analysis: a single-run, single-subject fMRI dataset

Intro to GLM Analysis: a single-run, single-subject fMRI dataset

Plotting images with transparent thresholding

Plotting images with transparent thresholding

Example of generic design in second-level models

Example of generic design in second-level models

Statistical testing of a second-level analysis

Statistical testing of a second-level analysis

Voxel-Based Morphometry on OASIS dataset

Voxel-Based Morphometry on OASIS dataset