Git Product home page Git Product logo

eeglabio's People

Contributors

jackz314 avatar larsoner avatar mscheltienne avatar sappelhoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

larsoner eegkit

eeglabio's Issues

BUG: All numeric types during export should be double

Quoting mne-tools/mne-python#11031 :

Reading a file exported by MNE on MATLAB

EEG.trials

ans =

  int64

   105

The type is int64 instead of double. This can cause all kinds of problems (I was trying to use the number of trials to calculate a ratio, and it was always returning the wrong value for example). This might be the case as well for other fields.

Export to EEGLAB should support single and double precision

Quoting mne-tools/mne-python#11015 :

Currently, exporting to EEGLAB always writes double precision floats. However, @arnodelorme mentioned in #11013, the EEGLAB default is actually single precision. Therefore, we should introduce a new parameter precision with two possible options "single" and "double". I'm not sure what the default should be, probably "double" to be on the safe side.

This should probably be implemented in eeglabio. Speaking of which, I wanted to suggest to include the code in MNE-Python directly to make things easier for us. I know we discussed outsourcing this to minimize maintenance costs for us, but this is not really the case. I actually think that maintenance will be easier if we have this code in our package. WDYT?

Error opening raw file on eeglab

Hi @jackz314 ,

I have converted the raw file on MNE into an epoched file and then back into a raw file. I saved this out using eeglabio and I could not open it on matlab/eeglab. I get an error (image below).
Screenshot 2021-09-10 at 13 18 49

export.export_raw does not write fids information in SET file

Describe the bug

export_raw does not exports fids information of SET files.

Steps to reproduce

>>> import mne
>>> import os
>>> file = "/Users/cmadjar/Desktop/eeg_test_data/2022-04-13/003_BaDaNovel_Rutgers_SM.set"
>>> raw = mne.io.read_raw_eeglab(input_fname=file, preload=False, verbose=True)
Reading /Users/cmadjar/Documents/MATLAB/eeglab2022.0/sample_data/eeglab_data.fdt

>>> raw.get_montage()
<DigMontage | 0 extras (headshape), 0 HPIs, 3 fiducials, 129 channels>
>>> raw.get_montage().get_positions()
... 'coord_frame': 'head', 'nasion': array([ 6.34122109e-16,  1.03559999e+01, -2.69400001e+00]), 'lpa': array([-6.71199989,  0.046     , -3.71199989]), 'rpa': array([ 6.71199989,  0.046     , -3.71199989]), 'hsp': None, 'hpi': None

>>> out_file = "/Users/cmadjar/Desktop/eeg_test_data/2022-04-13/test.set"
>>> mne.export.export_raw(fname=out_file, raw=raw, fmt='eeglab')
Reading 0 ... 340244  =      0.000 ...   680.488 secs...
>>> raw_test = mne.io.read_raw_eeglab(input_fname=out_file, preload=False, verbose=True)
>>> raw_test.get_montage()
<DigMontage | 0 extras (headshape), 0 HPIs, 0 fiducials, 129 channels>       # <---------------------
>>> raw_test.get_montage().get_positions()
... 'coord_frame': 'head', 'nasion': None, 'lpa': None, 'rpa': None, 'hsp': None, 'hpi': None       # <---------------------

Expected results

The fids should be exported to the SET file when creating the file from raw.

Actual results

See lines above flagged with # <---------------------

Additional information

Built mne using the following commit: mne-tools/mne-python@706dd3a

>>> mne.sys_info()
Platform:         macOS-11.3-x86_64-i386-64bit
Python:           3.9.12 (main, Mar 26 2022, 15:52:10)  [Clang 13.0.0 (clang-1300.0.29.30)]
Executable:       /Users/cmadjar/Development/python_venv/python_intel_3.9.4/eeg2bids_py3.9.12/bin/python
CPU:              i386: 8 cores
Memory:           Unavailable (requires "psutil" package)
mne:              1.1.dev0
numpy:            1.21.5 {blas=openblas, lapack=openblas}
scipy:            1.8.0
matplotlib:       3.5.1 {backend=MacOSX}

sklearn:          1.0.2
numba:            0.55.1
nibabel:          Not found
nilearn:          Not found
dipy:             Not found
cupy:             Not found
pandas:           1.4.1
pyvista:          Not found
pyvistaqt:        Not found
ipyvtklink:       Not found
vtk:              Not found
qtpy:             Not found
ipympl:           Not found
pyqtgraph:        Not found
pooch:            v1.6.0

mne_bids:         0.10
mne_nirs:         Not found
mne_features:     0.2
mne_qt_browser:   Not found
mne_connectivity: Not found

Related to #10474

Error opening a raw file that is converted from epoch file

Hi @jackz314 , I am getting an error on eeglab when I open a raw.set file that was earlier converted from an epoch.set file. I was trying to convert an existing epoch file(.set) to non-epoched file (.set) .

Here is a sample file that I opened as a raw object and then saved it as an epoch.set file locally. I then opened the epoch.set file separately and created a raw.set file again to get rid of the epochs (https://mne.discourse.group/t/converting-epoch-file-to-non-epoch-file/3421) . I tried opening this new raw.set file on eeglab and gave me an error (attached image).

Also, if you run this all at the same time, then the error does not show up on eeglab. But if you save the epoch.set file locally and then open it and convert it to a non-epoched file and then you get an error on eeglab.

import os
import mne
from mne.datasets import sample
from eeglabio.utils import export_mne_raw
from eeglabio.utils import export_mne_epochs
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
'sample_audvis_filt-0-40_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file)
raw.crop(tmax=60).load_data()
raw.pick(['EEG 0{:02}'.format(n) for n in range(41, 60)])
epochs = mne.make_fixed_length_epochs(raw, duration=1, preload=True)
export_mne_epochs(epochs, "epoch_name.set")


import mne
from eeglabio.utils import export_mne_raw
epoch_set=mne.io.read_epochs_eeglab('/Users/Desktop/epoch_name.set')
sfreq=epoch_set.info['sfreq']
ch_names=epoch_set.info['ch_names']
ch_types = ['eeg'] * 19
info = mne.create_info(ch_names=ch_names, ch_types=ch_types, sfreq=sfreq)
epoch=epoch_set.get_data()
n_epochs, n_channels, n_times = epoch.shape
data=epoch.transpose([1, 0, 2]).reshape((n_channels, n_epochs * n_times))
raw= mne.io.RawArray(data, info)
export_mne_raw(raw, "new_file_no_epoch.set")


Screenshot 2021-07-22 at 21 10 49

Feature Request: Support writing EEGLAB to mat files of version 7.3 and higher (=HDF5)

The code here uses scipy.io.savemat:

savemat(str(fname), eeg_d, appendmat=False)

This means saving EEGLAB data as MATLAB files up to version 7.2.

Starting with MATLAB file version 7.3, the data are actually encoded in HDF5 format: https://de.mathworks.com/help/matlab/import_export/mat-file-versions.html

This is a great development, as it makes these files more accessible to other readers outside of MATLAB.


could you please implement support for writing EEGLAB data to mat files of version 7.3 and higher?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.