From 10348e68db239c8daebf8b53339536038bd19480 Mon Sep 17 00:00:00 2001 From: Ruben Verweij Date: Thu, 23 Aug 2018 15:26:57 +0200 Subject: [PATCH] Workaround issue #6, fix unit test timesteps --- nd2reader/artificial.py | 6 +++--- nd2reader/parser.py | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/nd2reader/artificial.py b/nd2reader/artificial.py index df83c18..024c991 100644 --- a/nd2reader/artificial.py +++ b/nd2reader/artificial.py @@ -289,9 +289,9 @@ class ArtificialND2(object): 7, # CustomData|CustomDescriptionV1_0!", 7, # CustomData|Camera_ExposureTime1!", 7, # CustomData|CameraTemp1!", - 7, # CustomData|AcqTimesCache!", - 7, # CustomData|AcqTimes2Cache!", - 7, # CustomData|AcqFramesCache!", + [0], # CustomData|AcqTimesCache!", + [0], # CustomData|AcqTimes2Cache!", + [0], # CustomData|AcqFramesCache!", 7, # CustomDataVar|LUTDataV1_0!", 7, # CustomDataVar|GrabberCameraSettingsV1_0!", 7, # CustomDataVar|CustomDataV2_0!", diff --git a/nd2reader/parser.py b/nd2reader/parser.py index c413676..20b2095 100644 --- a/nd2reader/parser.py +++ b/nd2reader/parser.py @@ -265,8 +265,11 @@ class Parser(object): # The images for the various channels are interleaved within the same array. For example, the second image # of a four image group will be composed of bytes 2, 6, 10, etc. If you understand why someone would design # a data structure that way, please send the author of this library a message. - number_of_true_channels = int((len(image_group_data) - 4) / (height * width)) - image_data = np.reshape(image_group_data[image_data_start::number_of_true_channels], (height, width)) + number_of_true_channels = int(len(image_group_data[image_data_start:]) / (height * width)) + try: + image_data = np.reshape(image_group_data[image_data_start::number_of_true_channels], (height, width)) + except ValueError: + image_data = np.reshape(image_group_data[image_data_start::number_of_true_channels], (height, int(len(image_group_data[image_data_start::number_of_true_channels])/height))) # Skip images that are all zeros! This is important, since NIS Elements creates blank "gap" images if you # don't have the same number of images each cycle. We discovered this because we only took GFP images every