From b267d769244144ab3fb2a726f51eb4b680b1a658 Mon Sep 17 00:00:00 2001 From: jim Date: Sun, 9 Aug 2015 12:13:54 -0500 Subject: [PATCH 1/8] resolves #71: minor improvements to Makefile --- Makefile | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8a6a193..c5d8cb6 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,25 @@ -.PHONY: build py2shell py3shell test +.PHONY: info build shell py2 py3 test + +info: + @echo "" + @echo "Available Make Commands" + @echo "" + @echo "build: builds the image" + @echo "py2: mounts ~/Documents/nd2s to /var/nd2s and runs a Python 2.7 interpreter" + @echo "py3: mounts ~/Documents/nd2s to /var/nd2s and runs a Python 3.4 interpreter" + @echo "test: runs all unit tests (in Python 3.4)" + @echo "" build: docker build -t jimrybarski/nd2reader . -py2shell: +shell: + docker run --rm -v ~/Documents/nd2s:/var/nd2s -it jimrybarski/nd2reader bash + +py2: docker run --rm -v ~/Documents/nd2s:/var/nd2s -it jimrybarski/nd2reader python2.7 -py3shell: +py3: docker run --rm -v ~/Documents/nd2s:/var/nd2s -it jimrybarski/nd2reader python3.4 test: build From 1083ff663ba3b0c729e0283aaea0c926715c449c Mon Sep 17 00:00:00 2001 From: Jim Rybarski Date: Mon, 24 Aug 2015 21:32:55 -0500 Subject: [PATCH 2/8] resolves #69: Added docker ignore file --- .dockerignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..33aa1ed --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.gitignore +.git +*.md +*.txt +Dockerfile +Makefile +setup.cfg +env \ No newline at end of file From ac94f3789f04e661518b4af89fa1cacb3e6563c5 Mon Sep 17 00:00:00 2001 From: Jim Rybarski Date: Mon, 24 Aug 2015 23:17:47 -0500 Subject: [PATCH 3/8] resolves #73: it's now much easier to do functional testing via docker --- Dockerfile | 5 +++++ Makefile | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0334d55..7e9a453 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,12 +16,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ python-pip \ python3-pip \ libfreetype6-dev \ + python-numpy \ + python3-numpy \ python3-matplotlib \ libfreetype6-dev \ libpng-dev \ libjpeg-dev \ pkg-config \ python3-skimage \ + tk \ + tk-dev \ + python3-tk \ && pip3 install -U cython \ scikit-image \ && rm -rf /var/lib/apt/lists/* diff --git a/Makefile b/Makefile index c5d8cb6..7906c9d 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ info: @echo "Available Make Commands" @echo "" @echo "build: builds the image" - @echo "py2: mounts ~/Documents/nd2s to /var/nd2s and runs a Python 2.7 interpreter" - @echo "py3: mounts ~/Documents/nd2s to /var/nd2s and runs a Python 3.4 interpreter" + @echo "py2: maps ~/Documents/nd2s to /var/nd2s and runs a Python 2.7 interpreter" + @echo "py3: maps ~/Documents/nd2s to /var/nd2s and runs a Python 3.4 interpreter" @echo "test: runs all unit tests (in Python 3.4)" @echo "" @@ -14,13 +14,13 @@ build: docker build -t jimrybarski/nd2reader . shell: - docker run --rm -v ~/Documents/nd2s:/var/nd2s -it jimrybarski/nd2reader bash + xhost local:root; docker run --rm -v ~/Documents/nd2s:/var/nd2s -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$(DISPLAY) -it jimrybarski/nd2reader bash py2: - docker run --rm -v ~/Documents/nd2s:/var/nd2s -it jimrybarski/nd2reader python2.7 + xhost local:root; docker run --rm -v ~/Documents/nd2s:/var/nd2s -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$(DISPLAY) -it jimrybarski/nd2reader python2.7 py3: - docker run --rm -v ~/Documents/nd2s:/var/nd2s -it jimrybarski/nd2reader python3.4 + xhost local:root; docker run --rm -v ~/Documents/nd2s:/var/nd2s -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$(DISPLAY) -it jimrybarski/nd2reader python3.4 test: build docker run --rm -it jimrybarski/nd2reader python3.4 /opt/nd2reader/tests.py From 46d8ccd019aaa9a9184236fd9211a8da2b04d0b7 Mon Sep 17 00:00:00 2001 From: jim Date: Tue, 25 Aug 2015 18:26:56 -0500 Subject: [PATCH 4/8] added build files to dockerignore --- .dockerignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 33aa1ed..85515a5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,4 +5,7 @@ Dockerfile Makefile setup.cfg -env \ No newline at end of file +env +*.egg-info +build +dist \ No newline at end of file From e75729ea2fd5911e3e7754051a3c555bb4e2d40e Mon Sep 17 00:00:00 2001 From: jim Date: Tue, 25 Aug 2015 19:56:13 -0500 Subject: [PATCH 5/8] fixed dockerfile error --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 0334d55..7ee5208 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ python3-dev \ python-pip \ python3-pip \ + python-numpy \ + python3-numpy \ libfreetype6-dev \ python3-matplotlib \ libfreetype6-dev \ From b63e745698027b45388d5868c7f5cfa87cd62f33 Mon Sep 17 00:00:00 2001 From: Jim Rybarski Date: Wed, 26 Aug 2015 05:28:38 -0500 Subject: [PATCH 6/8] removed redundancy --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5e5ec3f..7b389fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,8 +18,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ python-numpy \ python3-numpy \ libfreetype6-dev \ - python-numpy \ - python3-numpy \ python3-matplotlib \ libfreetype6-dev \ libpng-dev \ From 74dc101776206d2c5160a0f4af0bdb8bfde7e58e Mon Sep 17 00:00:00 2001 From: jim Date: Thu, 27 Aug 2015 16:45:47 -0500 Subject: [PATCH 7/8] 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)) From 86d2924d356792dee863c4b39bcc5b230c9e3f6c Mon Sep 17 00:00:00 2001 From: jim Date: Fri, 28 Aug 2015 18:56:37 -0500 Subject: [PATCH 8/8] resolves #68: indexing was not returning the correct image and skipped frame entirely when there were multiple channels --- jim.py | 4 ---- nd2reader/__init__.py | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 jim.py diff --git a/jim.py b/jim.py deleted file mode 100644 index 95738e0..0000000 --- a/jim.py +++ /dev/null @@ -1,4 +0,0 @@ -import nd2reader -nd2 = nd2reader.Nd2("/var/nd2s/hawkjo.nd2") - -print(nd2) \ No newline at end of file diff --git a/nd2reader/__init__.py b/nd2reader/__init__.py index 2337034..e01360a 100644 --- a/nd2reader/__init__.py +++ b/nd2reader/__init__.py @@ -57,7 +57,8 @@ class Nd2(Nd2Parser): fov = self._calculate_field_of_view(item) channel = self._calculate_channel(item) z_level = self._calculate_z_level(item) - timestamp, raw_image_data = self._get_raw_image_data(item, channel_offset) + image_group_number = int(item / len(self.channels)) + timestamp, raw_image_data = self._get_raw_image_data(image_group_number, channel_offset) image = Image(timestamp, raw_image_data, fov, channel, z_level, self.height, self.width) except (TypeError, ValueError): return None