Help with the 'spacing' parameter in mne.setup_source_space

MNE version: 0.21.1
OS: Windows 10

Hi all, hope you all have a nice day.
I am a bit confused about the result of mne.setup_source_space.
This is the line of code I used to tes the spacing option for setting up a source space:

src = mne.setup_source_space('fsaverage', spacing = 15, subjects_dir=subjects_dir,  add_dist = True, n_jobs=-1)

This is the result:

 <SourceSpaces: [<surface (lh), n_vertices=163842, n_used=10242>, <surface (rh), n_vertices=163842, n_used=10242>] MRI (surface RAS) coords, subject 'fsaverage', ~33.8 MB>

First off, I may be confused by the number of active vertices in the source space. A spacing of 15 mm seems rather large for a brain roughly the length of 150 mm, so I would expect the number of generators to be in the order of 100, instead of 10,000. Maybe I am misinterpreting the variable. I assumed this would result in a cubic grid with a fixed spacing between each generator and its closes neighbours (I am trying to replicate the formulation of Laplacian operator to test LORETA and compare it to sLORETA).

Second, the distances in the grid seem to be ranging between 0-0.25 (mm?). How does the spacing of 15 mm translate to these values? The documentation on mne.setup_source_space doesn’t define whether the distances are calculated in mm or not.

Thanks!

for a cubic grid you want mne.setup_volume_source_space — MNE 0.23.4 documentation

But something does seem to be wrong with setup_source_space(..., spacing=some_integer). I tried values of 3, 10, 100, 400 and always got 10242 vertices used. Only if I specified 2 mm did I get a different result, of 77381 vertices used (and 2 is the minimum allowed value). Could you open a GitHub issue about this, with a link back to this thread?

Correct, the chosen distance does not seem to have an effect on the outcome. I got the exact same result as you, so this is something that should be looked into. The distances of the vertices in the source space are in meter of course and should be in the order of a mm for the full source space, so 10 mm for example should limit the number of vertices by a pretty large factor.

And thanks for offering a solution for my problem! This method does work for me at this moment, so no further questions.