Skip to content

Commit

Permalink
Resolves issue jrkerns#373 with updated WL tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crcrewso committed Apr 19, 2021
1 parent 90f261b commit c90164a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
10 changes: 6 additions & 4 deletions pylinac/winston_lutz.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def bb_shift_instructions(self, couch_vrt: Optional[float] = None, couch_lng: Op
move += f"\nNew couch coordinates (mm): VRT: {new_vrt:3.2f}; LNG: {new_lng:3.2f}; LAT: {new_lat:3.2f}"
return move

@argue.options(axis=(GANTRY, COLLIMATOR, COUCH, EPID, GBP_COMBO), value=('all', 'range'))
@argue.options(axis=(GANTRY, COLLIMATOR, COUCH, EPID, GBP_COMBO), value=('all', 'range', 'max'))
def axis_rms_deviation(self, axis: str=GANTRY, value: str='all') -> float:
"""The RMS deviations of a given axis/axes.
Expand All @@ -304,6 +304,8 @@ def axis_rms_deviation(self, axis: str=GANTRY, value: str='all') -> float:
rms = [getattr(img, attr).as_scalar() for img in imgs]
if value == 'range':
rms = max(rms) - min(rms)
if value == 'max':
rms = max(rms)
return rms

@argue.options(metric=('max', 'median'))
Expand Down Expand Up @@ -560,13 +562,13 @@ def results_data(self) -> dict:
data['WL CAX->EPID 2D max (mm)'] = self.cax2epid_distance('max')
data['WL CAX->EPID 2D median (mm)'] = self.cax2epid_distance('median')
data['WL Collimator 2D iso size (mm)'] = self.collimator_iso_size
data['WL Collimator RMS deviations (mm)'] = self.axis_rms_deviation(axis=COLLIMATOR)
data['WL Collimator RMS deviations (mm)'] = self.axis_rms_deviation(axis=COLLIMATOR, value='max')
data['WL # Coll images considered'] = num_coll_imgs
data['WL Couch 2D iso size (mm)'] = self.couch_iso_size
data['WL Couch RMS deviations (mm)'] = self.axis_rms_deviation(axis=COUCH)
data['WL Couch RMS deviations (mm)'] = self.axis_rms_deviation(axis=COUCH, value='max')
data['WL # Couch images considered'] = num_couch_imgs
data['WL Gantry 3D iso size (mm)'] = self.gantry_iso_size
data['WL Gantry RMS deviations (mm)'] = self.axis_rms_deviation(axis=GANTRY)
data['WL Gantry RMS deviations (mm)'] = self.axis_rms_deviation(axis=GANTRY, value='max')
data['WL # Gantry images considered'] = num_gantry_imgs
data['WL Gantry+Coll 3D iso size (mm)'] = self.gantry_coll_iso_size
data['WL # Gantry+Coll images considered'] = num_gantry_coll_imgs
Expand Down
31 changes: 16 additions & 15 deletions tests_basic/test_winstonlutz.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,61 +70,62 @@ def setUpClass(cls):
cls.wl = WinstonLutz.from_demo_images()

def test_results_data_cax2epid_max(self):
rd_result = self.wl.results_data()['cax2epid max']
rd_result = self.wl.results_data()['WL CAX->EPID 2D max (mm)']
result = self.wl.cax2epid_distance('max')
self.assertEqual(rd_result, result )
def test_results_data_cax2epid_median(self):
rd_result = self.wl.results_data()['cax2epid median']
rd_result = self.wl.results_data()['WL CAX->EPID 2D median (mm)']
result = self.wl.cax2epid_distance('median')
self.assertEqual(rd_result, result )

def test_results_data_cax2bb_max(self):
rd_result = self.wl.results_data()['cax2bb max']
rd_result = self.wl.results_data()['WL CAX->BB 2D max (mm)']
result = self.wl.cax2bb_distance('max')
self.assertEqual(rd_result, result )

def test_results_data_cax2bb_median(self):
rd_result = self.wl.results_data()['cax2bb median']
rd_result = self.wl.results_data()['WL CAX->BB 2D median (mm)']
result = self.wl.cax2bb_distance('median')
self.assertEqual(rd_result, result )

def test_results_data_coll_iso_size(self):
rd_result = self.wl.results_data()['coll iso size']
rd_result = self.wl.results_data()['WL Collimator 2D iso size (mm)']
result = self.wl.collimator_iso_size
self.assertEqual(rd_result, result )

def test_results_data_couch_iso_size(self):
rd_result = self.wl.results_data()['couch iso size']
rd_result = self.wl.results_data()['WL Couch 2D iso size (mm)']
result = self.wl.couch_iso_size
self.assertEqual(rd_result, result )

def test_results_data_gantry_iso_size(self):
rd_result = self.wl.results_data()['gantry iso size']
rd_result = self.wl.results_data()['WL Gantry 3D iso size (mm)']
result = self.wl.gantry_iso_size
self.assertEqual(rd_result, result )

def test_results_data_gantry_coll_iso_size(self):
rd_result = self.wl.results_data()['gantry coll iso size']
rd_result = self.wl.results_data()['WL Gantry+Coll 3D iso size (mm)']
result = self.wl.gantry_coll_iso_size
self.assertEqual(rd_result, result )

def test_results_data_mech_rad_x(self):
rd_result = self.wl.results_data()['MechRad x']
rd_result = self.wl.results_data()['WL Iso 3D position from BB']['x']
result = -1* self.wl.bb_shift_vector.x
self.assertEqual(rd_result, result)
def test_results_data_mech_rad_y(self):
rd_result = self.wl.results_data()['MechRad y']
rd_result = self.wl.results_data()['WL Iso 3D position from BB']['y']
result = -1* self.wl.bb_shift_vector.y
self.assertEqual(rd_result, result)
def test_results_data_mech_rad_z(self):
rd_result = self.wl.results_data()['MechRad z']
rd_result = self.wl.results_data()['WL Iso 3D position from BB']['z']
result = -1* self.wl.bb_shift_vector.z
self.assertEqual(rd_result, result)

def test_results_data_gaxis_rms(self):
rd_result = self.wl.results_data()['axis rms dev']
result = self.wl.axis_rms_deviation
self.assertEqual(rd_result, result )
def test_results_data_gantry_rms(self):
rd_result = self.wl.results_data()['WL Gantry RMS deviations (mm)']
result = self.wl.axis_rms_deviation(axis=GANTRY, value='max')
self.assertEqual(rd_result, result )


class TestPublishPDF(TestCase):

Expand Down

0 comments on commit c90164a

Please sign in to comment.