mne coreg issues

Hi guys!

I recently updated to mne 1.0. After the update, the mne coreg is not working. I am getting this error text:

cmd: mne coreg

output:

Using pyvistaqt 3d backend.

    Triangle neighbors and vertex normals...
Using high resolution head model in /media/dip_linux/Transcend/Visual_p3_data/3847/surf/lh.seghead
Traceback (most recent call last):
  File "/home/dip_linux/anaconda3/envs/mne/bin/mne", line 8, in <module>
    sys.exit(main())
  File "/home/dip_linux/anaconda3/envs/mne/lib/python3.10/site-packages/mne/commands/utils.py", line 107, in main
    cmd.run()
  File "/home/dip_linux/anaconda3/envs/mne/lib/python3.10/site-packages/mne/commands/mne_coreg.py", line 85, in run
    mne.gui.coregistration(
  File "<decorator-gen-558>", line 12, in coregistration
  File "/home/dip_linux/anaconda3/envs/mne/lib/python3.10/site-packages/mne/gui/__init__.py", line 193, in coregistration
    return CoregistrationUI(
  File "<decorator-gen-570>", line 12, in __init__
  File "/home/dip_linux/anaconda3/envs/mne/lib/python3.10/site-packages/mne/gui/_coreg.py", line 238, in __init__
    self.coreg = Coregistration(
  File "/home/dip_linux/anaconda3/envs/mne/lib/python3.10/site-packages/mne/coreg.py", line 1371, in __init__
    self._setup_bem()
  File "/home/dip_linux/anaconda3/envs/mne/lib/python3.10/site-packages/mne/coreg.py", line 1426, in _setup_bem
    'mesh (%d vertices): %s' % (len(self._bem_high_res.surf.rr),
AttributeError: 'dict' object has no attribute 'surf'

system info:

Platform:         Linux-5.13.0-39-generic-x86_64-with-glibc2.31
Python:           3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:38:57) [GCC 10.3.0]
Executable:       /home/dip_linux/anaconda3/envs/mne/bin/python
CPU:              x86_64: 8 cores
Memory:           15.3 GB

mne:              1.0.0
numpy:            1.21.5 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy:            1.8.0
matplotlib:       3.5.1 {backend=QtAgg}

sklearn:          1.0.2
numba:            0.55.1
nibabel:          3.2.2
nilearn:          0.9.0
dipy:             1.5.0
cupy:             Not found
pandas:           1.4.2
pyvista:          0.33.3 {OpenGL 3.3 (Core Profile) Mesa 21.2.6 via Mesa Intel(R) UHD Graphics (CML GT2)}
pyvistaqt:        0.8.0
ipyvtklink:       0.2.2
vtk:              9.1.0
PyQt5:            5.12.3
ipympl:           0.8.8
pooch:            v1.6.0

mne_bids:         Not found
mne_nirs:         Not found
mne_features:     0.2
mne_qt_browser:   0.2.6
mne_connectivity: 0.3

any help would be appreciated.

best,
Dip

how did you update mne?

Alex

just: pip install mne==1.0

sorry, I set the mne environment from scratch using the instructions given in mne website. So technically I didn’t update if that answer your question :slight_smile:

I want to make sure that you installed with conda on a fresh env.

otherwise consider using the fully packaged installer

Alex

Hello @dasdiptyajit, I think this might be a bug in MNE-Python.

It should not occur if you have a low-resolution head surface available. I assume that if you look inside the FreeSurfer subjects folder for that particular subject, and then navigate to the bem sub-folder (i.e., /media/dip_linux/Transcend/Visual_p3_data/3847/bem in this particular case), there’s no outer_skin.surf file, right?

Running make_scalp_surfaces() should fix this for you. Importantly, leave no_decimate at its default (False) so it will generate the low-resolution surface.

Please let me know how it goes,
Richard

1 Like

@richard it works! cool :smiley:

Thank you, I’ve reported the bug upstream: Coreg GUI doesn't start if only high-resolution, but no low-resolution skin surface is not available · Issue #10520 · mne-tools/mne-python · GitHub

Hi all,
I’m having this issue, too.

When I try mne.bem.make_scalp_surfaces I get an error for FREESURFER_HOME not being set up. I have a working freesurfer distribution. What should the FREESUREFER_HOME be and how do I set this variable for this module to work? Just making FREESURFER_HOME= ‘/path_to_freesurfer/’ didn’t do anything.

Thanks for the help,
Megan

Hi again,
I figured out to use mne.set_config(‘FREESURFER_HOME’,FREESURFER_HOME, set_env=True), so I was able to use mne.bem.make_scalp_surfaces. I see a head-dense.fif, head-medium.fif, and a head-sparse.fif in the subject/bem/ directory.

However, when I try mne coreg, I still see output that it’s trying to use the high resolution head model and I see the same errors listed above in this topic.

I did a fresh mne install in a conda environment, and I’m using mne1.0 on Ubuntu 18.04.5 LTS.

I don’t know where it’s getting the subject from when I do mne coreg, but the output lists
Using high resolution head model in /export/research/analysis/unm_psych/dquinn/Navigate_20673/MEG_source_analysis/M87102616/bem/M87102616-head-dense.fif

Thanks for any help,
Megan

One more update…

I tried adding the -s -d and -f tags to the mne coreg command to explicitly set those variables, and then I use --low-res-head. But it is STILL trying to open the dense head surface and still throwing the no attribute ‘surf’ error!

Megan

Please post the complete command you’re using and the full error message, thank you.

Exactly as dasdiptyajit said…

Trial 1:

(mne1.0_ubuntu) mschendel@mars:/export/research/analysis/unm_psych/dquinn/Navigate_20673/MEG_source_analysis/mne_source/python-scripts$ mne coreg
Using pyvistaqt 3d backend.

Using high resolution head model in /export/research/analysis/unm_psych/dquinn/Navigate_20673/MEG_source_analysis/M87102616/bem/M87102616-head-dense.fif
Traceback (most recent call last):
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/bin/mne", line 10, in <module>
    sys.exit(main())
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/lib/python3.10/site-packages/mne/commands/utils.py", line 107, in main
    cmd.run()
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/lib/python3.10/site-packages/mne/commands/mne_coreg.py", line 85, in run
    mne.gui.coregistration(
  File "<decorator-gen-558>", line 12, in coregistration
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/lib/python3.10/site-packages/mne/gui/__init__.py", line 193, in coregistration
    return CoregistrationUI(
  File "<decorator-gen-570>", line 12, in __init__
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/lib/python3.10/site-packages/mne/gui/_coreg.py", line 238, in __init__
    self.coreg = Coregistration(
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/lib/python3.10/site-packages/mne/coreg.py", line 1371, in __init__
    self._setup_bem()
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/lib/python3.10/site-packages/mne/coreg.py", line 1426, in _setup_bem
    'mesh (%d vertices): %s' % (len(self._bem_high_res.surf.rr),
AttributeError: 'dict' object has no attribute 'surf'

Trial 2 with tags:

(mne1.0_ubuntu) mschendel@mars:/export/research/analysis/unm_psych/dquinn/Navigate_20673/MEG_source_analysis/mne_source/python-scripts$ mne coreg -d '/export/research/analysis/unm_psych/dquinn/Navigate_20673/MEG_source_analysis/' -s 'M87102616' -f '/export/research/analysis/unm_psych/dquinn/Navigate_20673/MEG_AUTO_ANALYSIS/subjects/M87102616/M87102616_prosaccade_visit1_tsss_mc.fif' --low-res-head
Using pyvistaqt 3d backend.

Using high resolution head model in /export/research/analysis/unm_psych/dquinn/Navigate_20673/MEG_source_analysis/M87102616/bem/M87102616-head-dense.fif
Traceback (most recent call last):
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/bin/mne", line 10, in <module>
    sys.exit(main())
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/lib/python3.10/site-packages/mne/commands/utils.py", line 107, in main
    cmd.run()
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/lib/python3.10/site-packages/mne/commands/mne_coreg.py", line 85, in run
    mne.gui.coregistration(
  File "<decorator-gen-558>", line 12, in coregistration
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/lib/python3.10/site-packages/mne/gui/__init__.py", line 193, in coregistration
    return CoregistrationUI(
  File "<decorator-gen-570>", line 12, in __init__
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/lib/python3.10/site-packages/mne/gui/_coreg.py", line 238, in __init__
    self.coreg = Coregistration(
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/lib/python3.10/site-packages/mne/coreg.py", line 1371, in __init__
    self._setup_bem()
  File "/export/research/analysis/human/jstephen/shared/programs/python/anaconda_072020/new/envs/mne1.0_ubuntu/lib/python3.10/site-packages/mne/coreg.py", line 1426, in _setup_bem
    'mesh (%d vertices): %s' % (len(self._bem_high_res.surf.rr),
AttributeError: 'dict' object has no attribute 'surf'

Thanks for taking a look,
Megan

Are you sure you’re running the latest release of MNE-Python (1.0.3)? The problem should not occur there.

I’m sorry, I was mistaken, this fix is only in the development version and was not backported to 1.0.x.

Can you please share the contents (list of files and directories) inside the

/export/research/analysis/unm_psych/dquinn/Navigate_20673/MEG_source_analysis/M87102616/bem

folder?

Ok, I’m using 1.0.0
I’ll have to decide if I want to try the dev version or just use old tools.

I reread your instructions for the other user - should I have .surf files in the bem folder after using make_scalp_surfaces ? I only see the 3 head-*.fif files and no .surf ones.

Thanks,
Megan

Yes, exactly, you should see those .surf files.