Custom codes were written for the NodeMCU ESP-32S board (C++, Arduino), the control computer (Python), and for processing of collected data (R). All code can be found on corresponding GitHub repositories.
C++ code based on the Arduino framework which runs on the NodeMCU ESP-32S board simply receives samples from the HX711 IC and forwards it to the computer through its USB connection. Communication with the HX711 IC is done using the HX711 library6, making the code portable to other targets specified in the library’s documentation, including typical AVR-based Arduino boards, simply by adjusting the appropriate pin definitions. The code can be found on GitHub7.
Before starting the experiment, a WAVE sound file named startlesnd.wav needs to be constructed for the entire duration of the experiment, with short pulses of white noise with or without prepulses, separated by a silence of appropriate duration, depending on the experiment that is being performed. We used Audacity to generate this file according to the specification detailed in Supplement 1. It is available as Supplementary Audio Material 1.
The computer runs Ubuntu, a Linux distribution, with PASTA Chef, a Python script on the computer, which automates the entire startle experiment and prepares .pasta files for further analysis. It starts by asking the user for the test animal’s name which will provide the data output file name, as well as the test animal’s mass, after which the experiment starts. Before starting, it is advisable to reset the communication bridge board using the on-board RESET button (labeled EN on the NodeMCU ESP-32S board). The sound file is loaded and playback is started automatically at the same time as data logging. During the experiment, scale data is also plotted on-screen in real time using pyqtgraph. After the experiment is done, all raw data files with the file extension .pasta can be found in the data directory, as well as a mass.json file which contains masses of all test animals. A caveat of this setup is that, without extensive kernel and sound system modification and reconfiguration, there is no way to precisely synchronize the recording to the timestamps in the data. This is further discussed in Supplement 2, and is a subject of our ongoing research. Startle latency can still be obtained by videotaping the experiment and correcting PASTA output according to the video. The code for PASTA Chef can be found on GitHub8.
A helper program, C.A.V.A.9, was used to visualize the sound output on the computer screen, so that the exact moment when pulses are played can be registered during video analysis without relying on combined video-audio recordings.
To make data processing and visualisation easier, we have created an R package called ratPASTA (R-based Awesome Toolbox for PASTA), available from the Comprehensive R Archive Network (CRAN10) and from GitHub11. Briefly, the function loadStartleData(), loads and automatically merges all startle files from the folder. Unless otherwise specified, values are corrected for animal mass, and pulses are identified based on the inbuilt metadata. If necessary, users can manually specify which files to load and input custom metadata for puls identification. The functions basicStartlePlot() and startlePlot() are used to plot several graphs, whereas the function summariseStartle() returns a mathematical summary of the data. If users wish to expand the analysis, the output of the loadStartleData() function is a data frame and it can be used as an input for custom build functions. Detailed information is provided on the website of the package12.
Finally, to make the whole system more even user friendly, a Python wrapper package for ratPASTA (pastaWRAP) was developed to enable more streamlined data acquisition and analysis pipeline in a single programming environment (Python). pastaWRAP is available from the Python Package Index (PyPI)13, and the source code can be found on GitHub14.