Browse Source

added makefile, simplified the Dockerfile

master
Jim Rybarski 10 years ago
parent
commit
99c26b474f
4 changed files with 39 additions and 42 deletions
  1. +6
    -16
      Dockerfile
  2. +7
    -0
      Makefile
  3. +22
    -22
      nd2reader/model/__init__.py
  4. +4
    -4
      nd2reader/parser.py

+ 6
- 16
Dockerfile View File

@ -1,24 +1,14 @@
FROM ubuntu
MAINTAINER Jim Rybarski <jim@rybarski.com>
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

+ 7
- 0
Makefile View File

@ -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

+ 22
- 22
nd2reader/model/__init__.py View File

@ -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)
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

+ 4
- 4
nd2reader/parser.py View File

@ -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


Loading…
Cancel
Save