This function removes or replaces spikes in the data from the
channel specified. The algorithm used here is to discard points that lie outside of a threshold. The data are smoothed by a median filter of length
windowLength to produce a "reference" time series. Residuals are formed by subtracting the reference time series from the original time series. Residuals that fall outside of a
threshold, specified as the number of standard deviations, where the standard deviation is computed from the residuals, are flagged for removal or replacement.
The default behaviour is to replace the flagged values with NaNs. Flagged values can also be replaced with reference values, or replaced with values linearly interpolated from neighbouring "good" values.
The red circles indicate the samples in the blue time series that are spikes.