feat: Add mainlobe-to-sidelobe pressure and intensity ratios#355
Merged
Conversation
Adds the calculation and reporting of mainlobe-to-sidelobe pressure and intensity ratios to the SolutionAnalysis. - New fields in SolutionAnalysis dataclass. - PARAM_FORMATS updated for table display. - Ratio calculation logic added to Solution.analyze(), handling division by zero. - Tests updated and new tests added for ratio calculations.
Updates the previously added mainlobe-to-sidelobe ratios to be sidelobe-to-mainlobe ratios for pressure and intensity. - Field names and descriptions in SolutionAnalysis updated. - PARAM_FORMATS updated to match. - Ratio calculation logic in Solution.analyze() updated. - All relevant tests updated and verified.
35a3fb6 to
7ef2e8a
Compare
Contributor
Author
|
All the coding was done by Jules. I've verified that it works as expected. |
ebrahimebrahim
left a comment
Collaborator
There was a problem hiding this comment.
Tested in SlicerOpenLIFU, no issues there
Looked over the test cases a bit to sanity check
Left a question below, if that seems fine let me know.
| mainlobe_isppa = solution_analysis.mainlobe_isppa_Wcm2[-1] | ||
|
|
||
| if mainlobe_pnp == 0: | ||
| pressure_ratio = np.inf if sidelobe_pnp != 0 else np.nan |
Collaborator
There was a problem hiding this comment.
If we get nan's here, will ParameterConstraint checks fumble or will it know what to do?
From a cursory look, it looks like ParameterConstraint.compare doesn't check if something is nan
But any comparison against np.nan should be false, so maybe it's fine.
That's how we want it to behave right? If np.nan comes out for this ratio, parameter constraints will just fail and the solution cannot be approved.
Contributor
Author
|
Yeah, that makes sense as intended behavior.
…On Thu, Jul 10, 2025 at 2:14 PM Ebrahim Ebrahim ***@***.***> wrote:
***@***.**** commented on this pull request.
Tested in SlicerOpenLIFU, no issues there
Looked over the test cases a bit to sanity check
Left a question below, if that seems fine let me know.
------------------------------
In src/openlifu/plan/solution.py
<#355 (comment)>
:
> @@ -250,8 +250,29 @@ def analyze(self,
solution_analysis.mainlobe_isppa_Wcm2 += [float(ipa_Wcm2.where(mainlobe_mask).max())]
solution_analysis.mainlobe_ispta_mWcm2 += [float(ita_mWcm2.where(mainlobe_mask).max())]
- solution_analysis.sidelobe_pnp_MPa += [float(pnp_MPa.where(sidelobe_mask).max())]
- solution_analysis.sidelobe_isppa_Wcm2 += [float(ipa_Wcm2.where(sidelobe_mask).max())]
+
+ sidelobe_pnp = float(pnp_MPa.where(sidelobe_mask).max())
+ sidelobe_isppa = float(ipa_Wcm2.where(sidelobe_mask).max())
+
+ solution_analysis.sidelobe_pnp_MPa += [sidelobe_pnp]
+ solution_analysis.sidelobe_isppa_Wcm2 += [sidelobe_isppa]
+
+ # Calculate and store ratios (sidelobe / mainlobe)
+ mainlobe_pnp = solution_analysis.mainlobe_pnp_MPa[-1]
+ mainlobe_isppa = solution_analysis.mainlobe_isppa_Wcm2[-1]
+
+ if mainlobe_pnp == 0:
+ pressure_ratio = np.inf if sidelobe_pnp != 0 else np.nan
If we get nan's here, will ParameterConstraint checks fumble or will it
know what to do?
From a cursory look, it looks like ParameterConstraint.compare doesn't
check if something is nan
But any comparison against np.nan should be false, so maybe it's fine.
That's how we want it to behave right? If np.nan comes out for this
ratio, parameter constraints will just fail and the solution cannot be
approved.
—
Reply to this email directly, view it on GitHub
<#355 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABPN2LLOKXDVYO3TUXX37I33H2UPLAVCNFSM6AAAAACAMO5LPOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTAMBWG43TKNBZHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
ebrahimebrahim
approved these changes
Jul 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the calculation and reporting of mainlobe-to-sidelobe pressure and intensity ratios to the SolutionAnalysis.
Closes #345