A novel algorithm for removing artifacts from EEG data