Exporting PQM information to Excel or MATLAB

Nov 14, 2016 at 7:50 PM
Hi there,

I am repurposing the 'PlanQualityMetrics' project to generate reports for a few different planning protocols.
I am new to C#, and am wondering if there is a simple way of exporting or saving the extracted data into Excel or .txt files to be analyzed in another software.

Thanks in advance
Nov 17, 2016 at 2:08 PM
You can either export the DVH as text files and use the R package Radonc (https://cran.r-project.org/web/packages/RadOnc/index.html) to get the data in the required format in CSV files, or you could export the dicom files and import them using http://www.dicompyler.com/ note there is also the ability to analyse your data using ipython notebooks with https://github.com/dicompyler/dicompyler-core and of course export pandas data objects as CSV.
Cheers
Robin
Nov 22, 2016 at 10:46 PM
Hi LeeMacD,

You have all the things you need to write a CSV file to your computer (and this will open in Excel if it is set as the default program for opening these types of files in Windows). First, you need to use the System.IO namespace that is built in with your Visual Studio project. Put the following beneath all the using statements:
using System.IO;
Then you can use this as an example to write the DVH:
 Structure Bladder = context.StructureSet.Structures.Where(x => x.Id == "Bladder").First();
            DVHData dvh = context.PlanSetup.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));
                }
                sw.Flush();
            }
Nov 22, 2016 at 11:46 PM
A couple of other things to note:
dp.DoseValue will have a dose unit attached to it. To remove the unit, use dp.DoseValue.ValueAsString .
You may also want to put dose in the first column (x-axis) and volume in the second column (y-axis) to make it plot ready in excel
Hope this helps.
Nov 23, 2016 at 2:28 PM
Thanks very much mcschmidt.
I have my PQM script repurposed and working, the export to Excel is just due to the preference of our site.

Another short question I have:

Each time I make a change to the project code, and build my esapi.dll and re-run the script, in order to see the changes I've made I have to close and exit Eclipse & ARIA completely and reopen.
Is there any way around this?

Thanks again.
Nov 24, 2016 at 5:25 PM
Dec 1, 2016 at 12:12 AM
LeeMacD wrote:
Each time I make a change to the project code, and build my esapi.dll and re-run the script, in order to see the changes I've made I have to close and exit Eclipse & ARIA completely and reopen.
Hi LeeMacD,

This is a common problem when running binary plugins in Eclipse. You have a couple of options to get around this, but the option I use is to do all of my testing as a stand-alone executable, and then once the code is ready, I'll convert it back to a binary plug in. If you can figure out the differences in the two script types by looking at some examples that would be helpful, but if not, let me know and I'll be able to create an example of how I do this.

Best regards,

Matt.
Coordinator
Dec 4, 2016 at 6:44 PM
LeeMacD,

Another solution is to use a plug-in tester, like the one I've described here: http://www.carlosjanderson.com/run-and-test-plug-in-scripts-from-visual-studio. It is available as a NuGet package and the source code is here: https://github.com/redcurry/EclipsePlugInRunner.
Dec 5, 2016 at 4:31 PM
Thanks redcurry.
The PlugInRunner is very useful for developing scripts.