Viewing location of sensors over brain surface

  • MNE version: dev 1.2
  • operating system: Windows 10

I am following the fnirs preprocessing tutorial:


raw = read_hitachi(['Data/S11/S11_MES_Probe1.csv', 'Data/S11/S11_MES_Probe2.csv']) # both hemis.


montage11 = self_montage(file_path='Data/S11/0001.pos', csv_file='Data/S11/0001_edit.csv') # both hemis.
# montage11_1 = self_montage(file_path='Data/S11/0001.pos', csv_file='Data/S11/probe1_channel_montage.csv') # only left hemisphere

raw.set_montage(montage11) # both hemis.

fig = mne.viz.plot_sensors(raw.info, kind='3d')
fig.savefig('Data/S11/my_figure.png')  # looks fine

raw.load_data()
mne.datasets.fetch_fsaverage(subjects_dir=None, verbose=True)
brain = mne.viz.Brain('fsaverage', subjects_dir=None, background='white', cortex='0.5')
brain.add_sensors(raw.info, trans='fsaverage', fnirs=['channels','pairs','sources', 'detectors'])

brain.show_view(azimuth=20, elevation=90, distance=800)
brain.save_image('Data/S11/sensors.png')

Unfortunately, the sensors are not plotted as in the tutorial fnirs preprocessing describes but it only gives back the brain template and a huge Traceback.

The Traceback is the following:

0 files missing from root.txt in C:\Users\rebec\mne_data\MNE-fsaverage-data
0 files missing from bem.txt in C:\Users\rebec\mne_data\MNE-fsaverage-data\fsaverage
Traceback (most recent call last):
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local
-packages\Python38\site-packages\qtpy\__init__.py", line 204, in <module>
    from PySide import __version__ as PYSIDE_VERSION  # analysis:ignore
ModuleNotFoundError: No module named 'PySide'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "fNIRS_preprocessing.py", line 133, in <module>
    brain = mne.viz.Brain('fsaverage', subjects_dir=None, background='white', cortex='0.5')
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local
-packages\Python38\site-packages\mne\viz\_brain\_brain.py", line 357, in __init__
    self._renderer = _get_renderer(name=self._title, size=size,
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local
-packages\Python38\site-packages\mne\viz\backends\renderer.py", line 42, in _get_renderer
    _get_3d_backend()
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local
-packages\Python38\site-packages\mne\viz\backends\renderer.py", line 164, in _get_3d_backend
    _reload_backend(name)
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local
-packages\Python38\site-packages\mne\viz\backends\renderer.py", line 31, in _reload_backend
    backend = importlib.import_module(name=_backend_name_map[backend_name],
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\impor
tlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local
-packages\Python38\site-packages\mne\viz\backends\_qt.py", line 16, in <module>
    from pyvistaqt.plotting import FileDialog, MainWindow
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local
-packages\Python38\site-packages\pyvistaqt\plotting.py", line 58, in <module>
    from qtpy import QtCore
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local
-packages\Python38\site-packages\qtpy\__init__.py", line 210, in <module>
    raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found

C:\Users\rebec\fNIRS-project>python3 fNIRS_preprocessing.py
Loading C:\Users\rebec\fNIRS-project\Data\S11\S11_MES_Probe1.csv
Reading Hitachi fNIRS file version 1.25
Constructing pairing matrix for ETG-7000 (3x5)
Loading C:\Users\rebec\fNIRS-project\Data\S11\S11_MES_Probe2.csv
Reading Hitachi fNIRS file version 1.25
Constructing pairing matrix for ETG-7000 (3x5)
Using matplotlib as 2D backend.
Reading 0 ... 22346  =      0.000 ...  2234.600 secs...
0 files missing from root.txt in C:\Users\rebec\mne_data\MNE-fsaverage-data
0 files missing from bem.txt in C:\Users\rebec\mne_data\MNE-fsaverage-data\fsaverage
Traceback (most recent call last):
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\qtpy\__init__.py", line 204, in <module>
    from PySide import __version__ as PYSIDE_VERSION  # analysis:ignore
ModuleNotFoundError: No module named 'PySide'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "fNIRS_preprocessing.py", line 131, in <module>
    brain = mne.viz.Brain('fsaverage', subjects_dir=None, background='white', cortex='0.5')
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\mne\viz\_brain\_brain.py", line 357, in __init__
    self._renderer = _get_renderer(name=self._title, size=size,
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\mne\viz\backends\renderer.py", line 42, in _get_renderer
    _get_3d_backend()
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\mne\viz\backends\renderer.py", line 164, in _get_3d_backend
    _reload_backend(name)
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\mne\viz\backends\renderer.py", line 31, in _reload_backend
    backend = importlib.import_module(name=_backend_name_map[backend_name],
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\importlib\__init_
_.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\mne\viz\backends\_qt.py", line 16, in <module>
    from pyvistaqt.plotting import FileDialog, MainWindow
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\pyvistaqt\plotting.py", line 58, in <module>
    from qtpy import QtCore
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\qtpy\__init__.py", line 210, in <module>
    raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found

C:\Users\rebec\fNIRS-project>python3 fNIRS_preprocessing.py
Loading C:\Users\rebec\fNIRS-project\Data\S11\S11_MES_Probe1.csv
Reading Hitachi fNIRS file version 1.25
Constructing pairing matrix for ETG-7000 (3x5)
Loading C:\Users\rebec\fNIRS-project\Data\S11\S11_MES_Probe2.csv
Reading Hitachi fNIRS file version 1.25
Constructing pairing matrix for ETG-7000 (3x5)
Using matplotlib as 2D backend.
Reading 0 ... 22346  =      0.000 ...  2234.600 secs...
0 files missing from root.txt in C:\Users\rebec\mne_data\MNE-fsaverage-data
0 files missing from bem.txt in C:\Users\rebec\mne_data\MNE-fsaverage-data\fsaverage
Traceback (most recent call last):
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\qtpy\__init__.py", line 204, in <module>
    from PySide import __version__ as PYSIDE_VERSION  # analysis:ignore
ModuleNotFoundError: No module named 'PySide'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "fNIRS_preprocessing.py", line 131, in <module>
    brain = mne.viz.Brain('fsaverage', subjects_dir=None, background='white', cortex='0.5')
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\mne\viz\_brain\_brain.py", line 357, in __init__
    self._renderer = _get_renderer(name=self._title, size=size,
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\mne\viz\backends\renderer.py", line 42, in _get_renderer
    _get_3d_backend()
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\mne\viz\backends\renderer.py", line 164, in _get_3d_backend
    _reload_backend(name)
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\mne\viz\backends\renderer.py", line 31, in _reload_backend
    backend = importlib.import_module(name=_backend_name_map[backend_name],
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\importlib\__init_
_.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\mne\viz\backends\_qt.py", line 16, in <module>
    from pyvistaqt.plotting import FileDialog, MainWindow
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\pyvistaqt\plotting.py", line 58, in <module>
    from qtpy import QtCore
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Py
thon38\site-packages\qtpy\__init__.py", line 210, in <module>
    raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found

C:\Users\rebec\fNIRS-project>python3 fNIRS_preprocessing.py
Loading C:\Users\rebec\fNIRS-project\Data\S11\S11_MES_Probe1.csv
Reading Hitachi fNIRS file version 1.25
Constructing pairing matrix for ETG-7000 (3x5)
Loading C:\Users\rebec\fNIRS-project\Data\S11\S11_MES_Probe2.csv
Reading Hitachi fNIRS file version 1.25
Constructing pairing matrix for ETG-7000 (3x5)
Reading 0 ... 22346  =      0.000 ...  2234.600 secs...
0 files missing from root.txt in C:\Users\rebec\mne_data\MNE-fsaverage-data
0 files missing from bem.txt in C:\Users\rebec\mne_data\MNE-fsaverage-data\fsaverage
Traceback (most recent call last):
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\qtpy\__init__.py", line 204, in <module>
    from PySide import __version__ as PYSIDE_VERSION  # analysis:ignore
ModuleNotFoundError: No module named 'PySide'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "fNIRS_preprocessing.py", line 128, in <module>
    brain = mne.viz.Brain('fsaverage', subjects_dir=None, background='white', cortex='0.5')
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\mne\viz\_brain\_brain.py", line 357, in __init__
    self._renderer = _get_renderer(name=self._title, size=size,
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\mne\viz\backends\renderer.py", line 42, in _get_renderer
    _get_3d_backend()
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\mne\viz\backends\renderer.py", line 164, in _get_3d_backend
    _reload_backend(name)
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\mne\viz\backends\renderer.py", line 31, in _reload_backend
    backend = importlib.import_module(name=_backend_name_map[backend_name],
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\mne\viz\backends\_qt.py", line 16, in <module>
    from pyvistaqt.plotting import FileDialog, MainWindow
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pyvistaqt\plotting.py", line 58, in <module>
    from qtpy import QtCore
  File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\qtpy\__init__.py", line 210, in <module>
    raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found

What is the problem here?

I want to thank you again in advance for your outstanding support! :raised_hands:t2:

I think this is the important part of the traceback:

Please try conda install PySide or pip install PySide.

If you installed MNE-Python using our standalone installer, then use the conda command in the “MNE console” (I think that’s what it’s called? cc @richard to correct me if I’m wrong).

Otherwise (if you installed MNE-Python using our advanced instructions) then use either conda or pip depending on what you used during installation of MNE-Python.

1 Like

Thank you very much for you fast response!

I have tried it and it didn’t work, I am using (pip-22.2.2)and python 3.8. I got the following back:

Collecting PySide
Using cached PySide-1.2.4.tar.gz (9.3 MB)
Preparing metadata (setup.py) … error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
only these python versions are supported: [(2, 6), (2, 7), (3, 2), (3, 3), (3, 4)]
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I tried to install a later version and got a different output:

PySide == 1.2.2:

Collecting PySide==1.2.2
Downloading PySide-1.2.2.tar.gz (9.3 MB)
---------------------------------------- 9.3/9.3 MB 5.3 MB/s eta 0:00:00
Preparing metadata (setup.py) … error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [10 lines of output]
Traceback (most recent call last):
File “”, line 2, in
File “”, line 34, in
File “C:\Users\rebec\AppData\Local\Temp\pip-install-4nbsbgng\pyside_e7447f59fe6a4d578e4e669d7803fbfe\setup.py”, line 89, in
from utils import rmtree
File “C:\Users\rebec\AppData\Local\Temp\pip-install-4nbsbgng\pyside_e7447f59fe6a4d578e4e669d7803fbfe\utils.py”, line 10, in
import popenasync
File “C:\Users\rebec\AppData\Local\Temp\pip-install-4nbsbgng\pyside_e7447f59fe6a4d578e4e669d7803fbfe\popenasync.py”, line 26, in
if subprocess.mswindows:
AttributeError: module ‘subprocess’ has no attribute ‘mswindows’
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

What do you suggest to try?

Best, Rebecka

This is a clue. It’s a very old version of PySide. Please try installing as pip install PySide6. I forgot that they changed the package name at some point.

1 Like

Hi,
Thank you for the fast reply, tried that and got:

Successfully installed PySide6-Addons-6.3.2 PySide6-Essentials-6.3.2 pyside6-6.3.2 shiboken6
-6.3.2
C:\Users\rebec\fNIRS-project>python3 fNIRS_preprocessing.py
Loading C:\Users\rebec\fNIRS-project\Data\S11\S11_MES_Probe1.csv
Reading Hitachi fNIRS file version 1.25
Constructing pairing matrix for ETG-7000 (3x5)
Loading C:\Users\rebec\fNIRS-project\Data\S11\S11_MES_Probe2.csv
Reading Hitachi fNIRS file version 1.25
Constructing pairing matrix for ETG-7000 (3x5)
Reading 0 … 22346 = 0.000 … 2234.600 secs…
0 files missing from root.txt in C:\Users\rebec\mne_data\MNE-fsaverage-data
0 files missing from bem.txt in C:\Users\rebec\mne_data\MNE-fsaverage-data\fsaverage
Traceback (most recent call last):
File “C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra
8p0\LocalCache\local-packages\Python38\site-packages\qtpy_init_.py”, line 204, in <module
from PySide import version as PYSIDE_VERSION # analysis:ignore
ModuleNotFoundError: No module named ‘PySide’
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “fNIRS_preprocessing.py”, line 128, in
brain = mne.viz.Brain(‘fsaverage’, subjects_dir=None, background=‘white’, cortex=‘0.5’)
File “C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra
8p0\LocalCache\local-packages\Python38\site-packages\mne\viz_brain_brain.py”, line 357, in
init
self._renderer = _get_renderer(name=self._title, size=size,
File “C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra
8p0\LocalCache\local-packages\Python38\site-packages\mne\viz\backends\renderer.py”, line 42,
in _get_renderer
_get_3d_backend()
File “C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra
8p0\LocalCache\local-packages\Python38\site-packages\mne\viz\backends\renderer.py”, line 164
, in _get_3d_backend
_reload_backend(name)
File “C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra
8p0\LocalCache\local-packages\Python38\site-packages\mne\viz\backends\renderer.py”, line 31,
in _reload_backend
backend = importlib.import_module(name=backend_name_map[backend_name],
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz
5n2kfra8p0\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1014, in _gcd_import
File “”, line 991, in _find_and_load
File “”, line 975, in _find_and_load_unlocked
File “”, line 671, in _load_unlocked
File “”, line 848, in exec_module
File “”, line 219, in call_with_frames_removed
File “C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra
8p0\LocalCache\local-packages\Python38\site-packages\mne\viz\backends_qt.py”, line 16, in <
module>
from pyvistaqt.plotting import FileDialog, MainWindow
File “C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra
8p0\LocalCache\local-packages\Python38\site-packages\pyvistaqt\plotting.py”, line 58, in
from qtpy import QtCore
File "C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra
8p0\LocalCache\local-packages\Python38\site-packages\qtpy_init
.py", line 210, in <module

raise PythonQtError('No Qt bindings could be found') qtpy.PythonQtError: No Qt bindings could be found

I am not sure what the problem is :thinking:

I see that you say you’re using the dev version of MNE-Python. FYI (1) this can introduce new dependencies without installing them automatically, and (2) it can be a bit tricky to make sure they get installed in the right place. It seems likely that that is what happened here. So first, please show us the result of mne.sys_info().

Next, can you say more about how you installed MNE-Python (before upgrading to dev version)? Did you use the standalone installer? Are you using conda / anaconda? Which instructions did you follow? Did you do something custom / manual with your installation? E.g., based on this:

… it looks like a user-level Python was installed manually?

With the answers above I’ll attempt one more round of troubleshooting, after that I’ll recommend that you re-install the whole MNE-Python environment.

1 Like

Hi again, thank you for the response and help :point_up:t2:

I have been using Pycharm and found it quite troubelsome, so I now changed to Spyders, I have been working with it before, and I followed your mne-installation instructions correctly. So the good thing is, there are no errors and tracebacks anymore! :partying_face:

However the sensors still do not get plotted when I use a brain template. :thinking:

When I do this:

fig = mne.viz.plot_sensors(raw.info, kind='3d')
fig.savefig('Data/S11/my_figure.png')  # looks fine

The sensors look perfectly fine:

However, this

raw.load_data()
mne.datasets.fetch_fsaverage(subjects_dir=None, verbose=True)
brain = mne.viz.Brain('fsaverage', subjects_dir=None, background='white', cortex='0.5')
brain.add_sensors(raw.info, trans='fsaverage', fnirs=['channels','pairs','sources', 'detectors'])

brain.show_view(azimuth=20, elevation=90, distance=800)
brain.save_image('Data/S11/sensors.png')

just leaves me with an empty brain template. :brain:

Thank you for your help!

notice that the plot of sensors says that x, y, and z are in meters. So your sensors are probably offscreen in the brain plot. As a quick test of this, please when you load your .pos file divide the values by 1000 to convert millimeters to meters, and see if that fixes it.

2 Likes

Oh Thank you so much for your help and time! It worked :smiley: :partying_face:

However, It looks very different on both hemispheres:

right

left

Do you know why this is the case? Has it to do with my naming?

sorry again,

I’m not experienced with fNIRS so this is a guess, but yeah it looks like the left hemi is correctly defined (?) and the right hemi the matchup between the .pos file and the source/detector numbers is messed up. I’ll have to defer to @rob-luke at this point. He’ll probably want to see the .pos file and the function you’re using to match up the .pos with the source/detector names, so go ahead and post those to save some time.

1 Like

Hi, thank you! Okay, here are the most important functions and the content of the .pos- file:

The content of the .pos file looks like this:

[FileInfo]
ID=3DHeadShape
VER=2.20
ProductName=ETG4000
PROBE=2
TYPE=0
MODE=ETG
[User]
Name=SAMIAN
ID=S11
Comment=
Sex=Male
Age= 54y
Birth=1963/10/01
[Probe1]
MODE=3
ChNum=15
[Probe2]
MODE=3
ChNum=15
[MRI]
MarkColor=5
MarkColorSel=2
MarkSize=0.020000
Voxel=
Head=
Brain=
Set=0
[LeftEar]
X=71.8
Y=-0.0
Z=0.0
A=11.1
E=-5.5
R=-167.3
OX=-125.0
OY=-302.7
OZ=-8.7
EX=-86.3
EY=-295.1
EZ=-4.9
[RightEar]
X=-77.0
Y=0.0
Z=-0.0
A=-177.1
E=-8.4
R=177.6
OX=101.0
OY=-283.7
OZ=-10.2
EX=61.9
EY=-285.6
EZ=-4.4
[Nasion]
X=-0.0
Y=-106.0
Z=0.0
A=100.2
E=-4.0
R=-180.0
OX=4.2
OY=-427.6
OZ=31.7
EX=-2.8
EY=-388.7
EZ=34.4
[Back]
X=-6.3
Y=76.7
Z=29.3
A=-83.1
E=-11.8
R=-167.0
OX=-26.6
OY=-182.7
OZ=-9.9
EX=-22.0
EY=-221.2
EZ=-1.7
[Top]
X=-5.4
Y=-23.6
Z=134.2
A=27.2
E=86.1
R=20.3
OX=-9.5
OY=-311.3
OZ=177.7
EX=-7.1
EY=-310.0
EZ=138.2
[Probe1-ch1]
X=51.1
Y=47.9
Z=54.4
A=-145.31
E=-15.13
R=-150.79
NX=33.1
NY=-20.7
NZ=-40.8
OX=73.4
OY=-227.8
OZ=23.8
EX=42.0
EY=-249.5
EZ=34.1
[Probe1-ch2]
X=63.2
Y=21.9
Z=53.0
A=-159.99
E=-17.84
R=-141.40
NX=26.3
NY=48.4
NZ=-164.6
OX=70.2
OY=-266.3
OZ=33.0
EX=34.8
EY=-279.2
EZ=45.1
[Probe1-ch3]
X=69.6
Y=-6.1
Z=46.2
A=-169.37
E=-10.18
R=-153.95
NX=19.8
NY=13.4
NZ=-0.8
OX=82.0
OY=-296.8
OZ=38.2
EX=43.7
EY=-304.0
EZ=45.2
[Probe1-ch4]
X=70.0
Y=-33.8
Z=43.7
A=172.22
E=-19.03
R=-152.63
NX=13.9
NY=-22.1
NZ=-17.5
OX=90.9
OY=-331.4
OZ=34.5
EX=53.8
EY=-326.4
EZ=47.4
[Probe1-ch5]
X=63.4
Y=-61.4
Z=35.1
A=158.11
E=-9.33
R=-173.19
NX=26.7
NY=-60.0
NZ=12.8
OX=77.3
OY=-364.8
OZ=42.6
EX=41.1
EY=-350.3
EZ=49.0
[Probe1-ch6]
X=51.4
Y=40.5
Z=77.7
A=-137.43
E=6.73
R=-132.58
NX=43.2
NY=-387.0
NZ=920.7
OX=53.7
OY=-227.1
OZ=65.2
EX=24.7
EY=-253.7
EZ=60.6
[Probe1-ch7]
X=61.5
Y=17.4
Z=72.6
A=-158.35
E=17.43
R=-159.42
NX=28.3
NY=-8.0
NZ=-8.6
OX=68.3
OY=-258.6
OZ=74.3
EX=33.2
EY=-272.5
EZ=62.5
[Probe1-ch8]
X=68.3
Y=-9.4
Z=69.4
A=-171.73
E=15.79
R=-165.09
NX=17.1
NY=9.8
NZ=18.2
OX=76.2
OY=-297.4
OZ=75.7
EX=38.5
EY=-302.9
EZ=65.0
[Probe1-ch9]
X=66.5
Y=-37.0
Z=64.9
A=175.13
E=14.26
R=-149.64
NX=9.7
NY=-8.6
NZ=-60.5
OX=80.7
OY=-328.6
OZ=75.4
EX=42.4
EY=-325.3
EZ=65.6
[Probe1-ch10]
X=62.3
Y=-64.2
Z=59.1
A=162.20
E=21.34
R=-175.00
NX=21.9
NY=-63.3
NZ=10.5
OX=65.6
OY=-364.0
OZ=80.8
EX=30.5
EY=-352.7
EZ=66.3
[Probe1-ch11]
X=44.2
Y=35.9
Z=96.1
A=-118.72
E=37.98
R=-125.78
NX=45.7
NY=-151.2
NZ=351.7
OX=26.2
OY=-224.3
OZ=100.7
EX=11.2
EY=-251.7
EZ=76.3
[Probe1-ch12]
X=55.5
Y=11.3
Z=96.6
A=-148.05
E=34.91
R=-155.04
NX=35.2
NY=12.6
NZ=-44.1
OX=52.3
OY=-258.4
OZ=105.4
EX=24.7
EY=-275.6
EZ=82.8
[Probe1-ch13]
X=60.2
Y=-15.5
Z=97.0
A=-170.89
E=27.34
R=-139.28
NX=15.0
NY=224.4
NZ=-513.9
OX=67.3
OY=-291.4
OZ=106.6
EX=32.6
EY=-296.9
EZ=88.5
[Probe1-ch14]
X=57.5
Y=-43.0
Z=91.1
A=173.25
E=29.89
R=-147.79
NX=10.2
NY=9.0
NZ=-121.7
OX=66.1
OY=-332.8
OZ=107.3
EX=32.0
EY=-328.7
EZ=87.5
[Probe1-ch15]
X=46.2
Y=-71.1
Z=86.2
A=153.94
E=39.37
R=-178.73
NX=22.9
NY=-67.3
NZ=13.0
OX=49.7
OY=-360.4
OZ=113.3
EX=22.2
EY=-346.9
EZ=88.2
[Probe2-ch1]
X=-66.0
Y=-67.1
Z=30.8
A=30.26
E=-26.10
R=-52.62
NX=-30.1
NY=-65.8
NZ=34.7
OX=-91.1
OY=-383.6
OZ=18.6
EX=-60.4
EY=-365.7
EZ=36.0
[Probe2-ch2]
X=-73.6
Y=-40.3
Z=38.7
A=18.35
E=-22.81
R=-47.10
NX=-18.7
NY=-49.0
NZ=43.9
OX=-106.0
OY=-350.8
OZ=19.5
EX=-71.3
EY=-339.3
EZ=34.9
[Probe2-ch3]
X=-78.0
Y=-15.3
Z=45.3
A=-6.06
E=-18.73
R=-40.12
NX=-2.3
NY=-28.7
NZ=52.5
OX=-108.7
OY=-314.5
OZ=20.8
EX=-71.4
EY=-318.5
EZ=33.5
[Probe2-ch4]
X=-74.8
Y=14.4
Z=54.3
A=-2.21
E=-21.11
R=-47.46
NX=5.0
NY=-4.3
NZ=70.2
OX=-113.1
OY=-286.0
OZ=17.9
EX=-76.2
EY=-287.4
EZ=32.2
[Probe2-ch5]
X=-67.1
Y=39.2
Z=60.0
A=-26.40
E=-23.32
R=-38.29
NX=-20.6
NY=17.3
NZ=76.8
OX=-108.2
OY=-246.6
OZ=13.5
EX=-75.6
EY=-262.8
EZ=29.1
[Probe2-ch6]
X=-68.0
Y=-72.2
Z=50.9
A=30.12
E=21.33
R=-72.33
NX=-31.1
NY=-77.6
NZ=52.7
OX=-91.5
OY=-387.9
OZ=66.1
EX=-59.5
EY=-369.4
EZ=51.7
[Probe2-ch7]
X=-75.0
Y=-47.6
Z=60.3
A=14.55
E=7.98
R=-66.60
NX=-14.8
NY=-64.6
NZ=61.5
OX=-96.4
OY=-353.2
OZ=60.7
EX=-58.5
EY=-343.3
EZ=55.2
[Probe2-ch8]
X=-77.9
Y=-19.7
Z=69.4
A=10.29
E=6.07
R=-61.84
NX=-8.2
NY=-41.1
NZ=74.0
OX=-106.9
OY=-323.1
OZ=59.9
EX=-68.2
EY=-316.1
EZ=55.7
[Probe2-ch9]
X=-75.1
Y=4.8
Z=74.1
A=-9.96
E=10.43
R=-98.39
NX=-5.5
NY=-34.0
NZ=121.6
OX=-101.1
OY=-287.2
OZ=60.5
EX=-62.7
EY=-294.0
EZ=53.4
[Probe2-ch10]
X=-67.5
Y=27.2
Z=79.9
A=-34.82
E=10.70
R=-96.17
NX=-29.9
NY=-17.1
NZ=131.2
OX=-96.8
OY=-248.4
OZ=59.4
EX=-64.8
EY=-270.6
EZ=52.1
[Probe2-ch11]
X=-58.0
Y=-76.7
Z=79.2
A=46.31
E=30.21
R=-63.11
NX=-38.2
NY=-73.4
NZ=69.3
OX=-61.6
OY=-385.5
OZ=98.9
EX=-38.0
EY=-360.7
EZ=79.0
[Probe2-ch12]
X=-68.0
Y=-54.2
Z=84.9
A=19.57
E=29.79
R=-64.99
NX=-19.0
NY=-74.7
NZ=74.5
OX=-79.7
OY=-351.9
OZ=98.8
EX=-47.4
EY=-340.4
EZ=79.1
[Probe2-ch13]
X=-73.5
Y=-26.6
Z=92.2
A=12.64
E=31.48
R=-74.77
NX=-10.6
NY=-57.1
NZ=97.0
OX=-92.5
OY=-323.0
OZ=98.8
EX=-59.5
EY=-315.7
EZ=78.1
[Probe2-ch14]
X=-71.9
Y=-3.4
Z=97.7
A=-21.36
E=30.85
R=-66.77
NX=-19.3
NY=-33.8
NZ=101.8
OX=-93.6
OY=-280.0
OZ=97.3
EX=-62.0
EY=-292.4
EZ=77.0
[Probe2-ch15]
X=-61.0
Y=21.5
Z=104.2
A=-37.50
E=27.29
R=-84.74
NX=-28.8
NY=-24.3
NZ=134.6
OX=-88.5
OY=-241.6
OZ=94.8
EX=-60.6
EY=-263.0
EZ=76.6
[Angle]
X=21.37
Y=0.21
Z=356.32
[Measure]
3DSpaceData=1
Extension=1

This script is called pos_convert.py:


# output csv:  4 columns containing ch_name, x, y, and z.

def create_csv(read_filename, outfile):
    """
    Creates a .csv file out of .pos data
    :param read_filename: input file path that gets read
    :param outfile: path to which the output gets written
    :return: None (just creates an output-file)
    """

    with open(read_filename, 'r') as file:
        with open(outfile, 'w') as out_f:
            writer = csv.writer(out_f)
            lines = file.readlines()
            lines = [line.replace('\n', '') for line in lines]
            header = []
            indi = []
            for l in lines:
                if '[' and ']' in l:
                    header.append(l)
            for i in header:
                ind = lines.index(i)
                indi.append(ind)
            in_val = list(zip(header, indi))
            in_val = in_val[10:40]
            pre = in_val[0:10]
            h = ['ch_name', 'x', 'y', 'z']
            writer.writerow(h)
            for i in range(len(in_val)):
                if i != len(in_val)-1:
                    tup = in_val[i]
                    tup2 = in_val[i+1]
                    cont = lines[tup[1]:tup2[1]]
                    ch_n = cont[0]
                    ch_n = ch_n.lstrip('[').rstrip(']')
                    content = cont[1::]
                    x = content[0] 
                    x = float(x.lstrip('X=')) / 1000
                    y = content[1] 
                    y = float(y.lstrip('Y=')) / 1000
                    z = content[2] 
                    z = float(z.lstrip('Z=')) / 1000
                    list_content = [str(ch_n), str(x), str(y), str(z)]
                    writer.writerow(list_content)
                else:
                    tup = in_val[i]
                    cont = lines[tup[1]::]
                    content = cont[1::]
                    ch_n = cont[0] 
                    ch_n = ch_n.lstrip('[').rstrip(']')
                    x = content[0] 
                    x = float(x.lstrip('X=')) / 1000
                    y = content[1]
                    y = float(y.lstrip('Y=')) / 1000
                    z = content[2] 
                    z = float(z.lstrip('Z=')) / 1000
                    list_content = [str(ch_n), str(x), str(y), str(z)]
                    writer.writerow(list_content)

    # read .csv of positional .csv file
    df = pd.read_csv(outfile)
    df.to_csv(outfile, index=False, sep=',')  # restructure
    return


# test on participant S01
os.makedirs('C:/Users/rebec/fNIRS-project/Data/S11', exist_ok=True)

# write .pos to .csv
create_csv('Data/S11/0001.pos', 'Data/S11/0001.csv')

# read .csv file with columns: ch_name,x,y,z and create a dataframe
df = pd.read_csv('Data/S11/0001.csv')


# seperation of Probe1(left hemi)  and Probe2 (right hemi)
probe1 = df[df['ch_name'].str.startswith('Probe1')]
probe2 = df[df['ch_name'].str.startswith('Probe2')] 

df.drop('ch_name', axis=1, inplace=True)

new_names = ['S1', 'D1',
             'S2', 'D2',
             'S3', 'D3',
             'S4', 'D4',
             'S5', 'D5',
             'S6', 'D6',
             'S7', 'D7',
             'S8', 'D8',
             'S9', 'D9',
             'S10', 'D10',
             'S11', 'D11',
             'S12', 'D12',
             'S13', 'D13',
             'S14', 'D14',
             'S15','S16']
df.insert(0, 'ch_name', new_names)

# rename
# left hemisphere
new_names_1 = 'S1 D1 S2 D2 S3 D3 S4 D4 S5 D5 S6 D6 S7 D7 S8'.split()

# right hemisphere
new_names_2 = ['D8',
               'S9', 'D9',
             'S10', 'D10',
             'S11', 'D11',
             'S12', 'D12',
              'S13', 'D13',
              'S14', 'D14',
              'S15','S16']

probe1.drop('ch_name', axis=1, inplace=True)
probe2.drop('ch_name', axis=1, inplace=True)
probe1.insert(0, 'ch_name', new_names_1)
probe2.insert(0, 'ch_name', new_names_2)

# creates csv file for left hemisphere 
probe1.to_csv('Data/S11/probe1_channel_montage.csv', index=False, sep=',') 

 # creates csv file for right hemisphere 
probe2.to_csv('Data/S11/probe2_channel_montage.csv', index=False, sep=',')

# creats csv file of both hemisphere (left and right) 
df.to_csv('Data/S11/0001_edit.csv', index=False, sep=',')

My manuel_montage.py script looks like this and is further used for the DigMontage (in fnirs_preprocessing.py)


def convert_to_dic(csv_file):
    """ reuse csv file we got from pos_convert to get channel names and pos"""
    with open(csv_file) as f:
        df = pd.read_csv(f, header=None, index_col=0).iloc[1:, :]
        df1 = df.agg(list, axis=1).to_dict()
        dic = {}
        for ch_name, ch_pos in df1.items():
            ch_pos = np.asarray([eval(i) for i in ch_pos]) # ch_name with array of shape (3,)
            dic[ch_name] = ch_pos
        return dic
        

def read_montage(filename):
    """
    :param filename: file of montage coordinates from .pos
    we need following parameters: ch_pos, nasion, lpa, rpa, hsp (none), hpi (none), coord_frame = MRI 'mri'
    :returns right format for function make_dig_montage arrays and matrix
    """
    with open(filename, 'r') as file:
        lines = file.readlines()
        lines = [line.replace('\n', '') for line in lines]
        header = []
        indi = []
        for l in lines:
            if '[' and ']' in l:
                header.append(l)
        for i in header:
            ind = lines.index(i)
            indi.append(ind)
        in_val = list(zip(header, indi))
        info_index = in_val[5:11]  # list of tuples of header(info) and index
        dic = {}
        for i in range(len(info_index)):

            if i != len(info_index) - 1:
                tup = info_index[i]
                tup2 = info_index[i + 1]
                name = lines[tup[1]:tup2[1]][0]
                content = np.array(lines[tup[1]:tup2[1]][1::])
                name = name.lstrip('[').rstrip(']')

                if name == 'LeftEar':
                    name = 'lpa'
                elif name == 'RightEar':
                    name = 'rpa'
                elif name == 'Nasion':
                    name = 'nasion'

                x = content[0] 
                x = float(x.lstrip('X=')) /1000
                y = content[1] 
                y = float(y.lstrip('Y=')) /1000
                z = content[2] 
                z = float(z.lstrip('Z=')) /1000
                list_content = [name, [float(x), float(y), float(z)]]
                dic[list_content[0]] = list_content[1]


        hsp = np.matrix((dic['Back'], dic['Top']))
        back = np.array(dic['Back'])
        top = np.array(dic['Top'])
        lpa = np.array(dic['lpa'])
        rpa = np.array(dic['rpa'])
        nasion = np.array(dic['nasion'])
        coord_frame = 'mri' # or 'unknown'

        return lpa, rpa, nasion, hsp, coord_frame

And finally I am able to do the DigMontage this:


# Dig montage
def self_montage(file_path, csv_file):
    """
    :param file_path: .pos file with position of montage
    :param csv_file: enter csv file with the set ch_names and x,y,z-position
    :return: montage
    """
    lpa, rpa, nasion, hsp, coord_frame = manuel_montage.read_montage(file_path)
    ch_pos = manuel_montage.convert_to_dic(csv_file)
    return mne.channels.make_dig_montage(ch_pos=ch_pos, nasion=nasion, lpa=lpa, rpa=rpa,
                                             hsp=hsp, hpi=None, coord_frame='unknown')

Thank you a lot in advance! :pray:t2: