pymchelper.utils.radiotherapy package#
Submodules#
pymchelper.utils.radiotherapy.plan module#
Module for reading DICOM and PLD files.
One plan may contain one or more fields. One field may contain one or more layers. One layer may contain one or more spots.
- class pymchelper.utils.radiotherapy.plan.BeamModel(fn: Path, nominal=True)[source]#
Bases:
object
Beam model from a given CSV file.
- class pymchelper.utils.radiotherapy.plan.Field(layers: list = <factory>, n_layers: int = 0, dose: float = 0.0, cum_mu: float = 0.0, cum_particles: float = 0.0, pld_csetweight: float = 0.0, scaling: float = 1.0, xmin: float = 0.0, xmax: float = 0.0, ymin: float = 0.0, ymax: float = 0.0)[source]#
Bases:
object
A single field.
- cum_mu: float = 0.0#
- cum_particles: float = 0.0#
- dose: float = 0.0#
- layers: list#
- n_layers: int = 0#
- pld_csetweight: float = 0.0#
- scaling: float = 1.0#
- xmax: float = 0.0#
- xmin: float = 0.0#
- ymax: float = 0.0#
- ymin: float = 0.0#
- class pymchelper.utils.radiotherapy.plan.Layer(spots: ~numpy.array = <factory>, spotsize: ~numpy.array = <factory>, energy_nominal: float = 100.0, energy_measured: float = 100.0, espread: float = 0.0, cum_mu: float = 0.0, cum_particles: float = 0.0, xmin: float = 0.0, xmax: float = 0.0, ymin: float = 0.0, ymax: float = 0.0, repaint: int = 0, n_spots: int = 1, mu_to_part_coef: float = 1.0, is_empty: bool = True)[source]#
Bases:
object
Handle layers in a plan.
- spotsnp.array([[x_i, y_i, mu_i, n], […], …) for i spots.
x,y : are spot positions at isocenter in [mm]. mu : are monitor units or meterset weights for the individual spots [MU] n : is the estimated number of primary particles for this spot
spotsize: np.array() FWHM width of spot in along x and y axis, respectively [mm] enorm : nominal energy in [MeV] emeas : measured energy in [MeV] at exit nozzle cum_mu : cumulative monitor units for this layers [MU] repaint : number of repainting, 0 for no repaints TODO: check what is convention here. n_spots : number of spots in total mu_to_part_coef : conversion coefficient from MU to number of particles (depends on energy)
- cum_mu: float = 0.0#
- cum_particles: float = 0.0#
- energy_measured: float = 100.0#
- energy_nominal: float = 100.0#
- espread: float = 0.0#
- is_empty: bool = True#
- mu_to_part_coef: float = 1.0#
- n_spots: int = 1#
- repaint: int = 0#
- spots: array#
- spotsize: array#
- xmax: float = 0.0#
- xmin: float = 0.0#
- ymax: float = 0.0#
- ymin: float = 0.0#
- class pymchelper.utils.radiotherapy.plan.Plan(fields: list = <factory>, patient_id: str = '', patient_name: str = '', patient_initals: str = '', patient_firstname: str = '', plan_label: str = '', plan_date: str = '', n_fields: int = 0, beam_model: ~pymchelper.utils.radiotherapy.plan.BeamModel | None = None, beam_name: str = '', flip_xy: bool = False, flip_x: bool = False, flip_y: bool = False, factor: float = 1.0, scaling: float = 1.0)[source]#
Bases:
object
Class for handling treatment plans.
One plan may consist of one or more fields. One field may contain one of more layers.
Beam model is optional, but needed for exact modeling of the beam. If no beam model is given, MUs are translated to particle numbers using approximate stopping power for air (dEdx) and empirical scaling factors.
- beam_name: str = ''#
- export(fn: Path, cols: int, field_nr: int, nominal: bool)[source]#
Export file to sobp.dat format, ‘cols’ marking the number of columns.
fn : filename cols : number of columns for output format.
5 column format: energy[GeV] x[cm] y[cm] FWHM[cm] weight 6 column format: energy[GeV] x[cm] y[cm] FWHMx[cm] FWHMy[cm] weight 7 column format: energy[GeV] sigmaT0[GeV] x[cm] y[cm] FWHM[cm] weight
field_nr: in case of multiple field, select what field to export, use ‘0’ to export all fields. nominal : flag whether norminal energy should be exported or not
Todo
11 columns: ENERGY, ESPREAD, X, Y, FWHMx, FWHMy, WEIGHT, DIVx, DIVy, COVx, COVy
- factor: float = 1.0#
- fields: list#
- flip_x: bool = False#
- flip_xy: bool = False#
- flip_y: bool = False#
- n_fields: int = 0#
- patient_firstname: str = ''#
- patient_id: str = ''#
- patient_initals: str = ''#
- patient_name: str = ''#
- plan_date: str = ''#
- plan_label: str = ''#
- scaling: float = 1.0#
- pymchelper.utils.radiotherapy.plan.dedx_air(energy: float) float [source]#
Calculate the mass stopping power of protons in air following ICRU 49.
Valid from 1 to 500 MeV only.
- Params energy:
Proton energy in MeV
- Returns:
mass stopping power in MeV cm2/g
- pymchelper.utils.radiotherapy.plan.load(file: Path, beam_model: BeamModel, scaling: float, flip_xy: bool, flip_x: bool, flip_y: bool) Plan [source]#
Load file, autodiscovery by suffix.
- pymchelper.utils.radiotherapy.plan.load_DICOM_VARIAN(file_dcm: Path, scaling=1.0) Plan [source]#
Load varian type dicom plans.
- pymchelper.utils.radiotherapy.plan.load_PLD_IBA(file_pld: Path, scaling=1.0) Plan [source]#
Load a IBA-style PLD-file.
file_pld : a file pointer to a .pld file, opened for reading. Here we assume there is only a single field in every .pld file.
- pymchelper.utils.radiotherapy.plan.load_RASTER_GSI(file_rst: Path, scaling=1.0)[source]#
this is implemented in pytrip, maybe we could import it?.
- pymchelper.utils.radiotherapy.plan.main(args=None) int [source]#
Read a plan file (dicom, pld, rst), and convert it to a spot list, easy to read by MC codes.
The MU based spot list in dicom/pld/rst is converted to particle weighted spot list, optionally based on a realistic beam model, or on simple estimations.