Base Functions

transbrain.base.get_region_phenotypes(phenotype_nii_path, atlas_dict, atlas_type='bn', region_type='all', method='mean', resample=True, label_column='Atlas Index', region_column='Anatomical Name')[source]

Calculate region-wise phenotype values using a specified brain atlas.

This function extracts regional statistics (mean or sum) from a phenotype NIfTI image based on a chosen human or mouse brain atlas. The atlas can be automatically resampled to match the phenotype image resolution if needed.

Parameters:
  • phenotype_nii_path (str) – Path to the input phenotype NIfTI file. Should be in MNI space for human atlases, or Allen CCFv3 space for mouse atlas.

  • atlas_dict (dict) –

    A dictionary containing the following keys:

    • ’atlas’: The loaded atlas image.

    • ’atlas_data’: The atlas data as a numpy array.

    • ’region_info’: A list of anatomical names for the specified regions.

    • ’info_table’: The full ROI information table.

  • atlas_type ({'bn', 'dk', 'aal','mouse}, optional) –

    The type of atlas. Must be one of:

    • ’bn’ : Brainnetome Atlas (default)

    • ’dk’ : Desikan-Killiany Atlas

    • ’aal’ : Automated Anatomical Labeling (AAL) Atlas

    • ’mouse’ : Allen Mouse CCFv3 atlas

  • region_type ({'cortex', 'subcortex', 'all'}, optional) – Which regions to include in returned region names and info table: cortical, subcortical, or all. Default is ‘all’.

  • method ({'mean', 'sum'}, optional) – Method for aggregating voxel values within each region. Default is ‘mean’.

  • resample (bool, optional) – If True, resample the atlas to match the shape and resolution of the phenotype image. Default is True.

  • label_column (str, optional) – Name of the column in the atlas label CSV that contains numeric label indices. Default is ‘Atlas Index’.

  • region_column (str, optional) – Name of the column in the atlas label CSV that contains region names. Default is ‘Anatomical Name’.

Returns:

A DataFrame with aggregated phenotype values (mean or sum) for each region, , indexed by brain region name.

Return type:

pandas.DataFrame