ERP Bin Operations

The ERPLAB > ERP Bin Operations routine allows you to compute new bins that are combinations of the bins in the current ERP structure.  For example, you can average multiple bins together, and you can compute difference waves.  To use it, you will write simple equations that describe how the new bin is computed.  For example, to create a new Bin 3 that is the average of the current Bin 1 and Bin 2, you would write the following equation: Òb3 = (b1+b2)/2Ó (or Òb3 = 0.5*b1 + 0.5*b2Ó).  The screenshot below shows the GUI.  You will usually want to create a label for a new bin by putting Òlabel [text]Ó at the end of the equation.  In the example below, a difference wave is being created (b3 = b2 – b1) and ÒRare minus Frequent difference waveÓ is specified as the label.

The panel at the right side of the Bin Operations GUI lists the bins in the current ERPset.  The panel at the left side of the window contains the equations for creating the new bins.  The equations can be saved in a file (using Save list or Save list as) and loaded again at a later time (using Load list).  When you click RUN, the equations are sent to the routine that performs the requested computations.  Ordinarily, the equations in the window are sent as a cell array.  With a long list of equations, this will lead to a very complicated function call in your history.  If you check Send file rather than individual equations, the file will be sent instead of the equations, making the history simpler (which is convenient if you plan to turn the history into a script).  But the same bin operations will be performed either way.

Basically any standard mathematical equation can be used.  Here are some examples:

B5 = ((b1+b2)/2) – ((b3+b4)/2) label Average of bins 1 and 2 minus average of bins 3 and 4

Bin5 = sqrt(b2^2 + b3^2) label Square root of sum of squared bins 2 and 3

b5 = abs(b4) label Absolute value of bin 4 (rectification)

bin5 = b4 + 1 label Add an offset of 1 microvolt to the bin 4 waveform

                 

In addition, we have defined a function that averages together a set of bins, weighted by the number of epochs that contributed to each bin (which is stored in the ERP structure).   For example, if 10 epochs were originally averaged together into bin 1 and 90 epochs were originally averaged together into bin 2, you could create a bin that is equivalent to what you would have gotten by averaging these 100 epochs together during the initial averaging process (which is the same as Ò(10*bin1 + 90*bin2)/100Ó).  It is used as follows:

Bin3 = wavgbin(1, 2) label Weighted average of bins 1 and 2

Bin9 = wavgbin(1:8) label Weighted average of bins 1 through 8

Bin20 = wavgbin(1:4,6,9,12:15) label Weighted average of bins 1-4, 6, 9, and 12-15

                 

Modes of Operation

Bin Operations has two modes of operation, which are selected with the two buttons at the bottom right of the GUI (see screenshot above).  In one mode, the equations modify existing bins and add new bins within the current ERPset.  In this mode, you can modify one bin and then use this modified bin to create or modify another bin (this is called recursive updating).  In another mode, the current ERPset serves as the input to equations, and a new set of bins is created in a new ERPset (this is called performing a set of independent transformations).  The ERPLAB Tutorial provides detailed examples of these two modes.

Creating a new ERPset.  When you are creating a new ERPset, your equations begin with ÒnbÓ or ÒnewbinÒ as a reminder that you are creating a new bins within a new ERPset.  You must start with bin 1 (Ònb1 =Ó or Ònewbin1 =Ó) and then continue consecutively with bins 2, 3, 4, etc.  You can have as many or as few bins in the new ERPset as you desire in this mode.  Consider this example, in which the current ERPset contains 4 bins:

nb1 = b4

nb2 = b1

 

In this example, the bin 1 in the new ERPset is simply bin 4 from the current ERPset, and bin 2 in the new ERPset is simply bin 1 from the current ERPset.  Thus, the new ERPset contains only two bins, and they are in a different order than in the original ERPset.

Modifying the current ERPset.  When you are modifying the current ERPset, bins are referenced as ÒbÓ or ÒbinÓ on both sides of the equals sign (e.g, Òb3 = b2 – b1Ó or Òbin3 = bin2 – bin1Ó).  In this mode, you can modify existing bins or add new bins, but you cannot delete bins.  If you try to reorder the bins, you will likely run into problems.  Consider the following example, which looks as if it should swap the order of bins 1 and 2:

b1 = b2

b2 = b1

 

If you were to try this when modifying an existing ERPset, the first line would cause the contents of bin 1 to be replaced with the contents of bin 2.  The second line would then cause bin 2 to be replaced with this newly updated version of bin 1 (which now holds the original data from bin 2).  Thus, you would end up with the original contents of bin 2 in both bin 1 and bin 2.

Despite this limitation, it is often more convenient to modify the existing ERPset than to create a new ERPset.  For example, this mode allows you to add a set of difference waves to the end of the current ERPset rather than having two ERPsets, one for the original data and one for the difference waves.  In addition, it can sometimes be efficient to create a bin and then use this new bin in equations that create additional bins.

Hint: When you are modifying an existing ERPset, you might first want to make a duplicate of the current ERPset and work on that duplicate, as described in the section on saving ERPsets.

When you are modifying an existing ERPset, your list of equations does not need to re-define the existing bins.  However, the bins that are defined must be in ascending order, and the result cannot have any missing bins.  For example, if the current ERPset contains bins 1-10, you could have a list of equations like this:

B3 = B1 – B2 label Re-definition of bin 3

B11 = B3 – B5 label Create new bin 11 as difference between bin 5 and newly updated bin 3

B12 = B11^2 label Create new bin 12 that is the new bin 11 squared

 

However, you could not have a list of equations that began with bin 12 (because there would be no bin 11) or a list in which bin 12 came before bin 11.

Specifying subsets of channels

It is also possible to specify different subsets of channels for the different bins being used in a given equation.  For example, if you are trying to compute a lateralized readiness potential (LRP) waveform, you will want to subtract trials with an ipsilateral response from trials with a contralateral response, averaged across the left and right hemispheres.  That is, you want to make a contralateral average (left-hemisphere electrode sites for right-hand responses averaged with right-hemisphere electrode sites for left-hand responses) and an ipsilateral average (left-hemisphere sites for left-hand responses averaged with right-hemisphere sites for right-hand response) and compute the difference. 

To do this in Bin Operations, you first define sets of electrodes corresponding to the left and right hemispheres.  Imagine that the electrode sites 1-6 are as follows 1=F3, 2=F4, 3=C3, 4=C4, 5=P3, 6=P4.  And imagine that Bin 1 corresponds to left-hand responses whereas Bin 2 corresponds to right-hand responses.  The following shows how you would define left- and right-hemisphere groups and use them to form a contralateral waveform (new Bin 1), an ipsilateral waveform (new Bin 2), and a contra-minus-ipsi difference wave (new Bin 3):

LH = [1 3 5]

RH = [2 4 6]

b1 = (b2@LH + b1@RH)/2 label Average Contra

b2 = (b1@LH + b2@RH/2 label Average Ipsi

b3 = ((b2@LH + b1@RH)/2) – ((b1@LH + b2@RH)/2) label Average Contra Minus Ipsi

 

In this example, we first define two electrode groups, named LH and RH (containing the left-hemisphere and right-hemisphere electrode sites, respectively).  We then specify which electrode groups should be used for each bin by connecting the bin number and the electrode group with @ symbol.

The resulting ERPset would have only 3 channels (automatically labeled ÔF3/4Õ ÔC3/4Õ ÔP3/4Õ).  Consequently, you would not be able to update the existing ERPset when creating these new bins; you would need to create a new ERPset.

You can have ERPLAB automatically create left- and right-hemisphere groups on the basis of the channel labels.  Specifically, the ÒLH =Ó and ÒRH =Ó lines in the above example could be replaced by the following line:

[LH RH] = splitbrain(ERP)

The splitbrain() function finds pairs of electrodes whose names are identical except for ending with consecutive odd (for left-hemisphere) and even (for right-hemisphere) numbers (following the International 10/20 System convention).  For example, it would treat Fp1 and Fp2 as corresponding left-right pairs.  But the electrode names do not have to be standard 10/20 names (e.g., it would treat Temporal125 and Temporal126 as corresponding left-right pairs).  Any electrode sites that donÕt end in a number will be excluded from the channel groups (e.g., Fz), and will generate a warning (which you can usually ignore because you usually want to exclude such electrodes when creating left-right pairs).

Note that, although ÒLHÓ and ÒRHÓ were used to name the electrode groups in these examples, you can use any strings to name the groups.

<<Previous Section           Next Section >>


Back to Table of Contents