Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pilx] use dynamic masking for diffraction images #2450

Merged
merged 4 commits into from
Feb 21, 2025

Conversation

kif
Copy link
Member

@kif kif commented Feb 20, 2025

This allows to hide the intense gaps in Eiger images thus better auto- color scale.
close #2432

@kif kif added gui Affects only the graphical user interface ready to merge Please review labels Feb 20, 2025
@kif kif requested a review from loichuder February 20, 2025 14:18
Comment on lines 282 to 303
if maskfile:
mask_image = get_data(url=DataUrl(maskfile))
if mask_image.shape != image.shape:
mask_image = None
binning = [m//i for i, m in zip(image.shape, mask_image.shape)]
if min(binning)<1:
mask_image = None
else:
mask_image = rebin_fct(mask_image, binning)
else:
mask_image = None

detector = self.worker_config.poni.detector
if detector:
detector_mask = detector.mask
if detector.shape != image.shape:
detector.guess_binning(image)
detector_mask = rebin_fct(detector_mask, detector.binning)
if mask_image is None:
mask_image = detector_mask
else:
numpy.logical_or(mask_image, detector_mask, out=mask_image)
detector.mask = mask_image
mask_image = detector.dynamic_mask(image)
Copy link
Member

Choose a reason for hiding this comment

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

All these intertwined conditions make the code difficult to parse. I would suggest to move the highlighted part in a separate function (like get_mask_file) and use early returns. That will perhaps help a bit.

@kif kif merged commit 4e9da86 into silx-kit:main Feb 21, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gui Affects only the graphical user interface ready to merge Please review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pilx] Mask out the diffraction image
2 participants