Trouble connecting Brainstorm and MNE-Python (Unable to resolve the name)

Greetings,

I am working with MEG data (Elekta Neuromag). Accordingly, I would like to use the Maxwell Filter process in Brainstorm (I am on a Mac).

I followed the instructions here (https://neuroimage.usc.edu/brainstorm/MnePython). This included downloading CPython (3.12) and updating the Python executable path within Brainstorm (/Library/Frameworks/Python.framework/Versions/3.12/bin/python3).

I also followed this (https://www.mathworks.com/help/matlab/matlab_external/install-supported-python-implementation.html). I also checked the PythonEnvironment and I think everything looks okay:

      Version: "3.12"
   Executable: "/Library/Frameworks/Python.framework/Versions/3.12/bin/python3"
      Library: "/Library/Frameworks/Python.framework/Versions/3.12/lib/libpython3.12.dylib"
         Home: "/Library/Frameworks/Python.framework/Versions/3.12"
       Status: Loaded
ExecutionMode: InProcess
    ProcessID: "5987"
  ProcessName: "MATLAB"

Using the GUI, I select my Raw MEG file and attempt to apply the Maxwell Filter function, and I come across this error:

BST> Python 3.12 executable: /Library/Frameworks/Python.framework/Versions/3.12/bin/python3

** Error: [process_mne_maxwell] Pre-process > MNE-Python: maxwell_filter (SSS/tSSS)
** Line 44: Unable to resolve the name 'py.mne.io.constants.FIFF'.
**
** Call stack:
** >out_mne_channel.m at 44
** >out_mne_data.m at 167
** >process_mne_maxwell_py.m>Run at 121
** >process_mne_maxwell_py.m at 24
** >process_mne_maxwell.m>Run at 134
** >process_mne_maxwell.m at 27
** >bst_process.m>Run at 203
** >bst_process.m at 38
** >panel_process1.m>RunProcess at 138
** >panel_process1.m at 26
** >gui_brainstorm.m>CreateWindow/ProcessRun_Callback at 781
** >bst_call.m at 28
** >gui_brainstorm.m>@(h,ev)bst_call(@ProcessRun_CallbackProcessRun_Callback) at 301
**
*@rawHBM0001_Visit02_MEG_ER_raw
** File: HBM0001/@rawHBM0001_Visit02_MEG_ER_raw_(2)high/data_0raw_HBM0001_Visit02_MEG_ER_raw(2)_high.mat
**

Given the error, I even tried reviewing this (https://www.mathworks.com/help/matlab/matlab_external/undefined-variable-py-or-function-py-command.html) but was not able to solve this issue.

I was hoping for some help here for fixing this issue - any suggestions?

Thank you,

Paul

Hi @pdhami, few questions:

  • Which version of Matlab are you using?
  • Run each of these command in your system terminal, and post the answer:
    1.
    which -a python
    
    python --version
    
    python -c "import mne; mne.sys_info()"
    

Hi @Raymundo.Cassani

  • I am using Matlab 2024b

For the requested commands, I do “python3” instead of “python” since nothing shows up.

  1. which -a python3
/Library/Frameworks/Python.framework/Versions/3.12/bin/python3
/usr/local/bin/python3
/usr/bin/python3
  1. python --version

Python 3.12.10

  1. python -c "import mne; mne.sys_info()"
Platform             macOS-15.5-arm64-arm-64bit
Python               3.12.10 (v3.12.10:0cc81280367, Apr  8 2025, 08:46:59) [Clang 13.0.0 (clang-1300.0.29.30)]
Executable           /Library/Frameworks/Python.framework/Versions/3.12/bin/python3
CPU                  Apple M1 (8 cores)
Memory               8.0 GiB
Core
├☑ mne               1.11.0 (unable to check for latest version on GitHub, SSL error)
├☑ numpy             2.3.5 (unknown linalg bindings (threadpoolctl module not found: No module named 'threadpoolctl'))
├☑ scipy             1.16.3
└☑ matplotlib        3.10.7 (backend=macosx)
Numerical (optional)
└☐ unavailable       sklearn, numba, nibabel, nilearn, dipy, openmeeg, cupy, pandas, h5io, h5py
Visualization (optional)
└☐ unavailable       pyvista, pyvistaqt, vtk, qtpy, ipympl, pyqtgraph, mne-qt-browser, ipywidgets, trame_client, trame_server, trame_vtk, trame_vuetify
Ecosystem (optional)
└☐ unavailable       mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline, neo, eeglabio, edfio, curryreader, mffpy, pybv, antio, defusedxml

Also, I should note that based on the BST instruction page, I avoided installing with conda and instead I used the following pip instructions ( Install via pip or conda — MNE 1.11.0 documentation ). Is it due to the pip installation providing only the core dependencies, whereas the conda one is for all dependencies?

Thanks for your help.

Hi @pdhami, I did some tests on the same setup, and I'm able to go beyond the error that you reported

For your Matlab2024b, did you install also the macOS (Apple Silicon) version?
In Matlab type mexext:

  • mexmaca64: Apple Silicon
  • mexmaci64: Intel processor

Although I was able to pass that line error, now I'm facing this:

***************************************************************************
** Error: [process_mne_maxwell] Pre-process > MNE-Python: maxwell_filter (SSS/tSSS)
** Line 110: Unable to resolve the name 'py.mne.create_info'.
**
** Call stack:
** >out_mne_channel.m at 110
** >out_mne_data.m at 167
** >process_mne_maxwell_py.m>Run at 121
** >process_mne_maxwell_py.m at 24
** >process_mne_maxwell.m>Run at 134
** >process_mne_maxwell.m at 27
** >bst_process.m>Run at 203
** >bst_process.m at 38
** >panel_process1.m>RunProcess at 138
** >panel_process1.m at 26
** >gui_brainstorm.m>CreateWindow/ProcessRun_Callback at 781
** >bst_call.m at 28
** >gui_brainstorm.m>@(h,ev)bst_call(@ProcessRun_Callback) at 301
**
**
** File: Subject01/@rawS01_AEF_20131218_01_600Hz_notch/data_0raw_S01_AEF_20131218_01_600Hz_notch.mat
**
***************************************************************************

@chinmay.chinara, is this something you could help with?

@Raymundo.Cassani sure let me try it at my end.

Hi @Raymundo.Cassani

I type in the command and get: mexmaci64

So it’s the Intel processor - would that be an issue?

Best

Paul

@Raymundo.Cassani @pdhami

With the same configuration (on Windows 11), I get the same error, i.e.,

After some trial and error, it appears the issue is with the MNE package version. I tried with 1.11.0 and 1.10.0 and got the same error.

When I switched to the version specified in the tutorial, i.e., 1.0.3, everything worked fine.

The steps I followed are as under:

  • From the system terminal, clear all the packages installed by pip for the Python version 3.12.0 using the command:
    pip freeze | xargs pip uninstall -y
  • Use the command pip list to verify that all the packages were uninstalled
  • Install mne version 1.0.3 with some of its minimal dependencies using the command:
    pip install mne==1.0.3 setuptools psutil pyyaml.
    All the other dependencies will be automatically installed.
  • Running python -c "import mne; mne.sys_info() gives result as under:
> C:\\Users\\chinm\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\mne\\datasets\\eegbci\\eegbci.py:8: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html . The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
> import pkg_resources
> Platform:         Windows-11-10.0.26100-SP0
> Python:           3.12.10 (tags/v3.12.10:0cc8128, Apr  8 2025, 12:21:36) \[MSC v.1943 64 bit (AMD64)\]
> Executable:       C:\\Users\\chinm\\AppData\\Local\\Programs\\Python\\Python312\\python.exe
> CPU:              Intel64 Family 6 Model 183 Stepping 1, GenuineIntel: 32 cores
> Memory:           63.7 GB
>
> mne:              1.0.3
> numpy:            2.3.5 {}
> scipy:            1.16.3
> matplotlib:       3.10.7 {backend=tkagg}
>
> sklearn:          Not found
> numba:            Not found
> nibabel:          Not found
> nilearn:          Not found
> dipy:             Not found
> cupy:             Not found
> pandas:           Not found
> pyvista:          Not found
> pyvistaqt:        Not found
> ipyvtklink:       Not found
> vtk:              Not found
> PyQt5:            Not found
> ipympl:           Not found
> pooch:            v1.8.2
>
> mne_bids:         Not found
> mne_nirs:         Not found
> mne_features:     Not found
> mne_qt_browser:   Not found
> mne_connectivity: Not found
  • Open MATLAB 2024b and start Brainstorm. Configure MATLAB as per the tutorial by setting the Python executable path to the same path as given by the result in the point just above, in this case being C:\Users\chinm\AppData\Local\Programs\Python\Python312\python.exe
  • You might need to restart MATLAB, but after that, the process should work as expected.

EDIT: On doing some more trials (on Windows), the issue of Unable to resolve the name py.mne.create_info started from MNE version 1.6.0 onwards.

Yes, that is one of the issues.
From Matlab's "Configure Your System to Use Python" page:

If you are on a Mac platform, verify that the MATLAB and Python builds are consistent with your architecture (Apple silicon or Intel® processor)

When you run python3 -c "import mne; mne.sys_info()", it indicates that the platform is arm64-arm-64bit thus its for Apple Silicon

Also, as noted by @chinmay.chinar, please install a MNE-Python version between >= 1.0.3 and < 1.6.0

Thank you both for the responses. We have now decided to run our MEG preprocessing on a lab Windows machine, and I’m now facing installation errors again…

This computer is a Windows 11, with Matlab 2024a and Python 3.12 installed.

I go back to the installation webpage, and I follow the first instruction for installing MNE-Python.

pip install numpy scipy matplotlib numba pandas xlrd scikit-learn h5py pillow statsmodels jupyter joblib psutil numexpr traits pyface traitsui imageio tqdm spyder-kernels mne imageio-ffmpeg vtk pyvista pyvistaqt dipy nibabel nilearn neo python-picard PyQt5 mayavi PySurfer

Unfortunately, I run into the following error related to the package mayavi, which due to character limits, I’ve attached.

BST_mne_error.txt (41.6 KB)

Any help with this installation issue would be great.

Thank you,

Paul