axon_synthesis.atlas¶
Helpers for atlas.
Classes
|
Class to store the Atlas configuration. |
|
Atlas helper. |
- class axon_synthesis.atlas.AtlasConfig(path, region_filename=PosixPath('brain_regions'), layer_names: list[int | str] | None = None, load_region_map: bool = False, outside_region_id: int = 0, use_boundary: bool = True)¶
Bases:
objectClass to store the Atlas configuration.
- path¶
The path to the directory containing the atlas.
- Type:
- region_filename¶
The name of the file containing the brain regions.
- Type:
- class axon_synthesis.atlas.AtlasHelper(config: AtlasConfig, logger=None)¶
Bases:
objectAtlas helper.
- property brain_regions_and_ascendants: DataFrame¶
Return the brain regions and their ascendants from the hierarchy.
- property brain_regions_and_descendants: DataFrame¶
Return the brain regions and their descendants from the hierarchy.
- build_boundary(logger=None)¶
Build the boundary orientations.
- copy()¶
Return a copy of the current atlas.
- get_hemisphere(coord: list[number] | ndarray[Any, dtype[number]], h_axis: int = 2, h_origin: str = 'L') str¶
Return the hemisphere of the given coordinate.
- Parameters:
coord – The coordinate of the point.
h_axis – The axis along which to check the hemisphere.
h_origin – The origin of the hemisphere (‘L’ or ‘R’).
- Returns:
The hemisphere of the given coordinate, ‘L’ or ‘R’.
- get_random_voxel_shifts(size, *, rng: None | int | Sequence[int] | SeedSequence | BitGenerator | Generator = None)¶
Pick random shifts from voxel centers according to the voxel sizes.
- get_region_ids(brain_region_names: int | str | list[int | str], *, with_descendants: bool = True) tuple[list[str | int], list[str | int]]¶
Find brain region IDs from their names, acronyms or direct IDs.
- Parameters:
brain_region_names – The names of the brain regions to get IDs.
with_descendants – If set to True, all the descendants are included.
- get_region_points(brain_region_names: int | str | list[int | str], *, size: int | None = None, random_shifts: bool = False, inverse: bool = False, rng: None | int | Sequence[int] | SeedSequence | BitGenerator | Generator = None) ndarray | tuple[ndarray, list[str | int]]¶
Extract region points from the atlas.
If ‘random_shifts’ is set to False (the default), the voxel centers are returned. If ‘random_shifts’ is set to True, one random point inside each of these voxels (chosen using the given Random Number Generator) are returned.
- Parameters:
brain_region_names – The name of the regions to consider.
size – The number of points to return (they are chosen randomly along the possible ones).
random_shifts – If True, a random shift is applied to return a random point inside the voxel.
inverse – If True, choose points that are NOT located in the given regions.
rng – The random number generator (can be an int used as seed or a numpy Generator).
- get_region_voxels(brain_region_names: int | str | list[int | str], *, inverse: bool = False) ndarray | tuple[ndarray, list[str | int]]¶
Get the coordinates of the voxels located in the given regions from the atlas.
- property pia_coord: VoxelData¶
Return an atlas of the pia coordinate along the principal axis.
- place_point_in_hemisphere(coord: list[number] | ndarray[Any, dtype[number]], hemisphere: str, h_axis: int = 2, h_origin: str = 'L') list[number] | ndarray[Any, dtype[number]]¶
Place the point in the given hemisphere.
If the point is already in the given hemisphere, nothing is done. If the point is in the opposite hemisphere, an axial symmetry of axis h_axis is performed.
- Parameters:
coord – The coordinate of the point.
hemisphere – The hemisphere where the point should be (‘L’ or ‘R’).
h_axis – The axis along which to check the hemisphere.
h_origin – The origin of the hemisphere (‘L’ or ‘R’).
- Returns:
The coordinate of the point in the given hemisphere.
- property region_map¶
Return the region map.
- property region_map_df¶
Return the DF representation of the region map.
- save(path)¶
Export the atlas to the given directory.