From 74dc101776206d2c5160a0f4af0bdb8bfde7e58e Mon Sep 17 00:00:00 2001 From: jim Date: Thu, 27 Aug 2015 16:45:47 -0500 Subject: [PATCH] resolves #77: fixes bug where an nd2 with a single cycle or z-level wouldn't work --- jim.py | 4 ++++ nd2reader/parser.py | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 jim.py diff --git a/jim.py b/jim.py new file mode 100644 index 0000000..95738e0 --- /dev/null +++ b/jim.py @@ -0,0 +1,4 @@ +import nd2reader +nd2 = nd2reader.Nd2("/var/nd2s/hawkjo.nd2") + +print(nd2) \ No newline at end of file diff --git a/nd2reader/parser.py b/nd2reader/parser.py index 139e2fb..f00ec01 100644 --- a/nd2reader/parser.py +++ b/nd2reader/parser.py @@ -234,8 +234,10 @@ class Nd2Parser(object): except AttributeError: return [0] except TypeError: - count = int(re.match(pattern, self._dimensions.decode("utf8")).group(1)) - return list(range(count)) + match = re.match(pattern, self._dimensions.decode("utf8")) + if not match: + return [0] + return list(range(int(match.group(1)))) else: return list(range(count))