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
Fix profile penumbra part deux #327
Fix profile penumbra part deux #327
Conversation
This patch resolves issue jrkerns#323 by switching to detecting the outermost points that cross the threshold value when detecting field edges in SingleProfile.
Using default x=50 for find_fwxm_peaks in LeedsTOR caused the wrong peak to be detected. (Don't understand 100% why :?)
Not sure why yet but this PR breaks the starshot demo. |
Let me know if these help: pylinac/pylinac/core/profile.py Lines 616 to 619 in 265ca6a
and pylinac/pylinac/core/profile.py Lines 558 to 564 in 265ca6a
|
I read those but somehow confused myself. Yes that makes sense. Thanks. |
Looking at the starshot both with your recent change and this change now. I'm also doing some small refactoring. |
FYI the multiple image combine test has been failing for a while. |
Problem is somewhere in here: pylinac/pylinac/core/profile.py Lines 641 to 646 in 265ca6a
|
Just came to exact same conclusion! The first subprofile has this shape: and the new penumbra point detection method is picking up the right hand side. Should the penumbra detection take the gradient of the profile into consideration? So when looking for a profile from RIGHT it should only consider points where gradient is negative? |
lol |
I've not thought of using the sign of the gradient. That's pretty smart. I think this is why I did the center-looking-outward approach. |
In the find_peaks function there's a parameter |
pylinac/pylinac/core/profile.py Lines 572 to 575 in 265ca6a
|
Hacky, but the smallest solution instead of passing through pylinac/pylinac/core/profile.py Lines 670 to 672 in 265ca6a
|
Check commit I just pushed |
pylinac/planar_imaging.py
Outdated
@@ -738,7 +738,7 @@ def _phantom_angle_calc(self) -> float: | |||
|
|||
start_angle_deg = self._determine_start_angle_for_circle_profile() | |||
circle = self._circle_profile_for_phantom_angle(start_angle_deg) | |||
peak_idx = circle.find_fwxm_peaks(threshold=0.6, max_number=1)[0] | |||
peak_idx = circle.find_fwxm_peaks(threshold=0.6, x=80, max_number=1)[0] |
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.
This x=80 is failing a number of tests. Why are you choosing 80?
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.
No good reason...I think that I was somewhat confused and was experimenting with various parameters. (I'm not proud
I think scipy copied me 😂: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html#scipy.signal.find_peaks This is new in v1.1, which wasn't around when I created this. I'd much prefer to replace my implementation with theirs. @randlet are you okay with a scipy>=1.1 requirement? |
Yes that's ok with me.
…On Sun., Nov. 22, 2020, 11:51 James Kerns, ***@***.***> wrote:
I think scipy copied me 😂:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html#scipy.signal.find_peaks
This is new in v1.1, which wasn't around when I created this. I'd much
prefer to replace my implementation with theirs. @randlet
<https://github.com/randlet> are you okay with a scipy>=1.1 requirement?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#327 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAATCMGSKOEYAZGLWCZRBUTSRE6RLANCNFSM4T5F3R4A>
.
|
Awesome. This is perfect. It will find peaks and also the penumbra points. Refactor.... |
Always nice when you can eliminate a heap of code :) |
…ve threshold Previous iteration of _penumbra_point detection failed if there were multiple values above threshold in the profile. This commit ensures the point closest to the peak is used.
OK, I went back and actually figured out why the code wasn't working instead of sticking in an arbitrary x=80 🙄 . Thank you for calling me out on that! The issue was the penumbra point detection still picked the wrong location if there were multiple places in the profile with the correct gradient and the correct threshold. I fixed it so that the location closest to the peak meeting those conditions is used and it all seems good now! This is maybe just academic at this point if you're factoring most of this code out now, but I needed a fix in the interim. |
I am refactoring it 🤷♂️. The scipy implementation is very good. |
See if you can talk them into implementing phantom angle detection next 😆 ! |
time to launch a Kaggle contest for it! 😂 |
If there's interest in applying a similar logic for phantom angle detection, here is how I detect field image rotation for WLutz work: |
Probably a better and more clear example of using scipy's basinhopping to determine rotation: |
Thanks! I'm implementing a PTW EPID QC phantom now so maybe I'll give that a shot. |
This is a replacement for PR #324 and includes a fix for LeedsTOR which broke due to improper peak detection.
Warning: I don't 100% understand the difference between threshold & x in
find_fwxm_peaks
and I need to investigate more whether it breaks anything else. Any thoughts?