liom_toolkit.registration.utils module

liom_toolkit.registration.utils.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.registration.utils.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.registration.utils.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:

ants.ANTsImage

liom_toolkit.registration.utils.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:(ants.ANTsImage, pd.DataFrame)

liom_toolkit.registration.utils.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:

ants.ANTsImage