The Dragonfly Macro Engine for Executing Recorded Tasks in Image Processing and Visualization Mathieu Gendron 1 , Nicolas Piche 1 , Mike Marsh 1 1. Object Research Systems. Montreal, Canada. Automated data collection can outstrip data processing. A proven solution for dealing with routine processing is software macros that capture and reproduce sequences of user actions [1]. Since high- throughput imaging technologies are now affecting both 2D and 3D workflows, we have developed an image processing and visualization platform, called Dragonfly, that addresses data processing challenges with a user-friendly macro engine for recording, encapsulating, and executing processing pipelines in a scalable and highly flexible way. We report here on the unique architecture of the Dragonfly platform, the design of the macro engine, and macro-driven application examples. Dragonfly is the result of a software engineering effort whereby our team refactored an existing general- purpose application, called Visual SI, with the expressed goal of tightly integrating Python for the benefit of both developers and end-users. Python is an interpreted, high-level programming language that has gained widespread adoption in scientific programming [2]. The Dragonfly architecture reproduces a common software engineering pattern where compute-intensive code is decoupled from program logic. Taking advantage of this means that image processing and visualization is implemented in compiled code (C++) and system-level libraries (e.g. OpenGL), while the performance-insensitive application logic is coded in Python. Like other coupled-approach tools that came before [3], Dragonfly enjoys fast performance of performance-critical routines but also the rapid application development and short debug cycles of interpreted languages. Because Dragonfly’s API is open, end-users can also take advantage of Python for rapid development of plugins to extend Dragonfly functionality. Furthermore, the tight Python integration delivers users an embedded Python console directly in the application. This empowers users to prototype ideas directly in the rich graphical application in a way similar to how MATLAB (The Mathworks; Natick, Massachusetts, USA) developers test solutions on that platform. This Python integration is integral to Dragonfly’s macro engine. Dragonfly generally lets users execute arbitrary Python code to accomplish tasks, and the macro engine is a special case of executing Python code. The macro engine lets users automatically capture sequences of user interaction directly into a user macro, which is a special case Python script. Use of the automatic capture system is not strictly necessary as advanced users could bypass the recorder and choose to author a macro from scratch like any general purpose Python script. The macro player lets users play back those user macros with advanced playback features. Again, advanced users could bypass the player and execute the code directly from the console or from other contexts. A critical ingredient of Dragonfly’s design is the interface pattern that specifies that atomic user actions be encapsulated as single methods. In practice, this means that typical user activity (e.g. applying an image filter, adjusting a viewer camera angle, thresholding an image, etc) are defined by methods that meet a particular interface specification. The interface defines the method’s input and output datatypes using the standard Python docstring convention, and any Python method can be designated as a interface 246 doi:10.1017/S143192761700191X Microsc. Microanal. 23 (Suppl 1), 2017 © Microscopy Society of America 2017