-
Notifications
You must be signed in to change notification settings - Fork 163
Added ability to do segmented peak detection on polar transform of DP #726
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
base: dev
Are you sure you want to change the base?
Conversation
NJMarchese
commented
Jul 8, 2025
- Added new function to allow for different peak detection parameters for different q-spacings on the diffraction pattern.
- Also enabled the ability to pass a realspace mask onto find_peaks.
- Added an error catch onto the curve_fit of flowlines to give a more informative error message.
- Added kwargs.get method to find_peaks_single_pattern so that the figure and axes are passed correctly. Before wouldn't handle correctly, and if figax was passed it would give an error saying there were multiple values for figax (the default in the code and the one passed in kwargs)
- Added vmin and vmax kwargs pass to show_amorphous_ring_fit
- Added ability to return data for plot_radial_peaks
py4DSTEM/visualize/vis_special.py
Outdated
| **kwargs, | ||
| ) | ||
| if kwargs.get("vmax") is not None: | ||
| vmax = kwargs.pop("vmax") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you want to do this you need add vmin and max as flags to the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to add vmin and vmax as flags for the function input, but also had to change other lines of code since variable with names vmin and vmax assigned in line 154.
| kwargs_pass=None, | ||
| ): | ||
| """ | ||
| Peak detection function for polar transformations. Loop through all probe positions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing doc strings...especially for your new contributions with kwargs_pass, it'd be helpful to add detailed docs here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put in some doc strings, but as this is built off the original find_peaks function and the docstrings for that function is what is in find_peaks_segmented, I'm not sure if it's best for me to fill in those belonging to the original function. I added docstrings for the parameters I added for find_peaks_segmented.
| def find_peaks_segmented( | ||
| self, | ||
| mask=None, | ||
| mask_real=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be added to the other find_peaks function too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. When I looked at it the first time it seemed like it would break a bunch of things, so made it separate initially to keep everything in tact. I can take another look.
|
Hi @NJMarchese, thanks for contributing these features! I have a few small suggestions to your code. |
- Updated `find_peaks_single_pattern` to restore intensity scaling for scatter plot. - Enhanced `find_peaks_segmented` with new mask parameters for improved peak detection. - Modified `plot_radial_peaks` to allow customizable vertical lines. - Adjusted orientation histogram calculation to ensure angle conversion is in radians. - Added vmin and vmax parameters to `show_amorphous_ring_fit` for better visualization control.