question about forward solution

Hi, I have a question regarding the computation of the forward solution. I donā€™t understand whether it is necessary to set the ā€œmindistā€ parameter when using the functions ā€œmne.setup_volume_source_spaceā€ and ā€œmne.make_forward_solutionā€. If it is necessary, could you please explain why we need to exclude points closer than a certain distance (in mm) to the bounding surface?
Thanks a lot!

Can someone help answer this question? I am a novice and I do not understand the setup of this parameter. I would be very grateful for any help.

Hi @TTingW,

According to the functionā€™s doc-string:
mindist float: Minimum distance of sources from inner skull surface (in mm).

If you set a mindist parameter, Forward computation can remove vertices/dipoles that are too close to (or outside) the inner skull surface. Lets say, if you compute a forward solution with a mindist = 5.0 mm, all the potential vertices/dipole candidates will be excluded from the forward solution that are located within 5.0-mm distance limit.

In general, you can set a mindist parameter as 5.0 mm or 3.0 mm during the forward computation. Both parameters should work. For many functions, such as mne.compute_source_morph(), it is important to pass fwd['src'] or inv['src'] so that vertices removal is adequately accounted for.

You can have a look at this example for more details:
https://mne.tools/stable/auto_tutorials/forward/30_forward.html#sphx-glr-auto-tutorials-forward-30-forward-py

best,
Dip

I believe @TTingW would like to know why one should use mindist in the first place :thinking:

@richard Thanks for pointing it out. I have missed it. To my knowledge, mindist parameter mainly ensures that one should not compute the leadfield matrix i.e., forward operator for the dipoles that are not placed inside the brain. This can happen during setting up a source space i.e., Surface decimation problem. I think this can happen in volume source space setup since a grid of candidate dipoles inside a sphere model is not always perfect. But to be honest, till now I have never faced such a problem in a data set. Perhaps @larsoner can correct me and shed some light on the topic.

best,

2 Likes

Thank you for your response! @dasdiptyajit @richard

I asked about the ā€˜mindistā€™ parameter in ā€˜mne.setup_volume_source_spaceā€™ and ā€˜mne.make_forward_solutionā€™ , because I encountered some problems when calculating the volume source space in my experiment.
After running ā€˜recon-allā€™, the results folder did not contain a ā€˜bemā€™ subfolder. So, I used the function ā€˜mne.bem.make_watershed_bemā€™ to generate it. This folder now contains the following contents:

Screenshot from 2023-04-13 14-15-13ā€”ā€”fold

Next, I computed a mixed source space (surface source space + volume source space):

When I plotted the mixed source space, I noticed that some sources were outside the brain. (When generating the volume source space, I set the ā€˜mindistā€™ parameter to 5.)

Then I changed the mindist=10, I got a better results.

I donā€™t know if thatā€™s a reasonable approach. I also tried another approach.

I suspected that I may have obtained a poor skull strip when using ā€˜recon-allā€™. So, I used the ā€˜ mri_watershedā€™ function from FreeSurfer to generate a smaller bounding surface. The yellow box represents the inner skull before it shrinks inward, while the red box represents the inner skull after inward contraction.

mri_watershed -surf bem/inward_5mm -shk_br_surf 5 bem/inward_5mm -atlas mri/aparc+aseg.mgz mri/T1.mgz bem/T1_inward_5mm.mgz 

Next, I used the new ā€˜inner_skull.surfā€™ to compute the BEM and mixed source space. I found that there were fewer sources outside the brain than before when I set the ā€˜mindistā€™ parameter to 5 in ā€˜mne.setup_volume_source_spaceā€™. However, even when I set ā€˜mindistā€™ to 0, there were still some sources outside the brain.

mindist=5

mindist=0

Then, I ran the code from the tutorial and found that the example data set the ā€˜mindistā€™ parameter to 5 in ā€˜mne.setup_volume_source_spaceā€™ and obtained good results. However, when I changed the ā€˜mindistā€™ value from 5 to 0, there were still some sources outside the brain.
mindist=5

mindist=0

Does this mean that I can simply adjust the value of the ā€˜mindistā€™ parameter to obtain a better volume source space? Would setting the ā€˜mindistā€™ parameter to 10 be beyond reasonable bounds?

All the best!

@TTingW Thanks for sharing. I have couple of things to ask.

  1. From the code, I can see that you have created surface and volume source space separately. But you didnā€™t merge them. If you donā€™t merge them then you canā€™t create a mixed source space (surface+vol). I assume that you have done it properly since I donā€™t see that in the code.

This is an example to follow:
https://mne.tools/stable/auto_examples/inverse/mixed_source_space_inverse.html#sphx-glr-auto-examples-inverse-mixed-source-space-inverse-py

  1. You are plotting the volume source space in a cortical surface. You have to consider that many volume labels are not part of the cortical structure but rather comes under sub-cortical. For example: volume labels like Brain-Stem, Amygdala, Thalamus-Proper, Cerebellum-Cortex and so on, one should expect the dipoles should be outside of the cortical surface. All the dipoles underneath the visual cortex (outside the cortex in your figure) are mainly part of volume source space.

  2. I doubt that it can be an alignment issue during plotting. Can you share the whole script including plotting arguments so that we can help to debug the problem?

best,
Dip

@dasdiptyajit Thank you for your response !
Sorry, I donā€™t understand what you mean by merging surface and volume source space. In the example you mentioned, they also create surface and volume source space separately. Then they create a mixed source space (surface + volume). Here is my codeļ¼š


import os.path as op
import mne

# the raw file containing the channel location + types
data_path = '/data/meg/MUON/results/'+subjid[subject_num]
meg_path = data_path + '/meg'+'/'+submegfoldname[subject_num]+'/'+submegfolddate[subject_num]
mri_path='/data/meg/MUON/results/mri/'
trans_fname=meg_path+'/run01_raw_trans_ref_tsss-trans.fif'
fname_raw = meg_path + '/run01_raw_trans_ref_tsss.fif'

# The paths to Freesurfer reconstructions
subjects_dir = mri_path
subject = 'MUON_pilot01'

conductivity = (0.3,)  # for single layer
#conductivity = (0.3, 0.006, 0.3)  # for three layers:EEG
model = mne.make_bem_model(subject=subject, ico=4, conductivity=conductivity, subjects_dir=mri_path)
bem = mne.make_bem_solution(model)

# surface-based source space
src = mne.setup_source_space(subject, spacing='oct6', subjects_dir=subjects_dir,n_jobs=128) 
print(src)

mne.viz.plot_bem(src=src, **plot_bem_kwargs)

# volumetric  source space
#The aparc+aseg.mgz file shows the parcellated cortical ribbon at the same time as the segmented subcortical structures. 
#The "colormap=lut" tells freeview to display the aparc+aseg.mgz file with colors according to the look up table. 
#The aparc+aseg.mgz uses the Desikan-Killiany atlas. To see the Destrieux atlas, you would load fsaverage/mri/aparc.a2009s+aseg.mgz 
mri=subjects_dir+subject+'/mri/aseg.mgz'
vol_src = mne.setup_volume_source_space(
    subject, subjects_dir=subjects_dir, mri=mri,surface=None,pos=5.0, sphere=None, bem=bem, mindist=0, exclude=0.0, volume_label=None, verbose=None,
    add_interpolator=True) 
print(vol_src)

mne.viz.plot_bem(src=vol_src, **plot_bem_kwargs)

## mixed source space
mixed_src = src+vol_src

fig = mne.viz.plot_alignment(subject=subject, subjects_dir=subjects_dir,
                             surfaces='white', coord_frame='mri',
                             src=mixed_src)
mne.viz.set_3d_view(fig, azimuth=173.78, elevation=101.75,
                    distance=0.30, focalpoint=(-0.03, -0.01, 0.03))

In the picture I provided in my previous response, I mentioned that there were some sources outside the brain. I meant that sources appeared in areas where there was no brain tissue, as marked by my red brush. However, the area marked with my blue brush is the brain stem. Although it is outside the cortical surface, I believe this is normal. My question concerns the areas where there shouldnā€™t be any sources, but sources are present.


Thank you for helping me debug the problem !

All the best !

thanks for the code. I see what you actually meant now! I will have a look soon. Meanwhile, can you share a screenshot of the following code output?

surface-based source space

src = mne.setup_source_space(subject, spacing=ā€˜oct6ā€™, subjects_dir=subjects_dir,n_jobs=128)
print(src)

mne.viz.plot_bem(src=src, **plot_bem_kwargs) # screenshot of this one.

Do you see the similar issue if you setup a surface based source space? or is it mainly when you create a mixed source space?

best,

Thank you for your response. Here are the pictures:
mne.viz.plot_bem(src=src, **plot_bem_kwargs)


mne.viz.plot_bem(src=vol_src, **plot_bem_kwargs)

All the best !

My bad. Its difficult to see the source alignment within the bem surfaces. I wanted to see the outputs of the following.

fig = mne.viz.plot_alignment(subject=subject, subjects_dir=subjects_dir,
                             surfaces='white', coord_frame='mri',
                             src=surface_src)   # surface src
mne.viz.set_3d_view(fig, azimuth=173.78, elevation=101.75,
                    distance=0.30, focalpoint=(-0.03, -0.01, 0.03))
fig = mne.viz.plot_alignment(subject=subject, subjects_dir=subjects_dir,
                             surfaces='white', coord_frame='mri',
                             src=volume_src)   # volume src
mne.viz.set_3d_view(fig, azimuth=173.78, elevation=101.75,
                    distance=0.30, focalpoint=(-0.03, -0.01, 0.03))

fig = mne.viz.plot_alignment(subject=subject, subjects_dir=subjects_dir,
                             surfaces='white', coord_frame='mri',
                             src=mixed_src)   # mixed src
mne.viz.set_3d_view(fig, azimuth=173.78, elevation=101.75,
                    distance=0.30, focalpoint=(-0.03, -0.01, 0.03))

best,

No problem ! Here are the pictures:
surface src:


volume src (mindist=5):

mixed src (mindist=5):

volume src (mindist=10):

mixed src (mindist=10):

Does this mean that I can simply adjust the value of the ā€˜mindistā€™ parameter to obtain a better volume source space? Would setting the ā€˜mindistā€™ parameter to 10 be beyond reasonable bounds?

All the best !

@TTingW many thanks for sharing the screenshots.

Your surface based source space looks correct but you have an issue with volume source space. The alignment of the dipoles is rather far from the actual surface, something that you have already mentioned before. Do you see this phenomenon for all subjects or only for this particular subject? I am wondering if there is something went wrong during constructing bem surfaces, (I am not sure about generating a smaller bounding surface) I tried to look at some of my subjects but I canā€™t replicate the issue.

Coming back to your suggestion of adapting the ā€˜mindistā€™ parameter to 10, yes! this can be a workaround. The alignment looks definitely better compared to ā€˜mindistā€™ = 5 mm. The only potential concern is the no. dipoles that you are dropping while changing the ā€˜mindistā€™ parameter. Your can print vol_src and check n_used (no. of dipoles) after creating the volume source space. I would be cautious if the no. of dipoles differ a lot between mindist: 5 to 10.

I would rather go with your suggestion and try to reconstruct/localize the source with a mixed sources (mindist=10) and check if the results of the stc data make sense or not.
Feel free to share the results. We all can benefit from your interpretation. Meanwhile, lets wait for other authors to follow up.

best,
Dip

Keep in mind that youā€™re plotting the white surface when plotting the surface source space (correctly, because thatā€™s where itā€™s defined). But the white surface is inside the pial surface on the gray/white matter boundary. A volumetric source space will span from the pial surface inward even with a perfectly defined brain boundary.

More problematic I think is your current definition of the mixed source space. If you want a mixed source space, you shouldnā€™t use a whole brain volumetric source space. You should make the volumetric part span a set of sub-volumes that do not include cortex. Otherwise the volumetric parts and surface parts overlap, and there isnā€™t any point in having the surface parts. See for example how we do it in Compute MNE inverse solution on evoked data with a mixed source space ā€” MNE 1.3.1 documentation

2 Likes

@larsoner thanks for pointing it out, especially the later problematic part. I completely missed it to mention before. One should mainly consider to add a sub-section of volumetric labels in addition to cortical labels to create a mixed-source space.

Thank you for your responseļ¼ @dasdiptyajit @larsoner
I know what my next steps are. I gained a lot of knowledge from this question.

All the best !