neuromaps.parcellate.Parcellater

class neuromaps.parcellate.Parcellater(parcellation, space, resampling_target='data', hemi=None)[source]

Class for parcellating arbitrary volumetric / surface data.

Parameters:
  • parcellation (str or os.PathLike or Nifti1Image or GiftiImage or tuple) – Parcellation image or surfaces, where each region is identified by a unique integer ID. All regions with an ID of 0 are ignored.

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

  • resampling_target ({'data', 'parcellation', None}, optional) – Gives which image gives the final shape/size. For example, if resampling_target is ‘data’, the parcellation is resampled to the space + resolution of the data, if needed. If it is ‘parcellation’ then any data provided to .fit() are transformed to the space + resolution of parcellation. Providing None means no resampling; if spaces + resolutions of the parcellation and data provided to .fit() do not match a ValueError is raised. Default: ‘data’

  • hemi ({'L', 'R'}, optional) – If provided parcellation represents only one hemisphere of a surface atlas then this specifies which hemisphere. If not specified it is assumed that parcellation is (L, R) hemisphere. Ignored if space is ‘MNI152’. Default: None

fit()[source]

Prepare parcellation for data extraction.

fit_transform(data, space, ignore_background_data=False, background_value=None, hemi=None)[source]

Prepare and perform parcellation of data.

inverse_transform(data)[source]

Project data to space + density of parcellation.

Parameters:

data (array_like) – Parcellated data to be projected to the space of parcellation

Returns:

data – Provided data in space + resolution of parcellation

Return type:

Nifti1Image or tuple-of-nib.GiftiImage

transform(data, space, ignore_background_data=False, background_value=None, hemi=None)[source]

Apply parcellation to data in space.

Parameters:
  • data (str or os.PathLike or Nifti1Image or GiftiImage or tuple) – Data to parcellate

  • space (str) – The space in which data is defined

  • hemi ({'L', 'R'}, optional) – If provided data represents only one hemisphere of a surface dataset then this specifies which hemisphere. If not specified it is assumed that data is (L, R) hemisphere. Ignored if space is ‘MNI152’. Default: None

  • ignore_background_data (bool) – Specifies whether the background data values should be ignored when computing the average data within each parcel. If set to True and background_value is set to None, the background_value is estimated from the data: if there are NaNs in the data, the background value is set to NaN. Otherwise, it is estimated as the median of the values on the border of the images for volumetric images or as the median of the values within the medial wall for surface images. The background value can also be set manually using the background_value parameter. Default: False

  • background_value (float) – Specifies the background value to ignore when computing the averages and when ignore_background_data is True. Default: None

Returns:

parcellated – Parcellated data

Return type:

np.ndarray