Removing artifacts from a signal

I want to get the Stim-on and Stim-off times from a dataset of continous data, but am running into problems with artifacts occurring mid-pulse.
How can I remove these erroneous spikes from stimulation data, without shifting the rest of it?
Savitsky-Golay filter didn't work, template matching using convolution is not possible because the pulses are different widths.

1 Comment

The artifacts are not always mid pulse. They also differ in magnitude. But they are always just 1 sample wide. We also tried normalising the signal and using the first differential but because of this high-frequency noise, it doesn't work.

Sign in to comment.

Answers (1)

Mathieu NOE
Mathieu NOE on 9 Nov 2020
hi
maybe you can localize the artifacts by using the attached function (zero crossing)
artifacts will have two very nearby zero crossing time index, with opposite slopes (set threshold slightly below max amplitude)
so you can smooth out or remove the wrong values (and interpolate) inside some limited bins of values

2 Comments

I think Maria tried this, but it didn't work completely. SHe was able to remove like 95% of the artifacts but not all.
hello
so putting the crossing threshold around 2.7 does not remove 100% of the artifacts ?

Sign in to comment.

Categories

Commented:

on 12 Nov 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!