Tutorial Contents

Remove mains interference

Algorithm

Episodic data

Exclude artefacts

Noise spectrum

Contents

Remove Mains Interference

This recording is heavily contaminated with mains-frequency interference.

The upper trace in the preview shows the original raw data, the lower (red) trace shows the filtered data.

De-buzz preview
Preview of the de-buzz filter applied to a recording contaminated with interference at mains frequency. The upper trace is the original signal, the lower trace is the filtered signal.

The de-buzz filter evidently does quite a good job of removing the mains interference from the signal.

Algorithm

The de-buzz process works by taking the point-by-point average of several successive sections of a data trace, each section equal to the interference period in length. This generates an interference template by signal averaging. This template is then subtracted from each successive section of the original data signal, leaving, hopefully, the real data signal without the contaminating interference. Any DC component in the template also has to be added back to maintain it in the original signal.

The user has to supply the Noise interval for the interference period to the programme, but the two most likely values of 60 Hz (USA) and 50 Hz (most of the rest of the world) are supplied as pre-set options.

In theory we could de-buzz an entire recording using one template derived from the whole record. However, in practice, this doesn’t work very well. There are three problems.

  1. Interference is often not stable over a long period – it undergoes subtle changes in shape and waveform as the recording and environmental conditions change over time. This means that the template may need to be updated over time. The Number of cycles in template average parameter sets the limit to the cycles contributing to the template. Once the initial template has been subtracted from all the data that contributed to it, the template is updated by dropping the first interference cycle from the average, and adding the cycle that immediately follows the initial transform period. The next cycle period of the recording is processed using this updated template, and then the template is updated again. In this way the template is maintained as a rolling average that continuously updates throughout the process.
  2. If the original record is episodic, we absolutely must restart both the averaging and the subtraction process at each episode boundary, since there will almost inevitably be a phase shift in the interference at this point.
  3. If there are large amplitude but brief elements in the real signal (such as stimulus artefacts) these may contaminate the template, and then this contamination gets added back into the data at the same interval as the interference, which can make the interference pattern worse than it was to begin with. So sections of data containing brief large real signals must be excluded from the average.

The data in noise 50 are non-episodic and do not have any large artefacts, so the latter two issues do not occur. The first is covered by the number of cycles in the template being limited to 50 (the maximum allowed is 100).

The trace display within the main De-buzz dialog shows 50 overlaid successive sweeps of data as grey traces. Each sweep is one Noise interval in duration, and each has its vertical start position aligned on the first sweep. These sweeps make the first template. There is a horizontal purple line marking the zero value of the sweeps, and a red line that is the average of the grey sweeps, and hence constitutes the initial interference template.

The default noise interval is set to 20 ms, and if there is coherent interference at this interval, then the red line interference template should deviate signicantly from the zero-level purple line. It does.

De-buzz dialog
The De-buzz filter dialog with the default settings showing that the resulting noise template (red line) deviates from the zero value (purple line).

This recording was made in the UK where the mains frequency is 50 Hz, so the interference period does indeed match the template duration of 20 ms.

The template duration is now 16.66 ms and there is no coherence in the data sweeps so the red line average is flat (and disappears under the purple zero-line). The preview shows that the filtered data still has the mains interference. In fact, it is worse because the 60 Hz template adds additional noise.

Episodic data

This shows a two channel recording containing 3 episodes, each 800 ms in duration. A stimulus was applied about half way through each episode, and this evokes EPSPs in both traces, but is accompanied by a large stimulus artefact.

60 Hz interference
A 2-trace episodic recording with mains interference on the second trace. Note the DC shift between the 2nd and 3rd episode (marked by event 3 in channel a), and the large stimulus artefact that occurs about mid way through each episode.

The upper data trace is relatively clean, but the lower trace is heavily contaminated with mains-frequency interference, which has the crenellated appearance typical of a ground-loop problem.

The trace display within the dialog initially shows 35 overlaid successive sweeps of data as grey traces. The reduced Number of cycles in template average is because the programme has detected that the recording is episodic, and has set the number of cycles to the maximum (with some slack) that can be obtained from one episode.

At the moment, there is no coherence in the data sweeps and so the red line average is flat, apart from the deviation caused by the stimulus artefact. The parameters need to be adjusted to see the interference.

There is still no coherence in the data, which is actually encouraging because we are looking at trace 1, and the flat red line average indicates that there is no 60 Hz interference in trace 1, thus confirming the visual impression.

The wavy red line is the interference template that will be subtracted from the data. However, there is a problem - the obvious spike near its beginning. This is caused by the stimulus artefact. The artefact only occurs in one of the 35 noise sections comprising the average, but it is so large that it is still apparent after averaging. We will deal with this later.

The upper trace in the preview shows the original raw data, the lower (red) trace shows the transformed data. At the moment, the transformed data gain is too low to be useful.

The mains interference has been largely eliminated from the trace, which is what we want. However, there are regular vertical spikes at the mains frequency, because a diminished copy of the stimulus artefact has been added to each noise interval. This is definitely not what we want.

Exclude artefacts

We need to exclude the noise period containing the artefact from the average.

Two horizontal blue lines appear in the dialog display. These are draggable limit cursors, and any noise sections containing data values that cross these cursors are excluded from the average. Such sections are coloured green in the display. As it happens, the default positions of the blue cursors is pretty much where we want them, but if they were not you could drag them with the mouse.

The wavy red template line now shows the interference signal without the contaminating stimulus artefact, whose sweep is excluded because it crosses the limit cursors. And the annoying vertical lines have disappeared from the Preview display. If you wish, you can repeatedly uncheck and check the limit cursors box, and observe the change in the template and the preview.

a
de-buzz dialog
b
de-buzz preview
Artefact exclusion. a. The De-buzz dialog showing horizontal blue limit cursors. b. Preview of trace 2 after setting up the dialog parameters using limit cursors.

We are now ready to actually de-buzz the data

The display should now look something like this:

De-buzz result
The second trace is unchanged; it is still contaminated with interference. The third trace is the same trace after the de-buzz process.

If you wished you could have selected dialog options to replace the original trace 2 rather than adding a new trace. You could also have modified the original file (so long as it was a native Dataview dtvw-dat file not an original acquisition file) rather than writing a new file.

The Noise Spectrum

Spectral analysis of noise 60 shows the effectiveness of the de-buzz process.

a
60 Hz interference spectrum
b
60 Hz interference de-buzz spectrum
Power spectra before and after de-buzzing. a. The interference is apparent as narrow-band power spikes at 60, 180 and 300 Hz in the raw data trace. b. The interference has been eliminated after de-buzzing. Power and frequency scales are linear.

The high power at low frequency reflects the DC component of the membrane potential and the relatively slow evoked potential.