Skip to content

Commit a5eeb9a

Browse files
committed
Invalidate polar masks on detector transform
The polar masks need to be regenerated when the detectors are transformed. This adds functionality that does so. Signed-off-by: Patrick Avery <[email protected]>
1 parent 2d7343c commit a5eeb9a

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

hexrdgui/calibration/polarview.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from hexrdgui.constants import ViewType
1818
from hexrdgui.hexrd_config import HexrdConfig
1919
from hexrdgui.masking.constants import MaskType
20+
from hexrdgui.masking.mask_manager import MaskManager
2021
from hexrdgui.utils import SnipAlgorithmType, run_snip1d, snip_width_pixels
2122

2223
tvec_c = ct.zeros_3
@@ -503,7 +504,6 @@ def apply_intensity_corrections(self, img):
503504

504505
def apply_visible_masks(self, img):
505506
# Apply user-specified masks if they are present
506-
from hexrdgui.masking.mask_manager import MaskManager
507507
img = img.copy()
508508
total_mask = self.warp_mask
509509
for mask in MaskManager().masks.values():
@@ -523,7 +523,6 @@ def apply_visible_masks(self, img):
523523

524524
def apply_boundary_masks(self, img):
525525
# Apply user-specified masks if they are present
526-
from hexrdgui.masking.mask_manager import MaskManager
527526
img = img.copy()
528527
total_mask = self.warp_mask
529528
for mask in MaskManager().masks.values():
@@ -593,6 +592,9 @@ def update_detectors(self, detectors):
593592
# Update the individual detector image
594593
self.create_warp_image(det)
595594

595+
# Invalidate the masks that match these detectors
596+
MaskManager().invalidate_detector_masks(detectors)
597+
596598
# Generate the final image
597599
self.generate_image()
598600

hexrdgui/masking/create_polar_mask.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
22

3-
from hexrdgui.calibration.polarview import PolarView
43
from hexrdgui.constants import ViewType
54
from hexrdgui.create_hedm_instrument import create_hedm_instrument
65
from hexrdgui.hexrd_config import HexrdConfig
@@ -45,6 +44,7 @@ def convert_raw_to_polar(instr, det, line, apply_tth_distortion=True):
4544

4645

4746
def create_polar_mask(line_data):
47+
from hexrdgui.calibration.polarview import PolarView
4848
from hexrdgui.masking.mask_manager import MaskManager
4949
# Calculate current image dimensions
5050
# If we pass `None` to the polar view, it is a dummy polar view

hexrdgui/masking/mask_manager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ def threshold_mask(self):
326326
def mask_names(self):
327327
return list(self.masks.keys())
328328

329+
def invalidate_detector_masks(self, det_keys: list[str]):
330+
for mask in self.masks.values():
331+
if any(v[0] in det_keys for v in mask.data):
332+
mask.invalidate_masked_arrays()
333+
329334
def setup_connections(self):
330335
self.threshold_mask_changed.connect(self.threshold_toggled)
331336
HexrdConfig().save_state.connect(self.save_state)

0 commit comments

Comments
 (0)