Browse Source

Fix error in loop handling

feature/load_slices
Ruben Verweij 5 years ago
parent
commit
0a16ce9003
2 changed files with 19 additions and 14 deletions
  1. +1
    -1
      docs
  2. +18
    -13
      nd2reader/common_raw_metadata.py

+ 1
- 1
docs

@ -1 +1 @@
Subproject commit 47a1165d5558515d6df67fb20b3032172de56279
Subproject commit f700c239f8f9d7d1f99a3c10d9f67e2b3b8ef307

+ 18
- 13
nd2reader/common_raw_metadata.py View File

@ -40,20 +40,25 @@ def parse_roi_type(type_no):
def get_loops_from_data(loop_data):
loops = [loop_data]
if six.b('uiPeriodCount') in loop_data and loop_data[six.b('uiPeriodCount')] > 0:
# special ND experiment
if six.b('pPeriod') not in loop_data:
return []
# take the first dictionary element, it contains all loop data
loops = loop_data[six.b('pPeriod')][list(loop_data[six.b('pPeriod')].keys())[0]]
# special ND experiment
if six.b('pPeriod') not in loop_data:
return []
# exclude invalid periods
if six.b('pPeriodValid') in loop_data:
loops = [loops[i] for i in range(len(loops)) if loop_data[six.b('pPeriodValid')][i] == 1]
return loops
if six.b('uiPeriodCount') in loop_data and loop_data[six.b('uiPeriodCount')] > 0:
loops = []
for i, period in enumerate(loop_data[six.b('pPeriod')]):
# exclude invalid periods
if six.b('pPeriodValid') in loop_data:
try:
if loop_data[six.b('pPeriodValid')][i] == 1:
loops.append(loop_data[six.b('pPeriod')][period])
except IndexError:
continue
else:
# we can't be sure, append all
loops.append(loop_data[six.b('pPeriod')][period])
return [loop_data]
def guess_sampling_from_loops(duration, loop):


Loading…
Cancel
Save