Shady: A software engine for real-time visual stimulus manipulation.
Academic Article
Overview
abstract
BACKGROUND: Precise definition, rendering and manipulation of visual stimuli are essential in neuroscience. Rather than implementing these tasks from scratch, scientists benefit greatly from using reusable software routines from freely available toolboxes. Existing toolboxes work well when the operating system and hardware are painstakingly optimized, but may be less suited to applications that require multi-tasking (for example, closed-loop systems that involve real-time acquisition and processing of signals). NEW METHOD: We introduce a new cross-platform visual stimulus toolbox called Shady (https://pypi.org/project/Shady)-so called because of its heavy reliance on a shader program to perform parallel pixel processing on a computer's graphics processor. It was designed with an emphasis on performance robustness in multi-tasking applications under unforgiving conditions. For optimal timing performance, the CPU drawing management commands are carried out by a compiled binary engine. For configuring stimuli and controlling their changes over time, Shady provides a programmer's interface in Python, a powerful, accessible and widely-used high-level programming language. RESULTS: Our timing benchmark results illustrate that Shady's hybrid compiled/interpreted architecture requires less time to complete drawing operations, exhibits smaller variability in frame-to-frame timing, and hence drops fewer frames, than pure-Python solutions under matched conditions of resource contention. This performance gain comes despite an expansion of functionality (e.g. "noisy-bit" dithering as standard on all pixels and all frames, to enhance effective dynamic range) relative to previous offerings. CONCLUSIONS: Shady simultaneously advances the functionality and performance available to scientists for rendering visual stimuli and manipulating them in real time.