Brainstorm not recognising path or command to SimNIBS 4.0.0

Dear Francois,

I have downloaded the newest brainstorm version 230228 (source + binary) and would like to create a FEM Mesh with SimNIBS 4.0. However, I receive the following error message: "SimNIBS 4.x is not installed or not added to the system path: the command "charm" could not be found.".

Yet SimNIBS is correctly installed on linux and has been added to the system variables in the .bashrc file. Additionally, when I check system('charm') on the matlab command window it finds the correct charm.py file and when I type getenv('PATH') I get the correct system variables which include the path to SimNIBS 4.0.0.. Therefore,I suspect that the issue must lie with brainstorm.

ps. I am also able to start and use SimNIBS regularly on the computer.

Do you have any ideas how this could come about?

Thank you in advance for your time.
Best,
Daneila

I've just recompiled Brainstorm with the latest changes to the support for SimNIBS 4.
Please download this latest update (from today March 1st) and try again.
I'm actively working on this feature these days, so there are lots of last minute changes and possibly many bugs left.

This won't solve your problem, which is due to a wrong detection of the SimNIBS binaries. I developed this on Windows, and my guess is that the binaries do not have exactly the same names, and/or that SimNIBS4 does not create the same links as SimNIBS3.

Can you please execute the following commands in your Matlab command window, and copy-paste the output here?

system('charm --version');
system('charm.py --version');
system('charm.cmd --version');

If 'charm.py' works, can you please try editing the function process_fem_mesh.m, and replace line 728 with:
simCmd = 'charm.py';
Then try starting again the computation.

If nothing returns "4.0.0", can you please tell me what you have in the folder SimNIBS-4.0/bin?

Thank you for helping me debugging this.

Hi francois,

Hi Francoi,

I have downloaded the new version from the 2nd of march.

I receive the following output:

system('charm --version');
Traceback (most recent call last):
  File "/sw/SimNIBS/4.0.0/simnibs_env/lib/python3.9/site-packages/simnibs/cli/charm.py", line 30, in <module>
    from simnibs import __version__
  File "/sw/SimNIBS/4.0.0/simnibs_env/lib/python3.9/site-packages/simnibs/__init__.py", line 21, in <module>
    from .mesh_tools import *
  File "/sw/SimNIBS/4.0.0/simnibs_env/lib/python3.9/site-packages/simnibs/mesh_tools/__init__.py", line 6, in <module>
    from .mesh_io import *
  File "/sw/SimNIBS/4.0.0/simnibs_env/lib/python3.9/site-packages/simnibs/mesh_tools/mesh_io.py", line 49, in <module>
    from . import cgal
  File "/sw/SimNIBS/4.0.0/simnibs_env/lib/python3.9/site-packages/simnibs/mesh_tools/cgal/__init__.py", line 1, in <module>
    from .create_mesh_surf import *
ImportError: /sw/SimNIBS/4.0.0/simnibs_env/lib/python3.9/site-packages/simnibs/mesh_tools/cgal/create_mesh_surf.cpython-39-x86_64-linux-gnu.so: undefined symbol: __gmpq_add

 system('charm.py --version');
/bin/bash: line 1: charm.py: command not found

system('charm.md --version');
/bin/bash: line 1: charm.md: command not found

Unfortunately, charm.py did not work. I am trying to find out whether this issue is related to brainstorm or to python. What do you think?

Best Regards,
Daniela rodriguez M.

system('charm --version');

This indicates that the instructions in Brainstorm are correct, even on Linux: there is a binary file "charm" available in your system path from Matlab.

ImportError: /sw/SimNIBS/4.0.0/simnibs_env/lib/python3.9/site-packages/simnibs/mesh_tools/cgal/create_mesh_surf.cpython-39-x86_64-linux-gnu.so: undefined symbol: __gmpq_ad

This error indicates that the problem comes from your installation of SimNIBS.
Maybe the libraries distributed as part of SimNIBS are not compatible with your system and needs to be recompiled, or you have some dependencies missing on your system.

I'm not competent to help you with this issue, but you can ask the SimNIBS team:

@danielaRM I would recommend using the "headreco" process for now. We have already tested it for the FEM computations.

We need to do some validation tests on the Charm first and solve all these issues.

In the meantime, it will be helpful if you open a ticket in SimNibs Github and report this issue.

Have you tried to run simnibs without Brainstorm?

Dear Takfarinas Medani,
I have been able to run charm through the terminal and use the SimNIBS gui without an issue. Unfortunately, it looks like the issue is with matlab not being able to recognise charm.

ImportError: /sw/SimNIBS/4.0.0/simnibs_env/lib/python3.9/site-packages/simnibs/mesh_tools/cgal/create_mesh_surf.cpython-39-x86_64-linux-gnu.so: undefined symbol: __gmpq_add

I opened a ticket in the SimNIBS mailing list but it seems I have the correct version of gmpq.

I would greatly appreciate if you let me know whether there are updates regarding charm and brianstorm or the FEM computations.

Best Regards,
Daniela Rodriguez

I have been able to run charm through the terminal and use the SimNIBS gui without an issue. Unfortunately, it looks like the issue is with matlab not being able to recognise charm.

I don't know why the "system" command executed from Brainstorm creates a different environment than the terminal from which you start SimNIBS directly. It should be similar...
Make sure there is no difference of enviornment in the terminal from which your start Matlab and the one from which you start Matlab.

In the meantime, you can run SimNIBS manually and import the output in Brainstorm with the menu "Import anatomy folder" (similarly to FreeSurfer, but selecting the file format "SimNIBS").

I would greatly appreciate if you let me know whether there are updates regarding charm and brianstorm or the FEM computations.

If you want to get updates, you can "watch" the GitHub repository (GitHub - brainstorm-tools/brainstorm3: Brainstorm software: MEG, EEG, fNIRS, ECoG, sEEG and electrophysiology) and/or configure your forum account to receive all the post.

Information for others who encounter the same issue in the future:

We were able to solve this issue with the help of Jasper from the SimNIBS Mailing List. You can prepend the path to the libraries included in SimNIBS to LD_LIBRARY_PATH like so:

setenv(‘LD_LIBRARY_PATH’, sprintf(‘/path/to/simnibs/external/lib/linux:%s’, getenv(‘LD_LIBRARY_PATH’)))

Put this in your .m file before you call charm from MATLAB.

Hi all,
When I tried to use simnibs4 with brainstorm3, the following error occurred. Is there any solution? By the way, I completed the software installation according to the official installation process of simnibs4. I'm using this in Macos 14.
error details: SimNIBS 4.X is not installed or not added to the system path: the command "charm" could not be found.

Do you have any ideas how this could come about?

Thank you in advance for your time.
Best,
Jaycob