[Eeglablist] Preprocess a Group Study

Cedric Cannard ccannard at protonmail.com
Sun Sep 12 10:18:09 PDT 2021


Hi Chanda,

Here is some guidance: https://urldefense.proofpoint.com/v2/url?u=https-3A__eeglab.org_tutorials_10-5FGroup-5Fanalysis_study-5Fcreation.html&d=DwIGaQ&c=-35OiAkTchMrZOngvJPOeA&r=kB5f6DjXkuOQpM1bq5OFA9kKiQyNm1p6x6e36h3EglE&m=4Xxh0d9LmYt265_BhL_cnvVgHS6zdYADfP-Asn-ud7U&s=0tFE7MnMAFOoSIdwwgAwrVmf3viVxh_Sg0MjpQYXuxs&e= 

I recommend doing it first manually for 2 subjects in the GUI:
1) File > Create STUDY > Browse for datasets > Edit fields (or using BIDS export/import: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_sccn_bids-2Dmatlab-2Dtools&d=DwIGaQ&c=-35OiAkTchMrZOngvJPOeA&r=kB5f6DjXkuOQpM1bq5OFA9kKiQyNm1p6x6e36h3EglE&m=4Xxh0d9LmYt265_BhL_cnvVgHS6zdYADfP-Asn-ud7U&s=yKm4SxmmhIpstJW54IQdl8qM18duNeLotuhmfN8bn10&e= )
2) STUDY > Design > Create a design with the conditions of interest (can also be predefined in BIDS formatting)
3) STUDY > Precompute ERSP
4) STUDY > Plot results
5) type "eegh" in Matlab and you'll get the code lines to make a script for the whole group from that.

Cedric

Cedric

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Saturday, September 11th, 2021 at 9:41 PM, Chanda Steven <chandaelizabeth94 at gmail.com> wrote:

> Dear Cedric,
>
> Thank you very much for your replies, I worked on extracting the events of interest, and your advice worked. I wasn't just clear on an answer for the third response.
>
> 3. I would like to save all the time-frequency ERSP images from each channel at the same time in a folder, e.g if I have 19 channels, from each channel I plot the ERSP in a loop and save all the 19 images in a folder.
> any Matlab pop_functions lines of codes I can use with a loop?
>
> Create a STUDY, precompute ERSP in STUDY mode, it will save the files automatically, and you can analyze your group results easily in STUDY (or LIMO).
>
> Can you help with Matlab's few lines of codes on executing these steps because I tried to precompute a single subject ERSP via eeglab GUI but I could not find where the files are located? I would like to do this process via Matlab commands I am trying to develop an auto-preprocessing procedure for my EEG dataset.
>
> Thank You,
> Chanda Simfukwe.
>
> On Wed, Sep 8, 2021 at 1:11 PM Cedric Cannard <ccannard at protonmail.com> wrote:
>
>> Dear Chanda,
>>
>> Looks like it should do what you want when you do:
>> Eyes_Closed = strmatch('EyesClosed', {EEG.event.type}, 'exact');
>> EEG = pop_selectevent(EEG, 'event', Eyes_Closed, 'deletepochs', 'on', 'deleteevents', 'on');
>>
>> Did you epoch your data before that? e.g., EEG = pop_epoch(EEG, [], [-1 2])
>>
>> Doesn't this keep only your "Eyes_Closed" events of interest?
>> Note that you can keep them all, and in STUDY create a design with the event of interest only for analysis. But you'll save time computing ERSP if you remove them before group level.
>>
>> Use this filter instead (and 2 different passes instead of one bandpass):
>> EEG = pop_eegfiltnew(EEG, 'locutoff', 0.5);
>> EEG = pop_eegfiltnew(EEG, 'hicutoff', 50);
>>
>>> 3. I would like to save all the time-frequency ERSP images from each channel at the same time in a folder, e.g if I have 19 channels, from each channel I plot the ERSP in a loop and save all the 19 images in a folder.
>> any Matlab pop_functions lines of codes I can use with a loop?
>>
>> Create a STUDY, precompute ERSP in STUDY mode, it will save the files automatically, and you can analyze your group results easily in STUDY (or LIMO).
>>
>> Cedric
>>
>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>> On Tuesday, September 7th, 2021 at 6:58 PM, Chanda Steven <chandaelizabeth94 at gmail.com> wrote:
>>
>>> Dear Cedric,
>>>
>>> Thank you so much for your reply, the hit helped me but I have few more questions.
>>>
>>> 1. I managed to extract only the event of interest by using those two lines of codes you recommended but I would like to cut off the epoch without the events and only remain with epochs containing the events we are interested in, I have given a link with Matlab code of the image showing the event of interest Eyes_Closed but I will get rid of the highlighted filed and only extract epochs with EyesClosed.
>>>
>>> Image: https://urldefense.proofpoint.com/v2/url?u=https-3A__ibb.co_rc9zLCQ&d=DwIGaQ&c=-35OiAkTchMrZOngvJPOeA&r=kB5f6DjXkuOQpM1bq5OFA9kKiQyNm1p6x6e36h3EglE&m=4Xxh0d9LmYt265_BhL_cnvVgHS6zdYADfP-Asn-ud7U&s=c8Wymg1MXxnzTTTGX8EicyvbXl3Kmk5TvfwF7M-pxtY&e= 
>>>
>>> Matlab Code:
>>> %Open EEGLAB
>>> [ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab;
>>>
>>> %Load the EEG dataset
>>> EEG = pop_biosig('C:\Users\IBM\Desktop\Normal_Subjects\Eyes_Closed\00029426_020817\00029426_020817.EDF');
>>>
>>> %Load events from .txt file
>>> filepath = 'C:\Users\IBM\Desktop\Normal_Subjects\Eyes_Closed\00029426_020817\00029426_020817.txt';
>>>
>>> %Merge events with EEG data
>>> EEG = pop_importevent(EEG, 'event', filepath, 'fields', {'latency', 'type'}, 'append', 'no', 'align', NaN, 'timeunit', 1E-3);
>>>
>>> % Select the specific event of interest
>>> Eyes_Closed = strmatch('EyesClosed', {EEG.event.type}, 'exact');
>>>
>>> EEG = pop_selectevent(EEG, 'event', Eyes_Closed, 'deletepochs', 'on', 'deleteevents', 'on');
>>> pop_eegplot(EEG)
>>>
>>> 2. I ran the low pass filter and high pass filter code to eliminate the noise signs between low = 50HZ and high=0.5 but unfortunately the output EEG data seems not to be responsible in filtering compared to when I run it in EEGLAB GUI. See the output EEG data and please advise if the data was filtered accordingly.
>>>
>>> Image: https://urldefense.proofpoint.com/v2/url?u=https-3A__ibb.co_fQ1q2nC&d=DwIGaQ&c=-35OiAkTchMrZOngvJPOeA&r=kB5f6DjXkuOQpM1bq5OFA9kKiQyNm1p6x6e36h3EglE&m=4Xxh0d9LmYt265_BhL_cnvVgHS6zdYADfP-Asn-ud7U&s=N8g1yZkJxmce6ltckVk_Dj7WuxO-_EqJyCX2HRiW6xc&e= 
>>>
>>> Continue Matlab Code:
>>> %Apply high-pass and low-pass filter
>>> EEG = pop_eegfilt( EEG, 0.5, 50,[], 0);
>>>
>>> pop_eegplot(EEG)
>>>
>>> 3. I would like to save all the time-frequency ERSP images from each channel at the same time in a folder, e.g if I have 19 channels, from each channel I plot the ERSP in a loop and save all the 19 images in a folder.
>>> any Matlab pop_functions lines of codes I can use with a loop?
>>>
>>> Thank You,
>>> Chanda Simfukwe.
>>>
>>> On Sat, Sep 4, 2021 at 2:03 AM Cedric Cannard <ccannard at protonmail.com> wrote:
>>>
>>>> Hi Chanda,
>>>>
>>>> I developed a function recently to import EDF data into EEGLAB: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_amisepa_import-5FEDF&d=DwIGaQ&c=-35OiAkTchMrZOngvJPOeA&r=kB5f6DjXkuOQpM1bq5OFA9kKiQyNm1p6x6e36h3EglE&m=4Xxh0d9LmYt265_BhL_cnvVgHS6zdYADfP-Asn-ud7U&s=6l1VBzsFZHYdXbt-Gp_0SDKQrkPPOmQhOO6x6Pib4k0&e= 
>>>> You need Matlab 2020a or later and the signal processing toolbox to be able to use it. You can try to see if it eases your process by avoiding having to merge your events from the text file.
>>>>
>>>> Regarding your problem, there are many ways to process large quantities of files.
>>>> It sounds you just need to rename some events so that they are the same across subjects? You can do so with:
>>>> event_to_rename = strmatch('name_of_event_to_rename', { EEG.event.type }, 'exact');
>>>> EEG = pop_selectevent(EEG,'event', event_to_rename,'renametype','new_name','deleteevents','off');
>>>>
>>>> Once your events are homogenous across subjects, you can do any kind of standard EEGLAB pipeline on your large sample.
>>>>
>>>> I also invite you to check out these new great recent tools developed by the EEGLAB team for database management for computation automation and facilitating data sharing and compatibility across laboratories:
>>>> - HED (events): https://urldefense.proofpoint.com/v2/url?u=https-3A__www.hedtags.org_&d=DwIGaQ&c=-35OiAkTchMrZOngvJPOeA&r=kB5f6DjXkuOQpM1bq5OFA9kKiQyNm1p6x6e36h3EglE&m=4Xxh0d9LmYt265_BhL_cnvVgHS6zdYADfP-Asn-ud7U&s=l9TVZYStN2x24vR8Hkmr-7FdTW-7qFxSSyvYdPhDj2c&e= 
>>>> - BIDS (data structure): https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_bids-2Dstandard_bids-2Dspecification&d=DwIGaQ&c=-35OiAkTchMrZOngvJPOeA&r=kB5f6DjXkuOQpM1bq5OFA9kKiQyNm1p6x6e36h3EglE&m=4Xxh0d9LmYt265_BhL_cnvVgHS6zdYADfP-Asn-ud7U&s=F1xdxkpzncPdyhFFQv2-fUhLQXA4L73_iJdEBsdUs5Y&e= 
>>>> - LIMO (advanced methods to analyze your data): https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_LIMO-2DEEG-2DToolbox_limo-5Ftools_wiki&d=DwIGaQ&c=-35OiAkTchMrZOngvJPOeA&r=kB5f6DjXkuOQpM1bq5OFA9kKiQyNm1p6x6e36h3EglE&m=4Xxh0d9LmYt265_BhL_cnvVgHS6zdYADfP-Asn-ud7U&s=xPiQzSsssU-ZK0R0KJfZqfSTUeR-iFP51EKZY1HaTbM&e= 
>>>>
>>>> Hoe this helps,
>>>>
>>>> Cedric Cannard
>>>>
>>>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>>>>
>>>> On Thursday, September 2nd, 2021 at 8:25 PM, Chanda Steven via eeglablist <eeglablist at sccn.ucsd.edu> wrote:
>>>>
>>>>> Dear All,
>>>>>
>>>>> I am preprocessing a lot (1000+) of qeeg data in edf format with eeglab on
>>>>>
>>>>> Matlab, each subject has a unique file with events in the .txt file that I
>>>>>
>>>>> am merging with the subjects edf file and preprocesses the data to obtain
>>>>>
>>>>> the time-frequency plot (ERSP and ITC) for developing a machine learning
>>>>>
>>>>> model.
>>>>>
>>>>> The problem is that I can not create a group study due to subjects having
>>>>>
>>>>> different events and that is causing an error "Some datasets have only one
>>>>>
>>>>> trial, cannot compute ERPimages" when plotting the time-frequency (ERSP and
>>>>>
>>>>> ITC). Is there a way that I can use to preprocess a group of subjects at
>>>>>
>>>>> the same time and plot the time-frequency in Matlab or any python
>>>>>
>>>>> algorithm that I can use in MNE, I tried using MNE with python but
>>>>>
>>>>> importing events file and merge it with the edf and select only events of
>>>>>
>>>>> interest was a bit challenging. Any advice on this problem would be
>>>>>
>>>>> appreciated?
>>>>>
>>>>> Thank You,
>>>>>
>>>>> Chanda Simfukwe.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>>>>>
>>>>> Chanda Simfukwe
>>>>>
>>>>> Ph.D. Candidate
>>>>>
>>>>> Artificial Intelligence and Data Science,
>>>>>
>>>>> Chung-Ang University Dept. Medicine,
>>>>>
>>>>> The Korea Republic of.
>>>>>
>>>>> ..........................................
>>>>>
>>>>> 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
>>>
>>> --
>>>
>>> Chanda Simfukwe
>>> Ph.D. Candidate
>>> Artificial Intelligence and Data Science,
>>> Chung-Ang University Dept. Medicine,
>>> The Korea Republic of.
>>> ..........................................
>
> --
>
> Chanda Simfukwe
> Ph.D. Candidate
> Artificial Intelligence and Data Science,
> Chung-Ang University Dept. Medicine,
> The Korea Republic of.
> ..........................................


More information about the eeglablist mailing list