nispace.utils.utils.relabel_nifti_parc
- nispace.utils.utils.relabel_nifti_parc(parc, new_order=None, new_labels=None, dtype=None)[source]
Reassign a volumetric parcellation’s integer labels to a new label sequence.
Plain numpy/nibabel (no numba). Volumetric counterpart of
relabel_gifti_parc(); used incore/parcellation.pyfor the same combined cortex+subcortex label-harmonization step.- Parameters:
parc (image-like) – Input volumetric parcellation, loaded via
neuromaps.images.load_nifti.new_order (array-like of int, optional) – Existing label values to keep, in the order they should be relabeled. Defaults to all nonzero labels present in parc, sorted.
new_labels (array-like of int, optional) – New label values corresponding to new_order. Defaults to
1..len(new_order).dtype (optional) – Output label dtype. Defaults to the input image’s dtype.
- Returns:
Volume with labels reassigned.
- Return type:
nibabel.Nifti1Image
- Raises:
ValueError – If new_order/new_labels lengths don’t match the number of existing parcels, or if new_order isn’t a subset of the labels actually present in parc.