From 13139518b3c1ccd1e0239245be35f1bd3df00efe Mon Sep 17 00:00:00 2001 From: Jim Rybarski Date: Sat, 16 Jan 2016 11:53:02 -0600 Subject: [PATCH] Bump version to 2.1.0, updated documentation, removed skips from some unit tests --- CHANGELOG.md | 4 ++++ README.md | 16 ++++++++++++---- functional_tests/FYLM141111001.py | 3 +++ functional_tests/monocycle.py | 6 +----- nd2reader/__init__.py | 2 +- setup.py | 2 +- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81ed0d4..f46058f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.1.0] - 2016-01-16 +### ADDED +- `select` now supports `start` and `stop` keyword arguments to put bounds on images + ## [2.0.2] - 2016-01-06 ### ADDED - `Nd2.pixel_microns` gives the width of a pixel diff --git a/README.md b/README.md index 30b00a8..994d321 100644 --- a/README.md +++ b/README.md @@ -70,10 +70,16 @@ array([[1894, 1949, 1941, ..., 2104, 2135, 2114], If you only want to view images that meet certain criteria, you can use `select()`. It's much faster than iterating and checking attributes of images manually. You can specify scalars or lists of values. Criteria that aren't specified -default to every possible value. Currently, slicing and selecting can't be done at the same time: +default to every possible value. Currently, slicing and selecting can't be done at the same time, but you can +set a range with the `start` and `stop` arguments: ```python for image in nd2.select(channels="GFP", fields_of_view=(1, 2, 7)): + # gets all GFP images in fields of view 1, 2 and 7, regardless of z-level or frame + do_something(image) + +for image in nd2.select(z_levels=(0, 1), start=12, stop=3000): + # gets images of any channel or field of view, with z-level 0 or 1, between images 12 and 3000 do_something(image) ``` @@ -102,12 +108,14 @@ my_important_image = nd2[17] The `Nd2` object has some programmatically-accessible metadata: ```python ->>> nd2.height +>>> nd2.height # in pixels 1280 ->>> nd2.width +>>> nd2.width # in pixels 800 ->>> len(nd2) +>>> len(nd2) # the number of images 30528 +>>> nd2.pixel_microns # the width of a pixel in microns +0.22 ``` Each camera has its own settings. If you image multiple wavelengths with one camera, each channel will appear as its diff --git a/functional_tests/FYLM141111001.py b/functional_tests/FYLM141111001.py index 23c764e..e48c21a 100644 --- a/functional_tests/FYLM141111001.py +++ b/functional_tests/FYLM141111001.py @@ -213,3 +213,6 @@ class FYLM141111Tests(unittest.TestCase): direct_duration = time.time() - direct_start self.assertEqual(select_count, direct_count) self.assertGreater(direct_duration, select_duration) + + def test_pixel_microns(self): + self.assertEqual(round(self.nd2.pixel_microns, 2), 0.22) diff --git a/functional_tests/monocycle.py b/functional_tests/monocycle.py index e545024..4c1095c 100644 --- a/functional_tests/monocycle.py +++ b/functional_tests/monocycle.py @@ -81,11 +81,9 @@ class Monocycle2Tests(unittest.TestCase): def tearDown(self): self.nd2.close() - @unittest.skip('missing file') def test_pixel_size(self): - self.assertGreater(self.nd2.pixel_microns, 0.0) + self.assertGreater(round(self.nd2.pixel_microns, 2), 0.26) - @unittest.skip('missing file') def test_select(self): manual_images = [] for _, image in zip(range(20), self.nd2): @@ -106,7 +104,6 @@ class Monocycle2Tests(unittest.TestCase): self.assertEqual(a.field_of_view, b.field_of_view) self.assertEqual(a.channel, b.channel) - @unittest.skip('missing file') def test_select_order_all(self): # If we select every possible image using select(), we should just get every image in order n = 0 @@ -125,7 +122,6 @@ class Monocycle2Tests(unittest.TestCase): # If there's a problem, we'll have seen it by now. break - @unittest.skip('missing file') def test_select_order_subset(self): # Test that images are always yielded in increasing order. This guarantees that no matter what subset of images # we're filtering, we still get them in the chronological order they were acquired diff --git a/nd2reader/__init__.py b/nd2reader/__init__.py index 37ba498..d687d1d 100644 --- a/nd2reader/__init__.py +++ b/nd2reader/__init__.py @@ -1,3 +1,3 @@ from nd2reader.main import Nd2 -__version__ = '2.0.2' +__version__ = '2.1.0' diff --git a/setup.py b/setup.py index 56bbb62..0cc8c68 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup -VERSION = '2.0.2' +VERSION = '2.1.0' if __name__ == '__main__': setup(