top of page

Application Design Tip: Using the Structure ID Dictionary in ESAPI applications

Matthew Schmidt



Structure ID Dictionary Introduction

Within Visual Scripting, a structure dictionary was introduced in order to allow for structure matching with inconsistent naming when utilizing the Calculate DVH Metrics Action Pack. In fact, the structure dictionary is only applied when using the Calculate DVH Metrics Action Pack. As you'll see in this post, the Structure ID Dictionary's use in only the Calculate DVH Metrics Action Pack does not preclude you from utilizing the dictionary for your own purposes-- whether it be for structure generation, RapidPlan model structure matching, or even your own custom script to extract DVH metrics. In this example, the Structure Id Dictionary will be used for assessing structure matches in the open-source Simple Structure Builder application, but first, we can see how to access and modify this Structure ID Dictionary.


Accessing and Modifying the Structure ID Dictionary

In order to access the structure dictionary, a simple Visual Script has to be created. Visual Scripting can be launched from the External Beam Planning workspace. Locate Visual Scripting under the Tools menu.


Within the Visual Scripting interface, first drag a PlanSetup Context Item to the canvas. In the right-side selection menu, the Calculate DVH Metrics Action Pack available under the Can be connected to... section. Click on the icon in the center of the Calculate DVH Metrics Action Pack to open the Design Time UI.


Once the Structure ID Dictionary is open, the first step is to put a structure ID in the editable text box on the left side of the UI. When clicking add, the ID entered into the box should appear in the list box in the upper left. Once the ID in the list box is selected, an alias ID may be entered and submitted to the list box in the upper right.

Note: If the Add Button under the Alias ID seems to not be doing anything, insure that Structure Id is selected in the upper left list box.

Here multiple structures can be added to the list of Structure IDs and multiple aliases can be added for each structure Id.


After the Structure ID Dictionary has been created, the Dictionary can be viewed in file form as well. The Structure ID Dictionary file is stored in the VisualScripting folder within the VA_Data$ share. The easiest way to access this folder is to go to the Scripts item under the Tools menu, and click Open Folder... Navigate back one folder level-- to the Vision folder-- and enter the Visual Scripting Folder. There you will see the file StructureNameDictionary.xml




Using the Structure ID Dictionary with ESAPI

In this example, we will see how the structure Id dictionary is employed with the Simple Structure Builder. First, we need a simple class to mirror the syntax of the StructureNameDictionary. Notice the dictionary is composed of entries with the name StructureNameDictionaryStringListOfString. A class can be created that directly mirrors this object name.


Next, a static service is generated to handle all requests to the structure dictionary. The first role of the static service is to initialize the structure dictionary. In this Initialization method, the path is constructed from the known path of the structure dictionary. Next, the XMLSerializer deconstructs the XML file into our own StructureDictionaryOfStringListOfString class. Now our StructureDictionary property has all the StructureNameDictionary.xml entries.


Note: Most image server configurations have the name va_data$, but it has been seen that the folder may have a different name, such as va_data2$.

A method is included in the service to look up an entry by the key value.


The Structure Dictionary Service is then implemented in the import method of the Simple Structure Builder. The use of the structure dictionary is a selectable configuration option that can either be true of false in the configuration of the application. The import method first checks on this configuration value, and if it is true, it initializes the structure dictionary from the service.


After initializing the structure dictionary service, the JSON file that represents the structure builder templated steps is imported. The user selects the file from the OpenFileDialog class, and the file is converted to a StructureCreationModel class object by the JsonConvert method provided by the nuget package, NewtonSoft.Json.


After the class list has been initialized, the steps provided in the JSON are looped through. Setting the temporary flag and the Result structure of the step is simple, as the values are simply bool and string, respectively. Setting the BaseStructure takes a little more care since we must first determine if the base structure exists in the current StructureSet.

If the BaseStructure cannot be found in the current structure set, then we use the structure dictionary to see if there are any matches. The Structure Dictionary Service GetDictionaryValues method inputs the Base Structure and looks for any matches within the dictionary. Finally, if the Base Structure is not found, the BaseStructure property is set to null, and the user can select a structure from the structure set.

To complete the import method, the same is applied to the TargetStructure, or the structure to which the boolean operation from the base structure is happening. Finally, once the TargetStructure property is determined (or left null), the other properties such as the Margin, SelectedOperation, AsymmetricMargin values, StructureCode, and requested StructureColor are set in the property as well.



Final Thoughts

An alternative to using a Structure Dictionary would be to improve conformance around structure naming across the board. Initiatives to do just this have been at the forefront of Medical Physics, with one of the most notable being the AAPM Task Group 263. Unfortunately, challenges still remain to structure name compliance. For example, one could be data mining through old plans and structure sets that were generated prior to TG263 adoption, and target volume naming can sometimes be challenging to predict with variations on dose prescriptions being build into the structure Id.

A innovative programmatic implementation of TG 263 structure name compliance can be found in Rex Cardan's video using ESAPI-X.

Using the Structure Id Dictionary in my scripts has made it much easier to pivot when structure name compliance causes issues in structure creation or RapidPlan model structure matching. Many times, when the planning team contacts me with issues from our script-based planning solutions (either handled or unhandled exceptions), these errors are remedied by entering the Structure Id Dictionary UI through Visual Scripting as seen above, and adding a new structure to the values section of the dictionary for a given key. This is certainly more simple than having to make modifications to the source code, especially when that code would require approval prior to implementing the new code.







7 views0 comments

Recent Posts

See All

コメント


bottom of page