VarianAPIs / PyESAPI

Python interface to Eclipse Scripting API
MIT License
69 stars 32 forks source link

EvaluationDose and GetDoseAtVoxel, GetVoxelAtDose, GetDVHCumulativeData #21

Closed mfizyczka closed 1 day ago

mfizyczka commented 2 years ago

There is option to add EvaluationDose to plan (or to import dose in Eclipse TPS). In Eclipse it is possible to evaluate this dose, look into DVHs, compare with Clinical Goals etc. But if I try doing the same with scripting GetDoseAtVoxel, GetVoxelAtDose, GetDVHCumulativeData methods return nan. The Dose.DoseMax3D.Dose method still returns max dose.

PatientID = "MyPatientID"

# open patient
patient = app.OpenPatientById(PatientID)

patient.BeginModifications()

# select course
course = patient.CoursesLot('CourseName')

# select plan
plan = course.PlanSetupsLot('Test')

# select structure sets:
structureSet = patient.StructureSetsLot()[0]

# change dose presentation to absolute:
plan.DoseValuePresentation = 1

tempPlan = course.AddExternalPlanSetup(plan.StructureSet)
tempDose = tempPlan.CopyEvaluationDose(plan.Dose)

structure = structureSet.StructuresLot()[27]

# set step of exported lines:
step = 0.7

dvh = plan.GetDVHCumulativeData(structure, pyesapi.DoseValuePresentation.Absolute, pyesapi.VolumePresentation.Relative, step)
dvh2 = tempPlan.GetDVHCumulativeData(structure, pyesapi.DoseValuePresentation.Absolute, pyesapi.VolumePresentation.Relative, step)
dose = plan.GetDoseAtVolume(structure, 50, pyesapi.VolumePresentation.Relative, pyesapi.DoseValuePresentation.Absolute).Dose
dose2 = tempPlan.GetDoseAtVolume(structure, 50, pyesapi.VolumePresentation.Relative, pyesapi.DoseValuePresentation.Absolute).Dose

print('dvh', dvh)
print('dvh2', dvh2)
print('dose', dose)
print('dose2', dose2)

print('tempPlan max dose:', tempPlan.Dose.DoseMax3D.Dose)
The output is:
dvh VMS.TPS.Common.Model.API.DVHData
dvh2 None
dose 14.776034807492234
dose2 nan
tempPlan max dose: 103.92649999999999

How can I use Evaluation methods on EvaluationDose not on CalculatedDose?

fizxmike commented 1 day ago

For posterity,