nispace.utils.utils.vect_to_vol_arr

nispace.utils.utils.vect_to_vol_arr(vect, parc_arr, parc_idc, bg_value=0)[source]

Broadcast a per-parcel value vector back into a full volume array.

Numba-compiled; requires plain np.ndarray inputs. Inverse operation of parcel-mean extraction (e.g. vol_to_vect_arr()): each voxel is assigned its parcel’s value via a label lookup. No NaN-specific handling (a NaN in vect is simply assigned as-is). Used in plotting.py to reconstruct volume/vertex arrays for rendering.

Parameters:
  • vect (np.ndarray) – Per-parcel values, shape (n_parcels,), in the same order as parc_idc.

  • parc_arr (np.ndarray) – Parcellation label array (any shape; flattened internally).

  • parc_idc (np.ndarray) – Parcel label values corresponding to each entry of vect.

  • bg_value (scalar, default=0) – Value assigned to voxels not belonging to any parcel in parc_idc.

Returns:

Same shape as parc_arr, with each voxel set to its parcel’s value from vect (or bg_value).

Return type:

np.ndarray

Raises:

ValueError – If vect and parc_idc have different lengths.