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

dials.generate_mask trusted_range bug #978

Closed
dagewa opened this issue Oct 21, 2019 · 9 comments
Closed

dials.generate_mask trusted_range bug #978

dagewa opened this issue Oct 21, 2019 · 9 comments

Comments

@dagewa
Copy link
Member

dagewa commented Oct 21, 2019

The behaviour of dials.generate_mask appears to be to combine untrusted area definitions with the untrusted_range mask of the first image of a sequence. This causes overloaded spots on image 1 to be persistently masked throughout a dataset, like a flash burn. This example makes it obvious:

cat > mask.phil <<+
untrusted {
  rectangle = 0 1375 1246 1300
}
+
dials.import $(dials.data get -q x4wide)/*.cbf trusted_range=-1,100
dials.generate_mask imported.expt mask.phil
dials.import $(dials.data get -q x4wide)/X4_wide_M1S4_2_00*.cbf mask=pixels.mask

Now see the strong pixels from the first image masked throughout the whole dataset:
Screenshot from 2019-10-21 21-15-15

@dagewa
Copy link
Member Author

dagewa commented Oct 21, 2019

Probable culprit

dials/util/masking.py

Lines 144 to 145 in 9780dfd

# Get the first image
image = imageset.get_raw_data(0)

@graeme-winter
Copy link
Contributor

Good spot. Suspect that this was an attempt in $past to find and mask hot pixels. Ouch.

@graeme-winter
Copy link
Contributor

Verified bug but pointy finger of blame misplaced... print(1/0) just after this line does not cause crash.

@graeme-winter
Copy link
Contributor

Silver-Surfer util :) [master] $ rm -rfv masking
masking/__pycache__/__init__.cpython-36.pyc
masking/__pycache__
masking/__init__.pyc
masking
  • explains condusion - d'oh

graeme-winter added a commit that referenced this issue Oct 22, 2019
Loop is efficient for single-panel detectors and resolves the issue as published. Will be expensive for large image sets but that is the expected behaviour I would expect. Could do with refactoring for multi-panel detectors as the loop is inside out.
@graeme-winter
Copy link
Contributor

Branched to trusted-pixel-range-mask for fix.

@graeme-winter
Copy link
Contributor

We should discuss how this interacts with multi-panel detectors. Also for large image sets could have better way of doing this e.g. with random sampling?

@dagewa
Copy link
Member Author

dagewa commented Oct 22, 2019

I don't understand - I still see the same behaviour with the test case above while on the trusted-pixel-range-mask branch.

@graeme-winter
Copy link
Contributor

  551  dials.import $(dials.data get -q x4wide)/*.cbf trusted_range=-1,100
  552  dials.generate_mask imported.expt mask.phil
  553  dials.import $(dials.data get -q x4wide)/X4_wide_M1S4_2_00*.cbf mask=pixels.mask
  554  dials.image_viewer imported.expt 

Screenshot 2019-10-22 at 09 43 51

While this may not be helpful, it appears to work for me.

@dagewa
Copy link
Member Author

dagewa commented Oct 22, 2019

I had old .pyc files too... Working now, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants