diff --git a/nd2reader/model/__init__.py b/nd2reader/model/__init__.py index df1ed75..cfb7e28 100644 --- a/nd2reader/model/__init__.py +++ b/nd2reader/model/__init__.py @@ -62,13 +62,19 @@ class Image(object): @property def timestamp(self): - # TODO: Convert to datetime object + """ + The number of seconds after the beginning of the acquisition that the image was taken. Note that for a given field + of view and z-level offset, if you have images of multiple channels, they will all be given the same timestamp. + No, this doesn't make much sense. But that's how ND2s are structured, so if your experiment depends on millisecond + accuracy, you need to find an alternative imaging system. + + """ return self._timestamp / 1000.0 @property def data(self): if self._data is None: - self._data = np.reshape(self._raw_data, (self._height, self._width)) + self._data = np.reshape(self._raw_data, (self._height, self._width)).astype(np.float64) return self._data @property diff --git a/nd2reader/service/__init__.py b/nd2reader/service/__init__.py index b07fbc3..fdd0f65 100644 --- a/nd2reader/service/__init__.py +++ b/nd2reader/service/__init__.py @@ -29,7 +29,7 @@ class BaseNd2(object): def channels(self): metadata = self._metadata['ImageMetadataSeq']['SLxPictureMetadata']['sPicturePlanes'] try: - validity = self._metadata['ImageMetadata']['SLxExperiment']['ppNextLevelEx']['']['ppNextLevelEx']['']['pItemValid'] + validity = self._metadata['ImageMetadata']['SLxExperiment']['ppNextLevelEx'][''][0]['ppNextLevelEx'][''][0]['pItemValid'] except KeyError: # If none of the channels have been deleted, there is no validity list, so we just make one validity = [True for i in metadata] @@ -69,7 +69,7 @@ class BaseNd2(object): NIS Elements can figure it out, but we haven't found it yet. """ - return sum(self._metadata['ImageMetadata']['SLxExperiment']['ppNextLevelEx']['']['pItemValid']) + return sum(self._metadata['ImageMetadata']['SLxExperiment']['ppNextLevelEx'][''][0]['pItemValid']) @property def channel_count(self):