[Eeglablist] .set format python

Bruzadin Nunes, Ugo ugob at siu.edu
Tue May 26 16:19:52 PDT 2020


Dear Rita,

Here's a piece of code I have from a while ago. I'm not an expert in python, but the mne function  "raw = mne.io.read_epochs_eeglab(filename)" reads .set and .fdt, if I'm not wrong. I hope the code still works. Once you have the .fdt/.set in .fif you can use it in mne library. I clearly import too many libraries here (the code was much longer), but hopefully you can get to the gist.

-------
import os
import mne
import os.path as op
import numpy as np
from time import time
from mne import io, Epochs
from matplotlib import pyplot as plt
from mne.preprocessing import ICA
from mayavi import mlab
from mne.minimum_norm import (make_inverse_operator, apply_inverse,
                              write_inverse_operator)

path = 'c:\\UGO\\MNE\\sLORETA_project\\'

folders = []
files = []
filenames = []
setfiles = []
fdtfiles = []
eventfiles = []
headmodels = []
participants = []

#get files in the folder
# r=root, d=directories, f = files
for r, d, f, in os.walk(path):
    for folder in d:
        folders.append(os.path.join(r, folder)) # adds folders to array folders
    for file in f:
        files.append(os.path.join(r, file)) # adds filespaths to array files
        if not '.' in file:
            filenames.append(os.path.basename(file)) # adds all filenames without extension (raw)
            if file[0:4] not in participants:
                participants.append(os.path.basename(file[0:4])) # if participants was already added, it is not added again
        if not 'old' in file:
            if '.evt' in file:
                eventfiles.append(os.path.join(r, file)) # adds the events to array events
            if '.sfp' in file:
                headmodels.append(os.path.join(r, file))
            if '.set' in file:
                setfiles.append(os.path.join(r, file))
            if '.fdt' in file:
                fdtfiles.append(os.path.join(r, file))

for i in setfiles:
    fname = i
    raw = mne.io.read_epochs_eeglab(fname)
    raw.save(fname + '-epo.fif')



Ugo Bruzadin Nunes, PhD Candidate
PSYC 222 Lecturer - Effects of Recreational Drugs
Integrative Neuroscience Lab - Member
Brain and Cognitive Sciences Ph.D Program ||
School of Psychological and Behavioral Sciences
Southern Illinois University - Carbondale

________________________________
From: Delorme, Arnaud <adelorme at ucsd.edu>
Sent: Monday, May 25, 2020 3:34 PM
Cc: 'eeglablist' (eeglablist at sccn.ucsd.edu) <eeglablist at sccn.ucsd.edu>
Subject: Re: [Eeglablist] .set format python

Dear Rita,

See also this page about reading Matlab files in Python

https://sccn.ucsd.edu/wiki/EEGLAB_and_python

Note that as of this day, the combined EEG and MEG community primarily uses Matlab (totaling 90% of citations).

Best wishes,

Arno

> On May 25, 2020, at 9:59 AM, 周云晖 <yhzhou17 at fudan.edu.cn> wrote:
>
> Hi,
>
> You can the functions in this link (the second, jpapon's answer):
> https://urldefense.com/v3/__https://stackoverflow.com/questions/7008608/scipy-io-loadmat-nested-structures-i-e-dictionaries__;!!Mih3wA!TKr3CMEZQ-_hfjA4ntSi28WDOgTCafIpYmlTJcatXgbXpAcv5ZtGeoIFBuncn0Ykv1bRGg$
>
> And you can convert the loaded Python dictionary into Pandas DataFrame. Some fields, like EEG['data'] are now in nested list array, and you can use numpy to directly convert it into numpy array. The event and chanlocs field can be converted into nested Pandas DataFrame.
>
> These are my personal experience. Maybe someone being more expert on this will have better idea.
>
> Best,
> Yunhui
>
>
>> -----Original Messages-----
>> From: "Rita Matta" <
>
>> Sent Time: 2020-05-24 04:40:39 (Sunday)
>> To: "eeglablist at sccn.ucsd.edu" <eeglablist at sccn.ucsd.edu>
>> Cc:
>> Subject: [Eeglablist] .set format python
>>
>>
>> Hello,
>>
>> Does anyone know how to load .set format eeg data in python?
>>
>> Rita Matta
>> _______________________________________________
>> 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



More information about the eeglablist mailing list