Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_raw_eeglab does not read nasion, lpa and rpa values from .set file #10474

Closed
cmadjar opened this issue Mar 30, 2022 · 16 comments · Fixed by #10521
Closed

read_raw_eeglab does not read nasion, lpa and rpa values from .set file #10474

cmadjar opened this issue Mar 30, 2022 · 16 comments · Fixed by #10521
Labels

Comments

@cmadjar
Copy link

cmadjar commented Mar 30, 2022

Describe the bug

read_raw_eeglab does not read properly the nasion, lpa and rpa coordinates of a .set file.

Steps to reproduce

This can be reproduced on the sample data eeglab_data.set file that comes with EEGLAB.

>>> import mne
>>> import os
>>> from mne_bids import write_raw_bids, BIDSPath
>>> import eeglabio
>>> file = "/Users/cmadjar/Documents/MATLAB/eeglab2022.0/sample_data/eeglab_data.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, 0 fiducials, 32 channels>

>>> raw.get_montage().get_positions()
.... 'coord_frame': 'head', 'nasion': None, 'lpa': None, 'rpa': None, 'hsp': None, 'hpi': None

Screen Shot 2022-03-30 at 1 11 21 PM

However, when looking in the Matlab structure, the coordinates for nasion, lpa and rpa are indeed present in the file. So for some reason, this gets lost when loading the .set file with read_raw_eeglab

Additional information

Reproduced on several versions of mne and different OS.

Latest information:

>>> 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.0.0
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
PyQt5:            Not found
ipympl:           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
@cmadjar cmadjar added the BUG label Mar 30, 2022
@welcome
Copy link

welcome bot commented Mar 30, 2022

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

@agramfort
Copy link
Member

agramfort commented Mar 31, 2022 via email

@cmadjar
Copy link
Author

cmadjar commented Mar 31, 2022

Sure. Here is the EEGLAB sample data.
eeglab_data.zip

Note: when we add back the landmarks in the MNE raw object and we save the file as a .set file, the urchanlocs is not being saved either and therefore, we lose the landmark locations when saving the file too.

@agramfort
Copy link
Member

@cmadjar can you point me where to read the fiducial locations in the EEG structure:

loading the file in matlab I see

>> EEG

EEG =

             setname: 'Continuous EEG Data'
            filename: 'eeglab_data.set'
            filepath: '/Users/alex/Downloads/eeglab_data/'
             subject: ''
               group: ''
           condition: ''
             session: []
            comments: [6x769 char]
              nbchan: 32
              trials: 1
                pnts: 30504
               srate: 128
                xmin: 0
                xmax: 238.3047
               times: [1x30504 double]
                data: [32x30504 single]
              icaact: []
             icawinv: []
           icasphere: []
          icaweights: []
         icachansind: []
            chanlocs: [1x32 struct]
          urchanlocs: []
            chaninfo: [1x1 struct]
                 ref: 'common'
               event: [1x154 struct]
             urevent: [1x154 struct]
    eventdescription: {[2x29 char]  [2x63 char]  [2x36 char]  ''}
               epoch: []
    epochdescription: {}
              reject: [1x1 struct]
               stats: [1x1 struct]
            specdata: []
          specicaact: []
          splinefile: []
       icasplinefile: ''
              dipfit: []
             history: '
EEG = pop_loadset( 'filename', 'eeglab_data.set', 'filepath', '/data/common/matlab/eeglab/sample_data/');
EEG = eeg_checkset( EEG );
EEG = pop_loadset('filename','eeglab_data.set','filepath','...'
               saved: 'yes'
                 etc: [1x1 struct]
             datfile: 'eeglab_data.fdt'
                 run: []

>> length(EEG.chanlocs)

ans =

    32

@cmadjar
Copy link
Author

cmadjar commented Apr 1, 2022

@alexandrebarachant Apologies, looks like the eeglab_data.set do not have data in the urchanlocs structure... In the sample data that I have, the nasion, lpa and rpa information are stored in the urchanlocs structure. See below for the content.

Screen Shot 2022-04-01 at 3 44 18 PM

I don't think I can share that dataset unfortunately. I will ask the owner if it is possible to share it with you, just in case.

@agramfort
Copy link
Member

it's @agramfort not @alexandrebarachant :)

I need such a file to debug

@cmadjar
Copy link
Author

cmadjar commented Apr 1, 2022

@agramfort I can share the file with you. What is the best way to send it to you? Probably best not to share it openly on GitHub just in case.

Thanks!

@agramfort
Copy link
Member

agramfort commented Apr 3, 2022 via email

@cmadjar
Copy link
Author

cmadjar commented Apr 4, 2022

@agramfort I cannot see the email unfortunately

@agramfort
Copy link
Member

agramfort commented Apr 4, 2022 via email

@agramfort
Copy link
Member

diagnostic : we read only chanlocs and not urchanlocs.

@cmadjar has a file where urchanlocs are chanlocs concatenated with 3 fiducials (it's therefore partially the same information).

what shall we do? Give priorirty to urchanlocs if present? I don't know where to find the information.

cc @cbrnr @mmagnuski @arnodelorme

@arnodelorme
Copy link

The Fiducials are in EEG.chaninfo.nodatchans
You may use eeg_checkchanlocs(EEG) to add them to the list of other channels.

@agramfort
Copy link
Member

thx @arnodelorme

may I ask 2 side questions:

  • what is the difference between chanlocs and urchanlocs? what does "ur" refer to?
  • I do have things in EEG.chaninfo.nodatchans but the labels are E130, E131, E132. Can we assume a specific order in this list? It's always 3 values and it's Nasion, LPA and RPA?

do not hesitate to point me to the EEGLAB doc. 🙏

@SMoralesPhD
Copy link

Hello @agramfort,

  1. I am not sure what "ur" stands for, but here is the info about the channels from here:
    % EEG.chanlocs - structure array containing names and locations of the channels on the scalp
    % EEG.urchanlocs - original (ur) dataset chanlocs structure containing all channels originally collected with these data (before channel rejection)

  2. I am not sure you can make that generalization on the order. I think it will be the same for all MFF files (at least of this version of NetStation), but I am not sure for other systems. Could you use the description from EEG.chaninfo.nodatchans.description to confirm?

Thanks!

@agramfort
Copy link
Member

agramfort commented Apr 13, 2022 via email

@arnodelorme
Copy link

arnodelorme commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants