Integrate
To integrate data means to find the area under a section of waveform, often relative to some non-zero baseline such as the membrane potential. The integral can be positive or negative.
- Load the file sine 4 8
There are two traces. The upper shows a 4 Hz sine wave, the lower shows an 8 Hz sine wave. Both were constructed within DataView using the built-in expression parser. We will integrate the area under the first half cycle of the sine wave in the upper trace. We know exactly what the answer should be, because the integral of the first half cycle of a sine wave is:
\begin{equation*} \int_{t=0}^{t=1/(2f)} a\sin (2 \pi f t) dt\label{eq:eqDerivAlphaBetaP} \end{equation*}
where \(a\) is the amplitude (= 1), \(f\) is the frequency (= 4 Hz) and \(t\) is the time in seconds. This has the solution \(a/(\pi f)\), which for 4 Hz is 0.079577, or, if \(t\) is expressed in milliseconds, 79.577.
- Select the Analyse: Integrate menu command to open the Measure dialog.
This is a general-purpose measurement facility that is also available through other meu commands, but it now opens with the Integral A to B option pre-selected. We need to tell the program which section of data to analyse, and the baseline value. This can be done explicitly, or by setting cursors. Initially, we will do the latter, because it is quick and flexible.
- Press the 'h' key on your keyboard to add a horizontal cursor.
- Drag it until it lines up with the first datum in the waveform, which will have a value of 0. Note that the cursor label reads "Ax 1: 0.0 Ax 2: 6.8". The first value tells us that we have set the cursor correctly (within the limits of screen accuracy).
- Press the 'v' key on your keyboard to add a vertical cursor, and drag it to the extreme left of the view. Its label should show time 0.00 ms.
- Press v again, and drag the second to a position where it crosses the horizontal cursor at the end of the first "hump" in the sine wave. The time should read aboutAs discussed later, cursor position accuracy is limited by monitor screen resolution, so you may not be able to set a cursor at exactly the position you want. 125 ms.
- Click the Measure button in the Measure dialog.
When I tried this the Measure output showed 77.0175 val.msec. This is reasonably close to the predicted analytical value, but there is still non-trivial error. The problem is that cursor time and voltage values are read from their screen locations, and these are only accurate to the nearest pixel. The problem could be minimized by expanding the view to full screen and displaying on a high-definition monitor, but it may still not be as accurate as is possible with these data. This illustrates the limitations of using the screen cursors for making precise measurements.
- Select the Measure using: time option in the Measure dialog, and set the lower time B to 125 (leaving the upper time A at 0).
This will integrate from time 0 to 125 ms, which is the first half cycle of a 4 Hz sine wave. The data will be measured directly from the file. - Select the val option for the baseline, but leave the value at 0.
- Click the Measure button.
Now the measured value is 79.5733 val.msec, which very close to the predicted value.
- As a reality check, set the trace to 2 in the Measure dialog.
- Click Measure.
The integration time now encompasses the first full cycle of the 8 Hz sine wave, and the integral is 0 val.msec, as it should be.
Real data
The cursor method may be perfectly adequate if you are measuring from real data - the innaccuracy due to pixelation may be trivial compared to that caused by inherent noise. But for greater accuracy you can set the baseline explicitly by measuring the average data value from some "silent" part of the recording outside of the perturbation whose waveform you want to integrate. And setting the time values explicitly means that the measurements are completely repeatable, whereas setting cursors "by eye" can cause variability if you measure the same data twice with different view settings and/or monitor configurations.