opentps.core.processing.planDeliverySimulation package

Submodules

opentps.core.processing.planDeliverySimulation.beamDeliveryTimings module

opentps.core.processing.planDeliverySimulation.deliverySimulationConfig module

opentps.core.processing.planDeliverySimulation.planDeliverySimulation module

class PlanDeliverySimulation(plan: ~opentps.core.data.plan._rtPlan.RTPlan, CT4D: ~opentps.core.data.dynamicData._dynamic3DSequence.Dynamic3DSequence | None = None, model3D: ~opentps.core.data.dynamicData._dynamic3DModel.Dynamic3DModel | None = None, deliverySimulationFolderName: str | None = None, overwriteOutsideROI: ~opentps.core.data._roiContour.ROIContour | None = None, MCsquareSimulationPath: str | None = None, saveDosesToFile: bool = True, saveDosesInObject: bool = False, deliveryModel=<class 'opentps.core.processing.planDeliverySimulation.simpleBeamDeliveryTimings.SimpleBeamDeliveryTimings'>)

Bases: object

Class for simulating the delivery of a treatment plan on a 4DCT.

Variables:
  • plan (RTPlan) – Treatment plan to simulate

  • CT4D (Dynamic3DSequence) – 4DCT on which the plan is simulated

  • model3D (Dynamic3DModel) – Model of the 4DCT. If not provided, it is computed from the 4DCT

  • deliverySimulationPath (str) – Path to the simulation directory where the doses are saved

  • overwriteOutsideROI (ROIContour) – Overwrite values outside overwriteOutsideROI

  • MCsquareSimulationPath (str) – Path to the MCsquare simulation directory

  • saveDosesToFile (bool) – Whether or not to save the doses to file

  • saveDosesInObject (bool) – Whether or not to save the doses in the object

  • deliveryModel (BeamDeliveryTimings) – Class for computing the delivery timings of the spots in the plan

computeDVHBand(doseList: Sequence[DoseImage] = [], ROIList: Sequence[ROIContour] = [])

Compute DVH band from a list of doses and ROIs.

Parameters:
  • doseList (Sequence[DoseImage]) – List of doses

  • ROIList (Sequence[ROIContour]) – List of ROIs

Returns:

dvh_bands – The computed DVH bands

Return type:

Sequence[DVHBand]

computeDVHBand4DDD(ROIList, singleFraction=True)

Compute DVH band from 4DDD simulation results.

Parameters:
  • ROIList (Sequence[ROIContour]) – List of ROIs.

  • singleFraction (bool (default=True)) – Whether or not to compute the DVH band from the first fraction only.

Returns:

dvh_bands – The computed DVH bands.

Return type:

Sequence[DVHBand]

simulate4DDose()

4D dose computation (range variation - no interplay). Steps: 1) treatment plan plan is simulated on each phase of the 4DCT CT4D, 2) each resulting dose is non-rigidly registered to the MidP CT model3D.midp 3) the average of these doses is computed All doses are saved in the simulation directory simulation_dir.

simulate4DDynamicDose(save_partial_doses=True, start_phase=0)

4D dynamic dose computation (range variation + interplay). Steps: 1) Delivery timings of the spots in plan are computed if not present 2) treatment plan plan is dynamically simulated on the 4DCT CT4D in a loop until all spots are delivered, 3) each resulting dose is non-rigidly registered to the MidP CT model3D.midp 3) the sum of these doses is computed All doses are saved in the simulation directory simulation_dir.

Parameters:
  • save_partial_doses (bool (default=True)) – Whether or not to save partial doses, i.e. doses on each phase before accumulation

  • start_phase (int (default=0)) – Phase at which to start the delivery

Returns:

dose_MidP – Accumulated dose on the MidP CT

Return type:

DoseImage

simulate4DDynamicDoseScenarios(save_partial_doses=True, number_of_fractions=1, number_of_starting_phases=1, number_of_fractionation_scenarios=1)

4D dynamic simulation under different scenarios.

Parameters:
  • plan (RTPlan)

  • CT4D (Dynamic3DSequence)

  • model3D (Dynamic3DModel)

  • simulation_dir (str) – Path to the simulation directory where the doses are saved

  • overwriteOutsideROI (ROIContour) – Overwrite values outside overwriteOutsideROI

  • save_partial_doses (bool) – Whether or not to save partial doses, i.e. doses on each phase before accumulation

  • number_of_fractions (int) – Number of fractions for delivering the treatment

  • number_of_starting_phases (int) – Number of times we simulate the delivery where each time we start from a different phase. Hence, number_of_starting_phases <= len(4DCT)

  • number_of_fractionation_scenarios (int) – Number fractionation scenarios: how many scenarios we select where each scenario is a random combination with replacement of 4DDD simulations with a specific starting phase For instance, if number_of_fractions=5 and number_of_fractionation_scenarios=3; Simulate 3 scenarios with starting phases [1,2,3,4,5]; [1,3,1,2,4]; [4, 5, 1, 4, 2].

simulatePlanOnContinuousSequence(midp: CTImage, ct_folder, def_fields_folder, sequence_timings, output_dose_path=None, save_all_doses=False, remove_interpolated_files=False, downsample=0, start_irradiation=0.0)

4D dynamic simulation on a continuous sequence of CT. Same principle as simulate4DDD function but the 4DCT (i.e. continuous sequence) is not stored in the RAM.

Parameters:
  • midp (CTImage) – MidP CT on which the dose is accumulated

  • ct_folder (str) – Path to the folder containing the CT images

  • def_fields_folder (str) – Path to the folder containing the deformation fields

  • sequence_timings (np.ndarray) – Array of timings of the images in the continuous sequence

  • output_dose_path (str) – Path to the folder where the doses are saved

  • save_all_doses (bool) – Whether or not to save all doses on each image of the continuous sequence

  • remove_interpolated_files (bool) – Whether or not to remove interpolated files (i.e. files with _0.[0-9].mhd)

  • downsample (int) – Downsample the continuous sequence by a factor of downsample

  • start_irradiation (float) – Moment at which to start the irradiation with beginning of continuous seq = 0. and end = 1.

Module contents