Browse Source

New documentation

zolfa-add_slices_loading
Ruben Verweij 8 years ago
parent
commit
2c121dc0ff
7 changed files with 73 additions and 45 deletions
  1. +4
    -0
      README.md
  2. +1
    -1
      docs
  3. +10
    -12
      nd2reader/artificial.py
  4. +36
    -21
      nd2reader/legacy.py
  5. +2
    -2
      nd2reader/reader.py
  6. +4
    -9
      sphinx/index.rst
  7. +16
    -0
      sphinx/nd2reader.rst

+ 4
- 0
README.md View File

@ -38,6 +38,10 @@ with ND2Reader('my_directory/example.nd2') as images:
After opening the file, all `pims` features are supported. Please refer to the [pims documentation](http://soft-matter.github.io/pims/). After opening the file, all `pims` features are supported. Please refer to the [pims documentation](http://soft-matter.github.io/pims/).
#### Backwards compatibility
Older versions of `nd2reader` do not use the `pims` framework. To provide backwards compatibility, a legacy [Nd2](http://www.lighthacking.nl/nd2reader/docs/nd2reader.html#module-nd2reader.legacy) class is provided.
### Contributing ### Contributing
If you'd like to help with the development of nd2reader or just have an idea for improvement, please see the [contributing](https://github.com/rbnvrw/nd2reader/blob/master/CONTRIBUTING.md) page If you'd like to help with the development of nd2reader or just have an idea for improvement, please see the [contributing](https://github.com/rbnvrw/nd2reader/blob/master/CONTRIBUTING.md) page


+ 1
- 1
docs

@ -1 +1 @@
Subproject commit 1972b012f71a4c65b927ddfef5bf88d66ef521ef
Subproject commit 6e17cadb9d79143c4e41ababeb309d4e88f9038b

+ 10
- 12
nd2reader/artificial.py View File

@ -1,5 +1,4 @@
"""
Functions to create artificial nd2 data for testing purposes
"""Functions to create artificial nd2 data for testing purposes
""" """
import six import six
import numpy as np import numpy as np
@ -7,8 +6,7 @@ import struct
class ArtificialND2(object): class ArtificialND2(object):
"""
Artificial ND2 class (for testing purposes)
"""Artificial ND2 class (for testing purposes)
""" """
def __init__(self, file): def __init__(self, file):
@ -23,23 +21,22 @@ class ArtificialND2(object):
@property @property
def file_handle(self): def file_handle(self):
"""
The file handle to the binary file
"""The file handle to the binary file
Returns: Returns:
file: the file handle file: the file handle
""" """
return self._fh return self._fh
def close(self): def close(self):
"""
Correctly close the file handle
"""Correctly close the file handle
""" """
if self._fh is not None: if self._fh is not None:
self._fh.close() self._fh.close()
def write_version(self): def write_version(self):
"""
Write file header
"""Write file header
""" """
# write 16 empty bytes # write 16 empty bytes
self._fh.write(bytearray(16)) self._fh.write(bytearray(16))
@ -50,10 +47,11 @@ class ArtificialND2(object):
@staticmethod @staticmethod
def create_label_map_bytes(): def create_label_map_bytes():
"""
Construct a binary label map
"""Construct a binary label map
Returns: Returns:
tuple: (binary data, dictionary data) tuple: (binary data, dictionary data)
""" """
raw_text = six.b('') raw_text = six.b('')
labels = { labels = {


+ 36
- 21
nd2reader/legacy.py View File

@ -8,7 +8,9 @@ from nd2reader import ND2Reader
class Nd2(object): class Nd2(object):
""" Legacy Nd2 object for backwards compatibility. """
""" Warning: this module is deprecated and only maintained for backwards compatibility with the non-PIMS version of
nd2reader.
"""
def __init__(self, filename): def __init__(self, filename):
warnings.warn( warnings.warn(
@ -41,8 +43,8 @@ class Nd2(object):
return self.reader[item] return self.reader[item]
def select(self, fields_of_view=None, channels=None, z_levels=None, start=0, stop=None): def select(self, fields_of_view=None, channels=None, z_levels=None, start=0, stop=None):
"""
Select images based on criteria.
"""Select images based on criteria.
Args: Args:
fields_of_view: the fields of view fields_of_view: the fields of view
channels: the color channels channels: the color channels
@ -52,6 +54,7 @@ class Nd2(object):
Returns: Returns:
ND2Reader: Sliced ND2Reader which contains the frames ND2Reader: Sliced ND2Reader which contains the frames
""" """
if stop is None: if stop is None:
stop = len(self.frames) stop = len(self.frames)
@ -59,13 +62,17 @@ class Nd2(object):
return self.reader[start:stop] return self.reader[start:stop]
def get_image(self, frame_number, field_of_view, channel_name, z_level): def get_image(self, frame_number, field_of_view, channel_name, z_level):
"""
Deprecated. Returns the specified image from the ND2Reader class.
"""Deprecated. Returns the specified image from the ND2Reader class.
Args: Args:
frame_number: the frame number frame_number: the frame number
field_of_view: the field of view number field_of_view: the field of view number
channel_name: the name of the color channel channel_name: the name of the color channel
z_level: the z level number z_level: the z level number
Returns:
Frame: the specified image
""" """
return self.reader.parser.get_image_by_attributes(frame_number, field_of_view, channel_name, z_level, return self.reader.parser.get_image_by_attributes(frame_number, field_of_view, channel_name, z_level,
self.height, self.width) self.height, self.width)
@ -78,72 +85,80 @@ class Nd2(object):
@property @property
def height(self): def height(self):
"""
Deprecated. Fetches the height of the image.
"""Deprecated. Fetches the height of the image.
Returns: Returns:
int: the pixel height of the image int: the pixel height of the image
""" """
return self.reader.metadata["height"] return self.reader.metadata["height"]
@property @property
def width(self): def width(self):
"""
Deprecated. Fetches the width of the image.
"""Deprecated. Fetches the width of the image.
Returns: Returns:
int: the pixel width of the image int: the pixel width of the image
""" """
return self.reader.metadata["width"] return self.reader.metadata["width"]
@property @property
def z_levels(self): def z_levels(self):
"""
Deprecated. Fetches the available z levels.
"""Deprecated. Fetches the available z levels.
Returns: Returns:
list: z levels. list: z levels.
""" """
return self.reader.metadata["z_levels"] return self.reader.metadata["z_levels"]
@property @property
def fields_of_view(self): def fields_of_view(self):
"""
Deprecated. Fetches the fields of view.
"""Deprecated. Fetches the fields of view.
Returns: Returns:
list: fields of view. list: fields of view.
""" """
return self.reader.metadata["fields_of_view"] return self.reader.metadata["fields_of_view"]
@property @property
def channels(self): def channels(self):
"""
Deprecated. Fetches all color channels.
"""Deprecated. Fetches all color channels.
Returns: Returns:
list: the color channels. list: the color channels.
""" """
return self.reader.metadata["channels"] return self.reader.metadata["channels"]
@property @property
def frames(self): def frames(self):
"""
Deprecated. Fetches all frames.
"""Deprecated. Fetches all frames.
Returns: Returns:
list: list of frames list: list of frames
""" """
return self.reader.metadata["frames"] return self.reader.metadata["frames"]
@property @property
def date(self): def date(self):
"""
Deprecated. Fetches the acquisition date.
"""Deprecated. Fetches the acquisition date.
Returns: Returns:
string: the date string: the date
""" """
return self.reader.metadata["date"] return self.reader.metadata["date"]
@property @property
def pixel_microns(self): def pixel_microns(self):
"""
Deprecated. Fetches the amount of microns per pixel.
"""Deprecated. Fetches the amount of microns per pixel.
Returns: Returns:
float: microns per pixel float: microns per pixel
""" """
return self.reader.metadata["pixel_microns"] return self.reader.metadata["pixel_microns"]

+ 2
- 2
nd2reader/reader.py View File

@ -4,8 +4,8 @@ import numpy as np
class ND2Reader(FramesSequenceND): class ND2Reader(FramesSequenceND):
"""PIMS wrapper for the ND2 parser
"""PIMS wrapper for the ND2 parser.
This is the main class: use this to process your .nd2 files.
""" """
def __init__(self, filename): def __init__(self, filename):


+ 4
- 9
sphinx/index.rst View File

@ -1,8 +1,3 @@
.. nd2reader documentation master file, created by
sphinx-quickstart on Mon Mar 6 21:17:58 2017.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
``nd2reader``: a pure-Python package for reading Nikon .nd2 files ``nd2reader``: a pure-Python package for reading Nikon .nd2 files
================================================================= =================================================================
@ -10,11 +5,11 @@
The reader is written in the `pims <https://github.com/soft-matter/pims>`_ framework, enabling easy access to multidimensional files, lazy slicing, and nice display in IPython. To get started, see the quick start tutorial. The reader is written in the `pims <https://github.com/soft-matter/pims>`_ framework, enabling easy access to multidimensional files, lazy slicing, and nice display in IPython. To get started, see the quick start tutorial.
.. toctree:: .. toctree::
:maxdepth: 4
:caption: Contents:
:maxdepth: 4
:caption: Contents:
nd2reader quick start tutorial <tutorial>
nd2reader API reference <nd2reader>
nd2reader quick start tutorial <tutorial>
nd2reader API reference <nd2reader>
Indices and tables Indices and tables


+ 16
- 0
sphinx/nd2reader.rst View File

@ -54,3 +54,19 @@ nd2reader.exceptions module
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
nd2reader.exceptions artificial
-------------------------------
.. automodule:: nd2reader.artificial
:members:
:undoc-members:
:show-inheritance:
nd2reader.legacy module
-----------------------
.. automodule:: nd2reader.legacy
:members:
:undoc-members:
:show-inheritance:

Loading…
Cancel
Save