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

remove format_class.get_mask() as it doesn't appear to be used #65

Closed
wants to merge 1 commit into from

Conversation

rjgildea
Copy link

As far as I can tell the format_class.get_mask() method no longer appears to be called after the recent masking refactor. At least all the dials/dxtbx tests appear to pass after removing the methods. I don't know whether this is an oversight, a bug, or reflects a lack of test coverage.

@rjgildea rjgildea requested a review from jmp1985 July 15, 2019 16:40
Copy link

@jmp1985 jmp1985 left a comment

Choose a reason for hiding this comment

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

Everything looks fine to me except for FormatPYunspecified.py which I think @phyy-nx should have a look at before the pull request is merged.

@@ -176,37 +174,6 @@ def _scan(self):
epochs={1: self._timesec},
)

def get_mask(self, goniometer=None):
Copy link

Choose a reason for hiding this comment

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

This code was written by Tara Michaels-Clark in 2015. It's not clear exactly to me what it is supposed to do but it looks like the first section applies an untrusted region mask and then the second bit applies a trusted range mask.

In the new C++ code, the trusted range mask will be set so that is fine; however, all the stuff between line 180 and line 200 will not be applied. @phyy-nx would it be possible to apply the tile stuff as untrusted rectangles in the panel model?

@phyy-nx
Copy link

phyy-nx commented Jul 17, 2019

Help me understand this pull request? These get_mask methods all seem very custom, not just for FormatPYUnspecified.

@rjgildea
Copy link
Author

The point is that as a result of recent changes to the masking code the format_class.get_mask() method is no longer called, so the code being removed in this pull request is now dead code.

@biochem-fan
Copy link
Member

What is the new way to define a mask in a dxtbx class then?

@jmp1985
Copy link

jmp1985 commented Jul 17, 2019

@biochem-fan There are multiple ways to define a mask.

  1. The trusted range is automatically applied to mask pixel values
  2. The untrusted rectangle mask is applied by specifying untrusted rectangles in the Panel object
  3. A dynamic shadow mask object can be used to provide more complex dynamic masking. The Format class needs a method get_goniometer_shadow_masker which returns an object inheriting from GoniometerShadowMasker
  4. A static mask can be attached the image set during import or by setting the imageset.external_lookup.mask

@biochem-fan
Copy link
Member

biochem-fan commented Jul 17, 2019

@jmp1985 How do you deal with pixel masks in EIGER master files? Are they ignored after recent mask code changes?

The untrusted rectangle mask is applied by specifying untrusted rectangles in the Panel object

This is not very useful. Images from EIGER and SACLA contain a pixel mask as metadata. There is no point converting it back into rectangles, as they will be converted back into a pixel mask again internally.

A static mask can be attached the image set during import or by setting the imageset.external_lookup.mask

This is what I want, but cannot be set up from a dxtbx class?

@phyy-nx
Copy link

phyy-nx commented Jul 18, 2019 via email

@rjgildea
Copy link
Author

I think the primary issue with the get_mask method, and the reasoning behind the recent dynamic masking refactoring (#59) is that having to call back to a python get_mask() method is a performance blocker in threaded integration (dials/dials#705).

@biochem-fan are these masks static across the entire scan, or do they vary with each image? If the former, then it sounds like we need a way to define and assign a static pixel mask in the format class constructor which hopefully wouldn't be too difficult to implement. If the latter, then it sounds a bit like the ideas discussed in dials/dials#705. Hopefully @jmp1985 can comment further on this.

@biochem-fan
Copy link
Member

are these masks static across the entire scan, or do they vary with each image?

At least for MPCCD at SACLA and EIGER at SPring-8, the masks should be static across the entire dataset. Note that MPCCD datasets are stills and have one Experiment per image.

Another workaround could be setting pixel values under the mask to something beyond the trusted range in get_raw_data.

@jmp1985
Copy link

jmp1985 commented Jul 23, 2019

@biochem-fan @rjgildea If the mask is static across the dataset then we can set it as a static mask in the ImageSet class. I guess we could add a get_static_mask method to Format which returns either a mask or None and then set that in the ImageSet when it is instantiated. This can be done as follows:

imageset.external_lookup.mask.data = ImageBool(mask_flex_array_or_tuple_of_flex_arrays)

@biochem-fan
Copy link
Member

biochem-fan commented Jul 23, 2019

@jmp1985 This is a good idea, provided that a user-provided mask can be automatically merged with the mask from the format class. For example, dead pixels and pixels near the edges of MPCCD panels should be masked. These are specific to individual MPCCDs and provided as metadata in the HDF5 file. In addition, users might want to mask beam stop shadows.

@jmp1985
Copy link

jmp1985 commented Jul 23, 2019

@biochem-fan Currently, this is not the case but should be straightforward to implement.

@phyy-nx
Copy link

phyy-nx commented Jul 24, 2019 via email

rjgildea added a commit that referenced this pull request Aug 29, 2019
- Add an optional Format.get_static_mask() method to allow format classes to define a static mask to be used on all images.
- Add tests for static masks in FormatHDF5SaclaMPCCD and FormatPYunspecifiedStill.
- Remove superfluous Format.get_mask() functions - these are no longer called and the functionality they used to provide are provided elsewhere.

Resolves #70 (see also #65).
@rjgildea rjgildea closed this Aug 29, 2019
@rjgildea
Copy link
Author

Superseded by #73.

@rjgildea rjgildea deleted the format_get_mask branch August 29, 2019 10:12
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

Successfully merging this pull request may close these issues.

4 participants