Skip to content

Commit

Permalink
Merged in bugfix/RAM-3690_planar_adjustments (pull request #399)
Browse files Browse the repository at this point in the history
adjust the fine-tuning limitations

Approved-by: Randy Taylor
  • Loading branch information
jrkerns committed Jun 10, 2024
2 parents 6fc60d9 + 8c8708c commit dfc9eb7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
12 changes: 9 additions & 3 deletions pylinac/planar_imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,18 @@ def analyze(
validators.is_positive(roi_size_factor)
validators.is_positive(scaling_factor)
# can't set overrides and adjustments
if any((angle_override, center_override, size_override)) and any(
(x_adjustment, y_adjustment, angle_adjustment, scaling_factor)
):
if center_override and any((x_adjustment, y_adjustment)):
raise ValueError(
"Cannot set both overrides and adjustments. Use one or the other."
)
if angle_adjustment and angle_override:
raise ValueError(
"Cannot set the angle override and angle adjustment simultaneously. Use one or the other."
)
if size_override and scaling_factor != 1:
raise ValueError(
"Cannot set the size override and scaling factor simultaneously. Use one or the other."
)
self.x_adjustment = x_adjustment
self.y_adjustment = y_adjustment
self.angle_adjustment = angle_adjustment
Expand Down
28 changes: 23 additions & 5 deletions tests_basic/test_planar_imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def test_angle_adjustment(self):
instance.analyze(angle_adjustment=-10)
self.assertAlmostEqual(instance.phantom_angle, -10, delta=1)

def test_scaling_factor(self):
def test_roi_size_factor(self):
instance = LasVegas.from_demo_image()
# test before change
instance.analyze()
Expand All @@ -474,7 +474,7 @@ def test_scaling_factor(self):
scaled_roi = instance.results_data().low_contrast_rois[0]["visibility"]
self.assertAlmostEqual(scaled_roi, 275, delta=10)

def test_zoom_factor(self):
def test_scaling_factor(self):
instance = LasVegas.from_demo_image()
# test before change
instance.analyze()
Expand All @@ -498,12 +498,30 @@ def test_negative_scaling_fails(self):
with self.assertRaises(ValueError):
instance.analyze(roi_size_factor=-1)

def test_override_plus_adjustment_fails(self):
def test_size_and_adjustment_okay(self):
instance = LasVegas.from_demo_image()
instance.analyze(size_override=2000, x_adjustment=1, y_adjustment=1)

def test_center_and_adjustment_not_okay(self):
instance = LasVegas.from_demo_image()
with self.assertRaises(ValueError):
instance.analyze(
x_adjustment=1, y_adjustment=1, center_override=(100, 1000)
)

def test_angle_adjustment_and_override_not_okay(self):
instance = LasVegas.from_demo_image()
with self.assertRaises(ValueError):
instance.analyze(size_override=2000, x_adjustment=1)
instance.analyze(angle_override=22, angle_adjustment=1)

def test_size_override_and_scaling_factor_not_okay(self):
instance = LasVegas.from_demo_image()
with self.assertRaises(ValueError):
instance.analyze(angle_override=22, y_adjustment=1)
instance.analyze(size_override=2000, scaling_factor=2)

def test_size_and_angle_adjustment_okay(self):
instance = LasVegas.from_demo_image()
instance.analyze(size_override=2000, angle_adjustment=1)


class LasVegasDemo(LasVegasTestMixin, TestCase):
Expand Down

0 comments on commit dfc9eb7

Please sign in to comment.