{'fraction_non_alphanumeric': 0.028045271436792633, 'fraction_numerical': 0.01131785919815845, 'mean_word_length': 4.932180245789713, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Regulation of arousal via online neurofeedback improves human performance in a demanding sensory-motor task

Significance Our ability to make optimal decisions, judgments, and actions in real-world dynamic environments depends on our state of arousal. We show that we can use electroencephalography-based feedback to shift an individual’s arousal so that their task performance increases significantly. This work demonstrates a closed-loop brain–computer interface for dynamically shifting arousal to affect online task performance in accordance with the Yerkes and Dodson law. The approach is potentially applicable to different task domains and/or for clinical applications that utilize self-regulation as a targeted treatment, such as in mental illness.


An intuitive overview over the feedback conditions
The aim of this study is to investigate whether down-regulation of arousal via instantaneous electroencephalography-derived neurofeedback, can improve performance in a dynamic, increasingly difficult visuo-motor task, consistent with the Yerkes and Dodson law.
To test this hypothesis in our main experimental block, there were three feedback conditions. One condition was called BCI, where veridical neurofeedback was presented as changes in the loudness of an audio signal of a human heartbeat that was replayed in a loop. There were two control conditions: Silence, where no audio was provided and sham, where a mix of veridical neurofeedback and randomly generated signal were mapped onto the loudness of the same audio of a human heartbeat that was also used with condition BCI.
For condition BCI, the output of the electroencephalography based decoder (variable BCI below) was smoothed in time over 5 seconds and then mapped directly onto the loudness of audio of a human heartbeat playing repeatedly. Loudness was thus directly related to the decoded arousal state as in FeedbackAudioLoudness = BCI (Eq. S1) where the dynamic range of the BCI output can be thought of lying between 0 and 100 % with 100 % corresponding to maximum decoded arousal.
For control condition Sham, the same signal from the electroencephalography based decoder was mixed with random signal that had similar spectral characteristics, but was generated as novelty observations from an autoregressive model and is referenced here as AR_BCI. The loudness of the audio feedback for condition Sham was determined as FeedbackAudioLoudness = ½ * BCI + ½ * AR_BCI (Eq. S2) where the dynamic range of AR_BCI was 0 to 100 % with 100 % corresponding to maximum arousal.
For condition silence, no audio was presented and the loudness of the audio feedback was thus statically assigned as FeedbackAudioLoudness = 0 (Eq. S3) The variable FeedbackAudioLoudness (dynamic range 0 to 100 %) was finally mapped to a range of 0 to 50 % of the system audio volume on the Windows 7 computer that played the actual audio feedback, to make sure that the maximum feedback intensity would not be unpleasant or dangerously loud for the participants.

Omnibus statistics for dependent variable flight length
Ordinary least squares regression of our experimental variables onto the dependent variable flight time for data from 18 of 20 subjects indicated a statistically significant effect in the interaction between the factors course and feedback-condition (see Table S1). We followed up with analysis of variance, confirming significance of the interaction between course and feedback-condition (see Table S2). In the main article we report the results of post-hoc tests to test our specific hypotheses.  Table S2. Analysis of variance table for ordinary least squares regression of experimental variables onto the dependent variable flight length. + P<0.1, * P<0.05, ** P<0.01, *** P<0.001. The post-fix "Z" for the dependent variables above indicates which scores have been centered and scaled to unit variance. CV stands for cross-validation and AUC for area under the receiver operator characteristics curve.

Verification of assumptions for ordinary least squares regression
After threshold based outlier rejection, an additional 10 of 415 observations were iteratively removed based on standard diagnostic plots (see Fig. S1) and R heuristics until error residuals met statistically tested requirements related to skewness, kurtosis, heteroscedasticity and the link function (R package GVLMA, version 1.0.0.2; (1)). To control for multicollinearity, we made sure the generalized variance inflation factor (GVIF) corrected by degrees of freedom was lower than 2.5 for every independent variable.

Evidence for how neurofeedback modulated arousal
The aim of this supportive analysis was to test whether there was a relationship between decoder output and arousal or arousal change and if so, whether the nature of that relationship was in line with our main hypotheses. Specifically, since the EEG-based decoder is trained to track arousal, we would expect that the output of the decoder is correlated with pupil size, a known correlate of arousal. High frequency (HF) heart rate variability (HRV) on the other hand has been frequently found associated with changes in stress levels (2). However, it is important to note that HF HRV is more specifically understood to reflect modulation in vagal tone rather than vagal tone itself (3). For the experiment we instructed participants to use the audio feedback to down-regulate their arousal. Given this instruction, we had expected to see modulation of vagal tone (as measured by HF HRV) in association with changes in decoder output, but only when subjects were presented with veridical neurofeedback and used it to downregulate their arousal and not in condition silence, when the feedback was completely withheld.
In support of our prediction and our main hypotheses, we found that decoder output statistically significantly predicted HRV, but only when subjects also heard the decoder output (statistically significant interaction in linear mixed effects That means, when subjects heard the veridical feedback and were trying to downregulate their arousal based on the feedback (as per instruction), smaller decoder output (corresponding to a lower level of inferred task-dependent arousal) was associated with higher HRV (i.e. a change toward lower "stress"; (2)). Decoder output alone, did not significantly predict HRV (P>0.69). This is in line with our prediction, since there can be no decoder mediated modulation of vagal tone if subjects do not hear the decoder output. This outcome supports the main findings of the study also in that it can be interpreted as evidence, that subjects followed instructions in that they tried to down-regulate arousal based on the feedback and, even more importantly, that subjects were successful at regulating their arousal based on the feedback, since changes in decoder output were significantly correlated with concurrently observed HF HRV. Trivially and as expected, boundary size and FB-type both also significantly predicted HRV (both P<0.0001) such that smaller boundaries (higher task difficulty) was associated with lower HRV ("increasing arousal") and the presence of feedback alone also led to higher HRV ("lowering arousal").
Analogously, pupil size was statistically significantly predicted by the interaction of decoder output and feedback type (β=-0.020, SE=0.0094, t(2708)=-2.19, P=0.0287, 95% CI [-0.039 -0.002]), so that the same level of decoder output was associated with smaller pupil size when the decoder output was audible relative to when the feedback was not audible to the subject (linear mixed effects model; R 2 =0.623, Adjusted R 2 =0.622). This means, when subjects heard the veridical audio feedback and were also trying to down-regulate their arousal based on that veridical feedback, their pupil size was lower relative to when the feedback was inaudible. In contrast to the case of HRV and in line with our prediction, pupil size was statistically significantly predicted also by decoder output alone so that higher decoder output (higher level of inferred task-dependent arousal) was generally associated with larger pupil size (P<0.0001). Overall, this outcome is in line with our prediction and supports the main results of this experiment.
Details: For these analyses, averages for decoder output (averaged over 5 second time windows), HRV (pNN-35ms; computed across sliding window that was 10 seconds wide) and pupil size were extracted from within 2 second time windows before the rectangular boundaries from all of the hard task for when veridical feedback was provided ("BCI") and for when "no feedback" (silent) was provided. "BCI" and "no feedback" represented two levels of the factor FB-type. Separate linear mixed effects models were set up for the dependent variables HRV and pupil size. The independent variables were the categorical predictor FBtype, the continuous predictors decoder output and boundary size (3 sizes in this course) and the interaction of decoder output and FB-type. Subject number was included as a random effect to account for inter-subject differences.  Fig. S2). Heart rate variability (HRV) was also significantly lower in course type hard than in course type easy, also indicating higher arousal in course type hard (hard: -0.49 ± 0.57; easy: -0.10 ± 0.47; t 12 =2.523, P=0.027, R 2 =0.347; see Fig. S3). Even heart rate, where otherwise no significant effects were found, was significantly higher in course type hard than in course type easy, also indicating higher arousal in course type hard (hard: 0.16 ± 0.51; easy: -0.19 ± 0.59; t 13 =-3.495, P=0.004, R 2 =0.484; see Fig. S4).

Fig. S2.
We computed baseline pupil size in control condition silence for the two courses hard and easy by normalizing pupil size within subject and ring size (large and medium) and then collapsing the dimension ring size by computing the mean. This normalized pupil size was interpreted as a correlate of general arousal throughout each course. A two-sided t-test for dependent samples yields the Pvalue over the bracket, which we interpret as a statistically significantly larger pupil size in course hard relative to easy. This supports the assumption that arousal in course hard is higher than in course easy.

Fig. S3.
We computed baseline heart rate variability (HRV) for the two courses easy and hard by normalizing the HRV metric pNN-35ms within subject. Only data from the first section (large rings) was included since flight time was significantly shorter in the hard course. Contrary to pupil size and heart rate which can be estimated robustly based on seconds of data, high frequency HRV captures signal dynamics that are typically estimated from dozens of seconds or minutes. The P-value over the bracket was computed based on a two-sided t-test for dependent samples and is interpreted as a statistically significantly lower HRV in course hard relative to easy. This result supports the hypothesis that the baseline level of arousal in course hard is higher than in course easy (2). Fig. S4. Baseline heart rate in control condition silence for the two courses hard and easy was computed analogously to pupil size by first normalizing heart rate within subject and ring size (large and medium) and then collapsing the dimension ring size by computing the mean. The so attained normalized heart rate is again interpreted as a correlate of arousal throughout each course. A two-sided t-test for dependent samples yields the P-value over the bracket, which we interpret as a statistically significantly larger heart rate in course hard relative to easy. This result supports the assumption that the baseline level of arousal in course hard is higher than in course easy.

Pupil size for different time windows
For the condition BCI in the hard course, where performance increased, we found significantly decreased pupil size, but only in time window [1,2] s relative to medium sized rings (see Fig. S5) and not in the second directly after passing medium sized rings ([0, 1] s; see Fig. S6). We think this could be due to interfering effects that have been documented in literature as we mention in the result section of the main article.

Fig. S5.
For the hard course, normalized pupil size in the time window 1 to 2 s after medium sized rings was significantly smaller in condition BCI as compared to sham or silence. No significant differences in pupil size were found between control conditions in the hard course or between any conditions in the easy course. In other words, pupil size was only significantly decreased in the condition where increased task performance was observed. Numbers over brackets between boxplots represent uncorrected P-values of paired t-tests.

Fig. S6.
In the time window 0 to 1 s after medium sized rings, we found no significant differences in pupil size between any conditions in hard or easy course. Numbers over brackets between boxplots represent uncorrected P-values of paired t-tests.

Different metrics for high frequency heart rate variability
For the hard course, we found HRV increased with BCI feedback relative to sham and silence. Any such effects were absent for the easy course where no concomitant performance increase with BCI feedback was observed. This pattern of effects was observed across a variety of metrics that capture high frequency HRV, which is unsurprising as these metrics are known to be correlated (see Fig. S7). The metric pNNx is a widely used measure for short term, high frequency HRV, which was reported to be generally associated with levels of "stress" (2), but is more specifically understood to reflect a modulation in vagal tone (3). From a more practical perspective, pNNx has been shown to hold "diagnostic and prognostic information" (4) for a range of clinical and nonclinical conditions that interfere with the parasympathetic nervous system (e.g. references (5) to (8), etc.). Mietus and colleagues (4) showed that the sensitivity of the pNNx metric to detect a particular condition can be improved by tuning the parameters x to values lower than 50 ms, and presented significant improvements in separability for conditions like congestive heart failure, sleep/wake status or age. In our experiment, x=35 ms (pNN0.035) showed overall the highest sensitivity to the experimental conditions and is reported in the main article, but results based on the other configurations of pNNx and HRV metrics are consistent. If we, despite the inherent dependence between these different metrics, conservatively subject all 72 comparisons in Fig. S7 to false discovery rate based correction for multiple comparisons, the reported effects are still significant at P<0.05 (P Corr =0.032 for both Sil vs BCI and Sham vs BCI for the hard course and pNN0.035).

Fig. S7.
Statistical comparisons between experimental conditions for typical high frequency heart rate variability (HRV) metrics. Rows correspond to different metrics and columns to binary statistical comparisons between experimental conditions based on two-sided dependent sample t-tests. The value in each cell represents the P-value of said binary comparison rounded to four digits. Red cell background indicates P-values lower than 0.12, whereas white and then blue background color indicate increasingly higher P-values as indicated also by the colorbar. The presented HRV metrics are all based on the so called normal-tonormal (NN) time intervals between two consecutive R-spikes in the electrocardiogram. These metrics are known to be intercorrelated. Metric pNNX, where X is a time parameter typically on the order of tens of milliseconds, is defined as the percentage of consecutive NN differences where the NN interval changed by more than X milliseconds between consecutive NN differences. For pNN0.035, for example, that metric would be computed as the percentage of consecutive NN intervals where the interval changes by more than 35 ms. RMSSD is calculated as the square root of the mean squared differences of all NN intervals. SDNN is computed as the standard deviation of all NN intervals. This overview consistently shows the largest differences (as measured by low Pvalues) in high frequency HRV between BCI and control conditions within the hard course. For comparisons between control conditions in the hard course and between any conditions in the easy course statistically indicated differences are consistently absent. Overall, the pNN metric seems to be most sensitive to detect this difference with parameterizations from 5 to 50 ms revealing peak discriminability at 35 ms (pNN0.035).

Details on electroencephalography based decoder
Spectral and spatial separability patterns suggest that our decoder exploits both neural activity, such as from the anterior cingulate cortex, and non-neural activity seemingly including at least in part from changes in muscle tension, to discriminate task difficulty, thus fusing multiple signal modalities to generate the real-time feedback (sometimes referred to also as a "hybrid-BCI", cf. ref. 9; Fig. S8). One important reason for why EEG rather than more easily accessible signals were used to generate the feedback signal, was because our preliminary study showed that EEG allowed overall for the highest decoding performance; specifically also higher than joystick input, or EMG derived from face, neck or the lower arm. Fig. S8. Cross-validation of the decoder on the data set that had been used to train the decoder, shows patterns consistent with activity in anterior cingulate cortex (ACC), other neural and non-neural sources that may include electromyography. The actual decoder integrated activity across frequency bands and the associated performance is shown in the boxplot at the very left. Post-hoc, we computed cross-validation based on common spatial patterns for each training set separately for every single frequency band to analyze the bands contribution to decoding performance. We found better than chance (significance level P=0.01; average across subjects 55.1 ± 2.8 %; (10)) performance for delta and theta band for activity consistent with ACC involvement, and even higher performance for alpha, beta and gamma band where the decoder may rely at least in part on activity originating in the peripheral nervous system. Our filter bank common spatial pattern decoding model is based on six spatial filters per band. To give an intuition about the spatial distribution of the overall separability for every frequency band, we compute cross-validation based on univariate linear discriminant analysis on logarithmic bandpower for every electrode and project the resulting area under the receiver operator characteristics curve (AUC) values onto scalp maps. The color limits for the topographic plots were automatically set between a nominal level of chance of 0.5 and the maximum univariate AUC in the topoplot for that band to provide the best picture of the spatial distribution of separability. This visualization does not capture interactions between the bands, so there could be added discriminative value in correlations between channels which the "actual" decoder captures. We also show decoding performance based on full-band power of the joystick input signal as a reference in the rightmost boxplot.

How results from physiology integrate to support main behavioral findings
The exact use of pupil size, heart rate and HRV in the supportive analyses for this experiment was mainly based on the temporal resolution of these metrics and their respective meaning in terms of physiology.
Changes in pupil size, for example, occur on the order of seconds -similarly, instantaneous heart rate can be computed from seconds of data. Short term, high frequency HRV, on the other hand is typically computed from minutes or hours of data and is a metric that is computed by aggregating events that occur over time.
Thus, we reasoned that we had to compare HRV based on data of the same length from the first segment with large boundaries, particularly in the comparison between courses where the difference in flight length is substantial, but also in the comparison between conditions.
As per our experimental design, and in accordance with the Yerkes and Dodson law, we expect to see differences in arousal (or more specifically, differences in tonic baseline activity of the Locus Coeruleus as reflected in pupil size) as a function of feedback type only when arousal levels are substantially elevated (i.e. not with large but rather with medium size boundaries). In other words, our system works by lowering arousal in situations where arousal is elevated, but it is not designed to lower arousal when arousal is only at a low or medium level. In fact, by design, the dynamic range of our audio feedback is such that the feedback becomes inaudible at low or moderate levels of arousal and becomes loud only at high levels of arousal. We think this is a very attractive property of this system from a translational perspective. For the experiment, this means, that in a course section of large boundaries where arousal levels should be at a low or medium level we would not expect a significant difference in baseline pupil size. Statistical analyses for the first segment with large boundaries confirm, that there is no significant difference in pupil size between any of the conditions, neither within the easy course, nor within the hard course (see Fig. S9).

Fig. S9.
For large boundaries, where we expect arousal to be low or only moderately elevated we see no significant difference in pupil size compared across feedback types and within course types. For the hard course, P-values for comparisons between BCI and control conditions are slightly lower but also not significant which is in line with the Yerkes and Dodson law and our prediction.
Finally, while pupil size and heart rate are understood to be direct correlates of arousal, HF HRV has been shown to be associated with "stress" (2), but is more specifically understood to primarily reflect modulation in vagal tone, rather than vagal tone directly (3). This detail becomes relevant for our auxiliary analysis above where we use HRV to learn whether subjects are complying with instructions to down-regulate their arousal based on the feedback and are successful at regulating their arousal.

Additional control analyses comparing neurofeedback and sham signal
As discussed in the manuscript, the performance improvement in the BCI condition relative to silence could be considered surprising since the task in the condition BCI may be interpreted to be a dual-task, in which one may expect task performance to decrease rather than to increase. One may consider, that a hypothetical alternative explanation for the results could be that subjects consistently ignored the instruction to perform the task of down-regulating their arousal, but instead were calmed by the feedback in condition BCI and that higher and more variable sound volume in condition Sham leads to relatively lower flight performance in condition Sham. To investigate this hypothetical alternative explanation, we looked at the time series for the output of the neural decoder and the audio volume. For both time series we took the median for every 2 second epoch between boundaries and eventually calculated mean or standard deviation within boundary type and within subject. All further analyses were conducted across subjects. We found that audio volume was not statistically significantly different in the sections of medium and small boundaries (Fig. S10) where we find the reported improvement in behavioral performance. Counter to the hypothetical alternative explanation above, variance is actually slightly higher for veridical feedback relative to sham and not lower (Fig. S11). Finally, as expected audio feedback is found to be highly correlated with output of the EEG-based decoder for condition BCI but much less so in condition sham (Fig. S12). We interpret these results, together with the findings in heart rate variability and pupil size, which indicate significant modulation of arousal and increased cognitive control with veridical feedback relative to control conditions, as strong evidence, that subjects actively modulated their brain-state and that this self-modulation led to an increase in behavioral performance.

Fig. S10.
Average system audio volume of heartbeat audio feedback for all 18 participants, for two of the feedback conditions (Sham and BCI) and all three course sections (Large, Medium and Small sized boundaries) for the hard flight course. The difference between the respective medians for Sham (18.0 %) and BCI (8.8 %) for the large boundary size is small at 9.2 % of the dynamic range of system audio volume, relatively hard to detect by listening and no subject reported to notice a difference. As expected, not many participants reached the section with small boundaries, which explains why the two right-most boxplots are based on fewer data points. P-values over brackets are based on two-sided ttests for dependent samples.  S11. Standard deviation of system audio volume for heartbeat audio feedback for all 18 participants and for two of the feedback conditions (Sham and BCI) and all three course sections (Large, Medium and Small sized boundaries) for the hard flight course. The differences between the medians for the conditions Sham and BCI are small at 3.6 % for boundary size large and 4.2 % for medium sized boundaries. Many of the few participants that reached the section with the small boundary size in the hard course surpassed only one single boundary and thus no standard deviation is available for those cases. P-values over brackets are based on two-sided t-tests for dependent samples.

Fig. S12.
Pearson's correlation coefficient between BCI output (smoothed over five seconds) and sound volume of the presented heartbeat audio feedback for all 18 participants and two of the three feedback conditions Sham and BCI. The Pvalue over the bracket is based on a two-sided t-test for dependent samples.