Skip to content

Commit

Permalink
Closes #157
Browse files Browse the repository at this point in the history
  • Loading branch information
jrkerns committed Dec 14, 2018
1 parent a4bb9d0 commit ee86c4d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
8 changes: 8 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ V 2.2.1
Bug Fixes
^^^^^^^^^

* `#157 <https://github.com/jrkerns/pylinac/issues/157>`_ Dynalog MLC leaf error was calculated incorrectly. Expected positions were off by a row. Error results should be lower on average.

V 2.2.1
-------

Bug Fixes
^^^^^^^^^

* `#153 <https://github.com/jrkerns/pylinac/issues/153>`_ Log analyser PDF publishing fix.
* `#155 <https://github.com/jrkerns/pylinac/issues/155>`_ VMAT PDF report had tolerance listed incorrectly (absolute vs percentage) causing most tolerances to appear as zero.

Expand Down
16 changes: 14 additions & 2 deletions pylinac/log_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,9 @@ def from_dlog(cls, dlog, jaws, snapshot_data, snapshot_idx):
"""Construct an MLC structure from a Dynalog"""
mlc = MLC(Dynalog, snapshot_idx, jaws)
for leaf in range(1, (dlog.header.num_mlc_leaves // 2) + 1):
axis = LeafAxis(expected=snapshot_data[(leaf - 1) * 4 + 14], actual=snapshot_data[(leaf - 1) * 4 + 15])
# shift expected position per issue #157
shifted_expected = cls._shift_expected_mlc_for_dlog(snapshot_data[(leaf - 1) * 4 + 14])
axis = LeafAxis(expected=shifted_expected, actual=snapshot_data[(leaf - 1) * 4 + 15])
mlc.add_leaf_axis(axis, leaf)

# read in "B"-file to get bank B MLC positions. The file must be in the same folder as the "A"-file.
Expand All @@ -774,7 +776,9 @@ def from_dlog(cls, dlog, jaws, snapshot_data, snapshot_idx):

# Add bank B MLC positions to mlc snapshot arrays
for leaf in range(1, (dlog.header.num_mlc_leaves // 2) + 1):
axis = LeafAxis(expected=snapshot_data[(leaf - 1) * 4 + 14], actual=snapshot_data[(leaf - 1) * 4 + 15])
# shift expected position per issue #157
shifted_expected = cls._shift_expected_mlc_for_dlog(snapshot_data[(leaf - 1) * 4 + 14])
axis = LeafAxis(expected=shifted_expected, actual=snapshot_data[(leaf - 1) * 4 + 15])
mlc.add_leaf_axis(axis, leaf + dlog.header.num_mlc_leaves // 2)

# scale dynalog leaf positions from the physical plane to the isocenter plane and from 100ths of mm to cm.
Expand All @@ -784,6 +788,14 @@ def from_dlog(cls, dlog, jaws, snapshot_data, snapshot_idx):
mlc.leaf_axes[leaf].expected *= dynalog_leaf_conversion / 1000
return mlc

@staticmethod
def _shift_expected_mlc_for_dlog(expected_positions):
# insert a copy of the first value
extra_position = np.insert(expected_positions, 0, expected_positions[0])
# drop the last value so the # of positions are the same
shifted_positions = extra_position[:-1]
return shifted_positions

@classmethod
def from_tlog(cls, tlog, subbeams, jaws, snapshot_data, snapshot_idx, column_iter):
"""Construct an MLC instance from a Trajectory log."""
Expand Down
6 changes: 3 additions & 3 deletions tests_basic/test_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,9 @@ class TestDynalogDemo(TestIndividualDynalog, TestCase):
treatment_type = DYNAMIC_IMRT
num_beamholds = 20
num_snapshots = 99
average_rms = 0.037
maximum_rms = 0.076
average_gamma = 0.47
average_rms = 0
maximum_rms = 0
average_gamma = 0
percent_pass_gamma = 91
leaf_move_status = {'moving': (9, 3), 'static': (8, )}

Expand Down

0 comments on commit ee86c4d

Please sign in to comment.