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

Add option to find peaks using ratio variance/ mean in FindSXPeaksConvolve #37171

Merged
merged 10 commits into from May 2, 2024

Conversation

RichardWaiteSTFC
Copy link
Contributor

Description of work

Add option to find peaks using ratio variance/ mean in FindSXPeaksConvolve - this is a peak finding criterion used in DIALS, Winter (2018)
https://doi.org/10.1107/S2059798317017235

Here it is performed by doing 2 convolutions to evaluate E[y] and E[y^2] after scaling to ensure the data are in raw counts.

This work was started because it was noticed while benchmarking peak finding algorithms as part of testing #37123 that FindSXPeaksConvolve using ratio of I/sigma, was picking up lots of spurious noisy peaks in bank 1 of SXD (higher gain as upgraded detector bank recently) unless quite a high value of I/sigma chosen.

Here is a comparison of the two methods for an SXD run with lower stats

image

It can be seen that the new method (variance/mean) find ~15-20% more peaks that can be indexed with 90% accuracy with a hkl tolerance of 0.1 (note detector positions were calibrated prior to this benchmark). it also out performs the older FindSXPeaks algorithm with AllPEaks strategy (see comments in #37123).

There is no associated issue.

To test:

To-Do


Reviewer

Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.

Code Review

  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards?
  • Are the unit tests small and test the class in isolation?
  • If there is GUI work does it follow the GUI standards?
  • If there are changes in the release notes then do they describe the changes appropriately?
  • Do the release notes conform to the release notes guide?

Functional Tests

  • Do changes function as described? Add comments below that describe the tests performed?
  • Do the changes handle unexpected situations, e.g. bad input?
  • Has the relevant (user and developer) documentation been added/updated?

Does everything look good? Mark the review as Approve. A member of @mantidproject/gatekeepers will take care of it.

Gatekeeper

If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.

For a constant background the Poisson distributed counts should have Variance = mean (i.e. ratio = 1) - in the region of a Bragg peak the variance/mean > 1.
This idea is taken from DIALS software package for x-ray diffraction as described Winter (2018) https://doi.org/10.1107/S2059798317017235 - generalised to 3D TOF Laue
@RichardWaiteSTFC RichardWaiteSTFC added Diffraction Issues and pull requests related to diffraction Single Crystal Issues and pull requests related to single crystal ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS labels Apr 15, 2024
doc="Threshold value for variance/mean used to identify peaks.",
)
use_variance_over_mean = EnabledWhenProperty("PeakFindingStrategy", PropertyCriterion.IsNotDefault)
self.setPropertySettings("ThresholdVarianceOverMean", use_variance_over_mean)
Copy link
Contributor

Choose a reason for hiding this comment

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

From a user perspective, isn't it better to keep ThresholdIoverSigma and ThresholdVarianceOverMean variables closer and next to each other that becomes active/inactive based on the selection of PeakFindingStratergy after it?

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, but the convention is to put new arguments at the bottom so as to preserve the positional argument order in the python wrapper. Sometimes if there are loads of parameters that makes it more likely no one will be using positional arguments, but there are not so many arguments here so it's probably better to keep it as is. Is that OK?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah understood, I guess users won't bother much since there is only a small number of params to fill.

@@ -37,7 +37,7 @@ Here is an example using the ``SXD`` class that finds peaks and then removes dup

# find peaks using SXD static method - determines peak threshold from
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this comment needs to be updated to represent Variance over mean

Test passes on windows not on jenkins linux, asserts test the functionality sufficiently
@warunawickramasingha
Copy link
Contributor

Thanks for fixing the unit test issue and tested to be working properly as expected. Will approve after if you could update the above comment at docs/source/techniques/ISIS_SingleCrystalDiffraction_Workflow.rst

Copy link
Contributor

@warunawickramasingha warunawickramasingha left a comment

Choose a reason for hiding this comment

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

Thanks for updating the PR! The changes are working perfectly and happy to approve!

@SilkeSchomann SilkeSchomann merged commit bfe8895 into main May 2, 2024
10 checks passed
@SilkeSchomann SilkeSchomann deleted the variance_over_mean_ratio_in_FindSXPeaksConvovle branch May 2, 2024 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Diffraction Issues and pull requests related to diffraction ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS Single Crystal Issues and pull requests related to single crystal
Projects
Status: Merged
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants