Skip to content

Commit 4b52c6f

Browse files
committed
Add review suggestions (#230)
Adds suggestions made in [a review of SlicerOpenLIFU PR#250](#250 (review))
1 parent 80ef70b commit 4b52c6f

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

notebooks/test_solution_analysis.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# ---
1414
from __future__ import annotations
1515

16+
import numpy as np
17+
1618
from openlifu.bf import Pulse, Sequence, apod_methods, focal_patterns
1719
from openlifu.geo import Point
1820
from openlifu.plan import Protocol
@@ -27,7 +29,7 @@
2729
focal_pattern = focal_patterns.SinglePoint(target_pressure=1.2e6)
2830
focal_pattern = focal_patterns.Wheel(center=False, spoke_radius=5, num_spokes=3, target_pressure=1.2e6)
2931
apod_method = apod_methods.MaxAngle(30)
30-
sim_setup = SimSetup(x_extent=[-30,30], y_extent=[-30,30], z_extent=[-4,70])
32+
sim_setup = SimSetup(x_extent=(-30,30), y_extent=(-30,30), z_extent=(-4,70))
3133
protocol = Protocol(
3234
id='test_protocol',
3335
name='Test Protocol',
@@ -37,7 +39,7 @@
3739
apod_method=apod_method,
3840
sim_setup=sim_setup)
3941

40-
target = Point(position=(0,0,50), units="mm", radius=2)
42+
target = Point(position=np.array([0, 0, 50]), units="mm", radius=2)
4143
trans = Transducer.gen_matrix_array(nx=8, ny=8, pitch=4, kerf=0.5, id="m3", name="openlifu", impulse_response=1e6/10)
4244
# -
4345

@@ -48,12 +50,14 @@
4850
scale=True)
4951

5052
pc = {"MI":ParameterConstraint('<', 1.8, 1.85), "TIC":ParameterConstraint('<', 2.0), 'global_isppa_Wcm2':ParameterConstraint('within', error_value=(49, 190))}
51-
scaled_analysis.to_table(constraints=pc).set_index('Param')[['Value', 'Units', 'Status']]
53+
if scaled_analysis is not None:
54+
scaled_analysis.to_table(constraints=pc).set_index('Param')[['Value', 'Units', 'Status']]
5255

5356
protocol = Protocol.from_file('../tests/resources/example_db/protocols/example_protocol/example_protocol.json')
5457
solution, sim_res, analysis = protocol.calc_solution(
5558
target=target,
5659
transducer=trans,
5760
simulate=True,
5861
scale=True)
59-
analysis.to_table().set_index('Param')[['Value', 'Units', 'Status']]
62+
if analysis is not None:
63+
analysis.to_table().set_index('Param')[['Value', 'Units', 'Status']]

src/openlifu/plan/solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def num_foci(self) -> int:
9999
def analyze(self,
100100
transducer: Transducer,
101101
options: SolutionAnalysisOptions = SolutionAnalysisOptions(),
102-
param_constraints: Dict[str,ParameterConstraint]|None = None) -> SolutionAnalysis:
102+
param_constraints: Dict[str,ParameterConstraint] | None = None) -> SolutionAnalysis:
103103
"""Analyzes the treatment solution.
104104
105105
Args:

src/openlifu/plan/solution_analysis.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ def to_table(self, constraints:Dict[str,ParameterConstraint]|None=None, focus_in
101101
if p not in PARAM_FORMATS:
102102
raise ValueError(f"Unknown parameter constraint for '{p}'. Must be one of: {list(PARAM_FORMATS.keys())}")
103103
for param, fmt in PARAM_FORMATS.items():
104+
value_by_focus = None
105+
agg_value = None
104106
if fmt[0] is None:
105107
value_by_focus = None
106108
agg_value = self.__dict__[param]

0 commit comments

Comments
 (0)