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