nispace.nulls.find_parcel_hemispheres

nispace.nulls.find_parcel_hemispheres(parcellation)[source]

Auto-detect per-parcel hemisphere membership for a parcellation.

Plain numpy/nibabel (no numba). Used in core/parcellation.py for parcel-hemisphere bookkeeping (e.g. building parc_idc_lh/parc_idc_rh for downstream spin/distance-based null generation).

Parameters:

parcellation (tuple of two GiftiImage, nib.Nifti1Image, or single GiftiImage) –

  • Bilateral surface ((lh_img, rh_img)): trivial split by hemisphere.

  • Volumetric: each parcel’s hemisphere is decided by the majority of its voxels’ x-coordinate sign (world space, via the image affine).

  • Single (unilateral) GiftiImage: hemisphere membership cannot be determined without a second hemisphere to compare against.

Returns:

Index arrays (positions into the concatenated label list) and label arrays for each hemisphere. All four are None for single-Gifti input (undeterminable).

Return type:

(idc_lh, idc_rh), (labels_lh, labels_rh)

Raises:

ValueError – If parcellation is not one of the supported types.