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.image_viewer: Display -2 as "masked" occurs for non-Pilatus images #536

Closed
dagewa opened this issue Apr 14, 2018 · 14 comments
Closed

Comments

@dagewa
Copy link
Member

dagewa commented Apr 14, 2018

An example is in the backstop region of this image:

dials.image_viewer $(libtbx.find_in_repositories dials_regression)/image_examples/ESRF_BM14/mar225_1_001.mccd

mask_marccd

For those with access, the images in /dls/mx-scratch/rjgildea/fisher/013_021_G4 are worse, with many "masked" pixels across the image

@rjgildea
Copy link
Contributor

This is a known thing, and I'm not sure a fix is possible without a significant reworking of how the display is handled in the FlexImage class:
https://github.com/cctbx/cctbx_project/blob/master/iotbx/detectors/display.h#L236

@dagewa
Copy link
Member Author

dagewa commented Apr 16, 2018

I wonder if @nksauter would like to comment? Why do we need special code to display -2 as masked anyway? Shouldn't the masked pixels be defined by the mask?

@rjgildea
Copy link
Contributor

The code in FlexImage long-predates dxtbx and image masks (and also Pilatus detectors) - judging by labelit svn logs it dates back to 2004.

@dagewa
Copy link
Member Author

dagewa commented Apr 16, 2018

I haven't yet tried it, but I thought for a simple fix that this line: https://github.com/cctbx/cctbx_project/blob/master/iotbx/detectors/display.h#L199
should instead be
bool has_pilatus_inactive_flag = false;
and then it is set true individually for DECTRIS detectors based on vendortype and then doesn't end up true for e.g. CCD datasets

@rjgildea
Copy link
Contributor

Yes, but then it won't be possible to view image masks for CCD images. The problem is that the image viewer is (ab)using the functionality in FlexImage flagging the special Pilatus -2 pixels in order to display dxtbx image masks.

@graeme-winter
Copy link
Contributor

graeme-winter commented Apr 16, 2018 via email

@rjgildea
Copy link
Contributor

def mask_raw_data(self, raw_data):
mask = self.get_mask(self.pyslip.tiles.raw_image)
for rd, m in zip(raw_data, mask):
rd.set_selected(~m, -2)

@dagewa
Copy link
Member Author

dagewa commented Apr 16, 2018

I made the change anyway to see what happens. I defined a rectangular mask, imported with that then viewed in the image viewer. When "Show mask" is selected the -2 valued pixels are no longer red, and the masked region becomes white.
mask

@dagewa
Copy link
Member Author

dagewa commented Apr 16, 2018

Original code gets the red coloured mask, which is obviously better, but has the spurious -2 pixels "masked" as well.
mask2

@rjgildea
Copy link
Contributor

Presumably they are only appearing as white because of the code above that sets the masked pixels to -2, and -2 is a "small number", so the display is set to white (or close to white) for those pixels (with that colour scheme).

@nksauter
Copy link
Contributor

nksauter commented Apr 17, 2018 via email

@dagewa
Copy link
Member Author

dagewa commented Apr 18, 2018

Hi @nksauter, I don't think any of us are going to touch this until you have a chance to take a look. Thanks.

@dagewa
Copy link
Member Author

dagewa commented May 18, 2018

See also cctbx/cctbx_project#49

@dagewa
Copy link
Member Author

dagewa commented Oct 14, 2019

Just noting that I get problems with this particularly with electron diffraction datasets where there may be genuine negative-valued pixels. I'd like to see what the values are, but of course the image viewer always tells me they are -2.

dagewa added a commit that referenced this issue Nov 19, 2019
Use a special value -(2 ** 31) that will never be a valid pixel value
to indicate a masked pixel, rather than -2. For #536.
dagewa added a commit that referenced this issue Dec 5, 2019
* MASK_VAL for explicitly-masked pixels

Use a special value -(2 ** 31) that will never be a valid pixel value
to indicate a masked pixel, rather than -2. For #536.

* De-uglify formatting

* Use c_sizeof to avoiding hardcoding MASK_VAL

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

No branches or pull requests

5 participants