coord2region.fetching#

Fetch atlases from multiple sources.

This module provides the AtlasFetcher class to download and manage brain atlases from various sources including Nilearn, MNE, and direct URLs.

Attributes#

Classes#

AtlasFetcher

Fetch atlases from multiple sources.

Module Contents#

coord2region.fetching.logger[source]#
class coord2region.fetching.AtlasFetcher(data_dir: str = None)[source]#

Fetch atlases from multiple sources.

Parameters:

data_dir (str or None, optional) – Directory where downloaded files are cached. Defaults to ~/coord2region.

file_handler[source]#

Helper for file operations.

Type:

AtlasFileHandler

data_dir[source]#

Directory for storing downloaded atlas files.

Type:

str

subjects_dir[source]#

Directory for MNE data.

Type:

str or None

nilearn_data[source]#

Directory for storing Nilearn data.

Type:

str

_atlas_fetchers_nilearn[source]#

Mapping of atlas names to Nilearn fetcher functions.

Type:

dict

_coords_fetchers_nilearn[source]#

Mapping of atlas names to Nilearn coordinate fetchers.

Type:

dict

_atlas_fetchers_mne[source]#

Mapping of atlas names to MNE fetcher functions.

Type:

dict

Examples

>>> fetcher = AtlasFetcher()  
>>> 'aal' in fetcher.list_available_atlases()  
True
ATLAS_URLS[source]#
file_handler[source]#
data_dir = ''[source]#
nilearn_data[source]#
subjects_dir[source]#
list_available_atlases()[source]#

Return a sorted list of available atlas identifiers.

Returns:

Sorted list of available atlas identifiers.

Return type:

list of str

Raises:

None

Examples

>>> fetcher = AtlasFetcher()  
>>> isinstance(fetcher.list_available_atlases(), list)  
True
fetch_atlas(atlas_name: str, atlas_url: str = None, prefer: str = 'nilearn', **kwargs)[source]#

Fetch an atlas given an identifier.

The identifier may be a URL, local file path, or a known atlas name. The prefer flag allows choosing the primary source ("nilearn" or "mne").

Parameters:
  • atlas_name (str) – The name of the atlas or a URL.

  • atlas_url (str or None, optional) – Explicit URL of the atlas file.

  • prefer ({"nilearn", "mne"}, optional) – Preferred source for fetching the atlas.

  • **kwargs – Additional keyword arguments for fetching.

Returns:

Atlas volume, header, labels, and description.

Return type:

dict

Raises:

Examples

>>> fetcher = AtlasFetcher()  
>>> out = fetcher.fetch_atlas('aal')  
>>> out['labels'][0]  
'Precentral_L'
coord2region.fetching.HCP_LICENSE_ENV = 'COORD2REGION_ACCEPT_HCPMMP'[source]#
coord2region.fetching.HCP_LICENSE_PATH[source]#