Skip to content

Commit bc985a8

Browse files
committed
Do not try to draw boundary of threshold masks
Signed-off-by: Brianna Major <brianna.major@kitware.com>
1 parent 8558fd2 commit bc985a8

File tree

1 file changed

+38
-33
lines changed

1 file changed

+38
-33
lines changed

hexrdgui/image_canvas.py

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,7 @@ def draw_mask_boundaries(self, axis, det=None):
20122012
all_verts = []
20132013
for name in MaskManager().visible_boundaries:
20142014
mask = MaskManager().masks[name]
2015+
verts = None
20152016
if self.mode == ViewType.raw:
20162017
if HexrdConfig().stitch_raw_roi_images:
20172018
# Find masks to keep
@@ -2027,40 +2028,44 @@ def draw_mask_boundaries(self, axis, det=None):
20272028
ij, _ = self.iviewer.raw_to_stitched(v[:, [1, 0]], k)
20282029
verts.append(ij[:, [1, 0]])
20292030
else:
2030-
verts = [v for k, v in mask.data if k == det]
2031+
# Do not try to draw boundaries for threshold masks
2032+
if mask.type != MaskType.threshold:
2033+
verts = [v for k, v in mask.data if k == det]
20312034
elif self.mode == ViewType.polar or self.mode == ViewType.stereo:
2032-
# Do not apply tth distortion for the pinhole mask
2033-
apply_tth_distortion = mask.type != MaskType.pinhole
2034-
verts = create_polar_line_data_from_raw(
2035-
instr,
2036-
mask.data,
2037-
apply_tth_distortion=apply_tth_distortion,
2038-
)
2039-
if self.mode == ViewType.polar:
2040-
# Check for any major jumps in eta. That probably means
2041-
# the border is wrapping around.
2042-
for i, vert in enumerate(verts):
2043-
# If there are two points far away, assume there
2044-
# is a gap in the eta range.
2045-
eta_diff = np.abs(np.diff(vert[:, 1]))
2046-
delta_eta_est = np.nanmedian(eta_diff)
2047-
tolerance = delta_eta_est * 10
2048-
big_gaps, = np.nonzero(eta_diff > tolerance)
2049-
verts[i] = np.insert(
2050-
vert,
2051-
big_gaps + 1,
2052-
np.nan,
2053-
axis=0,
2054-
)
2055-
2056-
if self.mode == ViewType.stereo:
2057-
# Now convert from polar to stereo
2058-
for i, vert in enumerate(verts):
2059-
verts[i] = angles_to_stereo(
2060-
np.radians(vert),
2061-
self.iviewer.instr_pv,
2062-
HexrdConfig().stereo_size,
2063-
)
2035+
# Do not try to draw boundaries for threshold masks
2036+
if mask.type != MaskType.threshold:
2037+
# Do not apply tth distortion for the pinhole mask
2038+
apply_tth_distortion = mask.type != MaskType.pinhole
2039+
verts = create_polar_line_data_from_raw(
2040+
instr,
2041+
mask.data,
2042+
apply_tth_distortion=apply_tth_distortion,
2043+
)
2044+
if self.mode == ViewType.polar:
2045+
# Check for any major jumps in eta. That probably means
2046+
# the border is wrapping around.
2047+
for i, vert in enumerate(verts):
2048+
# If there are two points far away, assume there
2049+
# is a gap in the eta range.
2050+
eta_diff = np.abs(np.diff(vert[:, 1]))
2051+
delta_eta_est = np.nanmedian(eta_diff)
2052+
tolerance = delta_eta_est * 10
2053+
big_gaps, = np.nonzero(eta_diff > tolerance)
2054+
verts[i] = np.insert(
2055+
vert,
2056+
big_gaps + 1,
2057+
np.nan,
2058+
axis=0,
2059+
)
2060+
2061+
if self.mode == ViewType.stereo:
2062+
# Now convert from polar to stereo
2063+
for i, vert in enumerate(verts):
2064+
verts[i] = angles_to_stereo(
2065+
np.radians(vert),
2066+
self.iviewer.instr_pv,
2067+
HexrdConfig().stereo_size,
2068+
)
20642069

20652070
if not verts:
20662071
continue

0 commit comments

Comments
 (0)