From 3ff9c9ff809f3246537c16e3ccfea23180742a61 Mon Sep 17 00:00:00 2001 From: davidmcdonagh Date: Thu, 14 Dec 2023 14:17:35 +0000 Subject: [PATCH] Fixed pixel line plot requiring idxs reflection column. --- src/dials/array_family/flex_ext.py | 15 +++++++++++---- src/dials/util/image_viewer/spotfinder_frame.py | 4 +++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/dials/array_family/flex_ext.py b/src/dials/array_family/flex_ext.py index e87c16fd45..286682f47b 100644 --- a/src/dials/array_family/flex_ext.py +++ b/src/dials/array_family/flex_ext.py @@ -1064,7 +1064,7 @@ def contains_tof_data(self): return "tof" in self def get_pixel_bbox_centroid_positions( - self, panel: int, pixel_pos: Tuple[int, int] + self, panel: int, pixel_pos: Tuple[int, int], return_miller_indices: bool = True ) -> Tuple[list, list, list, list]: """ Finds any bounding boxes within px and py on panel @@ -1074,7 +1074,9 @@ def get_pixel_bbox_centroid_positions( sel = self["panel"] == panel x0, x1, y0, y1, z0, z1 = self["bbox"].select(sel).parts() - idxs = self["idx"].select(sel) + idxs = None + if "idx" in self: + idxs = self["idx"].select(sel) if "xyzobs.px.value" in self: centroids = self["xyzobs.px.value"].select(sel) else: @@ -1093,7 +1095,8 @@ def get_pixel_bbox_centroid_positions( if px >= x0[i] and px <= x1[i]: if py >= y0[i] and py <= y1[i]: bbox_pos.append([z0[i], z1[i]]) - refl_ids.append(idxs[i]) + if idxs: + refl_ids.append(idxs[i]) if centroids: centroid_pos.append(centroids[i][2]) ci = centroids[i][2] @@ -1104,7 +1107,11 @@ def get_pixel_bbox_centroid_positions( else: selected_miller_indices.append((0, 0, 0)) - return bbox_pos, centroid_pos, refl_ids, selected_miller_indices + if idxs: + return bbox_pos, centroid_pos, refl_ids, selected_miller_indices + elif return_miller_indices: + return bbox_pos, centroid_pos, selected_miller_indices + return bbox_pos, centroid_pos def find_overlaps(self, experiments=None, border=0): """ diff --git a/src/dials/util/image_viewer/spotfinder_frame.py b/src/dials/util/image_viewer/spotfinder_frame.py index 76aa7a8970..86a8ad5c67 100644 --- a/src/dials/util/image_viewer/spotfinder_frame.py +++ b/src/dials/util/image_viewer/spotfinder_frame.py @@ -2421,7 +2421,9 @@ def get_pixel_bbox_centroid_positions(self, panel: int, coords: Tuple[int, int]) all_bboxes = [] all_centroids = [] for rt in self.reflection_table_list: - bboxes, centroids = rt.get_pixel_bbox_centroid_positions(panel, coords) + bboxes, centroids = rt.get_pixel_bbox_centroid_positions( + panel, coords, False + ) all_bboxes += list(bboxes) all_centroids += list(centroids) return all_bboxes, all_centroids