Fig 1.
Screenshot of arbitrary RTXI workspace with core and custom modules.
The workspace is intended to demonstrate the level of user-configurability provided by RTXI, such as channel configurations, combinations of data I/O connections, and saving virtually every programmed element of each module. Additional custom modules are shown (e.g., Spike Detector, FIR Filter, Signal Generator, Neuron Model, etc) to demonstrate the versatility of RTXI’s API system for creation of any utility or model to be used in hard RT, closed-loop experiments. We refer the reader to the up-to-date user manual (S3 File) and tutorials (S3 File) available online for more information on how to navigate the RTXI workspace.
Fig 2.
The bottom block depicts the hardware layer with which RTXI interfaces. RTXI is capable of interfacing with DAQs using either PCI/PCIe, USB, or Ethernet interfaces (see Compatible hardware for more information). Hard RT communication with hardware devices is achieved through Analogy, a set of drivers within the Xenomai framework. The top block of the diagram illustrates the core architecture of RTXI. On each cycle of the RT period, the RT Thread wakes up, acquires new data, executes instructions defined within the hard RT function of both core and user modules (see Custom modules and Application Programming Interface (API)), outputs data to the DAQ, and returns to sleep (idle). Transmission of data to/from different modules is handled by the IO class. When the RT Thread is idle, resources are made available to other system applications and functions. The GUI and Data Storage Threads continuously run with a static period to provide a stable balance between hard RT performance and handling of user input, updating of visualizations, and data storage.
Fig 3.
Example template code available (S3 File) to users for writing custom modules, and corresponding module loaded within RTXI.
(A) Basic C++ header (plugin_template.h) for an RTXI module. (B) Users can declare inputs, outputs, states, parameters, and events for custom modules through the DefaultGUIModel struct and (C) implement hard RT code within the execute function. (D) The update function allows execution of state-specific code for the module. (E) The module after it is compiled with the provided Makefile and loaded into RTXI. Each element of the module GUI is tied to a specific line of code. For example, when “Button A” is clicked, the aBttn_event() (line 35, A) code is executed. Similarly, the “GUI label” (lines 5–6, B) and “A State” (lines 11–13, B) components of the GUI are created by the vars struct and their values are initialized from the INIT block of the update() function (lines 8–9, C). Visit the GitHub repository (S3 File) for complete corresponding C++ implementation (plugin_template.cpp) file.
Fig 4.
Hierarchical data format data file generated by RTXI.
Each trial is represented as an ordered group of data and metadata objects. By default, RTXI saves parameter values from all modules when recording is started into the “Parameters” group. All enabled DAQ AI channel configuration settings are also saved into the “System Settings” group. HDF5 files can be opened, modified, and appended to from a variety of post-hoc analysis frameworks (e.g., HDFView, MATLAB, R, Python).
Fig 5.
System performance under different computational loads and closed-loop configurations.
(A) System configurations tested. (B) System I/O latency does not exceed twice the system period (50 μs) nor are I/O events missed in all test cases, demonstrating hard RT performance and a delay of no more than one sample. (C) Distribution of measured RT periods in each tests case by the Real-Time Benchmarks module. The RT period should never exceed twice the desired RT period, otherwise hard RT behavior is compromised. The increase in RT period variability with increasing computational loads is predominantly from the initial time frame after which a protocol starts execution. This is represented by the RT period jitter data (D), which demonstrates the RT period stabilizing within the first few minutes of execution. (E) Time spent processing the execute() function of all loaded module on each RT loop cycle.
Fig 6.
Artificially modulating neuronal excitability mimics learning-induced increase in frequency, but not the regularity, of buccal motor pattern (BMP) genesis.
(A) Experimental protocol and equivalent electrical circuit for the addition of a dynamic-clamp-defined leak conductance (Gleak) to the natural input conductance (Gin) of an individual neuron using RTXI. (B) Introduction of an artificial Gleak of −60 nS (shaded panel) increased the excitability of a target B63 neuron (indicated by a decrease in spike threshold) compared with that arising from the natural leak conductance alone (i.e., Gleak: 0 nS). Horizontal and vertical scale bars represent 2 s and 20 mV, respectively. In (C), Gleak was introduced into one of B63, B30, or B65. In (D), Gleak was introduced into a B63 and current pulses for measuring coupling coefficients were injected into either postjunctional B30 or B65. (For details, see [35] Fig. S1.) (E) In a control preparation, the frequency, but not the regularity, of spontaneous BMP genesis and associated spike bursts in B63/B30/B65 increased in response to a dynamic-clamp-defined Gleak of −60 nS (shaded panel) introduced simultaneously into the three neurons. Horizontal and vertical scale bars represent 30 s and 25 mV, respectively. (F and G) Quantification of changes in frequency (F), but not irregularity (G), of BMP generation for different values of artificial Gleak added simultaneously to the three neurons. Group data show means ± SEM and individual sample sizes. All figures obtained and modified with permission from [35].
Fig 7.
Hard RT distorted auditory feedback system.
(A) Simplified diagram of the acoustic feedback system. When not triggered (top), the system computes the root mean square (RMS) of the input signal. When the RMS exceeds the threshold, the system is triggered. When triggered (bottom), the system computes the spectrogram of the most recent 20ms of signal and computes the correlation coefficient of this spectrogram with the spectrogram of the template sound (e.g., song syllable). The template sound is detected when the correlation coefficient exceeds a threshold value; in this case, acoustic feedback can be generated. Both the input and the acoustic output are saved to the computer hard drive. (B) Spectrogram of the song of a Bengalese finch and the times of occurrence of one of the song syllables. The system was programmed to only detect the occurrences of the target syllable in real time, no acoustic feedback was generated. The detection times are shown as vertical red lines. Bottom: the system is detecting the target syllables (vertical red lines) and is generating acoustic feedback after detection. The acoustic feedback waveform is shown below. The feedback signal is one of the birdsong syllables; the acoustic feedback pickup by the microphone is visible on the spectrogram. The zoomed-in spectrogram of the template is shown on the right. (C) DAF increases the duration of the time interval between Bengalese finch song syllables. Histogram depicts the time intervals between two subsequent syllables in the song in the presence of DAF (blue) and without DAF (red). The means are: Δtmean = 74.8ms (control, N = 637 syllables) and Δtmean = 75.7ms (feedback, N = 97 syllables), the difference is statistically significant (p = 0.001, two-way Kolmogorov—Smirnov test). All figures obtained and modified with permission from [38].
Fig 8.
Optimization of therapeutic benefit of tACS via closed-loop EEG feedback-controlled tACS.
(A) Hard real-time closed-loop protocol used for feedback-controlled delivery of tACS. EEG are measured and amplified prior to sampling with RTXI while the subject opens and closes their eyes every 30 seconds. EEG data from international 10–20 system sites O2, A1, and A2 are processed in hard RT using a custom module written to measure the alpha band power within a one second window. The computed power is validated against a threshold criteria, which determines the tACS amplitude to be delivered. The output from RTXI is connected to an external current-controlled stimulation and isolation unit. Sample alpha-filtered EEG traces with and without feedback-controlled tACS are shown in (B). Feedback-controlled tACS (C) almost completely suppressed alpha band power in a targeted way (Ratio ECα to EOα = 1.03, p = 0.041). Dose-matched random tACS (D) also suppressed alpha band power (normalized random-No Stim = −0.31, p = 0.0183), but was less effective than feedback-controlled tACS (normalized feedbackα—randomα = −0.10, p = 0.0145). All figures obtained and modified with permission from [14].