From 99c26b474f88be6580b241dfc98f0a97e3e67c38 Mon Sep 17 00:00:00 2001 From: Jim Rybarski Date: Sat, 16 May 2015 23:42:59 +0000 Subject: [PATCH] added makefile, simplified the Dockerfile --- Dockerfile | 22 +++++-------------- Makefile | 7 ++++++ nd2reader/model/__init__.py | 44 ++++++++++++++++++------------------- nd2reader/parser.py | 8 +++---- 4 files changed, 39 insertions(+), 42 deletions(-) create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile index 95602c0..51e6ff0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,14 @@ FROM ubuntu MAINTAINER Jim Rybarski +RUN mkdir -p /var/nds2 RUN apt-get update && apt-get install -y \ - gcc \ - gfortran \ - libblas-dev \ - liblapack-dev \ - libatlas-dev \ - tk \ - tk-dev \ - libpng12-dev \ - python \ - python-dev \ - python-pip \ - libfreetype6-dev \ - python-skimage - -RUN pip install numpy -RUN pip install --upgrade scikit-image + python-numpy \ + python-setuptools COPY . /opt/nd2reader WORKDIR /opt/nd2reader RUN python setup.py install +WORKDIR /var/nd2s + +CMD /usr/bin/python2.7 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..30e5e42 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: build test shell + +build: + docker build -t jimrybarski/nd2reader . + +shell: + docker run --rm -v ~/Documents/nd2s:/var/nd2s -it jimrybarski/nd2reader diff --git a/nd2reader/model/__init__.py b/nd2reader/model/__init__.py index 4d59b4d..64bf398 100644 --- a/nd2reader/model/__init__.py +++ b/nd2reader/model/__init__.py @@ -4,27 +4,6 @@ import logging log = logging.getLogger(__name__) -class ImageSet(object): - """ - A group of images that share the same timestamp. NIS Elements doesn't store a unique timestamp for every - image, rather, it stores one for each set of images that share the same field of view and z-axis level. - - """ - def __init__(self): - self._images = [] - - def add(self, image): - """ - :type image: nd2reader.model.Image() - - """ - self._images.append(image) - - def __iter__(self): - for image in self._images: - yield image - - class Image(object): def __init__(self, timestamp, raw_array, field_of_view, channel, z_level, height, width): self._timestamp = timestamp @@ -68,4 +47,25 @@ class Image(object): @property def is_valid(self): - return np.any(self._raw_data) \ No newline at end of file + return np.any(self._raw_data) + + +class ImageSet(object): + """ + A group of images that share the same timestamp. NIS Elements doesn't store a unique timestamp for every + image, rather, it stores one for each set of images that share the same field of view and z-axis level. + + """ + def __init__(self): + self._images = [] + + def add(self, image): + """ + :type image: nd2reader.model.Image() + + """ + self._images.append(image) + + def __iter__(self): + for image in self._images: + yield image \ No newline at end of file diff --git a/nd2reader/parser.py b/nd2reader/parser.py index 0aaa705..ee49d53 100644 --- a/nd2reader/parser.py +++ b/nd2reader/parser.py @@ -9,14 +9,14 @@ field_of_view = namedtuple('FOV', ['number', 'x', 'y', 'z', 'pfs_offset']) class Nd2Parser(object): - CHUNK_HEADER = 0xabeceda - CHUNK_MAP_START = "ND2 FILEMAP SIGNATURE NAME 0001!" - CHUNK_MAP_END = "ND2 CHUNK MAP SIGNATURE 0000001!" - """ Reads .nd2 files, provides an interface to the metadata, and generates numpy arrays from the image data. """ + CHUNK_HEADER = 0xabeceda + CHUNK_MAP_START = "ND2 FILEMAP SIGNATURE NAME 0001!" + CHUNK_MAP_END = "ND2 CHUNK MAP SIGNATURE 0000001!" + def __init__(self, filename): self._absolute_start = None self._filename = filename