How to generate finite element meshes for MRI and export as .stl?

As mentioned above, I hope to generate the corresponding finite element mesh model for MRI patients using brainstorm and further export the.mat file as the.stl file for finite element simulation in other software. Could you all provide relevant guidance? I'm extremely grateful for this!

If you use the SimNIBS pipeline for FEM model creation, the m2m folder will contain the .stl files you are looking for.

1 Like

Hi @YichenZeng

If you are looking for the surface [list of vertices and faces], the solution proposed by @SBeumer is a good option.
If you do not have access to the m2m files [which are temporary files], you can export the surfaces from the brainstorm interface by right-clicking on the surface => file => export as … and you select from the list

However, if you want the FEM mesh, ie, a list of elements and nodes, you can only export it to Matlab and then save it in the format you want to use. Currently, Brainstorm does not support exporting the FEM mesh into a specific file format.

Thank you for your suggestions. During the implementation process, however, I encountered certain technical difficulties. Specifically, errors occurred when generating the FEM for MRI using SimNIBS 4, which said “[ simnibs ] CRITICAL: Uncaught exception
subprocess.CalledProcessError: Command '['E:\simnibs\simnibs_env\python.exe', status = 1” and “Error: SimNIBS call: charm --forceqform --forcerun Subject01 C:\Users\user.brainstorm\tmp\charm_251014_103501\Subject01T1.nii”. In contrast, when employing ROAST, the corresponding FEM was successfully generated. Nevertheless, a limitation of ROAST is the lack of flexibility in adjusting mesh parameters, resulting in a relatively coarse mesh resolution. I would therefore like to inquire whether there are any recommended approaches to resolve the mesh generation errors in SimNIBS 4. Your guidance on this matter would be greatly appreciated.

Roast and Simnibs are two different methods that use different approaches to generate the FEM mesh. The recommended option is SimNibs for better model.

From the error you shared, we can not see what the issue is.

You can try using one of the previous versions, such as Headreco from SimNibs 3. Check here their previous releases: Releases · simnibs/simnibs · GitHub

Additionally, you can post your issue on their GitHub page to receive better support related to Charm and Headreco processes.