From 4c894fb21faa76c4360aa467676cb19e0741e647 Mon Sep 17 00:00:00 2001 From: jim Date: Wed, 10 Dec 2014 09:32:42 -0600 Subject: [PATCH] refactored a bit --- .gitignore | 1 + nd2reader/__init__.py | 4 ++-- nd2reader/service/__init__.py | 7 ++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 1a5c508..cfa1b7a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ run.py __pycache__/ *.py[cod] .idea/ +*.idea/* # C extensions *.so diff --git a/nd2reader/__init__.py b/nd2reader/__init__.py index d53beeb..db04f99 100644 --- a/nd2reader/__init__.py +++ b/nd2reader/__init__.py @@ -30,11 +30,11 @@ class Nd2(BaseNd2): if image.is_valid: yield image - def image_sets(self, field_of_view, timepoints=None, channels=None, z_levels=None): + def image_sets(self, field_of_view, time_indices=None, channels=None, z_levels=None): """ Gets all the images for a given field of view and """ - timepoint_set = xrange(self.timepoint_count) if timepoints is None else timepoints + timepoint_set = xrange(self.timepoint_count) if time_indices is None else time_indices channel_set = [channel.name for channel in self.channels] if channels is None else channels z_level_set = xrange(self.z_level_count) if z_levels is None else z_levels diff --git a/nd2reader/service/__init__.py b/nd2reader/service/__init__.py index fdd0f65..8798392 100644 --- a/nd2reader/service/__init__.py +++ b/nd2reader/service/__init__.py @@ -69,7 +69,12 @@ class BaseNd2(object): NIS Elements can figure it out, but we haven't found it yet. """ - return sum(self._metadata['ImageMetadata']['SLxExperiment']['ppNextLevelEx'][''][0]['pItemValid']) + try: + valid_fovs = self._metadata['ImageMetadata']['SLxExperiment']['ppNextLevelEx'][''][0]['pItemValid'] + except KeyError: + # if nothing was deleted, there won't be a 0 key + valid_fovs = self._metadata['ImageMetadata']['SLxExperiment']['ppNextLevelEx']['']['pItemValid'] + return sum(valid_fovs) @property def channel_count(self):