Browse Source

added some properties to Image

zolfa-add_slices_loading
jim 10 years ago
parent
commit
e7e2682949
2 changed files with 25 additions and 1 deletions
  1. +10
    -1
      nd2reader/model/__init__.py
  2. +15
    -0
      nd2reader/service/__init__.py

+ 10
- 1
nd2reader/model/__init__.py View File

@ -71,10 +71,19 @@ class Image(object):
"""
return self._timestamp / 1000.0
@property
def channel(self):
return self._channel
@property
def z_level(self):
return self._z_level
@property
def data(self):
if self._data is None:
self._data = np.reshape(self._raw_data, (self._height, self._width)).astype(np.float64)
# The data is just a flat, 1-dimensional array. We convert it to a 2D array and cast the data points as 16-bit integers
self._data = np.reshape(self._raw_data, (self._height, self._width)).astype(np.int64).astype(np.uint16)
return self._data
@property


+ 15
- 0
nd2reader/service/__init__.py View File

@ -19,10 +19,18 @@ class BaseNd2(object):
@property
def height(self):
"""
:return: height of each image, in pixels
"""
return self._metadata['ImageAttributes']['SLxImageAttributes']['uiHeight']
@property
def width(self):
"""
:return: width of each image, in pixels
"""
return self._metadata['ImageAttributes']['SLxImageAttributes']['uiWidth']
@property
@ -54,6 +62,13 @@ class BaseNd2(object):
@property
def timepoint_count(self):
"""
The number of images for a given field of view, channel, and z_level combination.
Effectively the number of frames.
:rtype: int
"""
return self._image_count / self.field_of_view_count / self.z_level_count
@property


Loading…
Cancel
Save