From df7913e6b380793a2043dcedbb8bd204a8af59b2 Mon Sep 17 00:00:00 2001 From: Ruben Verweij Date: Wed, 19 Apr 2017 15:05:11 +0200 Subject: [PATCH] Issue #2: fix calculation of image group number when there is no z-axis --- nd2reader/parser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nd2reader/parser.py b/nd2reader/parser.py index 8f52a2f..7ff9d6a 100644 --- a/nd2reader/parser.py +++ b/nd2reader/parser.py @@ -208,8 +208,12 @@ class Parser(object): int: the image group number """ - return frame_number * len(self.metadata["fields_of_view"]) * len(self.metadata["z_levels"]) + ( - fov * len(self.metadata["z_levels"]) + z_level) + z_length = len(self.metadata['z_levels']) + z_length = z_length if z_length > 0 else 1 + fields_of_view = len(self.metadata["fields_of_view"]) + fields_of_view = fields_of_view if fields_of_view > 0 else 1 + + return frame_number * fields_of_view * z_length + (fov * z_length + z_level) def _calculate_frame_number(self, image_group_number, field_of_view, z_level): """