[Eeglablist] Varying number of channels and computing grand mean ERPs

Arnaud Delorme arno at salk.edu
Mon Jul 18 18:06:54 PDT 2005

Dear Edward,

there is definitelly no easy answer to your question. The easiest way to 
deal with this issue would be to write a small script. If you have all 
the epochs for all the channels in EEGLAB and a cell array containing 
the epochs labelled as "good" for each channel, for instance

 > goodepochs = { [ 2 5 6 8 9 ... ] [ 3 4 8 9 ... ] ...};

meaning that epochs 2, 5, 6, 8, 9 etc... are good for the first channel, 
and epochs 3,4, 8, 9 are good for the second channel, you may then 
compute the ERP for all channels

 > for chan = 1:EEG.nbchan
 >     ERP(chan,:) = mean(EEG.data(chan,:,goodepoch{chan});
 > end;

A trick would be then to save the ERP in the EEG dataset

EEG.data = ERP;
EEG.event = [];
EEGLAB memory
eeglab redraw % update EEGLAB GUI

so you can use the grand average function in the menu once you have 
performed this operation for all datasets (all datasets contain then 1 
trial which is the ERP).

Hope this help,


Edward Justin Modestino, M.Phil. wrote:

>I am relatively new to EEGLAB.  I have been doing my data analysis,
>writing my own programs, in MATLAB.  I am interested in using the EEGLAB
>GUI.  I have my data imported into EEGLAB.
>The first problem was that my data was constructed on a channel by channel
>basis with artifact removal, i.e. only epochs (trials) within specific
>channels which have artifacts are removed.  This leads to a varying amount
>of epochs (trials) per channel within the same condition.  Thus, channel
>F5 may end up with 250 epochs for one condition and whereas channel P04
>may end up with 190 epochs for the very same condition.  Often a channel
>may go in and out during an experiment, or an artifact, other than an eye
>movement, may be present in in a select group of channels, ie, temporal
>channels and muscle artifacts, etc.  So, the only way this data can be
>kept is in a cell array. This is the way my advisor instructed me to  do
>This causes a problem with the importation into EEGLAB, which requires and
> a matrix, which obviously necessitates equal dimensions or the same
>amount of epochs for each channel.
>What I have done is find the lowest common number of epochs per channel.
>Often this does not leave me with enough data. If some channels have 120
>or 130 epochs, I delete all the data for that channel and use a higher cut
>off of epochs, like say 192.  So, all channels that have less than 192
>epochs, have all their data thrown away, whereas all channels with more
>than 192 epochs, say 260, have every epoch over 192 thrown away.  Thus, I
>end up with  data which has the same amount of epochs in each channel with
>data, i.e. 192.  Those without data are excluded from importation.  I do
>not use them in the location file.
>In doing this, I have thrown out whole channels completely which had some
>data and many epochs for channels with a high amount of intact epochs
>(trials) for a condition.
>Now, I have this in EEGLAB and can do analysis.  But, if I wish to do a
>grand mean ERP or compare different subjects for the same condition, I
>will run into a problem.  Some subjects may have a specific channel while
>others do not.  How can I perform a group analysis on a number of subjects
>when they have varying numbers of channels? One subject may have 75
>channels and another may have 82 channels.  How can I do a group analysis
>(grand mean ERP) of the data when channel F5 is only present for 2 of the
>4 subjects? How do I compare subjects for multiple conditions when each
>subject and each condition for each subject has a different electrode
>location file and a varying number of electrodes?  How will I be able to
>compare ERPs between subjects for say channel F5, if F5 is electrode
>number 5 for subject number 1 whereas F5 is electrode number 7 for subject
>number 2?
>Please let me know if you have any advice on how to make the most of my
>data and conduct various analyses using EEGLAB.
>Thank you,
>Ed Modestino


*Arnaud Delorme, Ph.D.*
Swartz Center for Computational Neuroscience, INC, University of San 
Diego California
La Jolla, CA92093-0961, USA

*Tel* :/(+1)-858-458-1927 ext 15/
*Fax* :/(+1)-858-458-1847/
*Web page*: sccn.ucsd.edu/~arno <http://www.sccn.ucsd.edu/%7Earno>
*To think upon*:

    Life is not a problem to be solved but a reality to be experienced.

        /Siren Kierkegaard/  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20050718/d3c5c369/attachment.htm

More information about the eeglablist mailing list