# Spikes reduction in data

## Description

Spikes in data due to different nature can be removed, if desired, from the original data. LTPDA spikecleaning detects and replaces spikes of the input AOs. A spike in data is defined as a single sample exceeding a certain value (usually, the floor noise of the data) defined by the user:

where is the input data high-pass filtered, is a value defined by the user (by default is 3.3) and is the standard deviation of . In consequence, a spike is defined as the value that exceeds the floor noise of the data by a factor , the higher of this parameter the more difficult to "detect" a spike.

## Syntax

```
b = spikecleaning(a, pl)
```

## Parameters

The following parameters can be set in this method:

• 'kspike' - set the value (default is 3.3)
• 'method' - method used to replace the "spiky" sample. Three methods are available ---see below for details---:
• 'random'
• 'mean'
• 'previous'
• 'fc' - frequency cut-off of the high-pass IIR filter (default is 0.025)
• 'order' - specifies the order of the IIR filter (default is 2)
• 'ripple' - specifies pass/stop-band ripple for bandpass and bandreject filters (default is 0.5)

## Algorithm

Random: this method substitutes the spiky sample by:

where is a random number of mean zero and standard deviation 1.

Mean: this method uses the following equation to replace the spike detected in data.

Previous: the spike is substitued by the previous sample, i.e.:

## Examples

1. Spike cleaning of a sequence of random data with kspike = 2.

```
x = ao(plist( 'waveform', 'noise', 'nsecs',1e4, 'fs',10)); % create an AO of random data sampled at 1 Hz.
pl = plist( 'kspike', 2);                         % kspike = 2
y = spikecleaning(x, pl);                         % spike cleaning function applied to the input AO, x
iplot(x, y)                                       % plot original and "cleaned" data
```