VarianAPIs / Varian-Code-Samples

Code samples for ESAPI and other Varian APIs and web services.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CreateVerificationPlan.cs for different beam properties

asocoliuc opened this issue · comments

Hi everybody,

I am new here and not experienced, but I am trying to get a verification plan with ESAPI for my IMRT and VMAT plans. I 've read conversations here and got inspired. I got a working script generating verification plans only for plans that do not have the jaw tracking option activated or, or even not activated, the gantry speed is constant . My question: is this code working for you when using jaw tracking (additional beam parameters X1,X2, Y1, Y2 for jaw positions):

ExternalBeamMachineParameters MachineParameters =
new ExternalBeamMachineParameters(originalBeam.TreatmentUnit.Id, originalBeam.EnergyModeDisplayName, originalBeam.DoseRate, originalBeam.Technique.Id, string.Empty);
// Create a new beam.
var collimatorAngle = getCollimatorAndGantryFromBeam ? originalBeam.ControlPoints.First().CollimatorAngle : 0.0;
var gantryStart = getCollimatorAndGantryFromBeam ? originalBeam.ControlPoints.First().GantryAngle : 0.0;
var gantryStop = getCollimatorAndGantryFromBeam ? originalBeam.ControlPoints.Last().GantryAngle : 0.0;
var gantryAngle = getCollimatorAndGantryFromBeam ? originalBeam.ControlPoints.First().GantryAngle : 0.0;
var gantrydir = originalBeam.GantryDirection;
var couchAngle = getCollimatorAndGantryFromBeam ? originalBeam.ControlPoints.First().PatientSupportAngle : 0.0;
var metersetWeights = originalBeam.ControlPoints.Select(cp => cp.MetersetWeight);
//var beamWeights = originalBeam.WeightFactor;
var beam = plan.AddVMATBeam(MachineParameters, metersetWeights, collimatorAngle, gantryStart, gantryStop, gantrydir, couchAngle, isocenter);
// Copy control points from the original beam.
var editableParams = originalBeam.GetEditableParameters();
for (var i = 0; i < editableParams.ControlPoints.Count(); i++)
{
editableParams.ControlPoints.ElementAt(i).LeafPositions = originalBeam.ControlPoints.ElementAt(i).LeafPositions;
editableParams.ControlPoints.ElementAt(i).JawPositions = originalBeam.ControlPoints.ElementAt(i).JawPositions;
}
editableParams.WeightFactor = originalBeam.WeightFactor;
beam.ApplyParameters(editableParams);

For me it does not work, I always get the same error: There were errors in beam parameters.
Sincerely, I do not understand why, since the leafs ad jaw positions are read for each control point...
The same error appear when the gantry speed is not constant and I do not know how to take this into account when scripting
Does anyone have an idea? Thanks a lot. Ani

Hello.
The issue is in the line "new ExternalBeamMachineParameters(...);"
The energy mode display name returns values that are different sometimes than the energy mode that needs to go into this constructor, specifically for FFF beams. The energy mode display name for 6FFF would be 6X-FFF, but the ExternalBeamMachineParameters would take 6X as the second argument and FFF as the last argument.
Please let me know if this helpsl