next up previous contents
Next: Averaging curves Up: Operating with arrays as Previous: Global operation on vectors   Contents

Measuring curves

Now we could try out some examples to apply the above concepts to something similar to a visual evoked potential (VEP). We are going to calculate a form similar to a VEP. Please, do not take into consideration at this moment how the trace is formed, we are only interested in the process of measurement.

We begin with


 
-->cleanvep = 2 * (sin(%pi*[0:127]/128).^2) .* (cos(2*%pi*[0:127]/128));
 
-->cleanvep = [zeros(1,36), cleanvep,zeros(1,36)];
 
 
-->plot(cleanvep)
We got `cleanvep', a trace similar to a visual evoked potential. It emulates a sweep of 200 ms sampled at 1 kHz. It has been denominated `cleanvep' because afterwards we will intend to extract this form from a noisy signal. First of all, we plot `cleanvep' in figure 3.1.

Figure 3.1: Simulation of a VEP
\begin{figure}
\epsfbox{figures/cleanvep.eps}
\end{figure}
It seems a form similar to a visual evoked potential (it has been represented as we usually see it in clinical examinations -negativity up- such as it appears on the plot). The amplitude goes from 1 uV to -2.6 uV and the latency of the component usually called `P100' lies around 100 ms. The plot has three small symbols (`+') indicating local maximum and minimum and we are going to calculate its position.

To calculate the minimum



-->[minval,minndx] = min(cleanvep)
 minndx  =
 
    101.  
 minval  =
 
  - 2.
The result indicates that our VEP has a latency of 101 ms (obviously in a real case it would be convenient a better sampling) and an amplitude or 2 uV. We have two different upward peaks but `max' does not return local maximums and we will have to make some arrangements. We can split the trace and calculate the peaks in two steps


-->[maxval1,maxndx1] = max(cleanvep(1:minndx))
 maxndx1  =
 
    58.  
 maxval1  =
 
    0.2498011
We get the first peak that has a latency of 58 ms and an amplitude of 0.24 uV. Peak-to-peak amplitude will be


-->maxval1 - minval
 ans  =
 
    2.2498011
If we calculate the second peak in a similar way


-->[maxval2,maxndx2] = max(cleanvep(minndx:$))
 maxndx2  =
 
    44.  
 maxval2  =
 
    0.2498011
The measurement of amplitude seems to be properly calculated but, as the plot clearly shows, it has not a latency of 44 ms. This fail derives from `cleanvep(minndx:$)' which produces a vector beginning with index `1'. To obtain the correct value we could make the correction


-->maxndx2 = maxndx2 + minndx - 1
 maxndx2  =
 
    144.
Once we have obtained the correct value it only rests to mark the curve. It can be done with the command


-->time = [maxndx1;minndx;maxndx2];
 
 
-->mark = [maxval1;minval;maxval2];
 
 
-->plot2d(time,mark,-1,'000')
The last command plots the marks (`small crosses') at the positions that we have previously calculated to show that the measurement process was correct.


next up previous contents
Next: Averaging curves Up: Operating with arrays as Previous: Global operation on vectors   Contents
j 2003-01-23