{'fraction_non_alphanumeric': 0.04387175324675325, 'fraction_numerical': 0.016132305194805196, 'mean_word_length': 4.2149206349206345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
An Incremental Approach to Online Dynamic Mode Decomposition for Time-Varying Systems with Applications to EEG Data Modeling

Dynamic Mode Decomposition (DMD) is a data-driven technique to identify a low dimensional linear time invariant dynamics underlying high-dimensional data. For systems in which such underlying low-dimensional dynamics is time-varying, a time-invariant approximation of such dynamics computed through standard DMD techniques may not be appropriate. We focus on DMD techniques for such time-varying systems and develop incremental algorithms for systems without and with exogenous control inputs. We build upon the work in [35] to scenarios in which high dimensional data are governed by low dimensional time-varying dynamics. We consider two classes of algorithms that rely on (i) a discount factor on previous observations, and (ii) a sliding window of observations. Our algorithms leverage existing techniques for incremental singular value decomposition and allow us to determine an appropriately reduced model at each time and are applicable even if data matrix is singular. We apply the developed algorithms for autonomous systems to Electroencephalographic (EEG) data and demonstrate their effectiveness in terms of reconstruction and prediction. Our algorithms for non-autonomous systems are illustrated using randomly generated linear time-varying systems.


1.
Introduction. Emergence of low cost sensors and their widespread deployment has led to an unprecedented amount of data. Extraction of actionable information from such plethora of data remains a challenge. It is often the case that a low dimensional dynamical system governs the high-dimensional spatiotemporal sensory data. Dynamic Mode Decomposition (DMD) has emerged as a popular data-driven technique to efficiently compute such low dimensional dynamics [19,30,33]. One of the attractive features of the DMD approach is that it requires minimal assumptions on the data. Furthermore, its strong connections with the Koopman operator [17,[23][24][25]29] makes it further appealing and theoretically grounded. The efficacy and simplicity of the DMD has inspired its application in a wide range of areas from fluid dynamics [19,30] to video processing [10,32] to epidemiology [28] to neuroscience [3].
For high-dimensional data that is generated by an underlying low dimensional time-varying dynamics, the standard DMD approach may be applicable only locally in time and appropriate time-varying DMD operators can be computed by discounting old data or considering a sliding window of observations [35]. Even in scenarios when underlying dynamics is time-invariant and nonlinear, such time-varying linear approximations have been shown to be very effective [7]. In this paper, we develop incremental methods for the computation of the DMD for time-varying systems and demonstrate the utility of the developed algorithm using Electroencephalographic (EEG) data.
Incremental approaches to DMD refer to methods that allow for efficiently computing the DMD when data is provided sequentially instead of being provided as a batch. The sequential arrival might be due to the inherent nature of the application or it may be used for computational efficiency even if all the data is accessible. One such technique is streaming DMD [12,13] that first computes the projection of new data on the current orthogonal basis for the range of the data matrix and compares the norm of the difference between the projection and the new data with a threshold. If the difference is larger than the threshold, then it appends the basis with an additional element. Incremental total DMD introduced in [21] applies incremental Singular Value Decomposition (SVD) [1,2,26] for incremental computation of dynamic modes and subsequent identification of dominant modes. Unlike the streaming DMD and the total DMD, our focus in this paper is on systems with time-varying dynamics.
Within the context of time-varying systems, an incremental approach is the Online DMD [35], which adapts the sequential least squares method [15,16] to incrementally update the DMD computation. The online DMD incrementally computes the DMD operator using the Sherman-Morrison identity [31]. Authors of [35] consider two strategies in their DMD computation to account for time-varying systems: (i) discounting the old data, and (ii) using a sliding window of observations. They also consider DMD for systems with control input [18,27]. In particular, they extend the DMD with control approach proposed in [27] to develop an online DMD with control algorithm for time-varying system.
In this paper, we build upon the work in [35], and develop incremental SVD based techniques for the computation of the online DMD for time-varying systems. The proposed approach provides access to singular values of the data matrix at each time and hence allows it to determine a reduced order model. For the scenarios in which the high-dimensional data is governed by a low-dimensional dynamics, such reduced order models provide better future prediction accuracy. Furthermore, for scenarios where the Sherman-Morrison identity cannot be applied, e.g., if the data matrix remains singular even after sufficiently long time, the access to singular values allows for efficient computation of appropriate pseudo-inverse. The major contributions of this work are fourfold (i). We leverage incremental SVD techniques to develop two algorithms for the computation of the online DMD for time-varying systems that rely on discounting old data and a sliding window of data, respectively; (ii). We extend both these algorithms to develop incremental SVD based algorithms for the computation of the online DMD with control input for timevarying systems; (iii). We apply our algorithms for the case without control input on an EEG dataset and show their efficacy in reconstructing and predicting error related potential, a slow cortical potential seen in the EEG signal that is elicited by an unexpected outcome; (iv). We apply our algorithms for the case with control input on randomly generated linear time-varying dynamical systems, and demonstrate their efficacy.
The remainder of the paper is organized as follows. In Section 2, we present some background on the DMD for time-invariant and time-varying systems. In Section 3, we present some background for the incremental SVD algorithms. In Section 4, we leverage the incremental SVD algorithms to develop novel incremental DMD algorithms. We apply these algorithms to EEG data in Section 5. We present incremental SVD-based algorithms for online DMD with control and illustrate its utility using numerical examples in Section 6. Finally, we conclude in Section 7.
Notation. We denote the set of real and complex matrices of size n × m by R n×m and C n×m , respectively. The set of real and complex n-dimensional vectors are denoted by R n and C n , respectively. We denote matrices with bold upper case letters, vectors with bold lower case letters, and scalars with normal lower case letters. We denote the matrix transpose and the matrix conjugate transpose by (·) T and (·) * , respectively. The kernel and range of a matrix X are denoted by KerX, and RanX, respectively.
2. Dynamic mode decomposition for time-varying systems. In this section, we recall the DMD setup and describe the time-varying DMD problem that we study in this paper.
2.1. Dynamic mode decomposition. Consider the following discrete-time system: where x k ∈ R n is a high-dimensional state vector (n 1) sampled at t k = k∆t, k ∈ {1, . . . , (m + 1)}, and f is an unknown map which describes the evolution of the state vector between two subsequent sampling times. Suppose that the evolution of the high-dimensional state x is governed by some underlying low-dimensional dynamics. Then, the DMD computes a data-driven linear approximation to the system (1) as follows [19,33].
Consider a collection of (m+1) sequential measurements arranged in the following two datasets: Let the projection of X onto its leading r singular vectors beX =Ū xΣxV * x , where r is the targeted dimension of the underlying low-dimensional dynamical system, U x ∈ C n×r ,V x ∈ C r×m , andΣ x = diag{σ 1 , . . . , σ r } ∈ C r×r . Then, the DMD framework approximates the dynamics (1) by whereĀ ∈ R n×n is called the DMD operator and is given bȳ Let the projection of the state x and the DMD operatorĀ onto the space spanned by leading r singular vectors of X bex k =Ū * x k and x , respectively. Then, the approximation to the underlying r-dimensional dynamics is

MUSTAFFA ALFATLAWI AND VAIBHAV SRIVASTAVA
Let Λ be the diagonal matrix of the eigenvalues ofÃ and W be the matrix of the associated eigenvectors such that Then, two types of DMD modes can be identified using the eigen-decomposition in (4): the projected DMD modesΦ =Ū x W and the exact DMD modes Φ = YV xΣ −1 x W [33]. Either of these DMD modes and the associated eigenvalues describe the evolution of the high-dimensional system using low-dimensional dynamics (3).

2.2.
Dynamic mode decomposition with control. Consider the following nonautonomous discrete-time system: where x k ∈ R n is a high-dimensional state vector (n 1) sampled at t k = k∆t, k ∈ {1, . . . , (m + 1)}, and f c is an unknown time-varying map which describes the evolution of the state vector between two subsequent sampling times, and γ k ∈ R l is the exogenous input. Then, the Dynamic Mode Decomposition with Control (DMDc) computes a data-driven linear approximation to the system (5) as follows [27].
Consider a collection of m sequential measurements x i ∈ R n and the associated exogeneous inputs γ i ∈ R l , i ∈ {1, . . . , m}. DMDc approximates the nonautonomous dynamics underlying these measurements by where A ∈ R n×n is called the DMD operator, B ∈ R n×l is called the input matrix, and G = A B ∈ R n×(n+l) . In particular, the DMDc algorithm constructs matrices X = x 1 · · · x m−1 , Y = x 2 · · · x m , and Γ = γ 1 · · · γ m−1 . Let The DMDc algorithm estimates G by Finally, U c * can be written in a partitioned form of U c * = U ca * U c b * , where U ca ∈ C n×(n+l) and U c b ∈ C l×(n+l) . Then, the DMDc algorithm computes the matrices A c and B c given by Similar to the case of the DMD, the DMDc algorithm also enables identification of the low-dimensional non-autonomous system underlying the high-dimensional measurements. Assume that the matrix X c can be approximated by its projection onto the leading p singular vectors byX c =Ū cΣcVc * , whereŪ c ∈ C (n+l)×p , Σ c ∈ C p×p , andV c ∈ C (m−1)×p , and the matrix X can be approximated by its projection onto the leading r ≤ p singular vectors byX =ŪΣV * , whereŪ ∈ C n×r , Σ ∈ C r×r , andV ∈ C (m−1)×r . Then, a reduced order model can be represented as follows:x where the lower-dimensional matricesÃ c ∈ R r×r andB c ∈ R r×l can be calculated by: 2.3. Problem formulation. In this paper, we study incremental algorithms for the time-varying DMD and DMDc problems defined below.
2.3.1. Time-varying DMD. Consider the time-varying discrete time system of the form where x k ∈ R n is a high-dimensional state vector (n 1) sampled at t k = k∆t, k ∈ {1, . . . , (m + 1)}, and f is an unknown time-varying map which describes the evolution of the state vector between two subsequent sampling times. Similar to the standard DMD setup, we assume that the high-dimensional dynamics (6) is generated by a low-dimensional time-varying dynamics.
Suppose that, at sampling time t k+1 , we have access to a collection of (w + 1) sequential measurements x k−w+1 x k−w+2 x k−w+3 · · · x k+1 . Our objective is to design efficient computational techniques to identify the time-varying DMD operator A k that approximates the system (6) by the following linear time-varying system such that the cost function is minimized, where ρ ∈ (0, 1] is a discounting factor.

2.3.2.
Time-varying DMDc. Consider the following variant of the system in (6) x where f c is an unknown time-varying map which describes the evolution of the state vector between two subsequent sampling times, and γ k ∈ R l is the exogenous input. Assume that, at sampling time t k+1 , two collections of sequential measurements are available, one for the system states x k−w+1 x k−w+2 x k−w+3 · · · x k+1 , and the other one for the exogenous inputs γ k−w+1 γ k−w+2 γ k−w+3 · · · γ k+1 . Our objective is to design efficient computational techniques to identify the timevarying DMDc operator A c k and input matrix B c k that approximates the system (9) by the following linear time-varying system such that the cost function is minimized, where ρ ∈ (0, 1] is a discounting factor. Then, the linear model (10) can be written as and the cost function (11) can be equivalently written as Online DMD approach [35] also minimizes the cost functions (8) and (11), and computes the time-varying DMD and DMDc operators. In addition to the computation of these operators, the computational techniques developed in this paper also enable efficient computation of (i) the associated DMD eigenvalues and modes, and (ii) the linear time-varying systems that approximate the low-dimensional dynamics underlying (6) and (9), respectively.
2.4. Block computation of time-varying DMD and DMDc. We refer to a computation that requires all the data until the sampling time t k to compute the desired solution at time t k as a block computation. In contrast, an incremental computation uses only the data at time t k and the solution at time t k−1 to compute the desired solution.
In this section, we describe block computation for time-varying DMD and DMDc in Lemma 1 and 2, respectively. These lemmas are immediate consequence of least square solutions of a linear system of equations [22,Section 5.13] and we omit their proofs. We will use these block computations to derive the incremental computations later in the paper. Lemma 1. Consider a sequence of (w + 1) measurements {x k−w+1 , . . . , x k+1 } at sampling time t k+1 that is arranged in the following two matrices Y k = ρ k y k−w+1 ρ k−1 y k−w+2 · · · y k , where x j ∈ R n , for each j ∈ {k − w + 1, · · · , k + 1}, and y j = x j+1 . Then, the following statements hold for the cost function (8) (i). if KerX * k is trivial, then the unique minimizer of (8) is where U x k ∈ C n×n is a unitary matrix, Σ x k = diag{σ 1 , . . . , σ n } ∈ C n×n , V x k ∈ C k×n has orthonormal columns, and are defined by the reduced SVD of k is non-trivial, then there exists infinitely many minimizers of (8), and the unique minimizer with the smallest induced two-norm is Consider two sequences of (w + 1) measurements {x k−w+1 , . . . , x k+1 }, and {γ k−w+1 , · · · , γ k+1 } at sampling time t k+1 that are arranged in the following two matrices . Then the following statements hold for the cost function in (13) (i). if KerX c * k is trivial, then the unique minimizer of (11) is where U c x k ∈ C k×(n+l) has orthonormal columns, and are defined by k is non-trivial, then there exists infinitely many minimizers of (11), and the unique minimizer with the smallest induced two-norm is Similar to the online DMD [35], we focus on two special cases of the cost functions (8) and (13), namely, the weighted cost functions and the windowed cost functions. The weighted cost functions consider a gradual elimination for the old measurements by assigning the discounting factor to be ρ ∈ (0, 1) and consider all the available data, i.e., they select w = k. The windowed cost functions consider a sharp cut-off window and use a non-discounted window of recent measurements, i.e., they select ρ = 1 and w < k. In the remainder of the paper, we will refer to the DMD and the DMDc operators/matrices obtained using the weighted (resp., windowed) cost functions by the weighted (resp., windowed) DMD and DMDc operator/matrices and denote them by A ρ k (resp., A w k ) and (A ρc k , B ρc k ) (resp., (A wc k , B wc k )), respectively.
3. Background on incremental SVD algorithms. At the heart of the DMD framework is the utilization of the SVD to identify an invariant subspace for the low-dimensional dynamics underlying the high-dimensional data. The techniques proposed in this paper for the computation of the time-varying DMD operator require access to the SVD of certain time-varying data matrix at each time. For efficient computation of these SVDs, we resort to incremental SVD techniques proposed in [1,2,26]. In this section, we present these incremental SVD techniques. The presentation below is adapted from [1] in order to facilitate better exposition in Section 4.

Weighted incremental SVD algorithm. Consider a weighted dataset
where 0 ≤ ρ ≤ 1 is a scalar discounting factor and k ≥ n. Given an additional datum x k+1 , let be the incremented dataset. Provided that the SVD of X k is known, the SVD of X k+1 can be incrementally computed using the following proposition, which is proved in Appendix A.
Assume that at sampling time t k+1 , a new datum x k+1 is accessed. Then, the SVD for the dataset in (22) x k+1 , is given by : where The above incremental SVD computation requires the computation of the SVD of matrix S k ∈ C n×(n+1) . The size of this matrix is smaller than the size of dataset X k+1 and it has the so-called broken arrow structure which enables efficient computation of its SVD [6,11,14].

Windowed incremental SVD algorithm. Consider a windowed dataset
where n is the dimension of measurements and w is the length of the time-window of the desired measurements. Define q as follows q n, if n < w, w, otherwise.
Consider another dataset Then, the incremental SVD computes the SVD of χ k+1 = U χ k+1 Σ χ k+1 V * χ k+1 as follows. First, it eliminates x k−w+1 from the dataset to obtain decremented dataset and the associated SVDχ Then, it incrementsχ k with x k+1 to obtainχ k+1 and the associated SVD. The SVD of the datasetχ k can be incrementally computed using the following proposition, which is proved in Appendix B.
Proposition 2. Let at sampling time t k , the SVD of the dataset in (24) be defined by where Uś k , Vś k , and Σś k are defined by the following SVD 2 is the submatrix of V χ k obtained after removing its first row.
In the incremental step, the new datum x k+1 is appended toχ k and the SVD of the resulting matrix χ k+1 can be obtained using the procedure presented in Section 3.1. In particular, letŜ k Σχ k U * χ k x k+1 = Uŝ k Σŝ k V * s k , and using equation (23), the SVD of The windowed incremental SVD computation requires the computation of the SVD ofŚ k ∈ R q×w . In general,Ś k may not possess any special structure. However, if n w, in which case q = w, the above incremental update maybe a lot cheaper than the computation of the SVD of an n × w matrix. Also, in this context, the above procedure helps in term of storage as it does not require the large matrix χ k+1 to be stored and uses only the first and last column of this matrix along with the SVD at the previous iteration. 4. Incremental DMD algorithms. In this section, we present two algorithms, namely weighted incremental DMD and windowed incremental DMD, respectively, for incremental computation of a time-varying lower-dimensional DMD operator. Similar to the existing approaches in the literature, the proposed algorithms perform incremental computations either by assigning decaying weights to the received data [16,35], or by using a sliding window of the received data [10,20,35]. The recursive updates derived in this section are similar to those in sequential least square method [16, Appendix 8C], recursive least square method [15, Section 9.4], as well as online DMD [35].

4.1.
Weighted incremental DMD algorithm. In this algorithm, the timevarying DMD operator is estimated by assigning a decaying weight to past measurements in order to gradually discount their representation as newer measurements become available. Assume that at sampling time t k+1 , we have access to the following weighted datasets: where y k = x k+1 , for each k ∈ N. Assume that at sampling time t k+2 , the datasets in (30) are updated with a pair of measurements (x k+1 , y k+1 ) such that Suppose that at sampling time t k+1 , the DMD operator A ρ k and the SVD of X k are known, then at sampling time t k+2 , the DMD operator can be updated with the new pair of measurements (x k+1 , y k+1 ) using the following theorem, which is proved in Appendix C.
x k be known, and let the DMD operator A ρ k ∈ R n×n minimize the cost function in (8) with Y k and X k given in (30). Assume that at sampling time t k+2 , a new pair of measurements (x k+1 , y k+1 ) is used to incrementally compute the SVD of X k+1 using Proposition 1. Then, the DMD operator A ρ k+1 ∈ R n×n which minimizes the cost function in (8) is If X k+1 is well-approximated by its projection onto its leading r singular vectors given byX k+1 =Ū x k+1Σ x k+1V * x k+1 , then the DMD operator update in (32) takes the formĀ Moreover, the DMD operatorĀ ρ k+1 ∈ R n×n can be projected onto a subspace spanned by the leading r left singular vectors of X k+1 to obtain a lower-dimensional DMD operatorÃ ρ k+1 ∈ R r×r given bỹ The update in equation (32) requires only the current DMD operator, measurement pair (x k+1 , y k+1 ), and the incremental SVD update. Specifically, these updates do not require the data matrix to be stored.

4.2.
Windowed incremental DMD algorithm. We now focus on windowed incremental DMD algorithm in which a sliding-window of w most recent measurements is used to estimate the time-varying DMD operator. Assume that we have access to the following windowed datasets at sampling time t k+1 : Accordingly, at sampling time t k+2 , we have access to Suppose that at sampling time t k+1 , the DMD operator A w k and the SVD of χ k are known, then at sampling time t k+2 , the DMD operator can be updated with the new pair of measurements (x k+1 , y k+1 ) using the following theorem, which is proved in Appendix D.
Theorem 2. Let at sampling time t k+1 the SVD of χ k = U χ k Σ χ k V * χ k be known, and let the DMD operator A w k ∈ R n×n minimize the cost function in (8) with Υ k and χ k given in (35). Assume that at sampling time t k+2 , a new pair of measurements (x k+1 , y k+1 ) is used to incrementally compute the SVD of χ k+1 using Proposition 2 and equation (29). Then, the DMD operator A w k+1 ∈ R n×n which minimizes the cost function in (8) is If χ k+1 is well-approximated by its projection onto its leading r singular vectors given byχ k+1 =Ū χ k+1Σ χ k+1V * χ k+1 , then the DMD operator takes the form Moreover, the DMD operatorĀ w k+1 ∈ R n×n can be projected onto a subspace spanned by the leading r left singular vectors of χ k+1 to obtain a lower-dimensional DMD operatorÃ w k+1 ∈ R r×r given bỹ Similar to the weighted incremental DMD, the update in equation (37) requires only the current DMD operator, measurement pair (x k+1 , y k+1 ), and the windowed incremental SVD update. For a fixed dimension r of the reduced order system, the computational complexity of rank one incremental SVD update is O(nr + r 3 ) [2, Section 4.3]. In comparison, computational complexities of each iteration in the streaming DMD and the online DMD are O(nr 2 ) and O(n 2 ), respectively. When data matrices are non-singular, both online and incremental DMD approaches can be used to compute time-varying DMD operators. In such cases, if a reduced order DMD operator of dimension r is of interest, then the proposed incremental DMD approach has a better computational complexity, when r < n 2/3 .

5.
Dynamic mode decomposition for error-related potentials in EEG data. Error-Related Potentials (ErrPs) are slow cortical potentials seen in the EEG signal of human subjects that are elicited by an unexpected (erroneous) outcome. For example, within the context of human-machine interaction, such signals are observed when the machine takes an unexpected action [4,5,9]. In this section, we illustrate the efficacy of the proposed DMD algorithms on EEG recordings taken from Monitoring Error-Related Potentials database [4,5]. These EEG recordings were collected from six subjects while they were observing the movement of a cursor between two labeled targets on a screen. The subjects had no control on the motion of the cursor. However, they had a priori knowledge about the intended directions of movement. The cursor movements were set to elicit ErrPs by generating two types of events, namely, correct events and erroneous events. The correct events correspond to the cursor movement in the intended direction, while the erroneous events correspond to the cursor movement in any unintended direction. EEG signals were recorded at sampling rate of 512 Hz, using Biosemi ActiveTwo system with 64 electrodes distributed according to the standard 10/20 international system as it is shown in Figure 1. A two step standard EEG preprocessing for ErrPs which consists of Common Average Reference (CAR) filtering, and then (1 − 10) Hz Band Pass (BP) filtering is performed on the data. Segments of EEG signals, from all the participants, corresponding to the correct and erroneous events were extracted into two separate groups. Then, the segments within each group were averaged to obtain a signal each for the correct and erroneous events. Finally, the ErrPs are calculated by subtracting the signal for correct event from the signal for the erroneous event. Figure  2 shows the ERP signals and topographical views corresponding to the correct and erroneous events, and the calculated ErrPs. EEGLAB was used for the processing of EEG signals and generating the topographical views for the related brain activities [8]. Note that for consistency with the literature, we investigate the averaged ERP signal. However, the confidence regions around the averaged signal shown in Figure 2 reveal that despite the variability in these signals, the key features are also seen in the signal associated with a single event. Thus, the following analysis can be performed on a single subject real time data as well.
As reported in [4,5], the ErrPs are characterized by a sequence of three peaks/troughs after the onset of the event in the EEG signal measured at channel FCz (see Figure 1). A sample ErrP is shown in Figure 2c where the first small positive peak is observed at 200 ms, followed by a negative trough at 260 ms, and finally a larger positive peak at 330 ms.
Two observations can be made by comparing the temporal behavior and the topographical views during the correct and erroneous events in Figures 2a and 2b, respectively. First, the ERP signal during the correct event tends to have broader peaks in comparison with the ERP signal during erroneous events, which indicates that it has slower dynamics, i.e., has smaller growth or decay rates. Second, by comparing the topographical views during the three characterizing peaks at FCz channel, it can be noticed that the ERP peaks during erroneous events have higher amplitudes than the peaks during correct events in both negative and positive directions. Note that the colormap bar values are different for the topographical views for the correct ERP, the erroneous ERP, and the ErrP in Figure 2.
As shown in Figure 2, the EEG patterns show coherent activities within the brain suggesting the possibility of a low-dimensional dynamics underlying this high dimensional data. Furthermore, these patterns change significantly with time and can possibly be better explained using a time-varying underlying model. To investigate these hypotheses, we apply the incremental DMD algorithms to the EEG recordings corresponding to correct and erroneous events. The weighted incremental DMD algorithm is applied with discounting factors ρ = {0.1, 0.2, 0.4, 0.8}, and the windowed incremental DMD algorithm with a time-window of width w = 512 samples. All singular values greater than σ thr = {0.01, 0.001} are used for computing the reduced order DMD operator. An initial window of 512 samples before the event occurrence is used to initialized the DMD models for both algorithms.
We compare the proposed algorithms with the online DMD approach proposed in [35]. To this end, we use the same parameters (discounting factor and width of time-window) in the online DMD algorithms as the incremental DMD algorithms. Recall that the online DMD algorithms rely on the Sherman-Morrison identity to compute the DMD operator and do not have access to the (time-varying) singular values of the data matrix and hence, the reduction of the DMD operator to leading singular vectors does not apply to online DMD algorithms.  In order to compute the time-varying DMD operator, we first compute a standard DMD operator using EEG data from a one-second window (512 samples) just before the correct or erroneous event. Subsequently, the EEG measurements are streamed with a rate of 1 sample/iteration to update the initial DMD operator. At each iteration, both weighted and windowed versions of the incremental DMD and online DMD algorithms are used to predict 64 future samples of the EEG signal at channel FCz. We compare the performance of these algorithms using normalized Root Mean Square (RMS) prediction error, denoted as e nrms (k) at each t k ∈ {0, · · · , 0.6} using the following formula: whereŷ i and y i are the estimated and recorded values, respectively, y k = max k+1≤i≤k+64 y i , and y k = min k+1≤i≤k+64 y i . Figure 3 shows the mean of the normalized RMS prediction error computed over all iterations as well as the associated 95% confidence sets for weighted and windowed incremental DMD algorithms and different choices of parameters. The performance of the incremental DMD does not appear to vary much with the weighting factor and the two choices of the threshold on singular values. The performance of the windowed incremental DMD algorithm is similar to the weighted incremental DMD. However, incremental DMD algorithms seem to outperform online DMD algorithms. This suggests that having a small threshold σ thr is more beneficial than having no threshold as in the case of online DMD algorithms. Figure 13 in Appendix E presents the evolution of the normalized RMS prediction error for each event.  In order to gain further insight into the influence of different thresholds σ thr and weighting factors ρ, we investigate how accurately the incremental DMD predicts the signature ERPs at channel FCz. To this end, we updated the initial DMD operator using incremental DMD algorithms until the first peak at 200 msec. We then used the updated lower-dimensional DMD operator to predict the future ERP until the third peak at 330 msec. The predicted signal and the associated normalized RMS are shown in Figures 4 and 5, respectively. For the erroneous event, the predicted signal from incremental DMD algorithms capture the trend of the original signal, while for the correct event, most incremental DMD algorithms fail to capture the final dip in the original signal. The only exception is the windowed incremental DMD with σ thr = 0.001. For σ thr = 0.01, the number of DMD modes used by the incremental DMD algorithms range from 26 to 31 for correct events and 28 to 32 for erroneous events. Similarly, for σ thr = 0.001, the number of DMD modes used by the incremental DMD algorithms range from 26 to 31 for correct events and 28 to 33 for erroneous events. In comparison, the predicted signal from the online DMD algorithms performs poorly. The key reason for this poor performance, is that the data matrix obtained after prepossessing is not full rank even if all the measurements are included. Thus, the Sherman-Morrison update cannot be applied in the standard form. Recall that the online DMD algorithm starts by initializing the DMD operator A k and the inverse of covariance matrix P k = X k X T initialization of online DMD algorithms, we adopted the suggestion in [35]: in the event that X k X T k is not full rank, A k can be initialized by an n × n zero matrix, and P k can be initialized by P init = αI where α is a large positive scalar.  During the correct events, there appears to be an interplay between the threshold σ thr and weighting factor ρ. As shown in Figure 5 for correct events, the normalized RMS decreases with decreasing the weighting factor until ρ = 0.2 and increases with further decrease in ρ. For ρ = 0.2, the higher dimension of the reduced system (σ thr = 0.001) leads to higher prediction error compared with the lower dimension reduced system (σ thr = 0.01). This suggests that for a weighting factor that leads to the smallest prediction error, including too many modes is not beneficial for prediction performance, since it leads to over-fitting. A similar interplay is not seen for the erroneous event in Figure 5. However, if we choose a smaller initial window to initialize the DMD model, we observe similar effects as shown in Figure 14 in Appendix F. Similar effects are observed for the windowed DMD as shown in Figure 15 in Appendix F.
To further compare the online DMD with the incremental DMD, we took the raw EEG data, i.e., data without any preprocessing (CAR and BP filtering). In this case, the data matrix is well-conditioned and the Sherman-Morrison identity is well defined. The performance of online DMD and the incremental DMD in terms of predicting future signal is shown in Figure 6. In this case, both incremental and online DMD algorithms have similar poor performance. This suggests that the difference in the performance of these algorithms is primarily due to ill-conditioned dataset. This also highlights the utility of applying appropriate band-pass filtering  to the raw EEG data. Without such filtering, the key activities seem to be lost in the background noise resulting in a poor prediction performance.
Topographical views for the real part of the four dominant DMD modes at 200 msec obtained from the incremental DMD algorithms for the correct and erroneous events are shown in Figure 7 and Figure 8, respectively. A comparison between the DMD modes during the erroneous and correct events shows that there is a stronger activity in the frontal lobe during the erroneous events especially around the FCz channel. This is consistent with the topographical views from EEG recordings shown in Figures 2a and 2b that show stronger activity in the frontal lobe during an erroneous event. This illustrates that a few principal DMD modes are able to capture the dominant activity in the brain during these experiments. Figure 9 shows the logarithm of eigenvalues of the DMD operator at 200 msec associated with different thresholds σ thr , weight factor ρ and time-window width. For smaller value of σ thr , the range of eigenvalues in the left half plane is bigger. This is consistent with the fact that smaller σ thr implies a larger reduced order model in which some states converge to zero much faster than other states. For the erroneous event, some eigenvalues are spread in the right half plane, which suggest a locally unstable dynamics underlie the evolution of ERP signal during erroneous  trials. This is also consistent with the faster dynamics (sharper peaks) in the EEG signal during the erroneous event (see Figure 2).
We now investigate the effectiveness of the incremental DMD algorithms in terms of reconstructing the ERP signals during the correct and erroneous events at FCz channel. To this end, we reconstruct the signal starting from the onset of the events until the end of the third peak at 330 msec. The reconstructed signals and the normalized RMS error for the reconstruction are shown in Figures 10 and 11, respectively. These results indicate that the incremental DMD models incur smaller reconstruction error than the online DMD models. This result is counter-intuitive, since online DMD uses more modes and should lead to smaller reconstruction error. This discrepancy happens due to the fact that the data matrix never achieves full rank and the online DMD is not able to overcome the heuristic initialization discussed above. There is no significant difference in the reconstruction error for incremental DMD models with different ρ and σ thr values as shown in Figure 10a.
Finally, we summarize the above investigation into the utility of incremental and online DMD in modeling EEG data. It appears that the pre-processing of the EEG data that requires domain-specific knowledge such as the band of frequency in  which the event of interest is observed is vital to obtain sensible DMD-based datadriven models. However, after such pre-processing, the data matrix may become ill-conditioned and under such scenarios incremental DMD techniques proposed in this paper appear more promising that the online DMD techniques. There exists a trade-off between the threshold on the singular values used for model reduction and the window-width or the discount factor used in the incremental DMD algorithms. We also observed that the principal DMD modes are consistent with the activity in the brain during the studied experiments. This suggests that the incremental DMD algorithms can compute an efficient basis for describing the evolution of the EEG activity. Finally, we observed that under erroneous events, some DMD eigenvalues  moved towards the right-half complex plane suggesting that certain events trigger (small time) unstable dynamics.
6. Incremental dynamic mode decomposition for systems with control input. In this section, we extended the incremental DMD algorithms to the case of non-autonomous dynamical systems. We first recall the Dynamic Mode Decomposition with Control (DMDc) algorithm proposed in [27] that estimates time-invariant non-autonomous system dynamics underlying high-dimensional data.
For the scenarios in which the non-autonomous system underlying the measurements is time-varying, the DMDc algorithm has been extended to the online  DMDc algorithm [35]. The online DMDc algorithm operates similarly to the online DMD algorithm and yields time-varying matrices A c k ∈ R n×n and B c k ∈ R n×l , k ∈ {1, 2, · · · }. Similar to the online DMD algorithm, the DMDc algorithm also does not allow for incremental computation of the lower dimensional non-autonomous system underlying high dimensional measurements. In the following, we extend the DMDc algorithm to the weighted and windowed incremental DMDc algorithms that enable us to obtain a lower-dimensional time-varying approximation for the underlying dynamics.
6.1. Weighted incremental DMDc algorithm. Assume that at sampling time t k+1 , the measurements and the associated exogeneous inputs are arranged in the following datasets respectively, where X k , Y k ∈ R n×k , Γ k ∈ R l×k , and X c k ∈ R (n+l)×k . At sampling time t k+1 , the datasets are updated with a new set of measurements (x k+1 , y k+1 ,  γ k+1 which results in the following Suppose that the weighted DMDc operator and input matrix at t k+1 , and the SVD of both X k and X c k are known, then according to the new incoming measurements at t k+2 , the updates for the weighted DMDc operator and input matrix can be obtained using the following theorem, which is proved in Appendix G. x k be known. Assume that the pair (A ρc k , B ρc k ) minimizes the cost function in (11) with X k and Γ k defined in (41). Consider that at sampling time t k+2 , a new triplet of measurements (x k+1 , y k+1 , γ k+1 ) is used to incrementally compute the SVD of both X c k+1 and X k+1 using Proposition 1. Then, the pair (A ρc k+1 , B ρc k+1 ) which minimizes the cost function in (11) is Assume that X c k+1 can be well-approximated by its projection onto its leading p singular vectors such that X c k+1 ≈X c k+1 =Ū c x k+1 ], whereŪ ca x k+1 ∈ C n×p andŪ c b x k+1 ∈ C l×p . Then, the update in (43) yields the following updates forĀ ρc k+1 ∈ R n×n andB ρc k+1 ∈ R n×l : Assume that X k+1 is well-approximated by its projection onto its leading r singular vectors such that X k+1 ≈X k+1 =Ū x k+1Σ x k+1V * x k+1 with r ≤ p. Then a reduced order model can be represented as: x k+1 =Ã ρc kx k +B ρc k γ k , where the lower-dimensional approximationÃ ρc k+1 ∈ R r×r andB ρc k+1 ∈ R r×l can obtained by projectingĀ ρc k+1 andB ρc k+1 onto a subspace spanned by the columns of U x k+1 as follows: The update in equation (43) requires only the current DMD operator (A ρc k , B ρc k ), measurements set of (y k+1 , x k+1 , γ k+1 ), and the incremental SVD update. Specifically, these updates do not require the large data matrix to be stored. 6.2. Windowed incremental DMDc algorithm. Assume that at sampling time t k+1 , the past w states and control input measurements are arranged in the following datasets where χ k , Υ k ∈ R n×w , Γ l ∈ R l×w , and χ c k ∈ R (n+l)×w , respectively. At sampling time t k+1 , the datasets are updated by adding a new set of measurements x k+1 , y k+1 , γ k+1 , and removing the oldest set of measurements (x k−w+1 , y k−w+1 , γ k−w+1 , such that: Suppose that the windowed DMDc operator and input matrix at t k+1 , and the SVD of both χ k and χ c k are known. Then, according to the new incoming measurements at t k+2 , the updates for the windowed DMDc operator and input matrix can be obtained using the following theorem, which is proved in Appendix H. χ k be known, and let the pair (A wc k , B wc k ) minimize the cost function in (11) with Υ k and χ k given in (44). Assume that at sampling time t k+2 , a new triplet of measurements (x k+1 , y k+1 , γ k+1 ) is used to incrementally compute the SVD of χ c k+1 and χ k+1 using Proposition 2 and equation (29). Then, the pair (A wc k+1 , B wc k+1 ) which minimizes the cost function in (11) is If χ c k+1 can be well-approximated by its projection onto its leading p singular vectors such thatχ c k+1 =Ū c χ k+1Σ c χ k+1V c * χ k+1 , whereŪ c χ k+1 ∈ C (n+l)×p ,Σ c χ k+1 ∈ C p×p , andV c χ k+1 ∈ C w×p , then equation (46) yields the following updates for A wc k+1 ∈ R n×n andB wc k+1 ∈ R n×n : Assume that χ k+1 can be projected onto its leading r singular vectors such thatχ k+1 =Ū χ k+1Σ χ k+1V * χ k+1 with r ≤ p. Then a reduced order model can be represented as:x k+1 =Ã wc kx k +B wc k γ k , where the lower-dimensional approximation ofÃ wc k+1 ∈ R r×r andB wc k+1 ∈ R r×l can obtained by projectingĀ wc k+1 andB wc k+1 onto a subspace spanned by the columns of U χ k+1 as follows: For simplicity of exposition, in Section 6.1 and 6.2, we assumed that the SVD of the data matrix X k (χ k ) and the augmented data matrix X c k (χ c k ) is known. However, if the dimension of the input γ k is small, or if the large dimension of the data matrix leads to storage concerns for two SVDs, it may be beneficial to store only the SVD of X k (χ k ) and subsequently, use incremental SVD updates to first compute SVD of X k+1 (χ k+1 ) and then compute the SVD of X c k+1 (χ c k+1 ). The former can be accomplished using the incremental SVD updates described in Section 3, while the latter update is described in Appendix I.
6.3. Numerical illustration for the incremental DMDc algorithm. In this section, we illustrate the efficiency of incremental DMDc algorithms. To this end, we generate a time-varying linear dynamical system as follows. We generate random linear discrete time invariant system matrices A ∈ R n×n and B ∈ R n×l using MATLAB function drss. These system matrices were used to generate the following time-varying linear system: where A k = (1 + sin ωk)A, and B k = (1 + sin ωk)B and γ k ∈ R l is selected as an i.i.d. sequence of standard Gaussian random vector. The system in (47) is used to run a simulation for m n time steps, to obtain two datasets X, Y ∈ R n×(m−1) , with ω = 1, = 0.001, m = 200, n = 20, and l = 2. Initial models are estimated using DMD and DMDc algorithms using initial windows of X = x 1 , · · · , x 40 , Y = y 1 , · · · , y 40 , and Γ = γ 1 , · · · , γ 40 . The weighted (ρ = 0.9) and windowed (w = 40 samples) incremental DMD and DMDc algorithms are applied at each iteration on the generated data x k , y k , γ k , for k ∈ {41, · · · , 200}, to update the initial DMD model and DMDc model. The two models are also used to predict 10 future state vectors at each iteration. The Frobenius norm of the prediction error for incremental DMDc (blue line) and the incremental DMD (red line) are shown in Figure 12. The incremental DMDc models have higher prediction accuracy because of its ability to characterize the relationship between the states and the control input which is vital for any predictive model. The windowed incremental DMDc algorithm appears to have smaller prediction error than the weighted incremental DMDc algorithm. 7. Conclusion and future direction. In this paper, we developed algorithms for incremental computation of time-varying dynamic mode decomposition for autonomous and non-autonomous systems. In contrast to existing algorithms, these algorithms rely on incremental singular value decomposition to update singular values of the data matrix and allow for computation of a reduced order model at each time step. These algorithms are particularly useful for the cases in which the data matrix is singular and incremental matrix inversion based algorithms cannot be applied. We applied the proposed algorithms to an EEG dataset associated with error-related potentials and showed the efficacy of the algorithms in terms of predicting the future EEG signal. We also illustrated that the principal DMD modes obtained were consistent with the EEG activity seen in the brain.
There are several interesting future research directions for this work. First, the proposed approach can be adapted to apply the incremental updates on a nonlinear mapping of the measurements. This could be done in the spirit of extended dynamic mode decomposition proposed in [34]. Such extension may further improve the predictive power of the computed models. Second, it would be interesting to conduct human-in-the-loop experiments in which the EEG data is used in real-time to computed a DMD-based model of human performance and the control is designed to improve the performance.
Code. The MATLAB code used to generate the numerical results presented in this paper is available at https://github.com/MSU-dcypherlab/Incremental-DMD-for-EEG-Data.git.
Appendix A. Proof of Proposition 1. The incremented dataset X k+1 can be represented in term of X k using the following additive updating formula where z k+1 = 0 0 · · · 1 T ∈ R k+1 .
and V s k ∈ C (n+1)×n . Then, V s k can be partitioned as V s k = V s k,1 v s k,2 such that v s k,2 ∈ C 1×n is orthogonal to V s k,1 ∈ C n×n , and X k+1 in (22) can be written as:

MUSTAFFA ALFATLAWI AND VAIBHAV SRIVASTAVA
Thus, the SVD of X k+1 = U x k+1 Σ x k+1 V * x k+1 is given by Appendix B. Proof of Proposition 2. Consider the updated dataset whereχ k 0 x k−w+2 · · · x k is theχ k dataset padded with n-dimensional zero column, and z 1 = 1 0 · · · 0 T ∈ R w . where Substituting the SVD from equation (50) into equation (49), the datasetX k can be expressed as: Since,χ k = 0χ k , it follows that A noteworthy property of the above decomposition that we will use in the later developments is that v χ k,1 Vś k = 0. To establish this property, we note that since U χ kŚ k v * χ k,1 = 0, v * χ k,1 ∈ Ker(U χ kŚ k ). Furthermore, since U χ k is full rank, then v * χ k,1 ∈ Ker(Ś k ) = span(Ṽś k ), and consequently v χ k,1 Vś k = 0.
Appendix C. Proof of Theorem 1. Let the SVD of X k+1 = U x k+1 Σ x k+1 V * be calculated by the incremental SVD update (23). Then, the time-varying DMD operator (15) at sampling time t k+1 is: Substituting the incrementally computed V k+1 from (23) into the DMD operator (53) yields: where I n is the identity matrix of order n, and A ρ k has been added and subtracted in (54). The term U x k+1 Σ x k+1 − ρU x k Σ x k V s k,1 can be rewritten as where (56) is obtained by substituting incremental update for V x k+1 from (23), and (57) is obtained by using the fact that the rows in V s k = V s k,1 v s k,2 are orthogonal to each other. Substituting equation (58) into the equation (55): Appendix D. Proof of Theorem 2. Let the SVD of χ k+1 = U χ k+1 Σ χ k+1 V * χ k+1 be calculated by the windowed SVD update (29). Then, the time-varying DMD operator (15) at sampling time t k+1 is Substituting the incrementally computed V k+1 from (29) into the DMD operator (59) yields: where equation (60) holds because v χ k,1 Vś k = 0 from equation (52). After following the same steps presented in the proof of Theorem 1, equation (61) becomes: The term U χ k+1 Σ χ k+1 − U χ k Σ χ k Vś k Vŝ k,1 can be rewritten as = χ k+1 − x k−w+2 · · · x k 0 V χ k+1 = 0 . . . 0 x k+1 V χ k,2 Vś k Vŝ k,1 vŝ k,2 = x k+1 vŝ k,2 , where equation (63) is obtained after substituting the windowed incremental update formula from (29), and (64) is obtained after substituting Vś k V * s k = Vŝ k,1 V * s k,1 = I and Vŝ k,1 v * s k,2 = 0. The substitution of (65) in (62) yields: Appendix F. ERP prediction error for incremental DMD algorithm with different initial window sizes. Figure 14 show the normalized RMS for the prediction error of the ERP signal during the correct and erroneous events using weighted incremental DMD with initial window size of w 0 = 128 samples, and Figure  15 shows the normalized RMS for the same error using windowed incremental DMD with w = {64, 128, 256}.