Issue when computing the gain matrix (head model)

Hi all,

I hope you're doing well.

I'm trying to compute a head model using DUNEuro within Brainstorm and then export it to Matlab to run it with some in-house scripts. I have a subject with 104 channels distributed in sEEG and ECoG arrays. I generated the FEM mesh with SimNIBS4 obtaining a segmentation of 12 layers. For the head model, I've tried using the inner layers from the segmentation (white, gray, CSF, blood, and muscle) or merging them for a 5-layer model and using only the inner ones (white, gray, and CSF). However, after computing my head model using DUNEuro in both scenarios, my gain matrix displays one-row entire of zeros. I've run it multiple times, and although the channel associated with the empty row changes, it is always the first contact of an sEEG shaft.

I've read on this forum (Something strange about the DUNEuro FEM head model Gain Matrix) that it's because of how the gain matrix is designed, assigning always the first channel as the reference. And here (How can I manually set a reference electrode from the Brainstorm interface? - #2 by Francois) they emphasize that if the gain matrix is going to be used outside Brainstorm a re-reference should be done. However I have a couple of questions:

  1. In the head models that I've computed, the row full of zeros is not always the first, it could be another one. Is this expected? The assigned reference for the head model is random or should be always be the first channel?

  2. I only have anatomical and channel data loaded intro Brainstorm to compute the FEM mesh and the head model. With this data, how can I re-reference my channels in order to obtain a complete gain matrix that I can use when exported to Matlab?

I appreciate any help you can provide. Thanks!

Valentina