Browse Source

resolves #150, #149: removed camera settings entirely because they are buggy and terrible

master
jim 9 years ago
parent
commit
4194f073dd
7 changed files with 11 additions and 78 deletions
  1. +0
    -31
      README.md
  2. +1
    -1
      ftest.py
  3. +8
    -0
      functional_tests/monocycle.py
  4. +1
    -1
      nd2reader/__init__.py
  5. +0
    -10
      nd2reader/main.py
  6. +0
    -34
      nd2reader/parser/v3.py
  7. +1
    -1
      setup.py

+ 0
- 31
README.md View File

@ -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 Settings: GFP>
Camera: Andor Zyla VSC-00461
Camera ID: VSC-00461
Exposure Time (ms): 100.0
Binning: 2x2, 'BF': <Camera Settings: 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


+ 1
- 1
ftest.py View File

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

+ 8
- 0
functional_tests/monocycle.py View File

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

+ 1
- 1
nd2reader/__init__.py View File

@ -1,3 +1,3 @@
from nd2reader.main import Nd2
__version__ = '2.1.1'
__version__ = '2.1.2'

+ 0
- 10
nd2reader/main.py View File

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


+ 0
- 34
nd2reader/parser/v3.py View File

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


+ 1
- 1
setup.py View File

@ -1,6 +1,6 @@
from setuptools import setup
VERSION = '2.1.1'
VERSION = '2.1.2'
if __name__ == '__main__':
setup(


Loading…
Cancel
Save