From 03c4a1305bf181d87409f6a9bb09d5d4fb46fc38 Mon Sep 17 00:00:00 2001 From: alessandrofelder Date: Mon, 22 Jul 2024 18:06:41 +0100 Subject: [PATCH] quickfix wrapup for admba, fix admba orientation/resolution Result of mob-programming! Co-authored-by: Viktor Plattner Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> --- .../atlas_scripts/admba_3d_dev_mouse.py | 8 +++++++- .../atlas_generation/wrapup.py | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py b/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py index 29a8583b..e80d869f 100644 --- a/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py +++ b/brainglobe_atlasapi/atlas_generation/atlas_scripts/admba_3d_dev_mouse.py @@ -302,6 +302,7 @@ def create_atlas( cleanup_files=False, compress=True, scale_meshes=True, + resolution_mapping=[2, 1, 0], ) print("Done. Atlas generated at: ", output_filename) return output_filename @@ -319,7 +320,12 @@ def create_atlas( atlas_link="https://search.kg.ebrains.eu/instances/8ab25629-bdac-47d0-bc86-6f3aa3885f29", atlas_file_url="https://data.kg.ebrains.eu/zip?container=https://object.cscs.ch/v1/AUTH_4791e0a3b3de43e2840fe46d9dc2b334/ext-d000023_3Drecon-ADMBA-E11pt5_pub", orientation="rsa", - resolution=(16, 20, 16), # possibly try 20, 16, 16 + resolution=( + 16, + 16, + 20, + ), # this is in ASR, the target orientation. + # The resolution in LR is lower than SI and AP! citation="Young et al. 2021, https://doi.org/10.7554/eLife.61408", root_id=15564, atlas_packager="Pradeep Rajasekhar, WEHI, Australia, " diff --git a/brainglobe_atlasapi/atlas_generation/wrapup.py b/brainglobe_atlasapi/atlas_generation/wrapup.py index ef0f9f6d..fc86fe1d 100644 --- a/brainglobe_atlasapi/atlas_generation/wrapup.py +++ b/brainglobe_atlasapi/atlas_generation/wrapup.py @@ -48,6 +48,7 @@ def wrapup_atlas_from_data( cleanup_files=False, compress=True, scale_meshes=False, + resolution_mapping=None, additional_references={}, additional_metadata={}, ): @@ -102,6 +103,9 @@ def wrapup_atlas_from_data( If True the meshes points are scaled by the resolution to ensure that they are specified in microns, regardless of the atlas resolution. + resolution_mapping: list, optional + a list of three mapping the target space axes to the source axes + only needed for mesh scaling of anisotropic atlases additional_references: dict, optional (Default value = empty dict). Dictionary with secondary reference stacks. @@ -171,7 +175,20 @@ def wrapup_atlas_from_data( if scale_meshes: # Scale the mesh to the desired resolution, BEFORE transforming: - mesh.points *= resolution + # Note that this transformation happens in original space, + # but the resolution is passed in target space (typically ASR) + if not resolution_mapping: + # isotropic case, so don't need to re-map resolution + mesh.points *= resolution + else: + # resolution needs to be transformed back + # to original space in anisotropic case + original_resolution = ( + resolution[resolution_mapping[0]], + resolution[resolution_mapping[1]], + resolution[resolution_mapping[2]], + ) + mesh.points *= original_resolution # Reorient points: mesh.points = space_convention.map_points_to(