liom_toolkit.utils.allen_sdk module

liom_toolkit.utils.allen_sdk.construct_reference_space(data_dir: str, resolution: int = 25, reference_space_key: str = 'annotation/ccf_2017') ReferenceSpace

Construct a reference space for the Allen brain atlas. Will use the 2017 adult version of the atlas.

Parameters:
  • data_dir (str) – The directory where the atlas and structure tree are saved.

  • resolution (int) – The resolution of the atlas in micron. Must be 10, 25, 50 or 100 microns

  • reference_space_key (str) – The reference space key to use.

Returns:

The reference space.

Return type:

ReferenceSpace

liom_toolkit.utils.allen_sdk.construct_reference_space_cache(resolution: int = 25, reference_space_key: str = 'annotation/ccf_2017') ReferenceSpaceCache

Construct a reference space cache for the Allen brain atlas. Will use the 2017 adult version of the atlas.

Parameters:
  • resolution (int) – The resolution of the atlas in micron. Must be 10, 25, 50 or 100 microns

  • reference_space_key (str) – The reference space key to use.

Returns:

The reference space cache.

Return type:

ReferenceSpaceCache

liom_toolkit.utils.allen_sdk.convert_allen_nrrd_to_ants(volume: ndarray, resolution: float) ANTsImage

Convert a nrrd file form the Allen reference spaces to an ants image. The returned image will be in RAS+ orientation.

Parameters:
  • volume (np.ndarray) – The already loaded nrrd file.

  • resolution (float) – The resolution of the nrrd file in millimeters.

Returns:

The converted image.

Return type:

ANTsImage

liom_toolkit.utils.allen_sdk.download_allen_atlas(data_dir: str, resolution: int = 25, keep_nrrd: bool = False) -> (<class 'ants.core.ants_image.ANTsImage'>, <class 'pandas.core.frame.DataFrame'>)

Download the allen mouse brain atlas and reorient it to RAS+.

Parameters:
  • data_dir (str) – The directory to save the atlas to.

  • resolution – The resolution of the atlas in micron. Must be 10, 25, 50 or 100 microns

  • resolution – int

  • keep_nrrd – Whether to keep the nrrd file or not.

  • keep_nrrd – bool

Returns:

The atlas as an ants image.

:rtype:(ANTsImage, pd.DataFrame)

liom_toolkit.utils.allen_sdk.download_allen_template(data_dir: str, resolution: int = 25, keep_nrrd: bool = False, rsc: ReferenceSpaceCache | None = None) ANTsImage

Download the allen mouse brain template in RAS+ orientation.

Parameters:
  • data_dir (str) – The directory to save the template to.

  • resolution (int) – The template resolution in micron. Must be 10, 25, 50 or 100 microns

  • keep_nrrd (bool) – Whether to keep the nrrd file or not.

  • rsc (ReferenceSpaceCache) – The reference space cache to use. If None, a new one will be constructed.

Returns:

The template as an ants image.

Return type:

ANTsImage

liom_toolkit.utils.allen_sdk.generate_label_color_dict_allen() list[dict]

Generate a label color dictionary for the allen atlas.

Returns:

The label color dictionary.

Return type:

list[dict]

liom_toolkit.utils.allen_sdk.load_allen_template(atlas_file: str, resolution: int, padding: bool) ANTsImage

Load the allen template and set the resolution and direction (PIR).

Parameters:
  • atlas_file (str) – The file to load.

  • resolution (int) – The resolution to set.

  • padding (bool) – Whether to pad the atlas or not.

Returns:

The loaded template.

Return type:

ANTsImage