Skip to content

Commit

Permalink
Merged in bugfix/RAM-3813_pf_relative_to_cax_negative (pull request #432
Browse files Browse the repository at this point in the history
)

RAM-3813 make signs the same for leaf positions and offsets from CAX

Approved-by: Hasan Ammar
  • Loading branch information
jrkerns committed Aug 20, 2024
2 parents d96c800 + b5f7da5 commit 771367b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
10 changes: 5 additions & 5 deletions pylinac/picketfence.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class PFResult(ResultBase):
title="Mean Picket Spacing (mm)",
)
offsets_from_cax_mm: list[float] = Field(
description="The offsets of each picket from the central axis in mm.",
description="The offsets of each picket from the central axis in mm. Positive is to the left.",
title="Offsets from CAX (mm)",
)
passed: bool = Field(
Expand All @@ -189,7 +189,7 @@ class PFResult(ResultBase):
description="The widths of the pickets in mm."
)
mlc_positions_by_leaf: dict[str, list[float]] = Field(
description="A dictionary where the key is the leaf number and the value is a list of positions in mm **from the CAX**. The distance is from the x-value (or y-value for left-right orientation) of the CAX. "
description="A dictionary where the key is the leaf number and the value is a list of positions in mm **from the CAX**. The distance is from the x-value (or y-value for left-right orientation) of the CAX. Positive is to the left."
"Rotation of the MLCs would affect these distances."
)
mlc_errors_by_leaf: dict[str, list[float]] = Field(
Expand Down Expand Up @@ -1274,11 +1274,11 @@ def _generate_results_data(self) -> PFResult:
leaf_items = list(group_iter) # group_iter is a generator
leaf_names = leaf_items[0].full_leaf_nums
for idx, leaf_name in enumerate(leaf_names):
pos_vals = [
m.position_mm[idx] - cax_physical_position for m in leaf_items
position_values = [
cax_physical_position - m.position_mm[idx] for m in leaf_items
]
error_vals = [m.error[idx] for m in leaf_items]
positions_by_leaf[str(leaf_name)] = pos_vals
positions_by_leaf[str(leaf_name)] = position_values
errors_by_leaf[str(leaf_name)] = error_vals
errors_by_leaf = dict(
sorted(errors_by_leaf.items())
Expand Down
11 changes: 9 additions & 2 deletions tests_basic/test_picketfence.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_results_data(self):
) # 36 leaf pairs in the image
# constancy check
self.assertAlmostEqual(
statistics.mean(data.mlc_positions_by_leaf["17"]), 7.91, delta=0.1
statistics.mean(data.mlc_positions_by_leaf["17"]), -7.91, delta=0.1
)
# check max error matches a combination of the leaf values
self.assertEqual(
Expand All @@ -175,6 +175,13 @@ def test_results_data(self):
# shouldn't raise
json.loads(data_str)

# check signs of leaf positions and picket positions from the CAX are the same.
self.assertAlmostEqual(
data_dict["mlc_positions_by_leaf"]["17"][0],
data_dict["offsets_from_cax_mm"][0],
delta=0.1,
)

def test_no_measurements_suggests_inversion(self):
file_loc = get_file_from_cloud_test_repo(
[TEST_DIR, "noisy-FFF-wide-gap-pf.dcm"]
Expand Down Expand Up @@ -349,7 +356,7 @@ def test_bb_pf_combo(self):
self.assertAlmostEqual(results.max_error_mm, 0.0, delta=0.005)
self.assertAlmostEqual(results.cax.x, 636.5, delta=0.1)
# bb is 2mm off in bb setup image above
self.assertAlmostEqual(results.mlc_positions_by_leaf["17"][0], -102, delta=0.1)
self.assertAlmostEqual(results.mlc_positions_by_leaf["17"][0], 102, delta=0.1)


class LoadingFromMultiple(TestCase):
Expand Down

0 comments on commit 771367b

Please sign in to comment.