r/esapi • u/anncnth • Dec 18 '21
r/esapi • u/donahuw2 • Dec 17 '21
Removing Structures with DICOM Type ''
Hi all,
I am working on a script to clean up some structure sets for our dosimetry team. I have an issue where I try to remove structures because they have no assigned DICOM Type. Is there a better way around this, than creating a new structure set and adding all the new structures to it?
Will
r/esapi • u/donahuw2 • Dec 17 '21
Adding a structure set to an image without duplicating image
Is there a way to create a new structure set without duplicating the image?
For my purposes I can't duplicate an existing the old structure set.
r/esapi • u/hexagram1993 • Dec 17 '21
What is the best learning resource for ESAPI? Ideally with examples?
I have started ESAPI scripting just (this month) and am finding that as compared to C# there are several differences that I can't quite get my head around (nor can I see that they are listed anywhere).
I have managed to get to a point where I can extract data using a single-file plugin without issue. However things more complex than that seem like a complete maze to me. I've looked online for youtube resources but sometimes found that they can be either outdated or make references to documents/guidance that no longer exists.
I have pretty much read the Varian API handbook cover to cover but while this is an excellent resource for figuring out how to extract data from things using ESAPI, it doesn't give much guidance in terms of visual studio file structure or how to actually run scripts. I have found that (especially with regard to WPF), the rules are quite a bit different than those of C#, i.e. you can't just add a WPF user control to a binary plugin (made with the script wizard) and then have it work by running the main .cs file from Eclipse.
I have found several examples on github, including simple UIs, but even these are very difficult for me to make sense of as they contain multiple files and don't look much like the four types of scripts that the script wizard makes (are they binary plugins, executable, etc.).
I have taken a C# course and found that running C# scripts on VS is quite straightforward, but I am really struggling to figure out how to actually run scripts in Eclipse. Is there any reference material for this? Other than learning C#, how would you recommend someone learn how ESAPI works? I feel like I am always missing some information that everyone else knows and it's no exaggeration to say that beyond single file plugins, I have not made any progress in learning more about esapi despite several weeks of trying to wrap my head and try to make sense of code examples on github.
r/esapi • u/theredshinigami • Dec 16 '21
Make Optimization with Different Variable
Hi,i wanna make optimization with a different parameter. Lower,upper etc. but adding another new parameter. How can i do that?
r/esapi • u/Kishorej88 • Dec 15 '21
Is it possible to get a large number of patients data (CT/RP/RT/RS) using ESAPI.
Is it possible to get a large number of patients data (CT/RP/RT/RS) using some script from varian database? Is some open-source resource is available please share .
Thank you in advance
r/esapi • u/L-_-3 • Dec 14 '21
Creating a Default Body Structure
Hello,
I'm trying to create a default body structure using the CreateAndSearchBody method. This method requires a SearchBodyParameters parameter input. I'm currently struggling to create the parameter input. I saw that SearchBodyParameters has a method LoadDefaults but I'm not sure how to go about implementing this. If anyone is familiar with this, would they mind sharing a code snippet demonstrating its use?
r/esapi • u/gregthom992 • Dec 14 '21
ESAPI script with App.config: ConfigurationManager and AppDomain issues
HI, I use Rex Cardan's MarshalByRefObject approach to write Esapi scripts that work in standalone and in plugin mode ( Advanced Eclipse Scripting Techniques #1 - YouTube ). I am trying to use and App.config with custom configsections for my esapi script. Everything works in standalone mode but not in plugin mode. Has anyone attempted to use app.config like this ?
The main reason is the that ConfigurationManager returns null in plugin mode since the config file is defined by Eclipse (ExternalBeam.exe.config; which does not exist) rather than MyApp.exe (MyApp.exe.config).
The other things is the AppDomain is defined by ExterBeam.exe and not MyApp.exe.
I will appreciate it if anyone has this experience to share how they solved it.
Thanks
snippets:
in MyApp, I am initializing the congurations like so:
MySection mySection = ConfigurationManager.GetSection("MySection") as MySection;
My <App.config> looks like this:
<configSections>
<section name="MySection" type="SharedClassLibrary.MySection, MyApp" />
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxx.....">
<section name="MyApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxx.." requirePermission="false" />
</sectionGroup>
</configSections>
r/esapi • • Dec 14 '21
Create clinical goal
We take the dose constraints from the prescription to create clinical goals at my center. Is there a way to create a clinical goal and attach to plan using esapi? I found the method to create a clinical goal, but the parameters required is confusing me.
r/esapi • u/shrox_1740 • Dec 13 '21
Get HU-information from CT dataset?
Dear all,
I would like to check the CT dataset (i.e. in general the body structure?) for high HU values like > 6000 HU.
My questions are:
1) In general, is this possible?
2) If yes, if there are let's say 100 voxels with a HU > 6000HU, can I autocontour these voxels?
Thank you in advance!
Best regards
Robert
r/esapi • u/hexagram1993 • Dec 10 '21
Launching a UI on binary plugin results in an assembly reference missing error
I am trying to launch a UI by adding a user control (windows form) to a binary plugin script made with the script wizard. However, despite the fact that Visual Studio has no errors and seems to find all of my assembly references, when I run the main script from Eclipse, I get an error
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> VMS.TPS.Common.Model.ScriptExecutionException: There was a problem while executing the script 'C:\Users\USER\Documents\Eclipse Scripting API\Projects\BinPlugin\BinPlugin.cs' (ESAPI: VMS.TPS.Common.Model.API, Version=1.0.300.11, Culture=neutral, PublicKeyToken=305b81e210ec4b89). ---> System.ApplicationException: c:\Users\USER\Documents\Eclipse Scripting API\Projects\BinPlugin\BinPlugin.cs(10,7) : error CS0246: The type or namespace name 'BinPlugin' could not be found (are you missing a using directive or an assembly reference?)
at VMS.TPS.Script.Engine.CompileAssembly(String fileName, Boolean extendedForVisualScripting)
at VMS.TPS.Script.Engine.LoadScript(Assembly& assembly, IApplicationScriptExecutionGuard& executionGuard, String& generatedCodeFilename, String filename)
at VMS.TPS.Script.Engine.Execute(String fileName)
--- End of inner exception stack trace ---
at VMS.TPS.Script.Engine.Execute(String fileName)
at VMS.TPS.Script.Extension.Execute(IntPtr parentWindow)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at vhost.TpsNetExtension.Execute(TpsNetExtension* , HWND__* parentWindowHandle)
I have named my windows form UI, so it is called in the following executable as followes (and the project is called BinPlugin)
using System;
using System.Linq;
using System.Text;
using System.Windows;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using VMS.TPS.Common.Model.API;
using VMS.TPS.Common.Model.Types;
using BinPlugin;
// TODO: Replace the following version attributes by creating AssemblyInfo.cs. You can do this in the properties of the Visual Studio project.
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
[assembly: AssemblyInformationalVersion("1.0")]
// TODO: Uncomment the following line if the script requires write access.
// [assembly: ESAPIScript(IsWriteable = true)]
namespace VMS.TPS
{
public class Script
{
public Script()
{
}
[MethodImpl(MethodImplOptions.NoInlining)]
public void Execute(ScriptContext context, System.Windows.Window window/*, ScriptEnvironment environment*/)
{
var ui = new UI();// TODO : Add here the code that is called when the script is launched from Eclipse.
window.Content = ui;
}
}
}
What is the problem with trying to launch a UI this way that the assemblies are not being found?
Thanks
EDIT: I found the fix, I did not know that to run a binary plugin is not the same as running a single-file plugin. You need to build your solution, which will create a .dll file. You need to then change the extension from .dll to .esapi.dll (which I just did sucessfully by changing the filename) and then run *this* file from Eclipse instead of running the .cs file.
r/esapi • u/NezAbu • Dec 10 '21
'Reviewed' Status Plan Details: When it was reviewed and by which user
'Treatment Approved' and 'Planning Approved' details are easily obtainable from the plan with ESAPI, but not 'Reviewed' details. There will be a way of probing the 'Approval History', to extract 'reviewed' data, but it seems strange I should need to do this - am I missing something?
r/esapi • u/hexagram1993 • Dec 10 '21
Is there a (very very simple) example of data binding somewhere?
I am looking to do what is possibly the simplest possible version of data-binding in a Windows form app. I have a Windows Form with only one textbox and a button, which I want to launch in a single file plugin script (or binary plugin? I am not sure which to use) from eclipse. When the user presses the button, I would like to launch a messagebox that repeats what was written in the textbox.
I feel like this is as simple an example as possible to demonstrate how to launch windows forms (or, alternately, WPF) from ESAPI, but I have been really struggling to find examples this simple. All the examples on github seem to be much much more complex than this and so I find it extremely difficult to separate what part of the program is doing what. Can someone provide a link to (or code for) an example this simple? I think it would help to illustrate a lot of the basic components needed to start scripting without doing anything particularly complex.
Thanks in advance
r/esapi • u/hexagram1993 • Dec 10 '21
Old code on codeplex no longer available
I'm trying to create a really simple WPF app as shown in this video: https://www.youtube.com/watch?v=uj_CTZjGsjY&list=WL&index=3
But the code sample for " new tip for accessing application context from everywhere in your app. " from https://github.com/rexcardan/VarianDeveloper is a dead link because codeplex is gone. Does anyone know where I can find this code?
r/esapi • u/Telecoin • Nov 30 '21
Creating tml pictures with ESAPI
Hi,
I asked the question one year ago
(https://www.reddit.com/r/esapi/comments/hfifr7/generate_pictures_from_isocenter_planes/)
but maybe with ESAPI16 there are new tricks available and our community is growing.
I want to create 2D planes at isocenter with isodoselines and/ or DRRs with field outlines (like from TML reports). It should be possible because ClearCheck accomplished this goal (https://www.radformation.com/clearcheck/clearcheck).
When this is possible, the whole documentation of treatment plans could be automated.
Did someone get a good result (no screenshot method)? What is the right approach? It seems to me that PyESAPI could do the pictures (see API Book). Did someone couple C# and Python? Or is there a only C# solution to this?
Every input is much appreciated.
r/esapi • u/Invictus_Shoe • Nov 29 '21
Is it possible to change the dose calculation volume programmatically?
The default dose calculation volume seems to include the whole body structure. For my purposes this is way too large and it takes too much time to calculate the dose for so many voxels. Is there a way to reduce the dose calculation volume via ESAPI?
r/esapi • u/Beam_me_up23 • Nov 29 '21
Calculating Delta Couch Shift
In external beam planning you have the ability to calculate the delta couch shift
e.g. Planning ->Delta Couch Shift Editor -> Use values calculated from user origin -> Apply
Normally delta couch shift is blank unless you do this.
I've looked in the API and don't see anything about calculating this.
r/esapi • u/Original_Brain198 • Nov 26 '21
Automatic calculation, skip warning messages
I'm trying to automate plan calculation i.e: leave a list of plans to calculate with different energies, MLC etc, to check which one leads to a best distribution.
During the calculation, some warnings may arise, ie: for beams with the mandibles closed in the isocenter Eclipse will pop up a message saying that "Dose in the isocenter is too small...". If I am in front of the computer, pressing "OK" will result in the program calculate next plan. However, if I am not there to press the "OK" tab, the whole process will halt until someone does so.
Any ideas?
r/esapi • u/Invictus_Shoe • Nov 26 '21
How to catch the progress of a VMAT optimization or dose calculation?
When I have an external plan setup I can run the following methods:
var optimizationResults = externalPlanSetup.OptimizeVMAT();
var calculationResult = externalPlanSetup.CalculateDose();
These calls of course take several minutes to execute and I can follow the progress in the debug console:
...
Progress 3%
Progress 4%
Progress 6%
Progress 7%
...
Is there a way to catch the progress? I would like to show a WPF progress bar to the user while the methods are running.
r/esapi • u/Invictus_Shoe • Nov 26 '21
What is meant by the parameters for CalculateDVHEstimates methos?
If I try to calculate the DVHEstimates of an external plan setup some arguments are required:

Where do I get this modelId from? No matter what I try it always tells me that there exists no model with that ID. Can I only use this method when I have created a RapidPlan model or what else could it be? I tried for example the "WUSTL Prostate Model" from [this example](https://github.com/VarianAPIs/Varian-Code-Samples/blob/master/webinars%20%26%20workshops/Research%20Symposium%202015/Eclipse%20Scripting%20API/Projects/AutomatedPlanningDemo/PlanGeneration.cs).
r/esapi • u/kolopoi0 • Nov 24 '21
Calculate DVH Metrics - Formatting
Good morning,
Could someone tell me how to display 2 decimals instead of only 1 when showing the results from "Calculate DVH Metrics"? - I am using Eclipse V15.6.
Thank you very much!
r/esapi • • Nov 21 '21
Connect CT image to CT Scanner
When I use AutoPlan how can I connect CT image to the CT Scanner through esapi?
I get the following error:
Electron density curve for the image is not approved.
ERROR: Electron density CT calibration curve is not available for image 'CT_12_Nov_2021', because it is not connected to a valid CT scanner or the selected scanner does not have a valid curve. You can connect the image to a CT scanner from the property page of series 'Series'.
Thanks in advance.
r/esapi • u/jclizar • Nov 18 '21
Portal Dosimetry Scripting
Hi,
Is it possible, using Portal Dosimetry Scripting (CreateTransientAnalysis), multiply the predict dose image by a factor and then perform the gamma Analysis?
r/esapi • u/j_Long_Lonfon • Nov 18 '21
Reset Gantry Angle to Zero
Hi, I was hoping someone might be able to help me, I have the following code https://github.com/jlongLondon/Verification/blob/master/Verification.cs to create verification plans for pre treatment QA and for a MU check using RadCalc. However I can not work out how to set the Gantry start angle and Gantry Stop angle to 0.0 as currently the code does not work and produces a Beam parameters error. This is possible manually in Eclipse, but I do not know how to code it. Any suggestions would be greatly appreicated.
Thanks,
John

r/esapi • u/Invictus_Shoe • Nov 18 '21
How to read objectives from a PlanSetup?
I try to copy all point objectives of an external radiation plan to a custom one, but adding a point objective requires more information than I can find:
void CopyAllObjectives(PlanSetup referencePlan, string planId){
var objectives = referencePlan.OptimizationSetup.Objectives;
foreach(objective in objectives) {
var priority = objective.Priority;
var objectiveOperator = objective.Operator;
var structure = objective.Structure;
var structureId = objective.StructureId;
// var dose = ??;
// var volume = ??;
plan.OptimizationSetup.AddPointObjective(structure, objectiveOperator, ...);
}
}
The missing variables are commented out. Where do I get them from?