Browse Source

Refactor CQ

zolfa-add_slices_loading
Ruben Verweij 7 years ago
parent
commit
04e67fc5ec
1 changed files with 12 additions and 7 deletions
  1. +12
    -7
      nd2reader/raw_metadata.py

+ 12
- 7
nd2reader/raw_metadata.py View File

@ -123,17 +123,13 @@ class RawMetadata(object):
return channels
def _process_channels_metadata(self, metadata):
try:
validity = self.image_metadata[six.b('SLxExperiment')][six.b('ppNextLevelEx')][six.b('')][0][
six.b('ppNextLevelEx')][six.b('')][0][six.b('pItemValid')]
except (KeyError, TypeError):
# If none of the channels have been deleted, there is no validity list, so we just make one
validity = [True for _ in metadata]
validity = self._get_channel_validity_list(metadata)
# Channel information is contained in dictionaries with the keys a0, a1...an where the number
# indicates the order in which the channel is stored. So by sorting the dicts alphabetically
# we get the correct order.
channels = []
for (label, chan), valid in zip(sorted(metadata[six.b('sPlaneNew')].items()), validity):
for valid, (label, chan) in zip(validity, sorted(metadata[six.b('sPlaneNew')].items())):
if not valid:
continue
if chan[six.b('sDescription')] is not None:
@ -142,6 +138,15 @@ class RawMetadata(object):
channels.append('Unknown')
return channels
def _get_channel_validity_list(self, metadata):
try:
validity = self.image_metadata[six.b('SLxExperiment')][six.b('ppNextLevelEx')][six.b('')][0][
six.b('ppNextLevelEx')][six.b('')][0][six.b('pItemValid')]
except (KeyError, TypeError):
# If none of the channels have been deleted, there is no validity list, so we just make one
validity = [True for _ in metadata]
return validity
def _parse_fields_of_view(self):
"""The metadata contains information about fields of view, but it contains it even if some fields
of view were cropped. We can't find anything that states which fields of view are actually


Loading…
Cancel
Save