From 517ed3f96d0581653e76ebfdcd6ab1357b3dd1ea Mon Sep 17 00:00:00 2001 From: Joost de Folter Date: Fri, 27 Sep 2024 15:05:09 +0200 Subject: [PATCH] Small fixed for position metadata and order redimensioning --- OmeSliCC/OmeSource.py | 12 ++++++++---- OmeSliCC/image_util.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/OmeSliCC/OmeSource.py b/OmeSliCC/OmeSource.py index 5b6b3f4..35044ff 100644 --- a/OmeSliCC/OmeSource.py +++ b/OmeSliCC/OmeSource.py @@ -92,10 +92,14 @@ def _get_ome_metadata(self): position = [] for plane in ensure_list(pixels.get('Plane', [])): - position = [(float(plane.get('PositionX')), plane.get('PositionXUnit')), - (float(plane.get('PositionY')), plane.get('PositionYUnit')), - (float(plane.get('PositionZ')), plane.get('PositionZUnit'))] - c, z, t = plane.get('TheC'), plane.get('TheZ'), plane.get('TheT') + position = [] + if 'PositionX' in plane: + position.append((float(plane.get('PositionX')), plane.get('PositionXUnit'))) + if 'PositionY' in plane: + position.append((float(plane.get('PositionY')), plane.get('PositionYUnit'))) + if 'PositionZ' in plane: + position.append((float(plane.get('PositionZ')), plane.get('PositionZUnit'))) + #c, z, t = plane.get('TheC'), plane.get('TheZ'), plane.get('TheT') self.position = position self.source_mag = 0 diff --git a/OmeSliCC/image_util.py b/OmeSliCC/image_util.py index 717fca2..087664b 100644 --- a/OmeSliCC/image_util.py +++ b/OmeSliCC/image_util.py @@ -104,7 +104,7 @@ def redimension_data(data, old_order, new_order, **indices): index = order.index(o) dim_value = indices.get(o, 0) new_data = np.take(new_data, indices=dim_value, axis=index) - order = order.replace(o, '') + order = order[:index] + order[index + 1:] # add for o in new_order: if o not in order: