nispace.io.parcellate_data

nispace.io.parcellate_data#

nispace.io.parcellate_data(data, data_labels=None, data_space=None, parcellation=None, parc_labels=None, parc_space=None, parc_hemi=None, resampling_target='data', drop_background_parcels=True, min_num_valid_datapoints=None, min_fraction_valid_datapoints=None, return_parc=False, dtype=None, n_proc=1, verbose=True, ignore_zero_division_warning=True)[source]#

Parcellates given imaging data using a specified parcellation.

Parameters:
  • parcellation (str, os.PathLike, nib.Nifti1Image, nib.GiftiImage, or tuple) – The parcellation image or surfaces, where each region is identified by a unique integer ID.

  • parc_labels (list) – Labels for the parcellation regions.

  • parc_space (str) – The space in which the parcellation is defined.

  • parc_hemi (list of str) – Hemispheres to consider for parcellation, e.g., [“L”, “R”].

  • resampling_target ({'data', 'parcellation'}) – Specifies which image gives the final shape/size.

  • data (list, dict, pd.DataFrame, pd.Series, or np.ndarray) – The imaging data to be parcellated.

  • data_labels (list) – Labels for the input data.

  • data_space (str) – The space in which the input data is defined.

  • drop_background_parcels (bool) – Whether to drop parcels that contain only background intensity.

  • min_num_valid_datapoints (int, optional) – Minimum number of valid datapoints required per parcel.

  • min_fraction_valid_datapoints (float, optional) – Minimum fraction of valid datapoints required per parcel.

  • n_proc (int) – Number of processors to use for parallel processing.

  • dtype (data-type) – Desired data type of the output.

Returns:

Parcellated data in a DataFrame.

Return type:

pd.DataFrame

Raises:
  • TypeError – If the input data type is not recognized.

  • ValueError – If the resampling target is invalid.

Notes

This function handles different types of input data, including lists, DataFrames, Series, and ndarrays. It also manages different parcellation formats and resampling targets.