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#
Fetch atlases from multiple sources. |
Module Contents#
- 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.
Examples
>>> fetcher = AtlasFetcher() >>> 'aal' in fetcher.list_available_atlases() True
- list_available_atlases()[source]#
Return a sorted list of available atlas identifiers.
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
preferflag allows choosing the primary source ("nilearn"or"mne").- Parameters:
- Returns:
Atlas volume, header, labels, and description.
- Return type:
- Raises:
ValueError – If the atlas name is not recognized.
FileNotFoundError – If the atlas file or labels file is not found.
Exception – If there is an error during fetching.
Examples
>>> fetcher = AtlasFetcher() >>> out = fetcher.fetch_atlas('aal') >>> out['labels'][0] 'Precentral_L'