From 4194f073ddc6212cb5e74a4996ccf20fadaf204b Mon Sep 17 00:00:00 2001 From: jim Date: Tue, 23 Feb 2016 14:03:49 -0600 Subject: [PATCH] resolves #150, #149: removed camera settings entirely because they are buggy and terrible --- README.md | 31 ------------------------------- ftest.py | 2 +- functional_tests/monocycle.py | 8 ++++++++ nd2reader/__init__.py | 2 +- nd2reader/main.py | 10 ---------- nd2reader/parser/v3.py | 34 ---------------------------------- setup.py | 2 +- 7 files changed, 11 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index 4492771..89f95d2 100644 --- a/README.md +++ b/README.md @@ -119,37 +119,6 @@ The `Nd2` object has some programmatically-accessible metadata: 0.22 ``` -Each camera has its own settings. If you image multiple wavelengths with one camera, each channel will appear as its -own camera: - -```python ->>> nd2.camera_settings -{'GFP': -Camera: Andor Zyla VSC-00461 -Camera ID: VSC-00461 -Exposure Time (ms): 100.0 -Binning: 2x2, 'BF': -Camera: Andor Zyla VSC-00461 -Camera ID: VSC-00461 -Exposure Time (ms): 100.0 -Binning: 2x2} -``` - -Camera information can be accessed programmatically: - -```python ->>> nd2.camera_settings['GFP'].id -'VSC-00461' ->>> nd2.camera_settings['GFP'].name -'Andor Zyla VSC-00461' ->>> nd2.camera_settings['GFP'].exposure -100.0 ->>> nd2.camera_settings['GFP'].x_binning -2 ->>> nd2.camera_settings['GFP'].y_binning -2 -``` - ### 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/jimrybarski/nd2reader/blob/master/CONTRIBUTING.md) page diff --git a/ftest.py b/ftest.py index 4ab9c99..d429b6a 100644 --- a/ftest.py +++ b/ftest.py @@ -1,7 +1,7 @@ import unittest from functional_tests.FYLM141111001 import FYLM141111Tests from functional_tests.single import SingleTests -from functional_tests.monocycle import Monocycle1Tests, Monocycle2Tests +from functional_tests.monocycle import Monocycle1Tests, Monocycle2Tests, OneTests if __name__ == '__main__': unittest.main() diff --git a/functional_tests/monocycle.py b/functional_tests/monocycle.py index 4c1095c..b1830da 100644 --- a/functional_tests/monocycle.py +++ b/functional_tests/monocycle.py @@ -136,3 +136,11 @@ class Monocycle2Tests(unittest.TestCase): n = image.index if n > 100: break + + +class OneTests(unittest.TestCase): + def test_opens(self): + # just testing that this doesn't throw an exception + nd2 = Nd2("/var/nd2s/001.nd2") + self.assertIsNotNone(nd2) + nd2.close() diff --git a/nd2reader/__init__.py b/nd2reader/__init__.py index dbfe52d..5e6282a 100644 --- a/nd2reader/__init__.py +++ b/nd2reader/__init__.py @@ -1,3 +1,3 @@ from nd2reader.main import Nd2 -__version__ = '2.1.1' +__version__ = '2.1.2' diff --git a/nd2reader/main.py b/nd2reader/main.py index 4e315fc..9ce3f75 100644 --- a/nd2reader/main.py +++ b/nd2reader/main.py @@ -154,16 +154,6 @@ class Nd2(object): """ return self._metadata.frames - @property - def camera_settings(self): - """ - Basic information about the physical cameras used. - - :return: dict of {channel_name: model.metadata.CameraSettings} - - """ - return self._parser.camera_metadata - @property def date(self): """ diff --git a/nd2reader/parser/v3.py b/nd2reader/parser/v3.py index 19c02b8..71799c1 100644 --- a/nd2reader/parser/v3.py +++ b/nd2reader/parser/v3.py @@ -141,7 +141,6 @@ class V3Parser(BaseParser): super(V3Parser, self).__init__(fh) self._label_map = self._build_label_map() self.raw_metadata = V3RawMetadata(self._fh, self._label_map) - self._parse_camera_metadata() self._parse_metadata() @property @@ -152,15 +151,6 @@ class V3Parser(BaseParser): """ return V3Driver(self.metadata, self._label_map, self._fh) - def _parse_camera_metadata(self): - """ - Gets parsed data about the physical cameras used to produce images and throws them in a dictionary. - - """ - self.camera_metadata = {} - for camera_setting in self._parse_camera_settings(): - self.camera_metadata[camera_setting.channel_name] = camera_setting - def _parse_metadata(self): """ Reads all metadata and instantiates the Metadata object. @@ -177,30 +167,6 @@ class V3Parser(BaseParser): pixel_microns = self.raw_metadata.image_calibration.get(six.b('SLxCalibration'), {}).get(six.b('dCalibration')) self.metadata = Metadata(height, width, channels, date, fields_of_view, frames, z_levels, total_images_per_channel, pixel_microns) - def _parse_camera_settings(self): - """ - Looks up information in the raw metadata about the camera(s) and puts it into a CameraSettings object. - Duplicate cameras can be returned if the same one was used for multiple channels. - - """ - for n, camera in enumerate(self.raw_metadata.image_metadata_sequence[six.b('SLxPictureMetadata')][six.b('sPicturePlanes')][six.b('sSampleSetting')].values()): - name = camera[six.b('pCameraSetting')][six.b('CameraUserName')] - id = camera[six.b('pCameraSetting')][six.b('CameraUniqueName')] - exposure = camera[six.b('dExposureTime')] - x_binning = camera[six.b('pCameraSetting')][six.b('FormatFast')][six.b('fmtDesc')][six.b('dBinningX')] - y_binning = camera[six.b('pCameraSetting')][six.b('FormatFast')][six.b('fmtDesc')][six.b('dBinningY')] - optical_configs = camera[six.b('sOpticalConfigs')] - - # This definitely is not working right. It seems to be totally inconsistent in each of the sample ND2s that I have. - # Fixing one breaks another. - if six.b('') in optical_configs.keys(): - channel_name = optical_configs[six.b('')][six.b('sOpticalConfigName')] - yield CameraSettings(name, id, exposure, x_binning, y_binning, channel_name) - else: - channel_names = [channel[six.b('Name')] for key, channel in camera[six.b('pCameraSetting')][six.b('Metadata')][six.b('Channels')].items()] - for channel_name in channel_names: - yield CameraSettings(name, id, exposure, x_binning, y_binning, channel_name) - def _parse_date(self, raw_metadata): """ The date and time when acquisition began. diff --git a/setup.py b/setup.py index f01f531..0ae1b10 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup -VERSION = '2.1.1' +VERSION = '2.1.2' if __name__ == '__main__': setup(