Browse Source

docstrings

zolfa-add_slices_loading
Ruben Verweij 8 years ago
parent
commit
2f2f138f17
6 changed files with 400 additions and 10 deletions
  1. +1
    -1
      docs
  2. +44
    -5
      nd2reader/common.py
  3. +123
    -0
      nd2reader/label_map.py
  4. +76
    -1
      nd2reader/parser.py
  5. +131
    -3
      nd2reader/raw_metadata.py
  6. +25
    -0
      nd2reader/reader.py

+ 1
- 1
docs

@ -1 +1 @@
Subproject commit 3db501b0c85343425c6e8269dcfce5b0ca28c845
Subproject commit 248bbb1aa20c11fe1c82c092ce68a3d9526156d2

+ 44
- 5
nd2reader/common.py View File

@ -69,6 +69,16 @@ def read_chunk(fh, chunk_location):
def read_array(fh, kind, chunk_location): def read_array(fh, kind, chunk_location):
"""
Args:
fh:
kind:
chunk_location:
Returns:
"""
kinds = {'double': 'd', kinds = {'double': 'd',
'int': 'i', 'int': 'i',
'float': 'f'} 'float': 'f'}
@ -110,10 +120,13 @@ def _parse_char_array(data):
def parse_date(text_info): def parse_date(text_info):
"""The date and time when acquisition began.
"""
The date and time when acquisition began.
Args:
text_info:
Returns: Returns:
datetime: The date and time when acquisition began.
""" """
for line in text_info.values(): for line in text_info.values():
@ -133,8 +146,11 @@ def parse_date(text_info):
def _parse_metadata_item(data, cursor_position): def _parse_metadata_item(data, cursor_position):
"""Reads hierarchical data, analogous to a Python dict. """Reads hierarchical data, analogous to a Python dict.
Args:
data:
cursor_position:
Returns: Returns:
dict: the metadata item
""" """
new_count, length = struct.unpack("<IQ", data.read(12)) new_count, length = struct.unpack("<IQ", data.read(12))
@ -149,6 +165,13 @@ def _parse_metadata_item(data, cursor_position):
def _get_value(data, data_type, cursor_position): def _get_value(data, data_type, cursor_position):
"""ND2s use various codes to indicate different data types, which we translate here. """ND2s use various codes to indicate different data types, which we translate here.
Args:
data:
data_type:
cursor_position:
Returns:
""" """
parser = {1: _parse_unsigned_char, parser = {1: _parse_unsigned_char,
2: _parse_unsigned_int, 2: _parse_unsigned_int,
@ -162,7 +185,14 @@ def _get_value(data, data_type, cursor_position):
def read_metadata(data, count): def read_metadata(data, count):
"""Iterates over each element some section of the metadata and parses it.
"""
Iterates over each element some section of the metadata and parses it.
Args:
data:
count:
Returns:
""" """
if data is None: if data is None:
@ -192,7 +222,16 @@ def read_metadata(data, count):
def _add_to_metadata(metadata, name, value): def _add_to_metadata(metadata, name, value):
"""Add the name value pair to the metadata dict
"""
Add the name value pair to the metadata dict
Args:
metadata:
name:
value:
Returns:
""" """
if name not in metadata.keys(): if name not in metadata.keys():
metadata[name] = value metadata[name] = value


+ 123
- 0
nd2reader/label_map.py View File

@ -12,6 +12,11 @@ class LabelMap(object):
self._image_data = {} self._image_data = {}
def image_attributes(self): def image_attributes(self):
"""
Returns:
"""
return self._get_location(six.b("ImageAttributesLV!")) return self._get_location(six.b("ImageAttributesLV!"))
def _get_location(self, label): def _get_location(self, label):
@ -27,18 +32,41 @@ class LabelMap(object):
@property @property
def image_text_info(self): def image_text_info(self):
"""
Returns:
"""
return self._get_location(six.b("ImageTextInfoLV!")) return self._get_location(six.b("ImageTextInfoLV!"))
@property @property
def image_metadata(self): def image_metadata(self):
"""
Returns:
"""
return self._get_location(six.b("ImageMetadataLV!")) return self._get_location(six.b("ImageMetadataLV!"))
@property @property
def image_metadata_sequence(self): def image_metadata_sequence(self):
# there is always only one of these, even though it has a pipe followed by a zero, which is how they do indexes # there is always only one of these, even though it has a pipe followed by a zero, which is how they do indexes
"""
Returns:
"""
return self._get_location(six.b("ImageMetadataSeqLV|0!")) return self._get_location(six.b("ImageMetadataSeqLV|0!"))
def get_image_data_location(self, index): def get_image_data_location(self, index):
"""
Args:
index:
Returns:
"""
if not self._image_data: if not self._image_data:
regex = re.compile(six.b("""ImageDataSeq\|(\d+)!""")) regex = re.compile(six.b("""ImageDataSeq\|(\d+)!"""))
for match in regex.finditer(self._data): for match in regex.finditer(self._data):
@ -49,76 +77,171 @@ class LabelMap(object):
@property @property
def image_calibration(self): def image_calibration(self):
"""
Returns:
"""
return self._get_location(six.b("ImageCalibrationLV|0!")) return self._get_location(six.b("ImageCalibrationLV|0!"))
@property @property
def image_attributes(self): def image_attributes(self):
"""
Returns:
"""
return self._get_location(six.b("ImageAttributesLV!")) return self._get_location(six.b("ImageAttributesLV!"))
@property @property
def x_data(self): def x_data(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|X!")) return self._get_location(six.b("CustomData|X!"))
@property @property
def y_data(self): def y_data(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|Y!")) return self._get_location(six.b("CustomData|Y!"))
@property @property
def z_data(self): def z_data(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|Z!")) return self._get_location(six.b("CustomData|Z!"))
@property @property
def roi_metadata(self): def roi_metadata(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|RoiMetadata_v1!")) return self._get_location(six.b("CustomData|RoiMetadata_v1!"))
@property @property
def pfs_status(self): def pfs_status(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|PFS_STATUS!")) return self._get_location(six.b("CustomData|PFS_STATUS!"))
@property @property
def pfs_offset(self): def pfs_offset(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|PFS_OFFSET!")) return self._get_location(six.b("CustomData|PFS_OFFSET!"))
@property @property
def guid(self): def guid(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|GUIDStore!")) return self._get_location(six.b("CustomData|GUIDStore!"))
@property @property
def description(self): def description(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|CustomDescriptionV1_0!")) return self._get_location(six.b("CustomData|CustomDescriptionV1_0!"))
@property @property
def camera_exposure_time(self): def camera_exposure_time(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|Camera_ExposureTime1!")) return self._get_location(six.b("CustomData|Camera_ExposureTime1!"))
@property @property
def camera_temp(self): def camera_temp(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|CameraTemp1!")) return self._get_location(six.b("CustomData|CameraTemp1!"))
@property @property
def acquisition_times(self): def acquisition_times(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|AcqTimesCache!")) return self._get_location(six.b("CustomData|AcqTimesCache!"))
@property @property
def acquisition_times_2(self): def acquisition_times_2(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|AcqTimes2Cache!")) return self._get_location(six.b("CustomData|AcqTimes2Cache!"))
@property @property
def acquisition_frames(self): def acquisition_frames(self):
"""
Returns:
"""
return self._get_location(six.b("CustomData|AcqFramesCache!")) return self._get_location(six.b("CustomData|AcqFramesCache!"))
@property @property
def lut_data(self): def lut_data(self):
"""
Returns:
"""
return self._get_location(six.b("CustomDataVar|LUTDataV1_0!")) return self._get_location(six.b("CustomDataVar|LUTDataV1_0!"))
@property @property
def grabber_settings(self): def grabber_settings(self):
"""
Returns:
"""
return self._get_location(six.b("CustomDataVar|GrabberCameraSettingsV1_0!")) return self._get_location(six.b("CustomDataVar|GrabberCameraSettingsV1_0!"))
@property @property
def custom_data(self): def custom_data(self):
"""
Returns:
"""
return self._get_location(six.b("CustomDataVar|CustomDataV2_0!")) return self._get_location(six.b("CustomDataVar|CustomDataV2_0!"))
@property @property
def app_info(self): def app_info(self):
"""
Returns:
"""
return self._get_location(six.b("CustomDataVar|AppInfo_V1_0!")) return self._get_location(six.b("CustomDataVar|AppInfo_V1_0!"))

+ 76
- 1
nd2reader/parser.py View File

@ -37,6 +37,12 @@ class Parser(object):
def calculate_image_properties(self, index): def calculate_image_properties(self, index):
"""Calculate FOV, channels and z_levels """Calculate FOV, channels and z_levels
Args:
index(int): the index (which is simply the order in which the image was acquired)
Returns:
tuple: tuple of the field of view, the channel and the z level
""" """
field_of_view = self._calculate_field_of_view(index) field_of_view = self._calculate_field_of_view(index)
channel = self._calculate_channel(index) channel = self._calculate_channel(index)
@ -52,6 +58,12 @@ class Parser(object):
eliminate this possibility in future releases. For now, you'll need to check if your image is None if you're eliminate this possibility in future releases. For now, you'll need to check if your image is None if you're
doing anything out of the ordinary. doing anything out of the ordinary.
Args:
index(int): the index (which is simply the order in which the image was acquired)
Returns:
Frame: the image
""" """
field_of_view, channel, z_level = self.calculate_image_properties(index) field_of_view, channel, z_level = self.calculate_image_properties(index)
channel_offset = index % len(self.metadata["channels"]) channel_offset = index % len(self.metadata["channels"])
@ -66,7 +78,18 @@ class Parser(object):
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_name, z_level, height, width):
"""Attempts to get Image based on attributes alone.
"""Gets an image based on its attributes alone
Args:
frame_number: the frame number
field_of_view: the field of view
channel_name: the color channel name
z_level: the z level
height: the height of the image
width: the width of the image
Returns:
Frame: the requested image
""" """
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)
@ -91,6 +114,12 @@ class Parser(object):
def _check_version_supported(self): def _check_version_supported(self):
"""Checks if the ND2 file version is supported by this reader. """Checks if the ND2 file version is supported by this reader.
Returns:
bool: True on supported
Raises:
InvalidVersionError: Raises an error if the version is unsupported
""" """
major_version, minor_version = get_version(self._fh) major_version, minor_version = get_version(self._fh)
supported = self.supported_file_versions.get((major_version, minor_version)) or \ supported = self.supported_file_versions.get((major_version, minor_version)) or \
@ -116,6 +145,9 @@ class Parser(object):
as some of the bytes contain the value 33, which is the ASCII code for "!". So we iteratively find each label, as some of the bytes contain the value 33, which is the ASCII code for "!". So we iteratively find each label,
grab the subsequent data (always 16 bytes long), advance to the next label and repeat. grab the subsequent data (always 16 bytes long), advance to the next label and repeat.
Returns:
LabelMap: the computed label map
""" """
self._fh.seek(-8, 2) self._fh.seek(-8, 2)
chunk_map_start_location = struct.unpack("Q", self._fh.read(8))[0] chunk_map_start_location = struct.unpack("Q", self._fh.read(8))[0]
@ -126,6 +158,11 @@ class Parser(object):
def _calculate_field_of_view(self, index): def _calculate_field_of_view(self, index):
"""Determines what field of view was being imaged for a given image. """Determines what field of view was being imaged for a given image.
Args:
index(int): the index (which is simply the order in which the image was acquired)
Returns:
int: the field of view
""" """
images_per_cycle = len(self.metadata["z_levels"]) * len(self.metadata["channels"]) images_per_cycle = len(self.metadata["z_levels"]) * len(self.metadata["channels"])
return int((index - (index % images_per_cycle)) / images_per_cycle) % len(self.metadata["fields_of_view"]) return int((index - (index % images_per_cycle)) / images_per_cycle) % len(self.metadata["fields_of_view"])
@ -133,6 +170,12 @@ class Parser(object):
def _calculate_channel(self, index): def _calculate_channel(self, index):
"""Determines what channel a particular image is. """Determines what channel a particular image is.
Args:
index(int): the index (which is simply the order in which the image was acquired)
Returns:
string: the name of the color channel
""" """
return self.metadata["channels"][index % len(self.metadata["channels"])] return self.metadata["channels"][index % len(self.metadata["channels"])]
@ -141,6 +184,12 @@ class Parser(object):
In the future, this will be replaced with the actual offset in micrometers. In the future, this will be replaced with the actual offset in micrometers.
Args:
index(int): the index (which is simply the order in which the image was acquired)
Returns:
The z level
""" """
return self.metadata["z_levels"][int( return self.metadata["z_levels"][int(
((index - (index % len(self.metadata["channels"]))) / len(self.metadata["channels"])) % len( ((index - (index % len(self.metadata["channels"]))) / len(self.metadata["channels"])) % len(
@ -150,6 +199,14 @@ class Parser(object):
""" """
Images are grouped together if they share the same time index, field of view, and z-level. Images are grouped together if they share the same time index, field of view, and z-level.
Args:
frame_number:
fov:
z_level:
Returns:
int: the image group number
""" """
return frame_number * len(self.metadata["fields_of_view"]) * len(self.metadata["z_levels"]) + ( return frame_number * len(self.metadata["fields_of_view"]) * len(self.metadata["z_levels"]) + (
fov * len(self.metadata["z_levels"]) + z_level) fov * len(self.metadata["z_levels"]) + z_level)
@ -158,6 +215,13 @@ class Parser(object):
""" """
Images are in the same frame if they share the same group number and field of view and are taken sequentially. Images are in the same frame if they share the same group number and field of view and are taken sequentially.
Args:
image_group_number:
field_of_view:
z_level:
Returns:
""" """
return (image_group_number - (field_of_view * len(self.metadata["z_levels"]) + z_level)) / ( return (image_group_number - (field_of_view * len(self.metadata["z_levels"]) + z_level)) / (
len(self.metadata["fields_of_view"]) * len(self.metadata["z_levels"])) len(self.metadata["fields_of_view"]) * len(self.metadata["z_levels"]))
@ -168,12 +232,23 @@ class Parser(object):
Image data is interleaved for each image set. That is, if there are four images in a set, the first image Image data is interleaved for each image set. That is, if there are four images in a set, the first image
will consist of pixels 1, 5, 9, etc, the second will be pixels 2, 6, 10, and so forth. will consist of pixels 1, 5, 9, etc, the second will be pixels 2, 6, 10, and so forth.
Returns:
dict: the channel offset for each channel
""" """
return {channel: n for n, channel in enumerate(self.metadata["channels"])} return {channel: n for n, channel in enumerate(self.metadata["channels"])}
def _get_raw_image_data(self, image_group_number, channel_offset, height, width): def _get_raw_image_data(self, image_group_number, channel_offset, height, width):
"""Reads the raw bytes and the timestamp of an image. """Reads the raw bytes and the timestamp of an image.
Args:
image_group_number:
channel_offset:
height:
width:
Returns:
""" """
chunk = self._label_map.get_image_data_location(image_group_number) chunk = self._label_map.get_image_data_location(image_group_number)
data = read_chunk(self._fh, chunk) data = read_chunk(self._fh, chunk)


+ 131
- 3
nd2reader/raw_metadata.py View File

@ -7,7 +7,25 @@ import numpy as np
def ignore_missing(func): def ignore_missing(func):
"""
Args:
func:
Returns:
"""
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
"""
Args:
*args:
**kwargs:
Returns:
"""
try: try:
return func(*args, **kwargs) return func(*args, **kwargs)
except: except:
@ -17,6 +35,10 @@ def ignore_missing(func):
class RawMetadata(object): class RawMetadata(object):
"""
RawMetadata class parses and stores the raw metadata that is read from the binary file in dict format
"""
def __init__(self, fh, label_map): def __init__(self, fh, label_map):
self._fh = fh self._fh = fh
self._label_map = label_map self._label_map = label_map
@ -163,6 +185,11 @@ class RawMetadata(object):
This includes the position and size at the given timepoints. This includes the position and size at the given timepoints.
Args:
raw_roi_dict:
Returns:
""" """
number_of_timepoints = raw_roi_dict[six.b('m_vectAnimParams_Size')] number_of_timepoints = raw_roi_dict[six.b('m_vectAnimParams_Size')]
@ -204,8 +231,14 @@ class RawMetadata(object):
return None return None
def _parse_vect_anim(self, roi_dict, animation_dict): def _parse_vect_anim(self, roi_dict, animation_dict):
"""Parses a ROI vector animation object and adds it to the global list of timepoints and positions.
"""
Parses a ROI vector animation object and adds it to the global list of timepoints and positions.
Args:
roi_dict:
animation_dict:
Returns:
""" """
roi_dict["timepoints"].append(animation_dict[six.b('m_dTimeMs')]) roi_dict["timepoints"].append(animation_dict[six.b('m_dTimeMs')])
@ -249,8 +282,15 @@ class RawMetadata(object):
self._metadata_parsed['experiment'] = experimental_data self._metadata_parsed['experiment'] = experimental_data
def _parse_loop_data(self, loop_data):
"""Parse the experimental loop data
@staticmethod
def _parse_loop_data(loop_data):
"""
Parse the experimental loop data
Args:
loop_data:
Returns:
""" """
loops = [loop_data] loops = [loop_data]
@ -296,81 +336,160 @@ class RawMetadata(object):
@property @property
@ignore_missing @ignore_missing
def image_text_info(self): def image_text_info(self):
"""
Returns:
"""
return read_metadata(read_chunk(self._fh, self._label_map.image_text_info), 1) return read_metadata(read_chunk(self._fh, self._label_map.image_text_info), 1)
@property @property
@ignore_missing @ignore_missing
def image_metadata_sequence(self): def image_metadata_sequence(self):
"""
Returns:
"""
return read_metadata(read_chunk(self._fh, self._label_map.image_metadata_sequence), 1) return read_metadata(read_chunk(self._fh, self._label_map.image_metadata_sequence), 1)
@property @property
@ignore_missing @ignore_missing
def image_calibration(self): def image_calibration(self):
"""
Returns:
"""
return read_metadata(read_chunk(self._fh, self._label_map.image_calibration), 1) return read_metadata(read_chunk(self._fh, self._label_map.image_calibration), 1)
@property @property
@ignore_missing @ignore_missing
def image_attributes(self): def image_attributes(self):
"""
Returns:
"""
return read_metadata(read_chunk(self._fh, self._label_map.image_attributes), 1) return read_metadata(read_chunk(self._fh, self._label_map.image_attributes), 1)
@property @property
@ignore_missing @ignore_missing
def x_data(self): def x_data(self):
"""
Returns:
"""
return read_array(self._fh, 'double', self._label_map.x_data) return read_array(self._fh, 'double', self._label_map.x_data)
@property @property
@ignore_missing @ignore_missing
def y_data(self): def y_data(self):
"""
Returns:
"""
return read_array(self._fh, 'double', self._label_map.y_data) return read_array(self._fh, 'double', self._label_map.y_data)
@property @property
@ignore_missing @ignore_missing
def z_data(self): def z_data(self):
"""
Returns:
"""
return read_array(self._fh, 'double', self._label_map.z_data) return read_array(self._fh, 'double', self._label_map.z_data)
@property @property
@ignore_missing @ignore_missing
def roi_metadata(self): def roi_metadata(self):
"""
Returns:
"""
return read_metadata(read_chunk(self._fh, self._label_map.roi_metadata), 1) return read_metadata(read_chunk(self._fh, self._label_map.roi_metadata), 1)
@property @property
@ignore_missing @ignore_missing
def pfs_status(self): def pfs_status(self):
"""
Returns:
"""
return read_array(self._fh, 'int', self._label_map.pfs_status) return read_array(self._fh, 'int', self._label_map.pfs_status)
@property @property
@ignore_missing @ignore_missing
def pfs_offset(self): def pfs_offset(self):
"""
Returns:
"""
return read_array(self._fh, 'int', self._label_map.pfs_offset) return read_array(self._fh, 'int', self._label_map.pfs_offset)
@property @property
@ignore_missing @ignore_missing
def camera_exposure_time(self): def camera_exposure_time(self):
"""
Returns:
"""
return read_array(self._fh, 'double', self._label_map.camera_exposure_time) return read_array(self._fh, 'double', self._label_map.camera_exposure_time)
@property @property
@ignore_missing @ignore_missing
def lut_data(self): def lut_data(self):
"""
Returns:
"""
return xmltodict.parse(read_chunk(self._fh, self._label_map.lut_data)) return xmltodict.parse(read_chunk(self._fh, self._label_map.lut_data))
@property @property
@ignore_missing @ignore_missing
def grabber_settings(self): def grabber_settings(self):
"""
Returns:
"""
return xmltodict.parse(read_chunk(self._fh, self._label_map.grabber_settings)) return xmltodict.parse(read_chunk(self._fh, self._label_map.grabber_settings))
@property @property
@ignore_missing @ignore_missing
def custom_data(self): def custom_data(self):
"""
Returns:
"""
return xmltodict.parse(read_chunk(self._fh, self._label_map.custom_data)) return xmltodict.parse(read_chunk(self._fh, self._label_map.custom_data))
@property @property
@ignore_missing @ignore_missing
def app_info(self): def app_info(self):
"""
Returns:
"""
return xmltodict.parse(read_chunk(self._fh, self._label_map.app_info)) return xmltodict.parse(read_chunk(self._fh, self._label_map.app_info))
@property @property
@ignore_missing @ignore_missing
def camera_temp(self): def camera_temp(self):
"""
Yields:
float: the temperature
"""
camera_temp = read_array(self._fh, 'double', self._label_map.camera_temp) camera_temp = read_array(self._fh, 'double', self._label_map.camera_temp)
if camera_temp: if camera_temp:
for temp in map(lambda x: round(x * 100.0, 2), camera_temp): for temp in map(lambda x: round(x * 100.0, 2), camera_temp):
@ -379,6 +498,10 @@ class RawMetadata(object):
@property @property
@ignore_missing @ignore_missing
def acquisition_times(self): def acquisition_times(self):
"""
Yields:
float: the acquisition time
"""
acquisition_times = read_array(self._fh, 'double', self._label_map.acquisition_times) acquisition_times = read_array(self._fh, 'double', self._label_map.acquisition_times)
if acquisition_times: if acquisition_times:
for acquisition_time in map(lambda x: x / 1000.0, acquisition_times): for acquisition_time in map(lambda x: x / 1000.0, acquisition_times):
@ -387,5 +510,10 @@ class RawMetadata(object):
@property @property
@ignore_missing @ignore_missing
def image_metadata(self): def image_metadata(self):
"""
Returns:
"""
if self._label_map.image_metadata: if self._label_map.image_metadata:
return read_metadata(read_chunk(self._fh, self._label_map.image_metadata), 1) return read_metadata(read_chunk(self._fh, self._label_map.image_metadata), 1)

+ 25
- 0
nd2reader/reader.py View File

@ -41,6 +41,12 @@ class ND2Reader(FramesSequenceND):
def get_frame(self, i): def get_frame(self, i):
"""Return one frame """Return one frame
Args:
i: The frame number
Returns:
numpy.ndarray: The requested frame
""" """
fetch_all_channels = 'c' in self.bundle_axes fetch_all_channels = 'c' in self.bundle_axes
@ -52,6 +58,12 @@ class ND2Reader(FramesSequenceND):
def _get_frame_all_channels(self, i): def _get_frame_all_channels(self, i):
"""Get all color channels for this frame """Get all color channels for this frame
Args:
i: The frame number
Returns:
numpy.ndarray: The requested frame, with all color channels.
""" """
frames = None frames = None
for c in range(len(self.metadata["channels"])): for c in range(len(self.metadata["channels"])):
@ -65,6 +77,14 @@ class ND2Reader(FramesSequenceND):
def get_frame_2D(self, c, t, z): def get_frame_2D(self, c, t, z):
"""Gets a given frame using the parser """Gets a given frame using the parser
Args:
c: The color channel number
t: The frame number
z: The z stack number
Returns:
numpy.ndarray: The requested frame
""" """
c_name = self.metadata["channels"][c] c_name = self.metadata["channels"][c]
return self._parser.get_image_by_attributes(t, 0, c_name, z, self.metadata["height"], self.metadata["width"]) return self._parser.get_image_by_attributes(t, 0, c_name, z, self.metadata["height"], self.metadata["width"])
@ -73,6 +93,8 @@ class ND2Reader(FramesSequenceND):
def pixel_type(self): def pixel_type(self):
"""Return the pixel data type """Return the pixel data type
Returns: the pixel data type
""" """
return self._dtype return self._dtype
@ -92,6 +114,9 @@ class ND2Reader(FramesSequenceND):
def get_timesteps(self): def get_timesteps(self):
"""Get the timesteps of the experiment """Get the timesteps of the experiment
Returns:
np.ndarray: an array of times in milliseconds.
""" """
timesteps = np.array([]) timesteps = np.array([])
current_time = 0.0 current_time = 0.0


Loading…
Cancel
Save