Browse Source

Merge pull request #15 from jbf81tb/master

parser, get_frame_2D: use channel index instead of channel name
zolfa-add_slices_loading
Ruben Verweij 6 years ago
committed by GitHub
parent
commit
36026553fb
2 changed files with 3 additions and 8 deletions
  1. +2
    -2
      nd2reader/parser.py
  2. +1
    -6
      nd2reader/reader.py

+ 2
- 2
nd2reader/parser.py View File

@ -77,7 +77,7 @@ class Parser(object):
else: else:
return image return image
def get_image_by_attributes(self, frame_number, field_of_view, channel_name, z_level, height, width):
def get_image_by_attributes(self, frame_number, field_of_view, channel, z_level, height, width):
"""Gets an image based on its attributes alone """Gets an image based on its attributes alone
Args: Args:
@ -94,7 +94,7 @@ class Parser(object):
""" """
image_group_number = self._calculate_image_group_number(frame_number, field_of_view, z_level) image_group_number = self._calculate_image_group_number(frame_number, field_of_view, z_level)
try: try:
timestamp, raw_image_data = self._get_raw_image_data(image_group_number, self._channel_offset[channel_name],
timestamp, raw_image_data = self._get_raw_image_data(image_group_number, channel,
height, width) height, width)
except (TypeError, NoImageError): except (TypeError, NoImageError):
return Frame([], frame_no=frame_number, metadata=self._get_frame_metadata()) return Frame([], frame_no=frame_number, metadata=self._get_frame_metadata())


+ 1
- 6
nd2reader/reader.py View File

@ -67,14 +67,9 @@ class ND2Reader(FramesSequenceND):
numpy.ndarray: The requested frame numpy.ndarray: The requested frame
""" """
try:
c_name = self.metadata["channels"][c]
except KeyError:
c_name = self.metadata["channels"][0]
x = self.metadata["width"] if x <= 0 else x x = self.metadata["width"] if x <= 0 else x
y = self.metadata["height"] if y <= 0 else y y = self.metadata["height"] if y <= 0 else y
return self._parser.get_image_by_attributes(t, v, c_name, z, y, x)
return self._parser.get_image_by_attributes(t, v, c, z, y, x)
@property @property
def parser(self): def parser(self):


Loading…
Cancel
Save