nimare.transforms.threshold_image
- threshold_image(image, threshold, thresholding_values=None, tail='upper', fill_value=0)[source]
Threshold an array or Niimg-like object and zero voxels that fail the criterion.
- Parameters:
image (array-like or Niimg-like) – Values to retain where the threshold criterion passes.
threshold (
float) – Threshold applied tothresholding_valuesor, when that argument is omitted, toimageitself.thresholding_values (array-like or Niimg-like, optional) – Values used to determine which voxels survive thresholding. Must match the shape of
image. If omitted, thresholding is applied directly toimage.tail ({"upper", "lower", "two-sided"}, optional) – Threshold direction.
"upper"keeps values >= threshold,"lower"keeps values <= threshold, and"two-sided"keeps values whose absolute value >= threshold. Default is"upper".fill_value (scalar, optional) – Replacement value for voxels that do not survive thresholding. Default is 0.
- Returns:
Thresholded output with the same container type as
image.- Return type:
array-like or Niimg-like