From 0869a2fa2132212effa07626669a012d75043118 Mon Sep 17 00:00:00 2001
From: Tamino Huxohl <thuxohl@techfak.uni-bielefeld.de>
Date: Mon, 29 Aug 2022 13:38:54 +0200
Subject: [PATCH] prepare script selects shape with fewest slices for meta.csv

---
 mu_map/data/prepare.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/mu_map/data/prepare.py b/mu_map/data/prepare.py
index 2037fd7..3f5adfc 100644
--- a/mu_map/data/prepare.py
+++ b/mu_map/data/prepare.py
@@ -406,7 +406,7 @@ if __name__ == "__main__":
                     ), f"Not all pixel spacings of the reconstructions are equal: {pixel_spacings}"
                     pixel_spacing = pixel_spacings[0]
 
-                    # extract shapes and assert that they are equal for all reconstruction images
+                    # use the shape with the fewest slices, all other images will be aligned to that
                     _map_lists = map(
                         lambda image: [image.Rows, image.Columns, image.NumberOfSlices],
                         recon_images,
@@ -414,9 +414,7 @@ if __name__ == "__main__":
                     _map_lists = map(lambda shape: list(map(int, shape)), _map_lists)
                     _map_ndarrays = map(lambda shape: np.array(shape), _map_lists)
                     shapes = list(_map_ndarrays)
-                    _equal = all(map(lambda shape: (shape == shapes[0]).all(), shapes))
-                    # assert _equal, f"Not all shapes of the reconstructions are equal: {shapes}"
-                    # print(shapes)
+                    shapes.sort(key=lambda shape: shape[2])
                     shape = shapes[0]
 
                     # exctract and sort energy windows
-- 
GitLab