From 014edde32abb6737fae6917fcfb1a9bd41ef3a25 Mon Sep 17 00:00:00 2001 From: David Hammer <dhammer@mailbox.org> Date: Wed, 18 Oct 2023 09:18:23 +0200 Subject: [PATCH] Small tweaks, respect image data path configuration --- src/calng/DetectorAssembler.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/calng/DetectorAssembler.py b/src/calng/DetectorAssembler.py index 80d6f8eb..31def2c0 100644 --- a/src/calng/DetectorAssembler.py +++ b/src/calng/DetectorAssembler.py @@ -1,6 +1,5 @@ import enum from timeit import default_timer -import functools import re from karabo.bound import ( @@ -98,11 +97,17 @@ class DetectorAssembler(TrainMatcher.TrainMatcher): .commit(), STRING_ELEMENT(expected) - .key("pathToStack") + .key("imageDataPath") .assignmentOptional() .defaultValue("image.data") .commit(), + STRING_ELEMENT(expected) + .key("imageMaskPath") + .assignmentOptional() + .defaultValue("image.mask") + .commit(), + OUTPUT_CHANNEL(expected) .key("assembledOutput") .dataSchema(schemas.preview_schema(wrap_image_in_imagedata=False)) @@ -191,7 +196,8 @@ class DetectorAssembler(TrainMatcher.TrainMatcher): super().initialization() self._preview_friend = preview_utils.PreviewFriend(self) - self._path_to_stack = self.get("pathToStack") + self._image_data_path = self.get("imageDataPath") + self._image_mask_path = self.get("imageMaskPath") self._geometry = None self._stack_input_buffer = None # set up source to index mapping @@ -331,8 +337,6 @@ class DetectorAssembler(TrainMatcher.TrainMatcher): earliest_source_timestamp = float("inf") self._stack_input_buffer.mask.fill(False) for source, (data, source_timestamp) in sources.items(): - if source not in self._source_to_index: - continue # regular TrainMatcher output self.output.write( data, ChannelMetaData(source, source_timestamp), copyAllData=False @@ -340,15 +344,19 @@ class DetectorAssembler(TrainMatcher.TrainMatcher): if bridge_output_choice is BridgeOutputOptions.MATCHED: self.zmq_output.write(source, data, source_timestamp) + if source not in self._source_to_index: + continue # prepare for assembly # TODO: handle failure to "parse" source, get data out - image_data = data["image.data"] + if not data.has(self._image_data_path): + continue + image_data = data[self._image_data_path] if isinstance(image_data, ImageData): # TODO: maybe glance encoding here image_data = image_data.getData() image_data = image_data.astype(np.float32, copy=False) # TODO: set dtype based on input? - if data.has("image.mask"): - image_mask = data["image.mask"] + if data.has(self._image_mask_path): + image_mask = data[self._image_mask_path] if isinstance(image_mask, ImageData): image_mask = image_mask.getData() else: -- GitLab