From 1fed0c1fb1e3653d2db212448b5ab790233856b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Sep 2019 17:53:25 -0400 Subject: [PATCH] fix to allow reading of ND2-files with missing frames, due to e.g. skipping z-positions in one channel of a multichannel image; based on most recent commit of master --- nd2reader/parser.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nd2reader/parser.py b/nd2reader/parser.py index de7e7c3..2bdcb58 100644 --- a/nd2reader/parser.py +++ b/nd2reader/parser.py @@ -283,7 +283,13 @@ class Parser(object): if np.any(image_data): return timestamp, Frame(image_data, metadata=self._get_frame_metadata()) - raise NoImageError + # If a blank "gap" image is encountered, generate an empty frame (black image) of corresponding height and width to avoid + # errors with ND2-files with missing frames. + else: + empty_frame = np.zeros([height, width]) + return timestamp, Frame(empty_frame, metadata=self._get_frame_metadata()) + + # raise NoImageError # <-- delete? def _get_frame_metadata(self): """Get the metadata for one frame