A system includes an array of electroencephalography (EEG) electrodes for placement on the head of a subject and a transcranial magnetic stimulation (TMS) device. A controller is configured to operate the array of EEG electrodes to acquire a plurality of EEG signals concurrently with operation of the TMS device to apply a TMS pulse to the head of the subject. The controller is further configured to select an initial set of EEG signals from the EEG signals and to fit an initial decreasing rational function of time to a TMS artifact component of each EEG signal of the initial set. The TMS artifact component of each remaining EEG signal is fit to a linear combination of the initial decreasing rational functions. Each EEG signal is corrected by removing from the EEG signal the function that is fit to the TMS artifact component of the EEG signal.