Source code for neuromaps_mouse.datasets.atlases

"""Atlas data fetching and loading functions."""

from neuromaps_mouse.datasets.utils import (
    MOUSEMAPS_ATLASES,
    fetch_files,
    get_data_dir
)


[docs] def get_atlas_dir(data_dir=None): """Return path to the atlas data directory. Parameters ---------- data_dir : str or Path, optional Base data directory. If None, uses the default. Default is None. Returns ------- Path Path to the atlases subdirectory. """ data_dir = get_data_dir(data_dir=data_dir) return data_dir / "atlases"
[docs] def fetch_allenccfv3(which=None, return_single=True, data_dir=None, verbose=1): """Fetch Allen CCFv3 atlas files. Parameters ---------- which : str or list of str, optional Which atlas file(s) to fetch. Use 'all' or None to fetch all. Default is None. return_single : bool, optional If True and only one file is fetched, return a single path instead of a list. Default is True. data_dir : str or Path, optional Base data directory. If None, uses the default. Default is None. verbose : int, optional Verbosity level. Default is 1. Returns ------- Path or list of Path Path(s) to the fetched atlas file(s). """ data_dir = get_data_dir(data_dir=data_dir) atlas = MOUSEMAPS_ATLASES["allen-ccfv3"] available_files = list(atlas["files"].keys()) if which is None or which == "all": which = list(available_files) if not isinstance(which, list): which = [which] atlas_files = [] for w in which: if w is None or w not in available_files: raise ValueError( f"Invalid 'which' value: {w}. " f"Should be one of {available_files}" ) atlas_files.append(atlas["files"][w]) targ_fname_list = fetch_files( atlas_files, file_type="atlases", data_dir=data_dir, verbose=verbose ) if len(targ_fname_list) == 1 and return_single: return targ_fname_list[0] else: return targ_fname_list
[docs] def fetch_all_atlases(): """Fetch all available atlases.""" pass