clinicaltemplatereader
A public API to interpret Eclipse plan templates, objective templates, and clinical protocols and utilize the interpretation in the generation of automated plans.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.8%) to scientific vocabulary
Repository
A public API to interpret Eclipse plan templates, objective templates, and clinical protocols and utilize the interpretation in the generation of automated plans.
Basic Info
- Host: GitHub
- Owner: WUSTL-ClinicalDev
- License: other
- Language: C#
- Default Branch: master
- Size: 453 KB
Statistics
- Stars: 25
- Watchers: 2
- Forks: 3
- Open Issues: 2
- Releases: 0
Metadata Files
README.md
Use and Description
The following is an example of using the ClinicalTemplateReder for automated planning. Start by generated a Stand-alone executable with the Eclipse Script Wizard
Save your solution!
Change your target framework to .NET 4.5.2. Go to the Nuget Package Manager and find the ClinicalTemplateReader package. You may find this by searching ESAPI. * For Version 15.6, make sure to get version 1.0.0.5 * For Version 16.0, make sure to get version 2.0.0.1
Add the following using to your code to resolve the ClinicalTemplateReader related references:
csharp
using ClinicalTemplateReader;
Review Template Statistics
In the Execute Method post the following code
```csharp static void Execute(Application app) { //Checking clinical templates Console.WriteLine("Reading Clinical Templates"); string server = "Varian Image Server"; // <== update to your image server address e.g. "localhost", "10.11.12.13" var clinicalProtols = new ClinicalTemplate(server);
var planStats_cp = clinicalProtols.GetPlanTemplateApprovals(true);
Console.WriteLine("Plan Template statistics with clinical protocols");
foreach (var planstat in planStats_cp)
{
Console.WriteLine($"\t{planstat.ApprovalStatus} - {planstat.Count}");
}
var objStats_cp = clinicalProtols.GetObjectiveTemplateApprovals(true);
Console.WriteLine("Objective Template Statistics with clinical protocols");
foreach (var objstat in objStats_cp)
{
Console.WriteLine($"\t{objstat.ApprovalStatus} - {objstat.Count}");
}
Console.ReadLine();
} ```
Running this should give the following response in the console.
Selecting a plan template
The following code will allow you to select a plan template.
```csharp static void Execute(Application app) { // Checking clinical templates string server = "Varian Image Server"; // <== update to your image server address e.g. "localhost", "10.11.12.13" var clinicalProtols = new ClinicalTemplate(server);
var approvedTemplates = clinicalProtols.PlanTemplates.Where(x => x.Preview.ApprovalStatus.Contains("Approved")).ToList();
for (int i = 0; i < approvedTemplates.Count(); i++)
{
Console.WriteLine($"[{i}]. {approvedTemplates.ElementAt(i).Preview.ID} - {approvedTemplates.ElementAt(i).Preview.LastModified}");
}
Console.WriteLine($"\n\nPlease pick your plan template from the list (0 - {approvedTemplates.Count() - 1}):");
var plantemplatenumber = Convert.ToInt32(Console.ReadLine());
var plantemplate = approvedTemplates.ElementAt(plantemplatenumber);
Console.WriteLine("\nObjective Template List (Approved):");
//Get template description
Console.WriteLine($"\n\nDescription of plan template");
Console.WriteLine($"Number of Fields: {plantemplate.Fields.Count()}");
Console.WriteLine($"Plan Rx: {plantemplate.DosePerFraction} x {plantemplate.FractionCount}");
Console.ReadLine();
} ```
The result:
Generating a plan from a template.
Finally, the following code will utilize the ClinicalTemplateReader API to generate an automated plan.
```csharp static void Execute(Application app) { // Generate plan from template string server = "Varian Image Server"; // <== update to your image server address e.g. "localhost", "10.11.12.13" var clinicalProtols = new ClinicalTemplate(server);
var approvedTemplates = clinicalProtols.PlanTemplates.Where(x => x.Preview.ApprovalStatus.Contains("Approved")).ToList();
var plantemplate = approvedTemplates.ElementAt(1); // Select an approved plan template
var _patient = app.OpenPatientById("PatientIDHere"); // Give a valid PatientID1
var _structureSet = _patient.StructureSets.FirstOrDefault(x => x.Id == "ROI");
Console.WriteLine("\n\nGenerating new automation plan");
_patient.BeginModifications();
//Generate plan
var _newplan = clinicalProtols.GeneratePlanFromTemplate(null, _structureSet, plantemplate, null);
//Set Prescription.
clinicalProtols.SetRx(plantemplate, _newplan, "cGy");
string plan_update = $"Plan created with {_newplan.Beams.Count()} beams";
Console.Write($"Generated Plan {_newplan.Id} in {_newplan.Course.Id}\n{plan_update}\nPlan Rx: {_newplan.TotalDose} in {_newplan.NumberOfFractions}fx");
app.SaveModifications();
app.ClosePatient();
Console.ReadLine();
}
To execute this part you must add the following attribute to your code:
csharp
[assembly: ESAPIScript(IsWriteable = true)]
```
The response from the console should be as follows.
After refreshing the patient in Eclipse, you should see a new course, plan, and fields generated on the patient.
Read Plan Quality Metrics from Clinical Protocols
A new feature available in Version 1.0.0.3 is the ability to leverage the plan quality metrics in a clinical protocol to evaluate the plan. Below is the code to select a clinical protocol, and based on that clinical protocol determine the pass/fail of each clinical plan.
This does not require that you first build the plan with the ClinicalTemplateReader, but rather can be used as a stand-alone feature for getting plan goals.
NOTE: This works for both plans and plan sums, so now you can build clinical protocols with goals for an overall plansum and get the objective results!
csharp
var reader = new ClinicalTemplate("Varian Image Server");
Console.WriteLine("Please select a clinical protocol:");
int cp_num = 0;
Console.WriteLine("Approval Statuses");
Console.WriteLine($"{String.Join("\n",reader.ClinicalProtocols.Select(x=>x.Preview.ApprovalStatus).Distinct())}");
var clinicalProtocols = reader.ClinicalProtocols.Where(x => x.Preview.ApprovalStatus == "Approved");
foreach (var cps in clinicalProtocols)
{
Console.WriteLine($"[{cp_num}]. {cps.Preview.ID} - {cps.Preview.TreatmentSite}: {cps.Preview.LastModified}");
cp_num++;
}
int cp_selection = Convert.ToInt32(Console.ReadLine());
var clinicalprotocol = clinicalProtocols.ElementAt(cp_selection);
//open patient, course and plan.
var patient = app.OpenPatientById("PatientId");//patient id here
var course = patient.Courses.FirstOrDefault(x => x.Id == "CourseId");//course id here
var plan = course.PlanSetups.FirstOrDefault(x => x.Id == "PlanId");//plan id here
//This is the method that compares the planning item to the clinical protocol.
var metrics = reader.CompareProtocolDoseMetrics(plan, clinicalprotocol);
foreach(var doseMetric in metrics)
{
Console.WriteLine($"{doseMetric.MetricText}\n\tResult: ({doseMetric.Pass}) {doseMetric.ResultText}");
}
The final result should look something like this.
Optimze plan with DVHEstimation (RapidPlan) -- V16 Only
In V16, the Rapidplan details, such as the structures included in a Rapidplan model, can be queried with ESAPI. This feature can now be leveraged by the ClinicalTemplateReader.
First set up the code to allow the user to select the Rapidplan model they want to select for a given plan. Here newplan is used as an example as seen above
```csharp
//optimize plan using Rapidplan.
var rpmodels = app.Calculation.GetDvhEstimationModelSummaries();
var rpcount = 0;
foreach(var rp in rpmodels)
{
Console.WriteLine($"[{rpcount}]. {rp.Name} - {rp.TreatmentSite}");
rpcount++;
}
Console.WriteLine("Please pick your RP Model:");
int rpnum = Convert.ToInt32(Console.ReadLine());
var rpmodel = rpmodels.ElementAt(rpnum);
clinicalProtols.OptimizeFromRapidPlanModel(app.Calculation.GetDvhEstimationModelStructures(rpmodel.ModelUID), newplan, rpmodel, null, null, false);
if (_newplan.Beams.First().Technique.Id.Contains("ARC"))
{
_newplan.CalculateDose();
}
else
{
_newplan.CalculateLeafMotionsAndDose();
}
app.SaveModifications();
``` Once the code has run, you should have optimization results driven by the DVH Estimation algorithm.
Some notes regarding this method - The targetmatches and structurematches can be determined by the client code beforehand and passed into the method. - The method can also determine these matches for you by matching first based on structure name and then on structure code. So make sure your Rapidplan model matches your structure template structure Ids - Target matches will always use the plan total dose as the dose input.
Owner
- Name: WUSTL Clinical Development
- Login: WUSTL-ClinicalDev
- Kind: organization
- Repositories: 2
- Profile: https://github.com/WUSTL-ClinicalDev
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Schmidt" given-names: "Matthew C" orcid: "https://orcid.org/0000-0003-3357-6703" - family-names: "Szentivanyi" given-names: "Peter" title: "Clinical Template Reader" version: 1.0.0.9 doi: date-released: 2020-11-13 url: "https://github.com/WUSTL-ClinicalDev/ClinicalTemplateReader"
GitHub Events
Total
- Watch event: 2
- Push event: 2
- Create event: 1
Last Year
- Watch event: 2
- Push event: 2
- Create event: 1
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 2
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 2
- Total pull request authors: 0
- Average comments per issue: 1.5
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- gbaltz (1)
- remsky (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- nuget 5,966 total
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 9
- Total maintainers: 1
nuget.org: clinicaltemplatereader
An API for assisting in the generation in the interpretation of planning templates for automated planning. This version is compatible with ESPAI 16.X
- Homepage: https://github.com/WUSTL-ClinicalDev/ClinicalTemplateReader
- License: other
-
Latest release: 2.0.0
published almost 5 years ago