Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions hexrdgui/calibration/polarview.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from hexrdgui.constants import ViewType
from hexrdgui.hexrd_config import HexrdConfig
from hexrdgui.masking.constants import MaskType
from hexrdgui.masking.mask_manager import MaskManager
from hexrdgui.utils import SnipAlgorithmType, run_snip1d, snip_width_pixels

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

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

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

# Invalidate the masks that match these detectors
MaskManager().invalidate_detector_masks(detectors)

# Generate the final image
self.generate_image()

Expand Down
2 changes: 1 addition & 1 deletion hexrdgui/masking/create_polar_mask.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np

from hexrdgui.calibration.polarview import PolarView
from hexrdgui.constants import ViewType
from hexrdgui.create_hedm_instrument import create_hedm_instrument
from hexrdgui.hexrd_config import HexrdConfig
Expand Down Expand Up @@ -45,6 +44,7 @@ def convert_raw_to_polar(instr, det, line, apply_tth_distortion=True):


def create_polar_mask(line_data):
from hexrdgui.calibration.polarview import PolarView
from hexrdgui.masking.mask_manager import MaskManager
# Calculate current image dimensions
# If we pass `None` to the polar view, it is a dummy polar view
Expand Down
5 changes: 5 additions & 0 deletions hexrdgui/masking/mask_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ def threshold_mask(self):
def mask_names(self):
return list(self.masks.keys())

def invalidate_detector_masks(self, det_keys: list[str]):
for mask in self.masks.values():
if any(v[0] in det_keys for v in mask.data):
mask.invalidate_masked_arrays()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bnmajor can you verify this function looks good?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, looks great to me!


def setup_connections(self):
self.threshold_mask_changed.connect(self.threshold_toggled)
HexrdConfig().save_state.connect(self.save_state)
Expand Down
Loading