VarianAPIs / Varian-Code-Samples

Code samples for ESAPI and other Varian APIs and web services.
MIT License
117 stars 108 forks source link

PortalDosimetry : Convert pixel raw value of max dose in the predicted image #147

Closed jejepalphys closed 2 years ago

jejepalphys commented 2 years ago

Hi,

With Portal Dosimetry Scripting, I try to find max dose on predicted image in portal dosimetry.

Function pdBeam.PredictedDoseImage.GetMinMax(out int minValue, out int maxValue, false) give me the pixel max raw value. Does anyone know how convert this value to dose.

Thanks

mattcschmidt commented 2 years ago

The FrameRT class (you can get from the PredictedDoseImages.FramesRT.ElementAt(0)) has a method called VoxelToDisplayValue that should provide CU values for you.

jejepalphys commented 2 years ago

I found it with : PredictedDoseImage.Image.FramesRT.ElementAt(0)

Thank you for your answer, it's perfect.

mattcschmidt commented 2 years ago

Your welcome!

jejepalphys commented 2 years ago

Hi @mattcschmidt,

I'm having difficulty with using the FrameRT class.

It works perfectly if in Portal Dosimetry I display the predicted image in the context. But, when I try to apply it to all images in the context plan, it doesn't work.

Here is my code : double maxValueCU; foreach (PDBeam pdBeam in Context.PDPlanSetup.Beams) { pdBeam.PredictedDoseImage.GetMinMax(out int minValue, out int maxValue, false); maxValueCU = pdBeam.PredictedDoseImage.Image.FramesRT.Last().VoxelToDisplayValue(maxValue); MessageBox.Show(maxValue.ToString() + " - " + maxValueCU.ToString()); }

With this example, if I have a plan with two beams, I display the first beam in Portal Dosimetry and run the script.

The maxValue of the GetMinMax() function works well for both beams.

But the conversion to CU is only correct for the first beam, here are the results:

Do you have any idea what mistake I am making?

Thanks again