Filter data
Filtering EEG data is a common method for reducing low and high frequency signal that is unlikely to reflect neural activity. Filtering can also improve ICA decomposition by removing low frequency drifts and spurious high frequency noise.

Cleaning the data

TESA includes a zero-phase bandpass and bandstop Butterworth filter which uses the Matlab butter and filtfilt functions. Butterworth filters are common bandpass and bandstop filters used in EEG signal processing.
Example of butterworth filtering. Data before and after bandpass (1-100 Hz) and bandstop (48-52 Hz) filtering using a zero-phase butterworth filter.

Removing spike artifacts

TESA also includes median filters which can be used to remove high frequency spike artifacts introduced by electrical components in some TMS machines. These filters replace small windows of data around an artifact with the median value of data from a larger window (definded by the filter order). Median filters can also be used to remove TMS-evoked pulse and muscle artifacts at the expense of the underlying neural signal.
Example of removing spike artifacts using median filtering. Top left: Smaller spike artifacts can be detected and selected using the manual gui option in tesa_findpulsepeak. Top right: High frequency spike artifacts are not locked to the TMS pulse and can occur randomly, most likely as a result of electrical components within the TMS machine. Bottom left: A magnified view showing a TMS artifact and a spike artifact. Bottom right: The spike artifact is removed with the median filter (window: -2, 2; filter order: 5).
Example of removing TMS-evoked muscle activity using median filtering. Median filters can also be used to remove the TMS-evoked muscle artifact, however this also removes the underlying TMS-evoked neural activity. Filter settings (window: -10, 40; filter order: 100).