Tutorial Contents

Remove stimulus artefacts

Algorithm

Process

Detect artefacts

Match events to artefacts

Remove artefacts

Final note

Contents

Remove Stimulus Artefacts

Stimulus artefacts are a common problem when a brief pulse of current is applied as an extracellular electrical stimulus in order to evoke a response. The problem is that the recording system often picks up the stimulus itself, which thus contaminates or obscures the real activity.

data with stimulus artefact
A recording contaminated by stimulus artefacts.

The initial view shows the entire recording. Adjusting the viewport start and end times allows the waveforms of the artefacts to be seen more clearly.

Recording with a large stimulus artefact
An expanded view of the recording shows details of the stimulus artefact in the two traces.

In the extracellular recording (upper trace) the artefact is so large that it dominates the visual appearance of the record. If the gain were increased in order to see the actual data, the artefact would become even larger. In the intracellular recording (lower trace) the artefact is more an aesthetic problem, but nonetheless it somewhat obscures the real data. In both cases it may be useful to remove these artefacts so that the underlying data can be seen more clearly.

Algorithm

The core algorithm is very simple:

  1. Detect each artefact as an event.
  2. Adjust the event onset times and duration so that each event completely encompass its partner artefact. Note that separate adjustments might be needed for each trace involved.
  3. Use the Transform: Set data value in events facility to replace the artefact with suitable data values.

Process

1: Detect Artefacts

In this recording the artefacts are synchronous in the two traces (although they differ in waveform), and so detecting them in one trace will suffice for the other trace too. However, because the challenges are different for the two traces, they will be dealt with separately for tutorial purposes.

Extracellular Recording (trace 1)

The peak-to-peak amplitude of the artefacts considerably exceeds that of the real data, and so a fairly simple threshold method can be used to detect them.

One problem is that the artefact has a moderately complex waveform with several peaks in the positive direction, so each artefact crosses a positive threshold several times in rapid succession. This could be solved by filtering the threshold detection:

The event monitor at the top of the dialog display should show a single event (the red U-shape) for each artefact, so that the threshold dialog looks something like this:

artefact threshold dialog
The artefact waveform crosses threshold several times in rapid succession.

Intracellular Recording (trace 2)

The intracellular recording is more challenging because the artefacts are superimposed on a varying baseline, and their peaks are sometimes below the peaks of adjacent real data (the spikes). However, the artefacts are all very brief, and so can be isolated by filtering.

After the new file loads you can use the threshold method as described for the extracellular recording to detect the artefact in the new trace (3). However, there is a slight complication:

Note that there is an initial negative transient in trace 3 at the start of the recording, which is caused by the filter as it removes the DC component of the membrane potential. If we use a negative threshold we might pick this up as well as the artefacts, so it is therefore easier to use a positive threshold.

You should now have 30 events in both channels a and b. The events should be synchronized relative to each other, although the start times and durations will differ in the two channels. Either event channel could be used for the next stage in the process.

Tidy up

The following is not essential, but it makes the next stage easier to follow.

You should now be back where you were after detecting the artefacts in the extracellular trace.

2: Match Events and Artefacts

Having got events that mark the location of each artefact, the next task is to make events that match the artefacts in start time and duration. Because the artefacts differ in the two traces, we need separate event channels for each.

We will set up a match for the extracellular artefact (trace 1) first.

Scope view matched artefact
The Scope view adjusted to match the stimulus artefact in trace 1.

Now we will match the intracellular artefact (trace 2).

At this stage the events in channel b should match the artefacts in the extracellular trace, while the events in channel c should match those in the intracellular trace. We are now ready to attempt to remove the artefacts.

3: Remove Artefacts

You can now see the actual data between the artefacts, but the artefacts dominate the preview display.

There are 3 options in the dialog which are relevant to artefact removal: Interpolate between event start-end, Set to constant value and Subtract within-event average of source. We can try each of these options on the 2 traces.

Extracellular trace

The default option is Interpolate between event start-end. The effect is apparent in the preview; in the second stimulus in particular, the waveform within the artefact has a strong upwards slope to join the last datum before the artefact with the first datum after. This slope may not be thought appropriate.

Now the artefact is simply replaced by a straight line.

This is the most complex option. The underlying concept is to generate an artefact template by making a point-by-point average of the waveforms within each event, and then to subtract this template from the individual event waveforms.

To be effective, the following conditions must be met:

The new display in the dialog shows the 30 event waveforms as grey traces, plus their point-by-point average in red. It is the red waveform which is subtracted from each event waveform.

The preview shows that this is fairly successful for this extracellular trace. However, there are a couple of points to note. First, the artefact is so large that its negative phase saturates the analog-to-digital converter (ADC) used in acquiring the data. This is apparent in the flat bottom of the negative peak. It also probably just saturates during the positive peak too. If the ADC saturates, then any real data occurring during the period of saturation is irretrievably lost. Second, the very first stimulus in the recording has a suspiciously large spike in it after artefact removal. It is not possible to be sure, but I suspect that the artefact waveform generated by the first stimulus in this recording was slightly different to that generated by subsequent stimuli.

Write Data

The "correct" choice of the three options depends on the data, but the safest is the second, since it does not risk introducing any new artefact into the data.

A new trace 2 is written which is identical to trace 1, except the waveform during the artefact has been set to 0. The gain on this trace can be increased to view the actual data, without the artefact dominating the display. You could select to replace the original trace rather than add a new trace, but you can always delete or hide the original trace later if you want, so keep the Add trace option selected at this stage.

Intracellular trace

The new extracellular trace has caused the intracellular trace to be shifted down, so that it is now trace 3 rather than trace 2.

The lower trace in the Preview window should now show the intracellular recording with the artefact removed. It is important to remember that this method reconstructs the waveform within the artefact by simple linear interpolation between the start and end, so there is no additional information content in this period. However, it does remove the visual distraction of the artefact from the display.

What about the other two options?

The template subtraction method also does a good job of removing the artefacts. For comparison, it is worth looking in more detail at the waveform.

Write Data

For the intracellular trace there are two viable options. The Interpolate option is the safest because it makes no attempt to reconstruct the detailed waveform within the artefact. However, with these data the Subtract option seems to work well, so leave it selected.

You now have a file with 4 traces. Traces 1 and 3 are the original data, traces 2 and 4 are the data after artefact removal. If you hide the original traces and event channels, the data should look like this:

artefact removed
The recording after removing the stimulus artefacts.

Final Note

As with any manipulation of experimental data, the artefact removal process should be documented in any report that uses the data.