Missing dune-subgrid for geometry-adapted hexahedral mesh

Hi Brainstorm community,

I am trying to use a 'geometry-adapted' hexahedral mesh with duneuro via brainstorm, however, I am getting the following error:

BST> Checking latest online version for duneuro...
BST> Plugin duneuro already loaded: C:\Users\andyh\.brainstorm\plugins\duneuro
DUNEURO> Detected parameter: GeometryAdapted=true
DUNEURO> Writing temporary files to: C:\Users\andyh\.brainstorm\tmp\duneuro_241104_142907
DUNEURO> System call: "C:\Users\andyh\.brainstorm\plugins\duneuro\bst_duneuro\bin\bst_duneuro_meeg_win64.exe" "C:\Users\andyh\.brainstorm\tmp\duneuro_241104_142907\duneuro_minifile.mini"
Dune reported error: Dune::Exception [make_meeg_driver:/home/juan/bst-duneuro/src/duneuro/duneuro/meeg/meeg_driver_factory_impl.hh:203]: geometry adaption needs dune-subgrid 

status =

    -1


***************************************************************************
** Error: Error during the DUNEuro computation, see logs in the command window.
***************************************************************************

Extra information:

  • Brainstorm version: 08-Oct-2024
  • MATLAB R2024b
  • Windows 10
  • x64-based processor

I found the following link about a similar issue on Github, but there has not been any updates since 2020 (Error: geometry adaption needs dune-subgrid? · Issue #3 · brainstorm-tools/bst-duneuro · GitHub)

Is there a way to implement this? or could someone please point me to a workflow that could use geometry-adapted hexahedral mesh?

Any help or guidance is greatly appreciated.

Thank you and kind regards,

Andy

@tmedani, can you take a look to this?

2 Likes

Hi @andy97

I'll look at this and check if we can recompile the source code with the missing libraries. However, this may take a little time since all the dependencies may need to be checked before running the cross-compilation for Windows.

Any help or guidance is greatly appreciated.

The faster solution is to use the Duneuro source code; you can find all the code and documentationentation here:

1 Like

Hi @tmedani

I was able to compile and run duneuro from source and solve the forward model. Is there a way to import duneuro's output back into brainstorm so I can continue my analysis (e.g. solve inverse problem)? Are there any functions that were created to get the duneuro output to work with brainstorm.

Thank you again for helping.

1 Like

Hi @andy97

I was able to compile and run duneuro from source and solve the forward model.

It is great to hear that you could run the duneuro from the source code. Were you able to integrate the dune-subgrid module? It will also be great to share here the steps you follow to solve the issue so that interested users can benefit from it.

Is there a way to import duneuro's output back into brainstorm so I can continue my analysis (e.g. solve inverse problem)?

Yes, you can, but there is no dedicated function to do it in Brainstorm right now.
All depends on the format of the LF that you have obtained, is it in Matlab? Python? txt/binary file?

You mainly need to read the Gain matrix [leadfieldfield matrix], which has Nchannel x 3*Nsource, and then import it to Brainstorm.

You need to make sure that all the links to the surface file and channel files are set correctly in the HeadModel file.

A fast solution is to compute a mock head model (not adapted geometry) using the same FEM model (tetra), same source model (cortex), and same channel file, and then export it to Matlab, replace the Gain matrix with the one you computed from Duneuro and then import it back to Brainstorm.
Here is the format of the headmodel that you need to change:
https://neuroimage.usc.edu/brainstorm/Tutorials/HeadModel#On_the_hard_drive

1 Like

Sure - I will give an update (or make a new thread?) once I've got everything working.

That sounds like a good idea - I'll give that a try! Thank you.

Hi @tmedani,

I've found after running duneuro from source, that I get the same error (missing dune-subgrid) as in bst's duneuro plugin. This only occurs when I have the parameter "geometry_adapted = True" set in the config when defining the MEEGDriver3d. I tried to find documentation for this parameter from duneuro wiki but there is no information on it. The section that explains how to create a driver (Create a driver · Wiki · duneuro / duneuro · GitLab) does not mention of this parameter. Everything works when I do not include this parameter when defining the driver.

My question is if this parameter is required when running bst's duneuro? If this parameter is removed from the 'duneuro_minifile.mini' file that is created and used to run duneuro from bst, then it should fix the issue mentioned in this thread.

duneuro_minifile.mini:

type = fitted
element_type = hexahedron
solver_type = cg
geometry_adapted = True # Remove this?
tolerance = 1.000000e-08
[electrodes]
...

Thanks

Hi @tmedani,

I am now getting a new error:

RuntimeError: Dune::Exception [findEntityImpl:/home/andy/Dune/duneuro/duneuro/common/edgehopping.hh:84]: coordinate is outside of the grid, or grid is not convex

I have checked that all the dipoles from the source grid is inside the grey matter (of the mesh). I am solving this in duneuro (standalone) by looping through each dipole within the source grid and solving using solveEEGForward(). This error only pops up at a certain dipole point. I checked the dipole that it stops at and found that it typically occurs when the dipole is located at the boundary of the grey matter (interface between grey matter and csf).

I have also tried this using bst-duneuro plugin and the same error occurs.

EDIT:
I just found your comment on the following thread (DUNEuro head model computation fails - #13 by berkiadam):

Could this be the problem causing the error message? Are there any workarounds for this?

Thanks

HI @andy97

Sorry for the late response; I missed this last message.

Have you checked visually the position of your source space with regards to the FEM mesh?

Have you checked the box "Force inside the GM" when running the FEM?

Can you share a view of the FEM mesh and the source space, you can play with the surface tab and change the color of the source space (cortex) once displayed together with the FEM mesh.