grayden maclennan mba, msm, ms,...

179
Grayden MacLennan MBA, MSM, MS, CIIP

Upload: others

Post on 14-Apr-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Grayden MacLennanMBA, MSM, MS, CIIP

Page 2: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Grayden worked for MIM Software from 2007-2013, but no longer has financial ties to the company.

• This presentation contains screenshots from several commercial software packages:– MIM– Velocity– RayStation– Pinnacle

Disclosures

MacLennan 2016 2

Page 3: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• I’m a tech geek, but NOT a natural born programmer

• Enthusiast more than expert

• I learned most of these systems while making this presentation

• I had a lot of help

My Background

MacLennan 2016 3

Page 4: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The What and the Why• Tools of the Trade• Two Simple Script Ideas• Writing Scripts in the Real World

– MIM– Velocity– RayStation– Pinnacle– Eclipse

• Next Steps

Table of Contents

MacLennan 2016 4

Page 5: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Identifying a specific sequence of actions that a user normally performs in the same order every time

• Creating a set of instructions that makes sense to a computer so that it can do those actions for the user

What is Scripting?

MacLennan 2016 5

Page 6: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• No, not the same thing

• Templates create or load a list of things– ROIs with specific names/colors– Isodose line settings/colors– Beam arrangements– Report sections

• Scripts are MUCH easier to implement if you also use templates– Predictable names for things are important

You Mean Templates?

MacLennan 2016 6

Page 7: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Contour creation and manipulation• Statistics processing• Image loading and unloading• Image creation, processing, editing• Image registration• Report generation• Dose evaluation• Display management• Beam setup• Plan calculation• lots more…

What Kinds of Actions?

MacLennan 2016 7

Page 8: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Pay close attention to the order of your actions– Do you REALLY do it the same way every time?– Can you write out the instructions in everyday language?

• Length vs. complexity– Is it truly a complex task?– Maybe just a lot of simple tasks back to back?

Establishing the Steps

MacLennan 2016 8

Page 9: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Lots of different kinds of pieces– Each one is relatively simple– Each one has different capabilities

• Identify which pieces you'll need• Identify how they will attach to each other• Identify the order in which they need to be added

• Create a document that describes the process

Making Instructions for a Lego Set

MacLennan 2016 9

Page 10: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Simple Instructions for a Lego Car

MacLennan 2016 10

Image ©2014 Jessica Brown

Page 11: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

We Can Use More Complex Parts…

MacLennan 2016 11

Image ©2012 Nathanaël Kuipers

Page 12: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

…to Build Something Better

MacLennan 2016 12

Image ©2012 Nathanaël Kuipers

Page 13: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Just Watch Out For Logic Problems

MacLennan 2016 13

Image adapted from comic by Peter Lea

Page 14: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Writing code by hand

• “Copy My Clicks” style script recorder

• Drag & drop visual script builder

Approaches to Script-Making

MacLennan 2016 14

Page 15: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Different Systems, Different Options

MacLennan 2016 15

Scripting Method LanguageXiO/Monaco None n/a

Eclipse Hand written code C#

Velocity Hand written code XML

Pinnacle "Copy My Clicks" recorder, Hand written code Proprietary

RayStation "Copy My Clicks" recorder, Hand written code Python

MIM Drag & drop visual builder (Workflows)Hand written code (MIMextensions)

n/aJava, MATLAB

Page 16: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Differing Attitudes Towards Scripting

MacLennan 2016 16

Boundless Optimism Crushing Pessimism

Page 17: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

It's just a Physics toy

Differing Attitudes Towards Scripting

MacLennan 2016 17

Page 18: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

How I Feel Most Days

MacLennan 2016 18

Page 19: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• It takes time to set up

• It doesn't do EXACTLY what I want

• It takes time to learn new skills

Arguments Against Scripting

MacLennan 2016 19

Page 20: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Time is invested, not spent

• Evaluating a process can help find inefficiencies, even if you don't end up using a script

– Helps to standardize your work process

• You learn a new skill!

Arguments For Scripting

MacLennan 2016 20

Page 21: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The key to finishing is starting

• Avoid analysis paralysis

– Pick something simple

– "Hello World" is usually the first program you write in every language for a reason

Psychological Hurdles

MacLennan 2016 21

Page 22: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• We will NOT be learning to program today– Tons of good tutorials online for every language

• Each system uses a different language– Explanations will dive in assuming you already have some

knowledge of that language

• Open/edit/save functions will be glossed over– They are either intuitive or in the manual

Setting Expectations for Today

MacLennan 2016 22

Page 23: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• I will be moving quickly

• Remember: these slides will be on the AAMD website after the conference

• You can come back and re-read the code later

No Need to Take Coding Notes

MacLennan 2016 23

Page 24: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The What and the Why• Tools of the Trade• Two Simple Script Ideas• Writing Scripts in the Real World

– MIM– Velocity– RayStation– Pinnacle– Eclipse

• Next Steps

Table of Contents

MacLennan 2016 24

Page 25: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Text Editor– NOT a Word Processor like Microsoft Word

• Spaces and tabs matter• Autocorrect and Autoformat will ruin your day

– Writing prose and writing code have different demands• A word processor operates on the principle that appealing layout of

printed pages is the ultimate goal

Tools of the Trade

MacLennan 2016 25

Page 26: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Syntax highlighting (code coloring)• Powerful find/replace tools• Will not wrap text to next line unless you say so• Autocomplete offered but not imposed• Smart indentation

Useful Text Editor Features

MacLennan 2016 26

Page 27: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Good editors can apply color based on code content<VelocityScript name="Excerpt from IMRT script">

<!-- Demo of syntax highlighting --><Crop

source="Bladder"target="Bladder_Avoid"cropSpecification="RemoveInside"marginDirection="Grow"margin="5"cropList="PTV"

/></VelocityScript>

<VelocityScript name="Excerpt from IMRT script"><!-- Demo of syntax highlighting --><Crop

source="Bladder"target="Bladder_Avoid"cropSpecification="RemoveInside"marginDirection="Grow"margin="5"cropList="PTV"

/></VelocityScript>

Syntax Highlighting

MacLennan 2016 27

Page 28: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Windows: Notepad++

• Mac: TextMate, BBEdit, TextWrangler

• Linux/Solaris/UNIX: emacs, vim, nano

Good Text Editors

MacLennan 2016 28

Page 29: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Integrated Development Environment (IDE)– Editors with extra tools for making software– Examples: Visual Studio, Eclipse (no relation), Xcode– Serious overkill for most of these projects

More Tools of the Trade

MacLennan 2016 29

Page 30: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The What and the Why• Tools of the Trade• Two Simple Script Ideas• Writing Scripts in the Real World

– MIM– Velocity– RayStation– Pinnacle– Eclipse

• Next Steps

Table of Contents

MacLennan 2016 30

Page 31: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• We are going to pick 2 simple script ideas

– Not super useful by themselves, but they demonstrate the clinical usefulness of expanding on the ideas

• We will see how to make those 2 scripts on several different systems

Two Simple Script Ideas

MacLennan 2016 31

Page 32: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Rename ROIs to RTOG-style names

• For simplicity, let's just rename 5 contours

Script Idea #1

MacLennan 2016 32

Old StyleRIGHT ORBITLEFT ORBITRIGHT OPTIC NERVELEFT OPTIC NERVEOPTIC CHIASM

New StyleEye_REye_LOpticNerve_ROpticNerve_LChiasm

Page 33: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Some contour atlases provide little control over ROI naming conventions

• Some clinical trials demand specific naming of ROIs

• In both cases, one known set of names must be mapped to another– Atlas standard names → Clinic standard names– Clinic standard names → Trial standard names

Script #1 Relevance

MacLennan 2016 33

Page 34: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Steps in script

– Find a contour– Rename it

• Assumptions for the demo– Source contours exist– They are named exactly as we expect them to be

Script #1 Process

MacLennan 2016 34

Lather, rinse, repeat

Page 35: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Create a few IMRT optimization structures

– Bladder_Avoid and Rectum_Avoid• Portion of each organ at least 5 mm outside PTV

– Ring1• Dose gradient control structure• 2 cm thick shell 1 cm away from the PTV

Script Idea #2

MacLennan 2016 35

Page 36: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 Starting Contours

MacLennan 2016 36

Page 37: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Bladder_Avoid & Rectum_Avoid

MacLennan 2016 37

Page 38: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Ring1

MacLennan 2016 38

Page 39: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Many plans use optimization or dose gradient control structures

• These structures are usually created the same way every time

• Perfect for automation

Script #2 Relevance

MacLennan 2016 39

Page 40: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Steps in Script (varies slightly by system)

– Crop Bladder 5 mm from PTV• Call the result "Bladder_Avoid"

– Crop Rectum 5 mm from PTV• Call the result "Rectum_Avoid"

– Expand from PTV 3 cm• Subtract 1 cm margin around PTV• Call the result "Ring1"

• Assumptions for the demo– Bladder, Rectum, and PTV all exist– They are named exactly as we expect them to be

Script #2 Process

MacLennan 2016 40

Page 41: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

confidential | proprietary

Cool.Let's Write Some Scripts.

MacLennan 2016 41

Page 42: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The What and the Why• Tools of the Trade• Two Simple Script Ideas• Writing Scripts in the Real World

– MIM– Velocity– RayStation– Pinnacle– Eclipse

• Next Steps

Table of Contents

MacLennan 2016 42

Page 43: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Scripting is built in

• Scripts are called Workflows

• Drag & Drop interface– No code writing necessary

• Most software functions are scriptable

Scripting in MIM

MacLennan 2016 43

Page 44: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• 23 page manual supplement– Mostly just a list of all the tools available

• Training video on support webpage

• Many sample workflows

• Support will help with writing and troubleshooting

MIM Documentation/Support

MacLennan 2016 44

Page 45: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

MIM Workflow Interface

MacLennan 2016 45

Page 46: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Page 1 of 3 in Workflow Builder

MacLennan 2016 46

Page 47: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Page 2 of 3 in Workflow Builder

MacLennan 2016 47

Page 48: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Page 3 of 3 in Workflow Builder

MacLennan 2016 48

Giant List of Scriptable ActionsData to Feed

Into Actions

Page 49: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 49

Page 50: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 50

Page 51: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 51

Page 52: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 52

Page 53: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 53

Page 54: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 54

Page 55: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 55

Page 56: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 56

Page 57: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 57

Page 58: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 58

Page 59: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 59

Page 60: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 60

Page 61: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 (Renamer) in MIM

MacLennan 2016 61

Page 62: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 Workflow Steps

MacLennan 2016 62

Page 63: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 63

Page 64: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 64

Page 65: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 65

Page 66: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 66

Page 67: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 67

Page 68: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 68

Page 69: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 69

Page 70: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 70

Page 71: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 71

Page 72: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 72

Page 73: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 73

Page 74: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 74

Page 75: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 75

Page 76: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 76

Page 77: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 77

Page 78: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Same process for Rectum_Avoid

• Ring1 is one PTV expansion minus another

Script #2 (IMRT ROIs) in MIM

MacLennan 2016 78

Page 79: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Complete IMRT ROI Script

MacLennan 2016 79

Page 80: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Extension API lets you manipulate the application from behind the scenes– Goes beyond stringing a series of steps together

• MIM doesn’t have a feature you need?– Make it yourself

• Java, JavaScript, or link to MATLAB

Tangent Topic: MIMextensions

MacLennan 2016 80

Page 81: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The What and the Why• Tools of the Trade• Two Simple Script Ideas• Writing Scripts in the Real World

– MIM– Velocity– RayStation– Pinnacle– Eclipse

• Next Steps

Table of Contents

MacLennan 2016 81

Page 82: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Scripting is built in

• Scripts must be hand-written– Easy to learn language: XML

• Limited capabilities– Only has 6 most commonly used contouring tools

• Margin, Crop, Intersection, Union, Fill Holes, Remove Pieces• Can also specify color of output ROI

Scripting in Velocity

MacLennan 2016 82

Page 83: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• 4 pages in User Manual with sample code for a few of the actions

• Full syntax reference guide is in the form of a hastily edited (but complete) example script– Need Velocity Admin User access the see reference guide

• Support will help with writing and troubleshooting

Velocity Documentation/Support

MacLennan 2016 83

Page 84: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

<VelocityScript name= "Script name for menu" >

<!– Freeform text to help with code documentation -->

<Action parameter=“value“ parameter=“value“ … /><Action parameter=“value“ parameter=“value“ … /><Action parameter=“value“ parameter=“value“ … /><Action parameter=“value“ parameter=“value“ … />

</VelocityScript>

Velocity Script Skeleton

MacLennan 2016 84

Page 85: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Contour renaming is not one of the 6 tools– We can improvise…– Use the margin tool with 0 cm expansion to create a new

contour with correct name

• Need a strategy for the old contour– There is no delete tool, but we can empty it out– It will be easier to know which one to delete later

Script #1 (Renamer) in Velocity

MacLennan 2016 85

Page 86: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Copy = Margin with no expansion<Margin source="LEFT ORBIT" target="Eye_L" margin="0" marginDirection="Grow" marginSpecification="Symmetric" />

• Code can be split onto separate lines for readability

<Marginsource="LEFT ORBIT"target="Eye_L"marginDirection="Grow"marginSpecification="Symmetric"margin="0"

/>

Improvising "Copy" with "Margin"

MacLennan 2016 86

Page 87: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Erase by cropping ROI from itself

<Cropsource="LEFT ORBIT"cropSpecification="RemoveInside"cropList="LEFT ORBIT"marginDirection="None"

/>

Improvising "Erase" with "Crop"

MacLennan 2016 87

Page 88: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

<VelocityScript name="AAMD 2016 Contour Renaming in Velocity">

<Margin source="RIGHT ORBIT" target="Eye_R" marginDirection="Grow"marginSpecification="Symmetric" margin="0" />

<Crop source="RIGHT ORBIT" cropSpecification="RemoveInside" cropList="RIGHT ORBIT"marginDirection="None" />

<Margin source="LEFT ORBIT" target="Eye_L" marginDirection="Grow"marginSpecification="Symmetric" margin="0" />

<Crop source="LEFT ORBIT" cropSpecification="RemoveInside" cropList="LEFT ORBIT"marginDirection="None" />

<Margin source="RIGHT OPTIC NERVE" target="OpticNerve_R" marginDirection="Grow"marginSpecification="Symmetric" margin="0" />

<Crop source="RIGHT OPTIC NERVE" cropSpecification="RemoveInside" cropList="RIGHT OPTIC NERVE"marginDirection="None" />

<Margin source="LEFT OPTIC NERVE" target="OpticNerve_L" marginDirection="Grow"marginSpecification="Symmetric" margin="0" />

<Crop source="LEFT OPTIC NERVE" cropSpecification="RemoveInside" cropList="LEFT OPTIC NERVE"marginDirection="None" />

<Margin source="OPTIC CHIASM" target="Chiasm" marginDirection="Grow"marginSpecification="Symmetric" margin="0" />

<Crop source="OPTIC CHIASM" cropSpecification="RemoveInside" cropList="OPTIC CHIASM"marginDirection="None" />

</VelocityScript>

Renamer Script in a Text Editor

MacLennan 2016 88

Page 89: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

How to Access Scripting

MacLennan 2016 89

Normal Users

Admin Users

Page 90: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Creating and Editing Scripts

MacLennan 2016 90

Page 91: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Select a Script to Edit

MacLennan 2016 91

Page 92: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #1 Loaded into Velocity

MacLennan 2016 92

Page 93: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Comparing Before and After

MacLennan 2016 93

Page 94: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Margins and Cropping are what Velocity's scripting systems was designed for

• Bladder_Avoid and Rectum_Avoid can both be done with a single Margin command

• Ring1 needs two actions: a Margin then a Crop

Script #2 (IMRT ROIs) in Velocity

MacLennan 2016 94

Page 95: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

<VelocityScript name="AAMD 2016 IMRT Contours in Velocity">

<!-- Create Bladder_Avoid by subtracting PTV from Bladder with a 5 mm margin --><Crop source="Bladder" target="Bladder_Avoid" cropSpecification="RemoveInside"

cropList="PTV" marginDirection="Grow" margin="5" />

<!-- Create Rectum_Avoid by subtracting PTV from Bladder with a 5 mm margin --><Crop source="Rectum" target="Rectum_Avoid" cropSpecification="RemoveInside"

cropList="PTV" marginDirection="Grow" margin="5" />

<!-- Start creating Ring1 by making a 30 mm expansion from PTV --><Margin source="PTV" target="Ring1" marginDirection="Grow"

marginSpecification="Symmetric" margin="30" />

<!-- Knock the center out of Ring1 by removing any portion with 10 mm of PTV --><Crop source="Ring1" cropSpecification="RemoveInside"

cropList="PTV" marginDirection="Grow" margin="10" />

</VelocityScript>

• Note: comment tags can provide documentation

Complete IMRT ROIs Script

MacLennan 2016 95

Page 96: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The What and the Why• Tools of the Trade• Two Simple Script Ideas• Writing Scripts in the Real World

– MIM– Velocity– RayStation– Pinnacle– Eclipse

• Next Steps

Table of Contents

MacLennan 2016 96

Page 97: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Scripting is built-in• Most program functions are scriptable

• Has a "Copy my Clicks" style script recorder• Hand-coding to edit recorded scripts• Hand-coding to make your own scripts

• Language is Python– Must install IronPython interpreter if it isn't already there

RayStation

MacLennan 2016 97

Page 98: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• 36 page manual supplement with code samples

• Videos on RaySearch website & YouTube

• Official discussion forums

• Training workshops (one coming up next weekend)

• Support will help with writing and troubleshooting

RayStation Documentation/Support

MacLennan 2016 98

Page 99: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Start the script recorder

• Manually rename each of the ROIs

• Stop the script recorder

Script #1 (Renamer) in RayStation

MacLennan 2016 99

Page 100: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Open the Scripting Tab

MacLennan 2016 100

Page 101: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Open the Script Creation Interface

MacLennan 2016 101

Page 102: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script Creation Window

MacLennan 2016 102

Page 103: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Now That We Are Recording…

MacLennan 2016 103

Page 104: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Examine the ROI List

MacLennan 2016 104

Page 105: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Start Editing ROIs Manually

MacLennan 2016 105

Double Click on ROI

Page 106: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Let's Rename this ROI

MacLennan 2016 106

Page 107: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Much Better

MacLennan 2016 107

Page 108: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Do That a Few More Times…

MacLennan 2016 108

Page 109: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Hit Stop Button When Done

MacLennan 2016 109

STOP

Page 110: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Here's the Code it Created for Us

MacLennan 2016 110

Page 111: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

# Script recorded 11 Apr 2016

# RayStation version: 4.7.2.5# Selected patient: ...

from connect import *

patient = get_current("Patient")

with CompositeAction('Apply ROI changes (RIGHT ORBIT)'):patient.PatientModel.RegionsOfInterest['RIGHT ORBIT'].Name = "Eye_R"# CompositeAction ends

with CompositeAction('Apply ROI changes (LEFT ORBIT)'):patient.PatientModel.RegionsOfInterest['LEFT ORBIT'].Name = "Eye_L"# CompositeAction ends

with CompositeAction('Apply ROI changes (RIGHT OPTIC NERVE)'):patient.PatientModel.RegionsOfInterest['RIGHT OPTIC NERVE'].Name = "OpticNerve_R"# CompositeAction ends

with CompositeAction('Apply ROI changes (LEFT OPTIC NERVE)'):patient.PatientModel.RegionsOfInterest['LEFT OPTIC NERVE'].Name = "OpticNerve_L"# CompositeAction ends

with CompositeAction('Apply ROI changes (OPTIC CHIASM)'):patient.PatientModel.RegionsOfInterest['OPTIC CHIASM'].Name = "Chiasm"# CompositeAction ends

Script #1 Code in a Text Editor

MacLennan 2016 111

Page 112: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• In this case, there is no need to edit the code at all

• Let's break it down anyway, just to see how it works

The Code is Ready to Use

MacLennan 2016 112

Page 113: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

# Script recorded 11 Apr 2016

# RayStation version: 4.7.2.5# Selected patient: ...

from connect import *

patient = get_current("Patient")

with CompositeAction('Apply ROI changes (RIGHT ORBIT)'):patient.PatientModel.RegionsOfInterest['RIGHT ORBIT'].Name = "Eye_R"# CompositeAction ends

with CompositeAction('Apply ROI changes (LEFT ORBIT)'):patient.PatientModel.RegionsOfInterest['LEFT ORBIT'].Name = "Eye_L"# CompositeAction ends

with CompositeAction('Apply ROI changes (RIGHT OPTIC NERVE)'):patient.PatientModel.RegionsOfInterest['RIGHT OPTIC NERVE'].Name = "OpticNerve_R"# CompositeAction ends

with CompositeAction('Apply ROI changes (LEFT OPTIC NERVE)'):patient.PatientModel.RegionsOfInterest['LEFT OPTIC NERVE'].Name = "OpticNerve_L"# CompositeAction ends

with CompositeAction('Apply ROI changes (OPTIC CHIASM)'):patient.PatientModel.RegionsOfInterest['OPTIC CHIASM'].Name = "Chiasm"# CompositeAction ends

Breaking Down the Code

MacLennan 2016 113

Time stamp and version record

Linkage to RayStation active session

Page 114: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The "CompositeAction" and its closing comment simply indicate the breadth of one Undo step

with CompositeAction('Apply ROI changes (RIGHT ORBIT)'):patient.PatientModel.RegionsOfInterest['RIGHT ORBIT'].Name = "Eye_R"# CompositeAction ends

• RayStation's Undo menuafter running the script

CompositeAction = Undo Step

MacLennan 2016 114

Page 115: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

# Script recorded 11 Apr 2016

# RayStation version: 4.7.2.5# Selected patient: ...

from connect import *

patient = get_current("Patient")

with CompositeAction('Apply ROI changes (RIGHT ORBIT)'):patient.PatientModel.RegionsOfInterest['RIGHT ORBIT'].Name = "Eye_R"# CompositeAction ends

with CompositeAction('Apply ROI changes (LEFT ORBIT)'):patient.PatientModel.RegionsOfInterest['LEFT ORBIT'].Name = "Eye_L"# CompositeAction ends

with CompositeAction('Apply ROI changes (RIGHT OPTIC NERVE)'):patient.PatientModel.RegionsOfInterest['RIGHT OPTIC NERVE'].Name = "OpticNerve_R"# CompositeAction ends

with CompositeAction('Apply ROI changes (LEFT OPTIC NERVE)'):patient.PatientModel.RegionsOfInterest['LEFT OPTIC NERVE'].Name = "OpticNerve_L"# CompositeAction ends

with CompositeAction('Apply ROI changes (OPTIC CHIASM)'):patient.PatientModel.RegionsOfInterest['OPTIC CHIASM'].Name = "Chiasm"# CompositeAction ends

Breaking Down the Code

MacLennan 2016 115

Page 116: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• We could strip out all of the extra CompositeActionlines and make the whole thing one undoable action

# AAMD 2016 Contour Renaming Script in RayStation

from connect import *

patient = get_current("Patient")

with CompositeAction('Run Renamer Script'):

patient.PatientModel.RegionsOfInterest['RIGHT ORBIT'].Name = "Eye_R"patient.PatientModel.RegionsOfInterest['LEFT ORBIT'].Name = "Eye_L"patient.PatientModel.RegionsOfInterest['RIGHT OPTIC NERVE'].Name = "OpticNerve_R"patient.PatientModel.RegionsOfInterest['LEFT OPTIC NERVE'].Name = "OpticNerve_L"patient.PatientModel.RegionsOfInterest['OPTIC CHIASM'].Name = "Chiasm"

# CompositeAction ends

Script #1 Condensed

MacLennan 2016 116

Page 117: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Whitespace (tabs, spaces, returns) matters in Python

• Long code lines can be split onto multiple lines, but it must be done with care– Indentation level is part of how the interpreter knows

what's going on

• Style guide at: https://www.python.org/dev/peps/pep-0008/

A Note About Python Code

MacLennan 2016 117

Page 118: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Start the script recorder

• Create Bladder_Avoid, Rectum_Avoid, and Ring1– They can all be done with the ROI Algebra tool

• Stop the script recorder

Script #2 (IMRT ROIs) in RayStation

MacLennan 2016 118

Page 119: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Find the ROI Algebra Tool

MacLennan 2016 119

Page 120: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Find the ROI Algebra Tool

MacLennan 2016 120

Page 121: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

ROI Algebra Window

MacLennan 2016 121

Page 122: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Set the Output ROI

MacLennan 2016 122

Page 123: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Script #2 Generated Code

MacLennan 2016 123

Page 124: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

# Script recorded 28 May 2016# RayStation version: 4.7.2.5

# Selected patient: ...

from connect import *

patient = get_current("Patient")examination = get_current("Examination")

with CompositeAction('ROI Algebra (Bladder_Avoid)'):

retval_0 = patient.PatientModel.CreateRoi(Name="Bladder_Avoid", Color="Blue", Type="Organ", TissueName=None, RoiMaterial=None )

retval_0.CreateAlgebraGeometry(Examination=examination,Algorithm="Auto",ExpressionA={'Operation': "Union", 'SourceRoiNames': ["Bladder"], 'MarginSettings': {'Type': "Expand", 'Superior': 0, 'Inferior': 0, 'Anterior': 0, 'Posterior': 0, 'Right': 0, 'Left': 0}},ExpressionB={'Operation': "Union", 'SourceRoiNames': ["PTV"], 'MarginSettings': {'Type': "Expand", 'Superior': 0.5, 'Inferior': 0.5, 'Anterior': 0.5, 'Posterior': 0.5, 'Right': 0.5, 'Left': 0.5}},ResultOperation="Subtraction",ResultMarginSettings={ 'Type': "Expand", 'Superior': 0, 'Inferior': 0, 'Anterior': 0, 'Posterior': 0, 'Right': 0, 'Left': 0 } )

# CompositeAction ends

with CompositeAction('ROI Algebra (Rectum_Avoid)'):

retval_1 = patient.PatientModel.CreateRoi( Name="Rectum_Avoid", Color="Yellow", Type="Organ", TissueName=None, RoiMaterial=None)

retval_1.CreateAlgebraGeometry(Examination=examination,Algorithm="Auto",ExpressionA={'Operation': "Union", 'SourceRoiNames': ["Rectum"], 'MarginSettings': {'Type': "Expand", 'Superior': 0, 'Inferior': 0, 'Anterior': 0, 'Posterior': 0, 'Right': 0, 'Left': 0}},ExpressionB={'Operation': "Union", 'SourceRoiNames': ["PTV"], 'MarginSettings': {'Type': "Expand", 'Superior': 0.5, 'Inferior': 0.5, 'Anterior': 0.5, 'Posterior': 0.5, 'Right': 0.5, 'Left': 0.5}},ResultOperation="Subtraction",ResultMarginSettings={'Type': "Expand", 'Superior': 0, 'Inferior': 0, 'Anterior': 0, 'Posterior': 0, 'Right': 0, 'Left': 0 })

# CompositeAction ends

with CompositeAction('ROI Algebra (Ring1)'):

retval_2 = patient.PatientModel.CreateRoi(Name="Ring1", Color="Pink", Type="Organ", TissueName=None, RoiMaterial=None)

retval_2.CreateAlgebraGeometry(Examination=examination,Algorithm="Auto",ExpressionA={'Operation': "Union", 'SourceRoiNames': ["PTV"], 'MarginSettings': {'Type': "Expand", 'Superior': 3, 'Inferior': 3, 'Anterior': 3, 'Posterior': 3, 'Right': 3, 'Left': 3 } },ExpressionB={'Operation': "Union", 'SourceRoiNames': ["PTV"], 'MarginSettings': {'Type': "Expand", 'Superior': 1, 'Inferior': 1, 'Anterior': 1, 'Posterior': 1, 'Right': 1, 'Left': 1}},ResultOperation="Subtraction",ResultMarginSettings={'Type': "Expand", 'Superior': 0, 'Inferior': 0, 'Anterior': 0, 'Posterior': 0, 'Right': 0, 'Left': 0 })

# CompositeAction ends

Formatted to (Vaguely) Fit Screen

MacLennan 2016 124

Page 125: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The generated code is ready to save and reuse

• The 9 longest lines are extra long because they specify ant/post/sup/inf/left/right margins– They are required, so we can't chop them out

• Could chop out the two extra CompositeActions, but there's really no point

The Code is Good! (But Long)

MacLennan 2016 125

Page 126: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The What and the Why• Tools of the Trade• Two Simple Script Ideas• Writing Scripts in the Real World

– MIM– Velocity– RayStation– Pinnacle– Eclipse

• Next Steps

Table of Contents

MacLennan 2016 126

Page 127: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Scripting is built-in• Many program functions are scriptable

• Has a "Copy my Clicks" style script recorder• Hand-coding to edit recorded scripts*• Hand-coding to make your own scripts*

• Language is proprietary

Pinnacle Scripting

MacLennan 2016 127

Page 128: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Script recorder is a supported feature– Manual tells you how to record actions and save scripts– Support will help you use the script recorder

• You are on your own if you want to edit the code– No official documentation of the language– Support will not help you

Pinnacle Documentation/Support

MacLennan 2016 128

Page 129: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Editing Pinnacle Scripts

MacLennan 2016 129

Page 130: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The language syntax and capabilities can be reverse engineered from recorded scripts and system logs

• Many people have spent a lot of time doing this

• The knowledge pool remains fragmented– Several places to look for these collections of knowledge

Made to be Reverse Engineered?

MacLennan 2016 130

Page 131: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Pinnacle Users Google Group– https://groups.google.com/d/forum/pinnacle3-users

• Guide by Sean Geoghegan, Royal Perth Hospital– 44 page scripting guide published in 2007– Covers core concepts, but no ROI manipulation details– Bundled with dozens of sample scripts

Unofficial Community Support

MacLennan 2016 131

Page 132: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Phone a friend?

Unofficial Community Support

MacLennan 2016 132

Page 133: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• There is no skeleton necessary for Pinnacle scripts

• Just start listing commands

Pinnacle Script Skeleton

MacLennan 2016 133

Page 134: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• We'll use the Script Recorder first

• We'll see if we can figure out what do to from there

Approach for Our Scripts

MacLennan 2016 134

Page 135: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Finding the Script Recorder

MacLennan 2016 135

Page 136: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

HotScripts Window

MacLennan 2016 136

Page 137: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Attempting Script #1

MacLennan 2016 137

• Script recorder is running

• Rename each of the ROIs

• Stop the recorder

Page 138: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

End Recording

MacLennan 2016 138

STOP

Page 139: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

RoiList .Current = 0;IF .RoiList .Current .AssociatedVolume .CanUseSUV .Is .True

.THEN .RoiList .Current .CanUseSUV = True

.ELSE .RoiList .Current .#"CanUseSUV=False";RoiList .Current .Name = "Eye_R";

RoiList .Current = 1;IF .RoiList .Current .AssociatedVolume .CanUseSUV .Is .True

.THEN .RoiList .Current .CanUseSUV = True

.ELSE .RoiList .Current .#"CanUseSUV=False";RoiList .Current .Name = "Eye_L";

RoiList .Current = 2;IF .RoiList .Current .AssociatedVolume .CanUseSUV .Is .True

.THEN .RoiList .Current .CanUseSUV = True

.ELSE .RoiList .Current .#"CanUseSUV=False";RoiList .Current .Name = "OpticNerve_R";

RoiList .Current = 3;IF .RoiList .Current .AssociatedVolume .CanUseSUV .Is .True

.THEN .RoiList .Current .CanUseSUV = True

.ELSE .RoiList .Current .#"CanUseSUV=False";RoiList .Current .Name = "OpticNerve_L";

RoiList .Current = 4;IF .RoiList .Current .AssociatedVolume .CanUseSUV .Is .True

.THEN .RoiList .Current .CanUseSUV = True

.ELSE .RoiList .Current .#"CanUseSUV=False";RoiList .Current .Name = "Chiasm";

Script #1 Output in a Text Editor

MacLennan 2016 139

• More than we need

• We don't care if the ROI can use SUV

• Scrap these lines

Page 140: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

RoiList .Current = 0;RoiList .Current .Name = "Eye_R";

RoiList .Current = 1;RoiList .Current .Name = "Eye_L";

RoiList .Current = 2;RoiList .Current .Name = "OpticNerve_R";

RoiList .Current = 3;RoiList .Current .Name = "OpticNerve_L";

RoiList .Current = 4;RoiList .Current .Name = "Chiasm";

The Part of the Code We Need

MacLennan 2016 140

Translation:

• Make the 1st ROI in the list the active ROI• Set name of the active ROI to "Eye_R"

Problem:• What if the right eye isn't the 1st ROI in the list?

Page 141: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

"Off By One" Error

MacLennan 2016 141

Page 142: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The Google Group is a useful resource– Forum contributor Wyatt Smith posted code for a script

that does almost exactly what we are doing

• https://groups.google.com/d/msg/pinnacle3-users/kANhYx3tXVE/MJjP3dWE-y8J

– He searches by ROI name, not by position in the list– He searches for every common name variant and tries to

perform a rename action on each one– He also specifies a standard color for each ROI

Can We Fix It?

MacLennan 2016 142

Page 143: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Surely one of these will work…RoiList .#"Eye R" .Name = "eye_R";RoiList .#"Eye_R" .Name = "eye_R";RoiList .#"R Eye" .Name = "eye_R";RoiList .#"R_Eye" .Name = "eye_R";RoiList .#"Rt Eye" .Name = "eye_R";RoiList .#"Rt_Eye" .Name = "eye_R";RoiList .#"RT EYE" .Name = "eye_R";RoiList .#"RT_EYE" .Name = "eye_R";RoiList .#"R EYE" .Name = "eye_R";RoiList .#"R_EYE" .Name = "eye_R";RoiList .#"eye RT" .Name = "eye_R";RoiList .#"eye_RT" .Name = "eye_R";RoiList .#"eye_R" .Color = "lightorange";

• Doesn't include "RIGHT ORBIT", but that's easy to fixRoiList .#"RIGHT ORBIT" .Name = "Eye_R";

Excerpt from Wyatt's Code

MacLennan 2016 143

Page 144: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

RoiList .#"RIGHT ORBIT" .Name = "Eye_R";RoiList .#"LEFT ORBIT" .Name = "Eye_L";

RoiList .#"RIGHT OPTIC NERVE" .Name = "OpticNerve_R";RoiList .#"LEFT OPTIC NERVE" .Name = "OpticNerve_L";

RoiList .#"OPTIC CHIASM" .Name = "Chiasm";

Script #1 Wyatt's Way

MacLennan 2016 144

Page 145: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Get the Script Recorder up and running

• Do the expansions and subtractions and ring

• Stop the Script Recorder

• See what we have

Script #2 (IMRT ROIs) in Pinnacle

MacLennan 2016 145

Page 146: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Note: We Need 2 Extra ROIs

MacLennan 2016 146

• PTV_05 = PTV + 5 mm• Bladder_Avoid = Bladder – PTV_05• Rectum_Avoid = Rectum – PTV_05• PTV_10 = PTV + 10 mm• Ring1 = 20 mm ring from PTV_10

Page 147: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Finding the ROI Expansion Tools

MacLennan 2016 147

Page 148: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

The ROI Expansion Window

MacLennan 2016 148

Page 149: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

WindowList .RoiExpandWindow .Create = "ROI Expansion/Contraction...";RoiList .#"*" .ResetRoiExpandState = "Clear All";IF .RoiList .#"#2" .RoiExpandState .Is .Source .THEN .RoiList .#"#2" .ResetRoiExpandState .ELSE .RoiList .#"#2" .RoiExpandState = "Source";RoiExpandControl .CheckTargetRoi = RoiList .#"#2" .Address;RoiExpandControl .ConstantPadding = " 0.5";RoiExpandControl .UseConstantPadding = "1";RoiExpandControl .TargetRoiName = "PTV_05";RoiExpandControl .CreateNewTarget = "1";RoiExpandControl .Expand = "1";RoiExpandControl .DoExpand = "Expand";WindowList .RoiExpandWindow .Create = "ROI Expansion/Contraction...";RoiList .#"*" .ResetRoiExpandState = "Clear All";IF .RoiList .#"#0" .RoiExpandState .Is .Source .THEN .RoiList .#"#0" .ResetRoiExpandState .ELSE .RoiList .#"#0" .RoiExpandState = "Source";RoiExpandControl .CheckTargetRoi = RoiList .#"#0" .Address;IF .RoiList .#"#3" .RoiExpandState .Is .#"Avoid Interior" .THEN .RoiList .#"#3" .ResetRoiExpandState .ELSE .RoiList .#"#3" .RoiExpandState = "Avoid Interior";RoiExpandControl .CheckTargetRoi = RoiList .#"#3" .Address;RoiExpandControl .ConstantPadding = " 0";RoiExpandControl .UseConstantPadding = "1";RoiExpandControl .TargetRoiName = "Bladder_Avoid";RoiExpandControl .CreateNewTarget = "1";RoiExpandControl .Expand = "1";RoiExpandControl .DoExpand = "Expand";IF .RoiList .#"#0" .RoiExpandState .Is .Source .THEN .RoiList .#"#0" .ResetRoiExpandState .ELSE .RoiList .#"#0" .RoiExpandState = "Source";RoiExpandControl .CheckTargetRoi = RoiList .#"#0" .Address;IF .RoiList .#"#1" .RoiExpandState .Is .Source .THEN .RoiList .#"#1" .ResetRoiExpandState .ELSE .RoiList .#"#1" .RoiExpandState = "Source";RoiExpandControl .CheckTargetRoi = RoiList .#"#1" .Address;RoiExpandControl .TargetRoiName = "Rectum_Avoid";RoiExpandControl .CreateNewTarget = "1";RoiExpandControl .Expand = "1";RoiExpandControl .DoExpand = "Expand";RoiList .#"*" .ResetRoiExpandState = "Clear All";IF .RoiList .#"#2" .RoiExpandState .Is .Source .THEN .RoiList .#"#2" .ResetRoiExpandState .ELSE .RoiList .#"#2" .RoiExpandState = "Source";RoiExpandControl .CheckTargetRoi = RoiList .#"#2" .Address;RoiExpandControl .ConstantPadding = " 1";RoiExpandControl .UseConstantPadding = "1";RoiExpandControl .TargetRoiName = "PTV_10";RoiExpandControl .CreateNewTarget = "1";RoiExpandControl .Expand = "1";RoiExpandControl .DoExpand = "Expand";RoiList .#"*" .ResetRoiExpandState = "Clear All";IF .RoiList .#"#6" .RoiExpandState .Is .Source .THEN .RoiList .#"#6" .ResetRoiExpandState .ELSE .RoiList .#"#6" .RoiExpandState = "Source";RoiExpandControl .CheckTargetRoi = RoiList .#"#6" .Address;RoiExpandControl .ConstantPadding = "2";RoiExpandControl .UseConstantPadding = "1";RoiExpandControl .TargetRoiName = "Ring1";RoiExpandControl .CreateNewTarget = "1";RoiExpandControl .DoRingExpansion = "Create Ring ROI";

Script #2 Output in a Text Editor

MacLennan 2016 149

Page 150: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

WindowList .RoiExpandWindow .Create = "ROI Expansion/Contraction...";

RoiList .#"*" .ResetRoiExpandState = "Clear All";

IF .RoiList .#"#2" .RoiExpandState .Is .Source.THEN .RoiList .#"#2" .ResetRoiExpandState.ELSE .RoiList .#"#2" .RoiExpandState = "Source";

RoiExpandControl .CheckTargetRoi = RoiList .#"#2" .Address;

RoiExpandControl .ConstantPadding = " 0.5";RoiExpandControl .UseConstantPadding = "1";

RoiExpandControl .TargetRoiName = "PTV_05";RoiExpandControl .CreateNewTarget = "1";

RoiExpandControl .Expand = "1";RoiExpandControl .DoExpand = "Expand";

Part 1 Under the Microscope

MacLennan 2016 150

Page 151: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

WindowList .RoiExpandWindow .Create = "ROI Expansion/Contraction...";

• Open the ROI Expansion Window

Code Snippet 1 of 7

MacLennan 2016 151

Page 152: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

RoiList .#"*" .ResetRoiExpandState = "Clear All";

• Clear all checkboxes (if not already clear)

Code Snippet 2 of 7

MacLennan 2016 152

Page 153: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

IF .RoiList .#"#2" .RoiExpandState .Is .Source.THEN .RoiList .#"#2" .ResetRoiExpandState.ELSE .RoiList .#"#2" .RoiExpandState = "Source";

• IF Source checkbox for the 3rd ROI is already checked– THEN uncheck it– ELSE check it

• In other words, toggle the Source checkbox on PTV• Why not just tell it we want it checked and

reference the ROI (PTV) by name while we're at it…

RoiList .#"PTV" .RoiExpandState = "Source";

Code Snippet 3 of 7

MacLennan 2016 153

Page 154: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

RoiExpandControl .CheckTargetRoi = RoiList .#"#2" .Address;

• No idea, but it looks important (no documentation)

• Let's at least reference the ROI by name

RoiExpandControl .CheckTargetRoi = RoiList .#"PTV" .Address;

Code Snippet 4 of 7

MacLennan 2016 154

Page 155: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

RoiExpandControl .ConstantPadding = " 0.5";RoiExpandControl .UseConstantPadding = "1";

• Set 5 mm margin• Uniform margin = True

• More readable with the order swapped

RoiExpandControl .UseConstantPadding = "1";RoiExpandControl .ConstantPadding = " 0.5";

Code Snippet 5 of 7

MacLennan 2016 155

Page 156: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

RoiExpandControl .TargetRoiName = "PTV_05";RoiExpandControl .CreateNewTarget = "1";

• Set target name to PTV_05• Creat new ROI = True

• More readable with the order swapped

RoiExpandControl .CreateNewTarget = "1";RoiExpandControl .TargetRoiName = "PTV_05";

Code Snippet 6 of 7

MacLennan 2016 156

Page 157: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

RoiExpandControl .Expand = "1";RoiExpandControl .DoExpand = "Expand";

• We are indeed doing an expansion• Do the expansion

Code Snippet 7 of 7

MacLennan 2016 157

Page 158: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• It's a LOT to take in– Mimics the way a human would do it rather than using a

more straightforward computer method

• Needs some tweaks to make it useful

• Hard if you're just beginning (took me many hours)– There might be a better way to do this

Is the Script #2 Code Any Good?

MacLennan 2016 158

Page 159: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The What and the Why• Tools of the Trade• Two Simple Script Ideas• Writing Scripts in the Real World

– MIM– Velocity– RayStation– Pinnacle– Eclipse

• Next Steps

Table of Contents

MacLennan 2016 159

Page 160: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• API = Application Programming Interface– Back end access to Eclipse session and patient database

• Not built-in. Have to run the Eclipse Scripting API installer to add files that are necessary for script development.– NOTE: Only Varian personnel may make changes to clinical

systems. Must use a different workstation for script development.

Eclipse Scripting API (ESAPI)

MacLennan 2016 160

Page 161: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• 31 page API Reference Guide– Explains main objects and their relationships– Includes instructions for installing API

• Varian Developer Website– https://variandeveloper.codeplex.com

• Training workshops– Example: Pre-conference workshop at AAPM

Eclipse Support

MacLennan 2016 161

Page 162: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Plug-In Scripts– Accessed while in Eclipse

• Stand-Alone Scripts– Separate programs that can access Eclipse data

Types of ESAPI Scripts

MacLennan 2016 162

Page 163: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

using System;using System.Text;using System.Windows;using VMS.TPS.Common.Model.API;namespace VMS.TPS{

class Script{

public Script(){}public void Execute(ScriptContext context){

if (context.Patient != null){

MessageBox.Show("Patient id is " + context.Patient.Id);}else{

MessageBox.Show("No patient selected");}

}}

}

Eclipse Script Skeleton

MacLennan 2016 163

Page 164: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Giving users with unknown training direct access to the database can make serious errors possible

• A badly written script could damage the patient database and alter treatment

Current Varian Scripting Philosophy

MacLennan 2016 164

Page 165: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Not a Likely Outcome of Making Rings

MacLennan 2016 165

Page 166: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• For now, Eclipse script actions are READ-ONLY– No ROI editing– No ROI creation– No beam editing– Etc…

Look But Don't Touch

MacLennan 2016 166

Page 167: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Script #1– Can't rename anything

• Script #2– Can't edit or create new ROIs

That's Going to Make This Hard

MacLennan 2016 167

Page 168: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Could run a check to evaluate ROI names– Produce a list of name changes that the user should make?

Can We Do Anything ROI-Related?

MacLennan 2016 168

Page 169: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Lot's of stuff!– Reports like Clinical Goal Scorecards– Plan quality checks– Data mining

• E.g. - Create a report of rectal V70 dose for all prostate cases in the last 6 months

– Research of many varieties

• But… today we are only talking about ROIs, so that will have to wait for a future presentation

Is There Anything Useful it CAN Do?

MacLennan 2016 169

Page 170: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• The What and the Why• Tools of the Trade• Two Simple Script Ideas• Writing Scripts in the Real World

– MIM– Velocity– RayStation– Pinnacle– Eclipse

• Next Steps

Table of Contents

MacLennan 2016 170

Page 171: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• You are a technical person

• You learned to plan

• You can learn to make scripts

Can I Really Do This?

MacLennan 2016 171

Page 172: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Prostate Planning Structures

Scripts the SPTC Uses Regularly

MacLennan 2016 172

Starting ROIsProstateCTVPTVBladderRectumFemoralHead_RFemoralHead_LCoil_RCoil_LCoil_Apex

Script-Generated ROIsPTVEvalBladder_AvoidBladderWallRectum_AvoidRectalEvalRectalWallEvalAir_In_RectumCoil_R_01Coil_L_01Coil_Apex_01

Page 173: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Proton-compatible patient outline

Scripts the SPTC Uses Regularly

MacLennan 2016 173

Page 174: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Better Brain ROI– 7 Step script that makes a better Brain than built-in tools

• QA Scan Resample and Adaptive Recontour

• CSI PTV Chopper

• Head & Neck OptiPTV Maker

Scripts the SPTC Uses Regularly

MacLennan 2016 174

Page 175: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Lexie Smith Raymond's 18 Opti Structures

• Thomas Constantino's SBRT ROIs

• Yolanda King's Dose Gradient Control Structures

Other Ideas?

MacLennan 2016 175

Page 176: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Pamela Lemish's1 cm junction slicesfor Low GradientField Matching

• 2 hours to write

• Runs in 20 seconds

Other Ideas?

MacLennan 2016 176

Page 177: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Start thinking about where you waste time doing repetitive tasks

• Figure out if a script might help

• TRY IT!

Your Homework

MacLennan 2016 177

Page 178: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

• Sara St. James, PhD, DABR• Eric Ford, PhD, FAAPM• Mark Daniels, BS, RT(T), CMD• Maggie Stauffer, MS• Hazel Ramirez, MS, DABR• Matthew Schmidt• Sean Hames, MS

Acknowledgements

MacLennan 2016 178

Page 179: Grayden MacLennan MBA, MSM, MS, CIIPatlanta2016.medicaldosimetry.org/2016AnnualConference/assets/Fil… · • Grayden worked for MIM Software from 2007-2013, but no longer has financial

Questions?

MacLennan 2016 179