To perform the LLAMAS Kalman filter in real time, channels were separated into EEG channels (those channels which correspond to the grommet locations listed above, except AFz and FCz, which were ground and reference), and reference channels (all other channels, excluding ECG, EMG1, 2, and 3, and E1, E2, M1 and M2). Filtering was performed separately for each EEG channel. When each new sample was received, the following steps were performed to produce the ‘cleaned’ sample:
Where and are indices tracking the current EEG channel number and sample number, respectively. is the error covariance matrix, which is initialized prior to each recording to be an identity matrix of size , where n is the number of reference channels. is the noise covariance matrix, which is a model hyperparameter and is held constant, and is assumed to be an identity matrix multiplied by a scalar of size is the Kalman gain vector. is the vector of reference channel data for the current time step (plus one additional constant value), a vector of size is the measurement noise covariance scalar, a constant model hyperparameter. is the weight vector, which is initialized prior to each recording to be a vector of zeros with size is the sample value for the current channel and timepoint and is the output cleaned sample. This procedure was based generally on an fNIRS artifact reduction technique (Abdelnour and Huppert, 2009).
EEG-LLAMAS is open-source and available at github.com/jalevitt/EEG-LLAMAS. Validation data is available at https://doi.org/10.6084/m9.figshare.22110872.v1. It is dependent upon two pre-existing software packages, specifically Lab Streaming Layer (LSL) (Kothe, 2014), which was used to stream data from the EEG amplifiers into MATLAB, and PsychToolbox (Brainard, 1997; Pelli, 1997), which can be used to present stimuli during recordings. A minimum MATLAB version of 2021a is required, including the Signal Processing Toolbox. It was developed on Ubuntu 18.04, but is compatible with other modern operating systems.
Do you have any questions about this protocol?
Post your question to gather feedback from the community. We will also invite the authors of this article to respond.
Tips for asking effective questions
+ Description
Write a detailed description. Include all information that will help others answer your question including experimental processes, conditions, and relevant images.