Skip to content

Commit

Permalink
Merged in bugfix/RAM-3933_tg51_dose_adjusted (pull request jrkerns#439)
Browse files Browse the repository at this point in the history
Bugfix/RAM-3933 TG51 dose adjusted property

Approved-by: Randy Taylor
  • Loading branch information
jrkerns committed Sep 6, 2024
2 parents 3f82d62 + 2aeb894 commit 3b20d7b
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 100 deletions.
5 changes: 5 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ ACR MRI
the full circle of the phantom. The algorithm no longer relies on this assumption and
is robust to these air gaps for the geometric distortion analysis.

TG-51
^^^^^

* A bug was causing the lookup for ``dose_mu_dmax_adjusted`` and ``dose_mu_dref_adjusted`` to error out.

Core
^^^^

Expand Down
44 changes: 42 additions & 2 deletions pylinac/calibration/tg51.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
and the class will compute all corrections and corrected readings and dose at 10cm and dmax/dref.
"""
import webbrowser
from abc import abstractmethod
from datetime import datetime
from typing import Optional

Expand Down Expand Up @@ -652,6 +653,26 @@ def kq_electron(*, chamber: str, r_50: float) -> float:


class TG51Base(Structure):
institution: str
physicist: str
unit: str
measurement_date: str
temp: float
press: float
chamber: str
n_dw: float
p_elec: float
electrometer: str
energy: int
voltage_reference: int
voltage_reduced: int
m_reference: NumberOrArray
m_opposite: NumberOrArray
m_reduced: NumberOrArray
mu: int
tissue_correction: float
m_reference_adjusted: NumberOrArray | None = None

@property
def p_tp(self) -> float:
"""Temperature/Pressure correction."""
Expand Down Expand Up @@ -700,6 +721,10 @@ def output_was_adjusted(self) -> float:
"""Boolean specifiying if output was adjusted."""
return self.m_reference_adjusted is not None

@abstractmethod
def publish_pdf(self, *args, **kwargs):
pass


class TG51Photon(TG51Base):
"""Class for calculating absolute dose to water using a cylindrical chamber in a photon beam.
Expand Down Expand Up @@ -750,6 +775,11 @@ class TG51Photon(TG51Base):
Correction value to calibration to, e.g., muscle. A value of 1.0 means no correction (i.e. water).
"""

fff: bool
measured_pdd10: float | None
clinical_pdd10: float
lead_foil: str | None

@argue.options(chamber=KQ_PHOTONS.keys(), lead_foil=LEAD_OPTIONS.values())
def __init__(
self,
Expand Down Expand Up @@ -982,6 +1012,12 @@ class TG51ElectronLegacy(TG51Base):
Correction value to calibration to, e.g., muscle. A value of 1.0 means no correction (i.e. water).
"""

m_gradient: NumberOrArray
cone: str
clinical_pdd: float
i_50: float
k_ecal: float

def __init__(
self,
*,
Expand Down Expand Up @@ -1163,7 +1199,7 @@ def publish_pdf(
]
if was_adjusted == "Yes":
text.append(
f"Adjusted Mraw @ reference voltage (nC): {self.m_reference_adjustment}"
f"Adjusted Mraw @ reference voltage (nC): {self.m_reference_adjusted}"
)
text.append(
f"Adjusted fully corrected M (nC): {self.m_corrected_adjustment:2.3f}"
Expand Down Expand Up @@ -1234,6 +1270,10 @@ class TG51ElectronModern(TG51Base):
Correction value to calibration to, e.g., muscle. A value of 1.0 means no correction (i.e. water).
"""

clinical_pdd: float
i_50: float
cone: str

def __init__(
self,
*,
Expand Down Expand Up @@ -1316,7 +1356,7 @@ def dose_mu_dref_adjusted(self) -> float:
"""cGy/MU at the depth of Dref."""
return (
self.tissue_correction
* self.m_corrected_adjusted
* self.m_corrected_adjustment
* self.kq
* self.n_dw
/ self.mu
Expand Down
Loading

0 comments on commit 3b20d7b

Please sign in to comment.