Extracting Dose Profiles in Eclipse

Aug 26, 2016 at 12:41 PM
Hi Everyone,

I'm new to all of this and have just started to read the Eclipse Scripting API Manual Reference Guide. I need to extract quite a number of dose profiles from Eclipse for commissioning purposes - I have just extracted 60 'by hand' and decided - no more! I'm hoping this is quite a simple thing to do using Eclipse Scripting API? Any help would be much appreciated.

Kind regards,

Wendy Hyland
Aug 28, 2016 at 1:40 AM
Hi Wendy,

Could you describe what you mean by dose profiles?

Aug 30, 2016 at 8:23 AM
Hi Redcurry,

In Eclipse there is the option to extract a dose profile (there is a little tool at the top of the page in extrenal beam planning) just to get the dose information along that line at whichever depth etc. you like - for example to compare that dose profile with what you have measured in the watertank etc. It is fine to use the tool for one of two cases however I would like to be able to automate this as I have quite a lot to do.


Sep 10, 2016 at 9:43 PM
It's not super simple to do, but here are some pointers. A PlanSetup has a Dose property, and the Dose has a method called GetDoseProfile. You can pass it two vectors, where to start and where to end, and an array of doubles where the dose values will be stored. The method returns a DoseProfile object, where you can get things like the Unit of the dose and the individual positions of where the dose was sampled.

That is the "bulk" of the code. You still need to go through the correct plans and at the end, output the results to a file.
Sep 14, 2016 at 12:07 AM
Edited Sep 15, 2016 at 5:43 PM
[edit 9/15: fixed errors in code]
Hi Wendy,

Carlos is exactly right on what method to use. The syntax below will help you extract the dose profiles that you need. Keep in mind, you will only be able to get the dose profiles for the entire plan, so if you want to compare to your scan data, you'll want to put each field in its separate plan. This is, of course, assuming that field doses are still not available in your version of ESAPI. Before starting, add using System.IO; underneath the other using statements. Then, in the spot where it says "Insert your code here" put the following.
Dose mydose = context.PlanSetup.Dose;
VVector start = new VVector();
VVector end = new VVector();
//this will be for lateral crossline profiles (i.e. changing x while y and z stay the same)
start.x = -200; start.y = 50; start.z = 0;
end.x = 200; end.y = start.y; end.z = start.z; // this profile will be 400cm long (you may not need it this long)
double[] size = new double[401];
DoseProfile dp = mydose.GetDoseProfile(start, end, size); //this doseproffile will create a list of ProfilePoint objects, so now we need to get those. 
using (StreamWriter sw = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop))+"\\testprofile.csv")
    sw.WriteLine("Dose,Value");//header for the csv file.
    foreach(ProfilePoint pp in dp)//get all profile points
        sw.WriteLine(String.Format("{0},{1}", pp.Position.x, pp.Value));
If you wanted to do multiple profiles at once, let's say for depth, you would want to put the start.y in a for loop as well. For instance using something like:
double[] depths = new double[] {150, 50, 100, 200};
for (double dub in depths)
   ... more code here
   start.x = -200; start.y = dub; start.z = 0;
But here, you would definitely want to change the file name over every iteration or else you'd be overwriting testprofile.csv every iteration of the for loop, but you could easily make that a variable that depends on the depth.
string filename = "profile_depth_" + dub.ToString("##");
using (StreamWriter sw = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)+"\\" + filename)
\\rest of the code goes down here.
or you could move the using statement up above everything else and put it all in the same file. Let me know how you want the info, and I will gladly help. I'll plug all this into Visual studio to check the syntax sometime this week, because I may have a typo or missed something.