[Eeglablist] Artifact detection and ICA on data with multiple epoch types

Becky Prince becky.prince at york.ac.uk
Wed May 8 08:23:06 PDT 2013


Hi all,

Thanks to everyone for the responses!

I tried Chad's solution first, which involved manually concatenating the
the 3 epoched data sets into the data field of an EEG structure, then
running ICA on the concatenated set and copying the ICA results into the
ICA fields in the epoched sets.  This solution works but I ran into a minor
problem that's worth mentioning for anyone else who wants to do this
following the solution previously posted by Chad.  When one of the data
sets is copied into TEMP and all of the epoched data is added to TEMP.data,
a few other fields in TEMP need to be changed (otherwise they retain the
data from the copied epoched set, and the ICA command produces an error).

TEMP.trials = 1;
TEMP.pnts = size(TEMP.data,2);
TEMP.xmin = 0;
TEMP.xmax = (TEMP.pnts/TEMP.srate);
TEMP.times = [];

 Mikolaj and Arno, thank you for the advice on converting the epochs of
different lengths to continuous data.  Mikolaj you said you thought there
was an EEGLAB function to 'de-epoch' the data, so I'm guessing you were
thinking of 'eeg_epoch2continuous' which Arno has also mentioned.  In case
anyone else is interested, I found that you can solve this problem with the
eeg_epoch2continuous function in the following way:

% epoched data set 1 = EEG1, epoched data set 2 = EEG2, epoched data set 3
= EEG3
% convert epoched data to continuous in order to merge for ICA
CEEG1 = eeg_epoch2continuous(EEG1);
CEEG2 = eeg_epoch2continuous(EEG2);
CEEG3 = eeg_epoch2continuous(EEG3);
MERGED_SET = pop_mergeset(CEEG1, CEEG2);
MERGED_SET = pop_mergeset(MERGED_SET, CEEG3); % pop_mergeset only works
with 2 INEEG arguments
% run ICA on the merged data
MERGED_SET = pop_runica(MERGED_SET,'extended',1);
% copy ICA results into EEG1, EEG2 and EEG3 (see earlier post by Chadwick
Boulay)

Mikolaj thank you for the link to the 'epoch_linearize' function as well.
 I haven't tried it yet but plan to as it looks very useful!

My last question about this is how to do component rejection on these data.
 When I first tried this I first did component rejection on the MERGED_SET,
then copied the ICA fields from the merged data set into the ICA fields for
each epoched data set (EEG1, EEG2, EEG3).  However I'm not sure if that
actually worked, so I think what I might have to do is: 1) copy the ICA
fields form the MERGED_SET into the epoched sets, 2) do component rejection
on one of the sets, 3) run the component rejection command on all epoched
data sets using the component numbers identified for rejection.  Is that
right?

Best wishes and thanks again for the help!
Becky



On 7 May 2013 04:18, Arnaud Delorme <arno at ucsd.edu> wrote:

> The command line function eeg_epoch2continuous also allows to transform
> EEG epochs into a continuous dataset.
> Best,
>
> Arno
>
> On 5 May 2013, at 16:06, Mikołaj Magnuski wrote:
>
> It seems I didn't send my last message to eeglablist, it can be found at
> the end of this one.
>
> Anyway, Becky, I have found and uploaded the beforementioned function
> to https://sites.google.com/site/analizasygnalow/zasoby/nasze-narzedzia
> the function name is epoch_linearize.m and it is called this way:
> newEEG = epoch_linearize(EEG);
>
> it does not retain events, but you don't need these for ICA.
> For linearizing multiple files you can use linearize_all_eeg
> (also on the page) like this:
> ALLEEG = linearize_all_eeg(files, folder);
> 'files' is assumed to be a cell matrix of file names
> (for example: {'subj01.set', 'subj02.set'}), while 'folder'
> a string defining filepath (like: 'C:\DATA\Exp1_2012\').
>
> You would still have to save these files and later
> join relevant ones. I had a script for this too
> where you could specify with regular expressions
> what files should be linearized and then concatenated,
> but I didn't transform it into a more universal function,
> I'll try to do this soon if you would find it useful.
>
> If you have any troubles using these functions -
> let me know!
>
>
> You can also transform all your subject subfiles (epochs of different
>> length) into continuous signals (instead of epochs you can place 'boundary'
>> events, although it is not necessary for ICA) - such that you have one file
>> per subject. Then you would perform ICA and copy ica weights to your
>> original epoched files. I think there is a function in EEGlab to 'de-epoch'
>> the data (Arno, Makoto, am I correct?). Anyway - I wrote such function some
>> time ago, so I'll see if I can still find it. The function did not retain
>> events from the original dataset, but you do not need this for ICA.
>> (there is yet another option - you could epoch the data into small chunks
>> of 1-s long or so, reject epochs containing artifacts or signal of no
>> interest, then perform ICA and copy ica weights to your normally epoched
>> data. I too have a function for this, which allows for several useful
>> options like automatic rejection of windows (these small epochs) that are
>> too far from cerain events or event sequences - so that you wouldn't have
>> to manually click and reject windows ocurring in breaks or during a task
>> you are not interested in. Unfortunatelly the function help is still in
>> polish - but the basic options are easy to explain in one short mail - that
>> is if you think you will find such function useful)
>>  30 kwi 2013 19:24, "Becky Prince" <becky.prince at york.ac.uk> napisał(a):
>>
>>>  Dear EEGLAB users,
>>>
>>> I have a question about the best artifact detection and ICA procedures
>>> for data sets with multiple epoch types of different lengths.
>>>
>>> Each trial in my EEG task is made up of 3 non-overlapping epochs of
>>> interest: 1) 4 seconds, 2) either 1.5 or 2.5 seconds, 3) 2.5 seconds.  For
>>> my previous ERP experiments I've used the following data processing
>>> procedure: epoch the data, reject bad epochs, run ICA on remaining epochs,
>>> reject ICA components, analyze data in channel space.  For my current
>>> experiment (with 3 epochs per trial), I haven't been able to run ICA on all
>>> of the epoched data at once because, as soon as I epoch the data, it is
>>> split into a separate data set.  I'm fairly sure that these 3 separate
>>> epoched data sets cannot be merged/appended for a single ICA run because
>>> the epochs are of differing lengths.
>>>
>>> I've come up with 2 different protocols for processing the individual
>>> data sets.  I'm not sure which is better or if I'm overlooking other
>>> options.
>>>
>>> Solution 1: artifact rejection and ICA on continuous data
>>> 1) reject artifacts in continuous data
>>> 2) run ICA on continuous data
>>> 3) reject ICA components
>>> 4) epoch the data (creates 3 separate data sets)
>>> 5) analyze data in channel space
>>>
>>> Solution 2: artifact rejection and ICA on epoched data
>>> 1) epoch the data (creates 3 separate data sets)
>>> Then for each of the 3 epoched data sets:
>>> 2) reject epochs
>>> 3) run ICA on remaining epochs
>>> 4) reject ICA components
>>> 5) analyze data in channel space
>>>
>>> My problem with solution 1 is that it is much more time consuming to
>>> detect the artifactual sections of continuous data than it is to detect and
>>> reject bad epochs.  Also, ICA seems to run more slowly in this case (even
>>> after taking into account the differences in the size of the continuous and
>>> epoched data sets).  My problem with solution 2 is that it doesn't seem
>>> right to run ICA separately for each epoched data set for the same
>>> subject/session.  Because I am doing within-subject comparisons among the 3
>>> trial segments, I'm concerned about producing artificial differences among
>>> these epochs as a result of differences in the ICA decomposition and
>>> component rejection.
>>>
>>> Sorry for the long question.  Can anyone tell me what they would
>>> recommend?  Any suggestions and/or criticisms of my current processing
>>> steps would be very helpful!
>>>
>>> Many thanks,
>>> Becky
>>> PhD Candidate
>>> Department of Psychology
>>> University of York
>>>
>>>
>>> _______________________________________________
>>> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
>>> To unsubscribe, send an empty email to
>>> eeglablist-unsubscribe at sccn.ucsd.edu
>>> For digest mode, send an email with the subject "set digest mime" to
>>> eeglablist-request at sccn.ucsd.edu
>>>
>>
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to
> eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to
> eeglablist-request at sccn.ucsd.edu
>
>
>
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to
> eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to
> eeglablist-request at sccn.ucsd.edu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20130508/2446a8a5/attachment.html>


More information about the eeglablist mailing list