Creating Scripts for Eclipse Automation
You can use the Eclipse Automation features in the Eclipse Scripting API for the tasks listed in this chapter.
Adding and Modifying Structures
You can add, remove, and modify structures by using the classes described below.
Adding and Removing Structures
Use the StructureSet class
to add and remove structures:
- Add structures with the
AddStructuremethod. You can use theCanAddStructuremethod to check if the script is able to add a new structure to the structure set.
To specify the type of structure to add, give the string representation of the
DICOM type as a parameter to the AddStructure method. Example values are EXTERNAL,
ORGAN, and PTV. For a complete list of allowed values see AddStructure.
- Add structure with structure code information with
AddStructure(StructureCodeInfo).
To construct StructureCodeInfo,
you need to pass coding scheme and structure code, for example:
StructureCodeInfo scInfo = new StructureCodeInfo("99VMS_STRUCTCODE", "Support");
Remove structures with the
RemoveStructuremethod.You can convert an isodose surface to a structure. See
Structure.ConvertDoseLevelToStructure.
Modifying Structures
Use the Structure class to
modify structures:
- Add contours to a structure with the
AddContourOnImagePlanemethod.
Input parameters:
- List of points defining the contour
- index of the image plane where the contours are to be added.
- Subtract contours with
SubtractContourOnImagePlanemethod.
Input parameters:
- List of points defining the contour
- Index of the image plane where the contours are to be subtracted.
Clear all contours for a structure with the
ClearAllContoursOnImagePlanemethod.Set a structure to the result of a Boolean operation with
These methods are also available in the SegmentVolume
class, which allows you to execute a combination of Boolean operations with an intermediate
variable of the SegmentVolume type before assigning the final result to a Structure
object. For more information, see the SegmentVolume property getter and setter
of the Structure class.
- Set a three-dimensional symmetric or asymmetric margin around a structure.
- First call the
MarginorAsymmetricMarginmethod. - Then set the resulting
SegmentVolumeobject to theStructureobject using theSegmentVolumeproperty. For more information, see the get and set accessors of theSegmentVolumeproperty of theStructureclass.
- First call the
Adding and Removing Artificial Phantom Images
Use the Patient class to add
and remove artificial phantom images:
- Add a phantom image with the
AddEmptyPhantommethod.
Input parameters:
- Patient orientation
- Size of the image set in X- and Y-directions in pixels and in millimeters
- Number of planes
- Separation between the planes in millimeters.
An image is created into a new Study.
The return value of the AddEmptyPhantom is a new StructureSet where you can add
structures and their contours. You can access the created Image
using the Image property of the StructureSet class.
- Remove a phantom image and associated
StructureSetwithRemoveEmptyPhantommethod.
Input parameter:
StructureSet, The set must be empty.
Before removing the phantom, you can use the CanRemoveEmptyPhantom
method to check if the script is able to remove the phantom Image.
Copying an Image from Another Patient
Use the Patient class to copy a 3D image from another patient. This must only be
used when creating Verification Plans with a script.
- Specify the identifiers of the other patient, the study of the other patient, and
the 3D image of the other patient. Validate the identifiers using the method
CanCopyImageFromOtherPatient. Copy the image using the methodCopyImageFromOtherPatient.
Input parameters:
- Identifier of the other patient
- Identifier of the study of the other patient
- Identifier of the 3D image of the other patient.
Creating and Modifying Plans and Fields
You can create and modify external beam photon plans and fields, as well as brachytherapy plans and applicators by using the classes described below. For brachytherapy plans, no additions or modifications are supported for solid applicators or seed collections.
Adding and Removing Plans
Use the Course class to add
and remove plans:
- Add a new external beam photon plan with the
AddExternalPlanSetupmethod.
Input parameter:
- Structure set
- Target structure (optional)
- Primary reference point (optional)
If a target structure is not defined target structure is picked from structure set target volumes.
If a primary reference point is not passed as an argument a new primary reference point without a location is automatically created for the plan.
You can use the CanAddPlanSetup
method to check if the script is able to add a new plan to the course.
- Add a new external beam photon plan as a verification plan with the
AddExternalPlanSetupAsVerificationPlanmethod.
Input parameters:
- Structure set
- Plan to verify
Use
AddIonPlanSetupfor creating a proton treatment plan.Use
AddIonPlanSetupAsVerificationPlanfor creating a proton verification plan.Remove a plan with the
RemovePlanSetupmethod.
Input parameter:
You can use CanRemovePlanSetup
to check if the script is able to remove the plan from the course.
Copy an external beam plan with
CopyPlanSetupto create a plan in another image that is not registered.Add a new brachytherapy plan with the
AddBrachyPlanSetupmethod.
Input parameters:
StructureSet. A valid structure set to be connected to the brachytherapy plan.DosePerFraction: Dose per fraction.BrachyTreatmentTechnique: Brachytherapy treatment technique.
Optionally
TargetStructureto be set as the target structure for the planPrimaryReferencePointto set an existing reference point to be used as the primary reference point instead of creating a new one.
If not specified a new primary reference point without a location is automatically created for the plan. The CanAddPlanSetup method can be used to check if the script is able to add
a new plan to the course.
- Copy a brachytherapy plan to another image with
CopyBrachyPlanSetup.
Modifying Brachytherapy Plan Properties
Treatment time
- Define the treatment time of the plan by setting the
BrachyPlanSetup.TreatmentDateTimeproperty.
- Define the treatment time of the plan by setting the
Treatment technique
- Define the treatment technique of the plan with
BrachyPlanSetup.BrachyTreatmentTechniqueproperty. The type of the property isBrachyTreatmentTechniqueType.
- Define the treatment technique of the plan with
Fractions (property
PlanSetup.NumberOfFractions):- Set
NumberOfFractionstogether with propertiesDosePerFractionandTreatmentPercentage, using theSetPrescriptionmethod.
- Set
Dose (property
PlanSetup.DosePerFraction):- Set
DosePerFractiontogether with propertiesNumberOfFractionsandTreatmentPercentage, using theSetPrescriptionmethod.
- Set
Treatment percentage (property
PlanSetup.TreatmentPercentage):- Set
TreatmentPercentagetogether with propertiesNumberOfFractionsandDosePerFraction, using theSetPrescriptionmethod.
- Set
Adding Reference Points in Brachytherapy Plans
Use the BrachyPlanSetup
class to add reference points:
- Add a new location to an existing reference point with the
AddLocationToExistingReferencePointmethod.
Input parameters:
- location: The location of the reference point.
- id: The identifier of the reference point.
- Add a new reference point to a brachytherapy plan with the
AddReferencePointmethod.
Input parameters:
- target: Indicates whether the reference point tracks treatment target (true) or organ at risk (false).
- id: The identifier of the reference point.
Copying a Brachytherapy Plan to a New Image
Use the Course class to copy a brachytherapy plan to a new image:
- Copy a brachytherapy plan with
Course.CopyBrachyPlanSetup. The target image must be registered with the primary image of the source plan.
Adding Reference Lines
Add a new reference line to a structure set using the StructureSet.AddReferenceLine
method.
Input parameters:
- name: The name of the reference line.
- id: The identifier of the reference line.
- referenceLinePoints: The points of the reference line.
Adding Fields
Use the ExternalPlanSetup
class to add photon fields:
Add a new static open field to the plan with the
AddStaticBeammethod.Add a new arc field to the plan with the
AddArcBeammethod.Add a field with static MLC shape with the
AddMLCBeamorAddMLCArcBeammethod.Add an arc field with dynamic MLC shape using the
AddConformalArcBeammethod.Add an IMRT field with the Multiple Static Segment delivery method using the
AddMultipleStaticSegmentBeammethod.Add an IMRT field with the Sliding Windows delivery method using the
AddSlidingWindowBeammethod.Add a
VMATfield with theAddVMATBeammethod.
Define the treatment machine configuration for added fields:
- Create an
ExternalBeamMachineParametersobject and use it as input for the above mentioned beam adding methods of theExternalPlanSetupclass.
Input parameters:
- Treatment machine identifier
- Energy mode identifier
- Field technique identifier
- Dose rate and
- Optionally, the primary fluence mode identifier.
For information about other input parameters for the beam adding methods of the ExternalPlanSetup
class, refer to Eclipse Scripting API Online Help.
Use the IonPlanSetup.AddModulatedScanningBeam
to add modulated scanning fields to a proton plan.
Modifying Photon Fields
Use the BeamParameters
class to modify a Beam:
Call the
GetEditableParametersmethod. Modify the returnedBeamParametersobject. CallApplyParameters. If the call succeeds, the beam data is updated.Set the optimal fluence of an IMRT field with the
SetOptimalFluencemethod.Modify
ControlPointsusing theControlPointsproperty of theBeamParametersclass. EachControlPointhas oneControlPointParametersobject. CallApplyParameters. If the call succeeds, the beam data is updated.Methods to perform MLC fitting are available. See
Beam.FitMLCToStructureandBeam.FitMLCToOutline.
Modifying Proton Fields
The following can be adjusted in a proton field:
- Proximal target margin
IonBeam.ProximalTargetMargin - Distal target margin
IonBeam.DistalTargetMargin - Lateral margins
IonBeam.LateralMargins
Modifying Proton Scanning Spots
Use the IonBeamParameters
class to modify the scanning spots of an IonBeam:
Call the
IonBeam.GetEditableParametersmethod.With the returned
IonBeamParametersobject, call propertyIonControlPointPairsto get a list of editable control point pairs.Iterate over the list of control point pairs and get the editable spot lists using method
IonControlPointPair.RawSpotListorIonControlPointPair.FinalSpotList.Iterate over the scanning spot list and set the position or weight of each spot using setter properties
IonSpotParameters.Weight,IonSpotParameters.XorIonSpotParameters.Y.When the scanning spots have been changed as desired, call
IonBeam.ApplyParameters(IonBeamParameters). If the call succeeds, the proton beam / control point / scanning spot data resident in Eclipse memory has been updated.
// unrealistic example shows how to edit the raw scanning spot lists
foreach (IonBeam ionBeam in context.IonPlanSetup.IonBeams)
{
IonBeamParameters beamParams = ionBeam.GetEditableParameters();
IonControlPointPairCollection cpList = beamParams.IonControlPointPairs;
foreach (IonControlPointPair icpp in cpList)
{
IonSpotParametersCollection rawSpotList = icpp.RawSpotList;
foreach (IonSpotParameters spot in rawSpotList)
{
spot.Weight = 1; // set weight to desired
spot.X = 1; // set X position of scanning spot
spot.Y = 1; // set Y position of scanning spot
}
}
// apply scan spot changes to Eclipse
ionBeam.ApplyParameters(beamParams)
}
Figure 13 Sample Script Code to Edit Raw Scanning Spots
- Methods
IonControlPointPair.ResizeFinalSpotListandIonControlPointPair.ResizeRawSpotListallow resizing the proton raw and final scanning spot lists.
Modifying Proton Range Shifter Settings
Use the IonBeamParameters class to modify the range shifter settings of an IonBeam:
Call the
IonBeam.GetEditableParametersmethod.With the returned
IonBeamParametersobject, access propertyPreSelectedRangeShifter1Id/PreSelectedRangeShifter2Idto set the range shifter IDs and propertyPreSelectedRangeShifter1Setting/PreSelectedRangeShifter2Settingto set the range shifter settings.
When the range shifter settings have been changed as desired, call IonBeam.ApplyParameters(IonBeamParameters).
If the call succeeds, range shifter beam line modifier settings have been updated.
DECT Features for Proton Plans
You can use the following Dual-Energy CT (DECT) specific methods:
Image.CalculateDectProtonStoppingPowers, that calculates the pixel-wise proton stopping powers from the planning CT and DECT Rho (relative electron density) and Z (effective atomic number) images.IonPlanSetup.CreateDectVerificationPlan, that can be used to evaluate the dose distribution of a proton treatment plan using DECT stopping power information.Use
Image.GetProtonStoppingPowerCurvemethod for reading the proton stopping power curve of the CT scanner associated with an image.
Adding Field and Plan Uncertainty for Photon and Proton Plans
You can add new plan or field uncertainties with parameters. Supported uncertainty types are:
IsocenterShiftUncertainty(photon-specific)BaselineShiftUncertainty(photon-specific)RangeUncertainty(proton-specific)RobustOptimizationUncertainty(=Perturbation, proton-specific)
Field-specific plan uncertainty dose can be used only for RobustOptimizationUncertainty.
In case of field-specific uncertainty, HUConversionError is overwritten to be always
zero. In case of BaselineShiftUncertainty, the isocenterShift parameter is actually
the target shift.
Functions to call to set plan or field uncertainties with parameters:
For protons:
IonPlanSetup.AddPlanUncertaintyWithParameters(PlanUncertaintyType planUncertaintyType, bool planSpecificUncertainty, double HUConversionError, VVector isocenterShift)
Parameters example:
planUncertaintyType = PlanUncertaintyType.RangeUncertainty
planSpecificUncertainty = true, The plan uncertainty dose is either plan-specific (true) or field-specific (false).
HUConversionError = 3.0, Unit is %.
isocenterShift = new VVector(0.3, 0.4, 0.5), Unit is cm.
Adding Brachytherapy Applicators and Seeds
Use the BrachyPlanSetup class to add brachy applicators:
- Add a new applicator to the brachytherapy plan with the
AddCathetermethod.
Input parameters:
- catheterId: a string defining the ID of the new applicator.
- treatmentUnit: an object defining the brachy treatment unit for the applicator.
- outputDiagnostics : A list of messages populated by the system to inform about the possible consequences of adding the applicator.
- appendChannelNumToId: If true, the channel number is appended to the applicatorID. If false, the channel number is not included in the applicator ID.
- channelNum: sets the channel number of the applicator with the given number.
The accepted range is from 1 to the maximum number of channels defined for the brachy unit in RT Administration.If the provided channel number is 0, the next available free channel number is assigned to the applicator. If the provided channel number is -1, the channel number is left empty.
- Adding new solid applicator or seed collection is not supported yet. Applicators with different treatment units cannot be added in the same plan.
Modifying Brachytherapy Applicators
Use the Catheter class to
modify brachytherapy applicators.
The applicator length can be defined by setting the
Catheter.ApplicatorLengthproperty.The length of the applicator dead space can be defined by setting the
Catheter.DeadSpaceLengthproperty. This property is not supported for solid applicators.Applicator source positions can be accessed with (read only)
- The applicator step size (property
Catheter.StepSize) - First source position (property
Catheter.FirstSourcePosition) - Last source position (property
Catheter.LastSourcePosition)
- The applicator step size (property
Source positions can be set with
Catheter.SetSourcePositionsmethod. Calling this method will also automatically recalculate the source positions.The applicator channel number can now be defined with the
ChannelNumberproperty.It is now possible to change the treatment unit of all applicators of a brachy plan with the
BrachyPlanSetup.ChangeTreatmentUnitmethod. A list of the available brachy treatment units can be get through the newEquipmentclass, with theEquipment.GetBrachyTreatmentUnitsmethod.It is now possible to define the applicator geometry by setting the
Catheter.Shapeproperty. This property is not supported for solid applicators.The ID property of class
Cathetercan now be set with theCatheter.SetID method. The ID must be unique within the plan. If not, the ID is not changed.It is now possible to link an existing reference line to an applicator in a brachytherapy plan using the
Catheter.LinkRefLinemethod.
Input parameter:
- RefLine (reference line to link with an applicator).
It is now possible to unlink a linked reference line from an applicator in a brachytherapy plan using the
Catheter.UnlinkRefLinemethod.It is now possible to link an existing reference point to an applicator in a brachytherapy plan using the
Catheter.LinkRefPointmethod.
Input parameter:
- RefPoint (reference point to link with an applicator).
It is now possible to unlink a linked reference point from an applicator in a brachytherapy plan using the
Catheter.UnlinkRefPointmethod.It is now possible to get/set nominal dwell time for each dwell position using the
SourcePosition.NominalDwellTimeproperty.It is now possible to get/set the dwell time lock for each dwell position using the
SourcePosition.DwellTimeLockproperty.
Adding Prescriptions
- Set the prescription with the
SetPrescriptionmethod of thePlanSetupobject.
Input parameters:
- Number of fractions
- Prescribed dose per fraction (using the dose unit defined for your system in the Varian Service Portal,
- Prescribed percentage.
Using External Beam Calculation Algorithms
You can use the classes described below for IMRT and VMAT optimization, leaf motion
calculation, and dose calculation.
Setting Calculation Models
Use the PlanSetup class to set the calculation models:
- Set the calculation model with the
SetCalculationModelmethod.
Input parameters:
- Calculation type
- Calculation model name.
The current calculation model can be retrieved with the GetCalculationModel
method. All available models can be read with the GetModelsForCalculationType
method of the ExternalPlanSetup class.
Set the calculation options using the
SetCalculationOptionmethod. The available options and their allowed values depend on the calculation model. Before setting the calculation options, set the calculation model.Clear the calculation model of a plan with the
ClearCalculationModelmethod.
Viewing Calculation Logs
Use the following classes to read the messages from the algorithms:
Access the calculation logs after calculation with the CalculationLogs
property. It returns a collection of BeamCalculationLog
objects that can be filtered using the Category
property. The category for the optimization log is, for example Optimization. Use the Trace class of the .NET framework to receive messages from the algorithms
during the calculation. For more information about how to use Trace Listeners, consult the Microsoft Developer Network (MSDN) documentation.
Executing DVH Estimation
Use the ExternalPlanSetup class or IonPlanSetup
class for executing DVH estimation.
- Run DVH estimation with the
CalculateDVHEstimatesmethod.
Input parameters:
- Identifier of the DVH estimation model
- Dose level for target structure(s)
- Mapping between the structures of the estimation model and the structure set of the plan.
Use the Success
property of OptimizerResult
to check if the algorithm executed without errors.
Optimizing IMRT and VMAT Plans
Use the following classes for optimizing IMRT and VMAT plans:
Setting up the Plan
Before starting the optimization, create open fields for the plan with the
AddStaticBeamorAddArcBeammethod of theExternalPlanSetupclass.Use the
OptimizationSetupproperty of thePlanSetupclass to access theOptimizationSetupobject.
Adding and Modifying Optimization Objectives
Use the OptimizationSetup object to add and modify optimization objectives:
Add point objectives with the
AddPointObjectivemethod.Add mean dose or gEUD objectives with the
AddMeanDoseObjectiveorAddEUDObjectivemethods.Add beam-specific parameters with the
AddBeamSpecificParametermethod.Add a Normal Tissue
Objectivewith theAddNormalTissueObjectivemethod.Remove optimization objectives with the
RemoveObjectivemethod.Remove optimization parameters with the
RemoveParametermethod.
Optimizing an IMRT Plan
Use the ExternalPlanSetup class to optimize an IMRT plan:
Run the IMRT optimization algorithm with the
Optimizemethod.Optimize(), run optimization until convergenceOptimize(int32 maxIterations), run until convergence but at most formaxIterationsOptimize(int32 maxIterations, OptimizationOption option)
run until convergence but at most formaxIterationswith addedOptimizationOptionto specify optimization staring condition.Optimize(int32 maxIterations, OptimizationOption option, String mlcid), as above but MLC to use specified with idmlcidOptimize(OptimizationOptionsIMRT options)withOptimizationOptionsIMRTthat have above options passed in astructwith an additional flagOptimizationIntermediateDoseOptionfor calculating intermediate dose when the optimization is restarted.
All existing optimal fluences
are removed. As a result of Optimize, the OptimizerResult object is returned.
Use the Success property of OptimizerResult to check if the algorithm executed
without errors.
After optimization you can read the actual number of iterations from OptimizerResult.NumberOfIMRTOptimizerIterations.
Optimizing a VMAT Plan
Use the ExternalPlanSetup class to optimize a VMAT plan:
Run the
VMAToptimization algorithm with theOptimizeVMATmethod. As a result ofOptimize, theOptimizerResultobject is returned. Use theSuccessproperty ofOptimizerResultto check if the algorithm executed without errors.You can use intermediate dose calculation during
VMAToptimization. To do this, create anOptimizationOptionsVMATobject by specifying either the optionOptimizationIntermediateDoseOption.UseIntermediateDoseor the number of optimization cycles. Then use the overloaded version of methodOptimizeVMATthat takes anOptimizationOptionsVMATobject as an input parameter.
Accessing Dose Volume Histograms
Use the OptimizerResult class to access the results of the optimization:
- Use the
StructureDVHsproperty to access theDoseVolume Histograms after optimization. The returned collection contains anOptimizerDVHobject for eachStructurethat had optimization objectives defined. Use theCurveDataproperty of theOptimizerDVHclass to access the points of theDoseVolume Histogram.
Accessing Optimal Fluences after IMRT Optimization
Use the Beam class to access the optimal fluence information:
- Read the optimal fluence matrix after optimization with the
GetOptimalFluencemethod.
Using Trade-Off Exploration
Use the TradeoffExplorationContext
class and its methods and properties for exploring trade-offs in plans:
Start from an optimized and calculated plan by using the
TradeoffExplorationContextclass.Select the trade-off objectives by using the
AddTradeoffObjective(Structure)method. At least one objective is needed.Query if all pre-conditions to generate the plan collection are met by calling the
CanCreatePlanCollectionproperty.If
CanCreatePlanCollectionis true, generate the plan collection by calling theCreatePlanCollectionmethod.If the plan collection is generated successfully, the
HasPlanCollectionproperty is set to true. The class is now ready for exploring different trade-offs.To evaluate the current trade-off, use the
GetObjectiveCost,CurrentDose, andGetStructureDvhmethods.To explore different trade-offs:
Use the
SetObjectiveCostmethod to reduce the cost of any objective.Use the
SetObjectiveUpperRestrictormethod to prevent the cost of an objective from exceeding a specified limit.
- Save the trade-off exploration results by calling the
ApplyTradeoffExplorationResultmethod. The method also applies the trade-off exploration result to the plan setup for IMRT plans. - In case of a
VMATplan, call theCreateDeliverableVmatPlanmethod to apply the trade-off exploration result to the plan setup. - To resume the trade-off exploration from a saved plan collection, call the
LoadSavedPlanCollectionmethod.
Calculating Leaf Motions after IMRT Optimization
Use the ExternalPlanSetup class to execute the leaf motion calculation algorithm:
Calculate leaf motions with the
CalculateLeafMotionsmethod. The method uses the default calculation options of the leaf motion calculation model set in the plan. The method returns aCalculationResultobject. This object has aSuccessproperty, which you can use to check if the algorithm executed without errors.To run the Varian Leaf Motion Calculator algorithm, use the overloaded
CalculateLeafMotionsmethod.
Input parameter:
LMCVOptionsobject. InLMCVOptions, you can specify the usage of fixed jaws. Check that the leaf motion calculation model of the plan is Varian Leaf Motion Calculator.
- To run the Varian Smart LMC algorithm, use the overloaded
CalculateLeafMotionsmethod.
Input parameter:
SmartLMCOptionsobject. InSmartLMCOptions, you can specify the usage of fixed field borders and jaw tracking. Check that the leaf motion calculation model of the plan is Varian Smart LMC.
- To run the non-Varian MSS Leaf Motion Calculator algorithm, use the overloaded
CalculateLeafMotionsmethod.
Input parameter:
LMCMSSOptionsobject. InLMCMSSOptions, you can specify the number of calculation iterations. Check that the leaf motion calculation model of the plan is MSS Leaf Motion Calculator.
Calculating Photon Plan Dose
Use the ExternalPlanSetup class for dose calculation:
Calculate the volume dose using the
CalculateDosemethod. The method returns aCalculationResultobject. This object has aSuccessproperty that you can use to check if the algorithm executed without errors.Calculate the volume dose with preset MUs using the
CalculateDoseWithPresetValuesmethod.
Input parameter: a list of Beam identifier and 'MeterSetValue', pairs.
- Calculate all plan uncertainty doses that are not calculated already using
CalculatePlanUncertaintyDoses.
Calculating Proton Plan Dose
Use the IonPlanSetup class for proton dose calculation:
Calculate DVH Estimates and generate optimization objectives based on a proton DVH Estimation model with the
IonPlanSetup.CalculateDVHEstimatesmethod.Calculate the beamline with the
IonPlanSetup.CalculateBeamLinemethod.Optimize a proton modulated scanning plan with the
IonPlanSetup.OptimizeIMPTmethod.Calculate the volume dose using the
CalculateDosemethod. The method returns aCalculationResultobject. This object has aSuccessproperty that you can use to check if the algorithm executed without errors.Calculate all plan uncertainty doses that are not calculated already using
IonPlanSetup.CalculatePlanUncertaintyDoses.
Additionally, the proton plan has the following new methods:
IonPlanSetup.SetNormalizationfor modifying Plan normalization mode.IonPlanSetup.SetOptimizationModefor changing plan normalization mode (Multi-field/single field optimization).'IonPlanSetup.PatientSupportDevice' for retrieving details of the patient support device.
Creating an Evaluation Dose
Use the ExternalPlanSetup or IonPlanSetup class:
Create a new
EvaluationDoseusing theCreateEvaluationDosemethod. The method returns anEvaluationDoseobject. This object has aSetVoxelsmethod that is called to set the content of the dose grid.Create a new
EvaluationDoseusing theCopyEvaluationDosemethod. The method copies an existingDoseand returns it as anEvaluationDoseobject. Use theSetVoxelsmethod to change the content of the dose grid.
Creating Halcyon Plans
Halcyon plans have additional requirements beyond standard photon plans before they can be approved. Halcyon plans need to have imaging setups and couch structures attached before they can be considered valid. To create a Halcyon plan with ESAPI automation:
- Create a plan with
Course.AddExternalPlanSetup - Add imaging setup with
ExternalPlanSetup.AddImagingSetup - Insert couch with
StructureSet.AddCouchStructures. - Check the validity of the plan with
ExternalPlanSetup.IsValidForPlanApproval
See the code sample below:
public void Execute(ScriptContext context)
{
context.Patient.BeginModifications();
Course c = context.Patient.AddCourse();
c.Id = "halcyon";
var ptv = context.StructureSet.Structures.First(s => s.DicomType == "PTV");
var eps = c.AddExternalPlanSetup(context.StructureSet, ptv, ptv, "refpt1");
var machineparameters = new ExternalBeamMachineParameters("Hal2_SX2_D5");
var flat = eps.AddFixedSequenceBeam(machineparameters, 20, 45, new VVector(0, 0, 0));
var imagingparameters = new ImagingBeamSetupParameters(ImagingSetup.MVCBCT_Low_Dose, 0, 0, 0, 0, 140, 140);
eps.AddImagingSetup(machineparameters, imagingparameters, ptv);
IReadOnlyList<Structure> addedStructures;
bool imageResized;
context.StructureSet.AddCouchStructures("RDS_Couch_Top", PatientOrientation.HeadFirstSupine, RailPosition.In, RailPosition.In, null, null, null, out addedStructures, out imageResized, out error);
eps.CalculateDose();
IEnumerable<PlanValidationResultDetail> reasons;
if (!eps.IsValidForPlanApproval(out reasons))
{
string message = "";
foreach (PlanValidationResultDetail pvrd in reasons)
{
message += pvrd.MessageForUser + "\n";
}
MessageBox.Show("Halcyon plan is not valid for approval.Messages = n" + message);
}
else
{
MessageBox.Show("Halcyon plan is valid for approval");
}
}
Figure 14 Additional Halcyon setup
Using Brachytherapy Calculation Algorithms
You can use the methods described below for the dose calculation of brachytherapy plans.
Calculating Brachytherapy Plan Dose
It is now possible to calculate the TG-43 dose for brachy plans.
The
BrachyPlanSetup.CalculateTG43Dosemethod calculates the dose for the brachy plan. The dose is calculated using the TG-43 dose calculation algorithm.The
CalculateTG43Dosemethod returns aCalculateBrachy3DDoseResultobject that indicates if the operation was successful or not in theSuccessproperty.For a successful dose calculation the
RoundedDwellTimeAdjustRatioproperty indicates how the much the dwell times where adjusted. A value of zero (0.0) indicates that dwell times where not adjusted.If the dose calculation was not successful, the reason(s) for the failure is included in the
Errorsproperty.