Browse Source

Refactor CQ

feature/load_slices
Ruben Verweij 8 years ago
parent
commit
482d719c3e
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 return channels
def _process_channels_metadata(self, metadata): 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 # 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 # indicates the order in which the channel is stored. So by sorting the dicts alphabetically
# we get the correct order. # we get the correct order.
channels = [] 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: if not valid:
continue continue
if chan[six.b('sDescription')] is not None: if chan[six.b('sDescription')] is not None:
@ -142,6 +138,15 @@ class RawMetadata(object):
channels.append('Unknown') channels.append('Unknown')
return channels 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): def _parse_fields_of_view(self):
"""The metadata contains information about fields of view, but it contains it even if some fields """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 of view were cropped. We can't find anything that states which fields of view are actually


Loading…
Cancel
Save