Set Data Value in Events
DataView allows you to set data values within the times encompassed by events in a variety of different ways. This is particularly useful in the construction of artificial data for experimental purposes (several tutorial sample files were constructed using this facility), but it can also be used to manipulate experimental data. Of course, any such manipulation should be fully documented in any report that uses the data.
The following walk-through demonstrates some of the possibilities.
- Load the file flat with events.
As the name suggests, the initial data trace is a flat line. There are 3 events, with their durations shown as labels.
- Select the Transform: Set data value in events menu command to open the Set data value within events dialog.
- Select the Set with user-defined equation option.
- Enter sin((1000/ed)*_pi*et/1000) into the equation edit box (you can cut-and-paste from this page if desired). This should generate a half-wave sine signal (amplitude 1) within each event, with the wave frequency scaled so that the half wave completely occupies the event.
The standard formula for generating a sine wave is \(y = \sin(f\, 2\, \pi \, t)\), where f is the frequency (Hz) and t is time (s). In the DataView formula, ed is the duration of the current event and so relates to the desired frequency, and et is the relative time within the event. These values are in milliseconds, so need scaling into seconds. The variable _pi is π. Because the 2 is ommitted, the formula generates a half-wave rather than the full cycle.
- Select the Replace trace(s) option.
- Click OK, and choose a new file name when prompted.
- Click the Autoscale toolbar button () when the new file loads.
- Click the Reduce gain toolbar button () to make the trace easier to see.
You should see the 3 half-wave sine signals within each event.
- With the new file active, open the Set data value within events dialog again.
- Select the Set to average within event option.
The default trace 1 should be the trace with the half sine waves in each event. - Uncheck the Write new file option, but leave the Add trace(s) option selected.
- Click OK.
The new trace should contain 3 square waves, with identical amplitudes of 0.637. This is indeed the average value of a half standard sine wave, whatever the frequency. (You can easily check the DataView values using the Analyse: Measure Data: Click-and-list method.)
See also...
One practical use for this facility is to remove stimulus or other artefacts from a trace. A example is given here.