plan sum DVH

Nov 21, 2016 at 6:04 PM
Does anyone know how to get DVHdata from a plan sum?
Nov 22, 2016 at 10:43 PM
Hi Joshua,

You can definitely get the DVH from a plansum without any extra code magic to go through. I've adapted an answer I posted earlier in this thread to count the plansum.
First, add the System.IO namespace to your project under all of the other using statements:
using System.IO;
then you can put together a plansum like this.
PlanSum ps = context.PlanSumsInScope.First();
            Structure Bladder = ps.StructureSet.Structures.Where(x => x.Id == "Bladder").First();
            DVHData dvh = ps.GetDVHCumulativeData(Bladder, DoseValuePresentation.Absolute, VolumePresentation.Relative, 200);
            using (StreamWriter sw = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\dvhtest.csv"))
                sw.WriteLine("Volume, dose");
                foreach (DVHPoint dp in dvh.CurveData)
                    sw.WriteLine(String.Format("{0},{1}", dp.Volume, dp.DoseValue.ValueAsString));
Note: This is just getting the first plansum in the scope window. If you have multiple plansums, you will want to remove the First() on the first line of code above and then loop through all of your plansums. Also, to plot in excel, you may want dose on the first column and volume in the second. right now this code is backward. For instance,
sw.WriteLine(String.Format("{0},{1}", dp.DoseValue.ValueAsString, dp.Volume)); 
is plot ready right in excel.
Dec 2, 2016 at 3:29 PM
Awesome, thanks!
Dec 2, 2016 at 5:39 PM
Do you know if that StreamWriter code will work with a citrix based Eclipse system?
Dec 5, 2016 at 3:52 PM
Hi Josh,

I think it should work over Citrix. I don't have a Citrix system to test it on, but I've tested this code over a network before. If you want to specify the exact server you want to save the file to, you can by putting the server name into the file path of StreamWriter; i.e.
using(StreamWriter sw = new StreamWriter("\\\\<server name>\folder_name(s)\filename.csv"))
    //add sw code here.
If you can get this to work. I think the community, myself included, would like to hear if you are successful.

Best Regards
Dec 5, 2016 at 8:21 PM
This appears to be working. I used the path for the eclipse dose export to a network drive and was able to create a text file. Thanks!