nispace.utils.utils.get_background_value
- nispace.utils.utils.get_background_value(img, border_size=2)[source]
Auto-detect a volumetric image’s background value from its border voxels.
Adapted from
nilearn.masking.compute_background_mask. Only implemented for 3D/volumetric input — for anything else (e.g. surface data), this silently returnsNonerather than raising. Used byParcellaterto resolvebackground_value="auto"(see [[project_parcellation_bg_handling]]).- Parameters:
img (image-like) – Input accepted by
neuromaps.images.load_data.border_size (int, default=2) – Border thickness (in voxels) sampled to estimate the background.
- Returns:
The detected background value (border median),
np.nanif any border voxel is NaN, orNoneif img is not 3D.- Return type:
float, np.nan, or None