The Medical Physicist as Computer Geek: Custom Software in the Clinic Brian Tonner, Ph.D. Moffitt Cancer Center Tampa, Florida Florida AAPM Fall Meeting Sarasota Florida, November 2015 NO CONFLICTS OF INTEREST.
Presentation Goals Why should you consider custom software in the clinic? What are some examples? How is it done?
Physics toolbox, circa 1970
Physics toolbox, circa 2020
Is Medical Physics doomed? The AAPM proposes Medical Physics 3.0: the new paradigm of clinical medical physics practice extending from traditional insular models of compliance towards team-based models of operational engagement. OLD RTT MD NP/PA NEW MD RTT NP/PA QMP QMP
Following the data PROCESS INTAKE DATA Medical Record CONSULT CT/MR/Path/Rx SIM CT/Fusion PLANNING DICOM-RT QA QA record TX Chart F/Up Report
What can software development achieve in the clinic? Eliminate repetition in clinical tasks Improve efficiency of team member s efforts Remove road-blocks between vendor s products Custom Software Development RESEARCH (Large teams, extensive examples) CLINIC (Smaller team, fewer examples)
What about the U.S. FDA? Medical Device Regulation FDA's Center for Devices and Radiological Health (CDRH) is responsible for regulating firms who manufacture, repackage, relabel, and/or import medical devices sold in the United States. In addition, CDRH regulates radiation-emitting electronic products (medical and non-medical) such as lasers, x-ray systems, ultrasound equipment, microwave ovens and color televisions. Software Validation Any software used to automate any part of the device production process or any part of the quality system must be validated for its intended use, as required by 21 CFR 820.70(i). (i) Automated processes. When computers or automated data processing systems are used as part of production or the quality system, the manufacturer shall validate computer software for its intended use according to an established protocol. All software changes shall be validated before approval and issuance. These validation activities and results shall be documented. Lack of regulation is not evidence of absence of responsibility.
Examples of Four Application Techniques Glue programming Small utilities that pass data from one application to another In-application scripting Uses internal tools of application Visual Basic for Applications (VBA) is one common example Application extension Uses applications hooks (the Application Programming Interface or API) Allows for significant customization of how an application interacts with external data and users Free-standing applications Use elements of all of the above
Glue programming Refers to a technique of passing data through multiple applications using a control program Glue programming can be done in nearly any computer language, but some are more convenient than others Component Object Model Interface R & V TPS D I C O M Control Program ( Glue ) S F T P
Problem: Multi-vendor environment doesn t permit patient plan transfer to treatment machine Pinnacle TPS, Varian TrueBeam, Elekta Mosaiq TPS located off-site, two hospital fire-walls in between Vendors unable to resolve problem Solution: Wrote a custom software interface between TPS and R&V.
Application Extension Modern applications (Pinnacle, Eclipse, Raystation, Microsoft Office, etc.) include some form of application extension capability For Pinnacle, this can be done by a process of scripts that call external programs that create call-back scripts Pinnacle Script: Calls external program External Program (located anywhere; any language) Creates Callback Script for Pinnacle Call-back Script runs in Pinnacle
Problem: TPS does not adequately import dose distributions Dose can be imported but only for review: not a real distribution Needed to import dose from any valid DICOM source Need to interface to DIR/fusion software for adaptive planning SOLUTION: Wrote custom GUI-based system for flexible dose import from any source (DICOM) Dose can be scaled to represent BED Can optimize over the dose (but not usually recommended) Interfaces seamlessly with adaptive planning software (DIR) Supports many research projects Wit extreme caution, can be used in a clinically advisory manner
Problem: Need to track changes and approvals in TPS Plan approval needs electronic signature at TPS review time Need contour, fusion, etc. approval within TPS Need notes and approvals to transfer to R&V with plan SOLUTION: Pinnacle Post-it Notes Fast and easy to use Keeps track of instructions for planning ( post-it notes) Includes electronic signature for Contours, Plan, Physics, Other Printouts bundled with plan
Problem: Eliminate cases of couch collisions Perform a virtual collision check at planning time Eliminate need to use gantry time Support research on SNARC (4-pi) treatments Mathematics handled by an external program SOLUTION: Simple In-Pinnacle tool implemented Main limitation is accuracy (5 deg) and requires training Valuable compared to having nothing else! A much improved 3D version is discussed later in the talk
Problem: Poor TPS performance Many thousands of patients in database leading to slow performance TPS tools for archive and restore interfered with workflow and were not user-friendly SOLUTION: Wrote custom GUI based Archive and Restore tools. Successfully archived over 12,000 patients. The custom software toolbase is now in use to create a DICOM database for deep introspective data-mining.
Problem: High volume TPS, need to customize by user Need custom scripts and TPS configurations Pinnacle Launchpad is not user friendly Solution: Individual login s plus Personal Pinnacle Automated creation and configuration of individual logins Personal Pinnacle is an easy to use, flexible search tool to find your patients Creates a recent patient list to select for planning
Problem: Need a safe TPS based Plan Review tool Peer review process needs to load and display 30-50 patients in a weekly session TPS forces a halt to work for an entire ½ day No way for two people to view a given plan at the same time No way to view two plans for same patient at same time Solution: Peer Review tool Opens plans in Read Only mode. As many copies as needed can be open. Dramatically speeds up opening up to 50 plans at a time.
Free-standing applications Data collected through DICOM import/export Processing through custom software Viewing and analysis using OTS (off-the-shelf) software
Problem: How to verify VMAT plans are delivered as designed? TPS only plans for control points; machine interpolates between them Multiple file transfers between 3 rd party systems opens up possibilities for data corruption Desire to check on machine performance treatment by treatment USER INPUT Soft QA TRAJECTORY LOGS LINAC TPS DICOM INPUT TRANSLATION R&V DICOM TRANSLATION INPUT TrueBeam XML TRANSLATION INTERNAL FORMAT INTERNAL FORMAT INTERNAL FORMAT Solution: Soft QA compares ORIGINAL plan (RTPLAN) to Trajectory logs A GUI based tool was written and automated scripts Used to evaluate initial and day-to-day VMAT performance Helped identify factors that produce lower pass rates for certain VMAT plans
Loading Data for Analysis Select Directory containing RTPLAN.dcm and *.bin/*.txt Trajectory Logs Program reports progress and analysis details. Can cut-and-paste output.
Import Verification Basic plots and reports Quick CP review MLC Plan & T.L. Trajectory Log Summaries MLC Actual - Expected Leaf error (plan-actual)
Creates Spreadsheets of Trajectory Logs and Beam QA Program reports xls file creation progress. From QA spreadsheet. From Trajectory Log spreadsheet (partial).
Comprehensive MLC analysis Overall MLC leaf error histogram (#CP s x #MLC s) Leaf error probability (all beams in plan) Maximum Leaf Error, by Beam Max Leaf Speed, by Beam
Problem: Simplify plan review Compare plan achieved results to Department/Physician guidelines (dose objectives review) Print report as PDF suitable for R&V import Reduce data entry by hand SOLUTION: xlsdvh a program that takes output from any TPS and creates an Excel spreadsheet and PDF report Export plan, structures, and dose in DICOM format from TPS Select a template made very simply in Excel Review and edit if needed, save as PDF
3D modelling of couch collision problem Implemented on the 3DSlicer platform Very accurate (0.5 degree and 1 cm) Dynamic collision checking: all parts are movable Under development to simplify user interface Accurate CAD 3D model of linac
How is it done? Nearly everyone has used a custom spreadsheet VBA (Visual-Basic for Applications) can extend that spreadsheet to external software Often, more than one software tool or language is needed PERL, shell, Python, C/C++/C#,.NET, SQL All custom software (including spreadsheets) needs QA Called unit testing in software development, it can be accomplished with sets of trial data and tested outputs Every change, even simple ones, requires completing unit testing
Varian Eclipse Scripting C++ based API Plug-in and Stand-alone applications Comprehensive documentation
Philips Pinnacle3 Scripting In clinical mode, uses Pinnacles internal scripting language Still the main documentation: Scripting on the Pinnacle-3 TPS, Sean Geoghegan, Perth Hospital, 2007 In research mode, can develop plug-ins in C++ or in Python Can extend clinical Pinnacle scripts with external Python, perl, or shell script executables Many scripts traded between Pinnacle users Help available on the Google Pinnacle Users Group
FLEXIBILITY Scripting Languages vs. Compiled Programs FEATURE SCRIPTING COMPILED Rapid development +++ - Learning curve ++ - Available resources + + Program Size -- ++ Program Speed --- +++ SCRIPTS COMPILED PERFORMANCE
Who uses Python and for what? PYPL PopularitY of Programming Language Index (2015, based on Google search data) Rank Language Share Trend 1 Java 24.4 % +0.1 % 2 Python 11.3 % +1.1 % 3 PHP 10.9 % -0.6 % 4 C# 9.1 % +0.3 % 5 C++ 7.7 % -0.4 % 6 C 7.5 % -0.3 % Python is used in more than 1/3 of the world s servers It is used by large scientific computing groups at LLNL, NIH, and NASA It is part of a surprising number of commercial products, like DropBox. 7 Javascript 7.1 % +0.3 % 8 Objective-C 5.2 % -1.1 %
Simple Python program
Features of Python Very rapid GUI-based program development PyQT5 for Windows, Mac, Linux, Android, ios wxpython for Windows Extensive scientific subroutine availability Full availability of DICOM and image rendering tools Polished plotting (very similar to MatLab ) Math extensions run in optimized C-code (fast) Python is integrated into RayStation (Raysearch Labs) Python is available as an extension to Pinnacle Scripting Language Python is integrated into Pinnacle in research mode
Dicompyler: open-source plan review tool 2D viewer with DVH s Extensible with Python plug-ins
3DSlicer : an open source medical physics tool Supported by NCI, NIH, etc. Compiled C code; Python scripting interface Auto-segmentation, DWI, Deformable registration, many other applications
Verify, Verify, Verify Build on what has gone before. All software needs to be extensively tested; quality assurance must be performed by the medical physicist before any custom software is used in the clinic Be realistic about your skill and confidence level Note what an open-source program includes in it s copyright:
How we see medical physics.
How others see medical physics
How they might see medical physics THANK YOU!