From 2298c82da4ca9b73a48ca940365eea8b893f50a5 Mon Sep 17 00:00:00 2001 From: Ruben Verweij Date: Thu, 6 Apr 2017 15:35:16 +0200 Subject: [PATCH] Fix the number of frames --- nd2reader/raw_metadata.py | 13 +++---------- nd2reader/reader.py | 5 +++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/nd2reader/raw_metadata.py b/nd2reader/raw_metadata.py index 2a72663..888bb8a 100644 --- a/nd2reader/raw_metadata.py +++ b/nd2reader/raw_metadata.py @@ -33,14 +33,15 @@ class RawMetadata(object): if self._metadata_parsed is not None: return self._metadata_parsed + frames_per_channel = self._parse_total_images_per_channel() self._metadata_parsed = { "height": self._parse_if_not_none(self.image_attributes, self._parse_height), "width": self._parse_if_not_none(self.image_attributes, self._parse_width), "date": self._parse_if_not_none(self.image_text_info, self._parse_date), "fields_of_view": self._parse_fields_of_view(), - "frames": self._parse_frames(), + "frames": np.arange(0, frames_per_channel, 1), "z_levels": self._parse_z_levels(), - "total_images_per_channel": self._parse_total_images_per_channel(), + "total_images_per_channel": frames_per_channel, "channels": self._parse_channels(), "pixel_microns": self._parse_if_not_none(self.image_calibration, self._parse_calibration), } @@ -114,14 +115,6 @@ class RawMetadata(object): """ return self._parse_dimension(r""".*?XY\((\d+)\).*?""") - def _parse_frames(self): - """The number of cycles. - - Returns: - list: list of all the frame numbers - """ - return self._parse_dimension(r""".*?T'?\((\d+)\).*?""") - def _parse_z_levels(self): """The different levels in the Z-plane. diff --git a/nd2reader/reader.py b/nd2reader/reader.py index 663d389..9d5f343 100644 --- a/nd2reader/reader.py +++ b/nd2reader/reader.py @@ -147,6 +147,11 @@ class ND2Reader(FramesSequenceND): if loop['stimulation']: continue + if loop['sampling_interval'] == 0: + # This is a loop were no data is acquired + current_time += loop['duration'] + continue + timesteps = np.concatenate( (timesteps, np.arange(current_time, current_time + loop['duration'], loop['sampling_interval']))) current_time += loop['duration']