ucdavis / erplab

ERPLAB Toolbox is a free, open-source Matlab package for analyzing ERP data. It is tightly integrated with EEGLAB Toolbox, extending EEGLAB’s capabilities to provide robust, industrial-strength tools for ERP processing, visualization, and analysis. A graphical user interface makes it easy for beginners to learn, and Matlab scripting provides enormous power for intermediate and advanced users.
http://erpinfo.org/erplab
270 stars 73 forks source link

ERPLAB/EEGLAB artifact synchronization issues #22

Open jasonarita opened 9 years ago

jasonarita commented 9 years ago

Problem

There are 2 issues here:

  1. ERPLAB > Artifact detection in epoched data > Synchronize artifact info in EEG and EVENTLIST or pop_syncroartifacts throws the following error every time it is used: erplab_eegscanner (line 60) error: Not enough input arguments screen shot 2015-04-17 at 4 01 24 pm

Solution: In pop_syncroartifacts (line 133) the function call to erplab_eegscanner in pop_syncroartifacts needs to be fixed so that 7 inputs are passed in instead of 6. erplab_eegscanner looks like it was recently modified so that a new 7th variable checknoevents is required as input. Also the help for erplab_eegscanner needs to be updated to account for this new input variable chcknoevents.

  1. Rejecting epoched trials marked with artifact flags via EEGLAB (ie. EEGLAB > Tools > Reject data epochs > Reject marked epochs does not update ERPLAB's EEG.EVENTLIST.trialsperbin variable, thus causing ERPLAB > Summarize artifact detection > (all) to report incorrect number of trials accepted. Currently, pop_syncroartifacts only updates the artifact flags and not the EEG.EVENTLIST.trialsperbin variable which is used when summarizing the artifact flags.

Note: Keep in mind that marking artifacts (i.e. artifact detection) and rejecting epoched trials (i.e. artifact rejection) are 2 separate steps.


Reported by Darren Tanner

Darren Tanner to erplab, Kailen, Nyssa Apr 15

Hi all,

I have some questions about/issues with synchronizing artifact rejection/detection between EEGLAB and ERPLAB. I'll try to document what we're doing and what we've done to test this in good detail below. If anyone has advice for how to deal with the issue, please let us know.

Background:

Basically, we want to do ICA on data epochs that we've created with binlister in ERPLAB to perform blink correction. We want to hand-reject bad epochs with before running the ICA. We're doing this using the EEGLAB > Tools > Reject data epochs > Reject by inspection tool.

We have no trouble marking the epochs for rejection in EEGLAB, and we can transfer those marks to the ERPLAB event list using pop_syncroartifact (though, like previous posters have said, we had to go back to ERPLAB v4.0.2.3, since the newest version always threw us an error).

When we check the ERPLAB EventList, we see the AR flags on the correct trials, and when we summarize artifact rejection, we see the correct number of trials per condition being marked for rejection within ERPLAB.

The problem:

The problem comes when we actually go to reject the epochs in EEGLAB, prior to running the ICA (since presumably, we don't want the ICA to have the crappy epochs in the training set).

When we go to EEGLAB > Tools > Reject data epochs > Reject marked epochs, it does indeed delete the epochs we marked. But the problem is when we go back to ERPLAB: the artifact detection summary now does not recognize that we have marked any epochs for rejection. All of the trials are still listed in each bin, but it says that none have been marked for rejection.

So, say we had 180 trials in Bin1. We marked 4 for exclusion by hand in EEGLAB. We can synchronize with ERPLAB and see those 4 trials marked with an artifact flag in the EventList, and the artifact detection summary shows 176 good trials and 4 bad trials in Bin1. BUT -- after we reject the trials in EEGLAB, ERPLAB now shows 180 good trials in Bin1 in the artifact detection summary table. However, when we check the EventList, the bad trials that we had previously marked still show the artifact flags. So it's retaining the information in the EventList, but the artifact detection summary loses the data.

We want to be able to keep track of how many trials we hand-reject in each bin, so that we can report this in our manuscripts, and we want to be able to be sure that when we run artifact detection in ERPLAB after we do ICA blink correction, that the counts of bad trials in the artifact summary table is actually correct (that is, that it reflects both the trials that were hand rejected in EEGLAB and detected in ERPLAB following blink correction).

Does anyone have a suggestion/fix for this, so that we can hand-reject epochs in EEGLAB and retain the information in the ERPLAB artifact detection fields? It seems to be retaining the information in the EventList about the epochs we marked, so I'm not sure why the summary tables do not reflect this.

Thanks! Darren


Darren Tanner, Ph.D. Assistant Professor of Linguistics Affiliate faculty, Program in Second Language Acquisition and Teacher Education Affiliate faculty, Beckman Institute for Advanced Science and Technology Affiliate faculty, Neuroscience Program University of Illinois at Urbana-Champaign Office: FLB 4043 Mailing: FLB 4080, MC-168 707 S. Mathews Ave. Urbana, IL 61801 http://darrentanner.wordpress.com/

jasonarita commented 9 years ago

A quick read through the steps, it sounds like the problem might be that pop_syncroartifacts needs to be run again after the EEGLAB > Tools > Reject data epochs > Reject marked epochs step, to resynchronize ERPLAB's EEG.EVENTLIST.trialsperbin variable

jasonarita commented 9 years ago

Solution

One possible solution is to modify pop_syncroartifacts to also update the EEG.EVENTLIST.trialsperbin variable with the new epoch count.