Skip to content

Remove glitches

Thomas Vincent edited this page Feb 19, 2019 · 5 revisions

Context

Transient disconnections or sampling errors may happen during recording. Here, the case of very brief glitches happening only during one sample is considered.

The signal of such artifacts looks like spikes with large variations:

signal

signal zoom

Process

The process NIRS > Remove glitches works by detecting hat-shape patterns with large variations in the signal. It then replaces the detected artifactual samples with the average the two flanking samples.

signal zoom

Parameter "Variation threshold: X * std(gradient)" defines what should be considered large variations. Large variations are detected if the absolute gradient at any position is X times the standard deviation of the gradient over the whole time-series. These positions with large variations are then filtered to only keep those corresponding to a hat (strong increase then decrease or strong decrease then increase). Note that large variations occurring at the first or last samples are also fixed but no hat shape detection can be done there.

The sample values at the detected positions are replaced with the average of the previous and the next sample values. For the first sample, the average is over the two next sample values. For the last sample, the average is over the two previous samples values.

Example

Input signal:

signal zoom

Treated signal: signal zoom