## 5 Methods
### Application of CNN-LSTM for Artifact Removal
#### 5.1.1 Generation of Augmented EEG Recordings  
For each participant in the study (S01-S24), a 60 s session was recorded during which the individual sat still and observed a switched-off LED with their eyes open. Under these conditions, the recorded EEG signals were assumed to be free of muscle artifacts. Next, one-second time windows were selected based on the judgment and visual assessment of a clinical neurophysiologist. The number of such artifact-free windows varied among participants, ranging from a few to several dozen.  
To increase the number of artifact-free EEG examples identified by the expert, a data augmentation process was performed. Three signal-modification techniques were used to diversify the dataset in a realistic way while preserving essential signal characteristics. These techniques were spectrum modification, sample shifting, and noise addition.  
The augmentation method based on spectrum modification involved randomly altering the EEG signal spectrum. Phase shifting alters the shape of the signal in the time domain, which can lead to changes in its appearance, including that of the EEG signal. However, this operation does not affect the amplitude spectrum, thereby preserving the spectral characteristics of the signal. In practice, this means that the distribution of energy across individual frequency bands remains unchanged, which is crucial for many EEG analyses based on spectral features. As a result, phase shifting can be used as a data augmentation method that enables the generation of new, diverse signal variants while maintaining their essential frequency-domain properties. First, each EEG channel was transformed using the fast Fourier transform (FFT) to analyze its spectral components. Random changes in amplitude and phase were then introduced in the frequency domain.  
Figure 5: Diagram illustrating how data are used to train the CNN-LSTM.  
The amplitude of each frequency component was scaled by a random factor in the range of 0.8 to 1.2, and a random phase shift between \(-\pi\) and \(\pi\) was added to each component. After these modifications, the inverse FFT (IFFT) was used to convert the spectrum back to the time domain, resulting in a modified EEG signal.  
The augmentation method using sample shifting involved randomly and cyclically shifting the EEG signal in time. An offset between \(-100\) and \(100\) samples was selected randomly. The signal was then shifted accordingly, with samples exiting from one end and re-entering at the other end in a first-in-first-out manner. This approach maintained data integrity while introducing variability in the time domain, thus enriching the training set.  
The augmentation method involving noise addition introduced random Gaussian noise to simulate real-world measurement conditions, where interference naturally occurs. First, Gaussian noise was generated and scaled relative to the standard deviation of the EEG signal, at 5% of that standard deviation. The noise was then added to the EEG signal, introducing subtle distortions that resembled actual recording conditions.  
By employing these augmentation techniques, a diverse dataset was created that closely mirrored the properties of raw EEG signals while also increasing the dataset's size and variety. This provided a solid foundation for training and testing neural network models. Each of the techniques was applied separately. In total, 80,000 EEG signals were generated through these augmentation methods. A visual inspection of several dozen randomly chosen augmented EEG samples confirmed that they closely resembled raw EEG recordings.