ChildDevLab/MADE-EEG-preprocessing-pipeline

epoch duplication

Closed this issue · 5 comments

Dear authors,
We have been having some issues with the epoching, particularly with the function epoch, called by pop_epoch. In function epoch, a cell array alleventout is created, but the epoch numbering in the array does not fit our data (our data is from 2003). Then, the duplication and modification steps in pop_epoch lead to some epochs being rejected and others kept incorrectly. We wondered if removing the duplication and modification steps would result in problems later in the pipeline. We have numbered the epochs manually without duplication, should we eventually modify any other field in the EEG structure?
Thank you in advance!

Hi Silvanasp,

Thank you for bringing up this issue. We are happy to hear that you are trying to use the pipeline with older data. We'd like the pipeline to work for all types of data and so we'd like to do what we can to help you solve this issue. Can you please share a few pieces of information with us in order to aid our troubleshooting?

-What version of MATLAB and eeglab are you using?
-What system was used to collect this data in 2003 and what format is the raw data in?
-What import function are you using to load your data into MATLAB?
-Can you give line numbers corresponding to the steps causing problems that you mentioned (e.g., duplication and modification)?
-Can you share any outputs showing the epoch numbering in alleventout vs your data?

Also, you mentioned that you ended up numbering the epochs manually, what other things did you try before doing this to fix the issue?

Thanks,
Steph

-What version of MATLAB and eeglab are you using?
Matlab 2019 and eeglab2020_0

-What system was used to collect this data in 2003 and what format is the raw data in?
"EEG data were collected using a 64-electrode geodesicsensor-net (Electrical Geodesic, Inc. system) referenced to the vertex."
Peña, M., Pittaluga, E., & Mehler, J. (2010). Language acquisition in premature and full-term infants. Proceedings of the National Academy of Sciences, 107(8), 3823-3828.
We are using their data.

-What import function are you using to load your data into MATLAB?
mff_import, as is used in your code. We have not changed this. If we want to directly import the data using only the eeglab pop-up window, we realize that the "EGI Net station .mff file" option works better than "EGI/Philips .mff file," i.e, the latter option does not import the data correctly.

-Can you give line numbers corresponding to the steps causing problems that you mentioned (e.g., duplication and modification)?
When we go into the pop_epoch(), we get these warnings:
pop_epoch():975 epochs selected
Epoching...
Warning: event 1 out of data boundary
Warning: event 2 out of data boundary
Warning: event 3 out of data boundary
Warning: event 4 out of data boundary
Warning: event 972 out of data boundary
Warning: event 973 out of data boundary
Warning: event 974 out of data boundary
Warning: event 975 out of data boundary
pop_epoch():967 epochs generated
eeg_checkset warning: 8 event had invalid epoch numbers and were removed
Event resorted by increasing latencies.
pop_epoch(): checking epochs for data discontinuity
Then in pop_epoch, from line 364 on, there seems to be a section for duplication of the number of events, up to line 388. We believe this may be the cause for our problems, and commented the lines before adding our own lines (shown below).

-Can you share any outputs showing the epoch numbering in alleventout vs your data?
See the attachments.
Image 1 is from the EEG.event field that we modified by manually inserting epoch numbers where there is a new event at each row. We are interested in the epochs that are marked by these events: trp1, trp2, trp3, trp4. We try to keep also TRSP because it has information about the sentences listened to. We deleted some fields from this variable (EEG.event) to facilitate the visualization. Also in this image you can see the epochevent variable that results from epoch(), which does not match the epoch numbering that we wish to have.
Image 2 shows the events with corresponding latencies in EEG.event field before the duplication section of pop_epoch():
Image 3 shows the events with corresponding (?) latencies in EEG.event field after the duplication section of pop_epoch(). This not only creates incorrect epoch numbers for us as you can see in the “epoch” field, but also repeats some of the events, as you can see in the highlighted rows.
As you can see, TRSP always appears after trp4, and it has the information from the preceding epochs. We believe that the duplication of these TRSPs might be causing problems, because epoch numbering is wrong both when we specify TRSP as an event and when we do not add it to the list of events.

-Also, you mentioned that you ended up numbering the epochs manually, what other things did you try before doing this to fix the issue?
Beside commenting the duplication and modification lines in pop_epoch() mentioned earlier, we added these lines in pop_epoch between lines 388 and 389 to create the indexing of epochs that fit our data:

for i = 1:size(EEG.data,3)
EEG.event(i).epoch = 0;
end
for i = 1:size(EEG.data,3)+4
EEG.event(i+4).epoch = i;
end

We thank you very much for your help and look forward to your response.
Silvana

Picture1

Picture2

Picture3

Hi Silvanasp,

Thank you for your patience. We think this might be an issue with the import function that isn't noticeable until epoching. As you mentioned, "the 'EGI Net station .mff file' option works better than 'EGI/Philips .mff file,' i.e, the latter option does not import the data correctly". The import function we use in the script is the latter function. After speaking to a few colleagues who use the pipeline, we found out from one of them that they ran into this same issue when using the EGI/Philips .mff file import function on data collected in the early 2000s. This colleague said that changing the import function in the script from

EEG=mff_import(currentTaskFilename);

to

EEG = pop_readegimff(subject_raw_data);

fixed the issue in their dataset. Therefore, our first suggestion would be to try changing the import function. Note, the colleague we spoke to about this ran their data on a MAC with Matlab/2018b and eeglab13_6_5b. If the issue still occurs after changing the import function, please reach back out to us and we will continue troubleshooting.

Thanks,
Steph

Hello,

We used the function pop_readegimff and wrote the lines below to create a data matrix that has a reference channel 'Cz.'
EEG.nbchan=EEG.nbchan+1; % add 1 to the total channel count
EEG.data(end+1,:)=0; % add a row of zeros to the data
EEG.chanlocs(end+1).labels = ' Cz'; % add the Cz label to chanlocs

Segmentation step is still problematic:

  1. EEG.event still has way too many rows: 2471 because some events are duplicated again
  2. size(EEG.data,3) and length(EEG.epoch) are luckily the number: 735.
    Although this seems like good news, EEG.epoch does not register any event that is marked by an event marker we set: trp1. It only registers epochs marked by trp2, trp3, and trp4. You can see in the attached image that EEG.epoch separates epochs marked by trp2, trp3 and trp4, but although we have a marker trp1, we do not get any individual epoch for that. It gets clustered with another trigger, 'bgin,' which we are not defining as a trigger.
    EEG_epoch-eventmarkers

Any idea why we are not getting epochs marked by one of the triggers?

Note: Code was run on MatLabR2017b and eeglab2021.0.

Thanks a lot,
Ege

Hi Ege,

We are unfamiliar with this issue. However, we would like to continue trying to help troubleshoot. Because we are unfamiliar with this issue, it might be easier to troubleshoot if you share a file with us. Would that be possible? If yes, please contact us by email to coordinate (sleach12@umd.edu).

Thanks,
Steph