diff --git a/pylinac/picketfence.py b/pylinac/picketfence.py index 60d3e049..690ce86d 100644 --- a/pylinac/picketfence.py +++ b/pylinac/picketfence.py @@ -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( @@ -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( @@ -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()) diff --git a/tests_basic/test_picketfence.py b/tests_basic/test_picketfence.py index a77574bf..e8f97207 100644 --- a/tests_basic/test_picketfence.py +++ b/tests_basic/test_picketfence.py @@ -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( @@ -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"] @@ -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):