[Eeglablist] Problems with epoch rejection

ANA BUJAN ana.bujan at gmail.com
Tue Jan 21 07:18:57 PST 2020


  Dear all,

I have been trying to reject raw epochs (no ICA) through a handmade script
based on Makoto's pipeline with some changes. I would like to perform
rejection of epochs by all methods of rejection as the last pre-processing
step. However, each way I have tried, I got an error. I'm not a proficient
person programming and relatively new with EEGlab. So, it is almost for
sure I'm doing something wrong but I'm not able to see it...
So, I will make clear my point in order for you to be able to figure out
what I'm doing wrong. These the steps of the script:

1. Import Biosig data.
2. Set channel locs
3. Remove baseline and filters (0.5-40)
4. Bad channels rejection through pop_rejchan
5. Remove bad data segments with ASR
6. ICA and IC label for correction of artifacts (by the way, sometimes, no
always, EEG = pop_iclabel in the script doesn't work, the error is :

Undefined function or variable 'pop_iclabel'.
Error in rs_batchcode_superpose (line 45)
    EEG = pop_iclabel(EEG, 'default')
7. Interpolation of removed channels and average reference
8. Epochs extraction
9. Epochs rejection

So, this last step is where I'm having trouble. I've tried three options:

OPTION 1. Mark the bad epochs, then superpose, then reject

    EEG = pop_eegthresh(EEG,1,[1:64] ,-100,100,0,1.998,2,0);
    EEG = pop_rejtrend(EEG,1,[1:64] ,1024,75,0.3,2,0);
    EEG = pop_jointprob(EEG,1,[1:64] ,5,5,0,0,0,[],0);
    EEG = pop_rejkurt(EEG,1,[1:64] ,5,5,0,0,0,[],0);
    EEG = pop_rejspec( EEG, 1,'elecrange',[1:64]
,'method','multitaper','threshold',[-50 50;-100 25],'freqlimits',[0 2;20
40],0,0);
    EEG = eeg_rejsuperpose( EEG, 1, 1, 1, 1, 1, 1, 1, 1);
    EEG = pop_rejepoch( EEG, [EEG.reject.rejglobal] ,0);

This way the code got staked at pop_rejspec, so it never finishes, and I
don' understand why.... I copied the code from the history file....

When I try this same option but erasing the rejection for spectra, I got
his error:
*******************************************************************************************
64 channel selected
0/86 trials marked for rejection
Selecting trials...
64 channel(s) selected
0/86 trial(s) marked for rejection
The following trials have been marked for rejection

Computing joint probability for channels...
Computing all-channel probability...
3/86 trials marked for rejection
3 trials marked for rejection
Computing kurtosis for channels...
Computing all-channel kurtosis...
6/86 trials marked for rejection
6 trials marked for rejection
Error using  |
Matrix dimensions must agree.

Error in eeg_rejsuperpose>rejarray (line 135)
dest = dest | ori;

Error in eeg_rejsuperpose (line 81)
rejglobalE = rejarray( rejglobalE, EEG.reject.rejconstE);

Error in rs_batchcode_superpose (line 105)
    EEG = eeg_rejsuperpose( EEG, 1, 1, 1, 1, 1, 1, 1, 1);

>>

****************************************************************************************

OPTION 2: Marked bad epochs (without pop_rejspec, because there is no
variable for this in the EEG > reject), reject the marked ones

    EEG = pop_eegthresh(EEG,1,[1:64] ,-100,100,0,1.998,0,0);
    EEG = pop_rejtrend(EEG,1,[1:64],1024,75,0.3,0,0);
    EEG = pop_jointprob(EEG,1,[1:64],5,5,0,0,0,[],0);
    EEG = pop_rejkurt(EEG,1,[1:64],5,5,0,0,0,[],0);

    EEG = pop_rejepoch( EEG,[EEG.reject.rejthresh, EEG.reject.rejkurt,
EEG.reject.rejconst, EEG.reject.rejfreq],0);

In this case, the epochs are marked, but when the first rejection is
performed (by threshold), the epochs info is not longer then, and the set
has just 1 epoch... Of course, after this, the rest of the rejections is
not performed...
*******************************************************************************************
64 channel selected
11/89 trials marked for rejection
Selecting trials...
64 channel(s) selected
1/89 trial(s) marked for rejection
The following trials have been marked for rejection
1
Computing joint probability for channels...
Computing all-channel probability...
2/89 trials marked for rejection
2 trials marked for rejection
Computing kurtosis for channels...
Computing all-channel kurtosis...
8/89 trials marked for rejection
8 trials marked for rejection
20/89 trials rejected
Removing 11 trial(s)...
Pop_select: removing 22 unreferenced events
eeg_checkset note: data array made 3-D
eeg_checkset warning: 3rd dimension size of data (1) does not match the
number of epochs (78), corrected
eeg_checkset note: upper time limit (xmax) adjusted so (xmax-xmin)*srate+1
= number of frames
*********************************************************************************************************************************
OPTION 3: Reject the epochs directly instead of marking them.

    EEG = pop_eegthresh(EEG,1,[1:64],-100,100,0,1.998,0,1);
    EEG = pop_rejtrend(EEG,1,[1:64],1024,75,0.3,0,1);
    EEG = pop_jointprob(EEG,1,[1:64] ,5,5,0,1,0,[],0);
    EEG = pop_rejkurt(EEG,1,[1:64] ,5,5,0,1,0,[],0);
    EEG = pop_rejspec( EEG, 1,'elecrange',[1:64]
,'method','multitaper','threshold',[-50 50;-100 100],'freqlimits',[0 2;20
40],'eegplotcom','','eegplotplotallrej',0,'eegplotreject',1);

It happens the same as in the previous option: after the first rejection id
made, there are no longer epochs. This is the error:
**********************************************************************************************************************************
64 channel(s) selected
0/1 trial(s) marked for rejection
The following trials have been marked for rejection

0/1 trials rejected
Computing joint probability for channels...
Computing all-channel probability...
0/1 trials marked for rejection
0 trials marked for rejection
0/1 trials rejected
Computing kurtosis for channels...
Computing all-channel kurtosis...
1/1 trials marked for rejection
1 trials marked for rejection
1/1 trials rejected
Error using pop_select (line 227)
Error: dataset is empty

Error in pop_rejepoch (line 96)
EEG = pop_select( EEG, 'notrial', tmprej);

Error in pop_rejkurt (line 269)
        EEG = pop_rejepoch(EEG, rej, 0);

Error in proof_rejall (line 104)
    EEG = pop_rejkurt(EEG,1,[1:64] ,5,5,0,1,0,[],0);
**********************************************************************************************************
I apologize for the long message, but I wanted to make clear all the things
I checked. So, this is all, let me know if you need more info or files to
replicate the errors or whatever.

Many thanks for a great job.

Ana Buján



More information about the eeglablist mailing list