Vilim Štih, Luigi Petrucco, Andreas M. Kist
We present Stytra, a flexible, open-source software package, written in Python, that we designed to cover all the general requirements involved in larval zebrafish behavioral experiments. It allows timed stimulus presentation, interfacing with external devices and simultaneous real-time tracking of position, tail and eye motion in both freely-swimming and head-restrained preparations. It logs in standardized formats all recorded quantities, metadata, and code version to allow full provenance tracking, from data acquisition through analysis to publication. The package is modular and expandable for different experimental protocols and setups. Current releases can be found at https://github.com/portugueslab/stytra. We also provide complete documentation with examples for extending the package to new stimuli and hardware, as well as a schema and parts list for behavioral setups. We showcase Stytra by reproducing two previously behavioral protocols, one with head-restrained and the other with freely-swimming larvae, as well as an experiment in which the software is used in the context of a calcium imaging experiment, where it can trigger and communicate with other acquisition devices. Our aims are to help laboratories with little or no experience in the field to start implementing behavioral experiments and to provide a platform for sharing stimulus protocols to enable easy reproduction of experiments and straightforward validation. In addition, Stytra can easily serve as a base platform to design behavioral experiments in other model organisms.