nispace.utils.utils.relabel_gifti_parc
- nispace.utils.utils.relabel_gifti_parc(parc, new_labels=None)[source]
Reassign a surface parcellation’s integer labels to a new label sequence.
Plain numpy/nibabel (no numba). Used in
core/parcellation.pyto harmonize labels when combining a cortex surface parcellation with a subcortex volume parcellation into one combined (“+”) parcellation.- Parameters:
parc (nib.GiftiImage) – Input surface parcellation (single hemisphere).
new_labels (array-like of int, optional) – New label values, one per existing (nonzero) parcel, in the order of
np.uniqueof the existing labels. Defaults to1..n_parcels.
- Returns:
Deep copy of parc with labels reassigned.
- Return type:
nib.GiftiImage
- Raises:
ValueError – If parc is not a GiftiImage, if new_labels is not 1D array-like, or if its length doesn’t match the number of existing parcels.