# Help with the 'spacing' parameter in mne.setup\_source\_space

**URL:** <https://mne.discourse.group/t/help-with-the-spacing-parameter-in-mne-setup-source-space/3867>\
**Category:** Support & Discussions\
**Tags:** ﻿source-localization, eeg\
**Created:** [October 28, 2021, 7:29am UTC](https://mne.discourse.group/t/help-with-the-spacing-parameter-in-mne-setup-source-space/3867 "2021-10-28T07:29:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TijmenWartenberg](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tijmenwartenberg/32/913_2.png) [@TijmenWartenberg](https://mne.discourse.group/u/TijmenWartenberg)\
**Post date:** [October 28, 2021, 7:29am UTC](https://mne.discourse.group/t/help-with-the-spacing-parameter-in-mne-setup-source-space/3867/1 "2021-10-28T07:29:28Z")

</div>

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:

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

```

This is the result:

```python
 <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!

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [October 28, 2021, 3:15pm UTC](https://mne.discourse.group/t/help-with-the-spacing-parameter-in-mne-setup-source-space/3867/2 "2021-10-28T15:15:25Z")

</div>

for a cubic grid you want [mne.setup\_volume\_source\_space — MNE 0.23.4 documentation](https://mne.tools/stable/generated/mne.setup_volume_source_space.html)

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?

---

<div class="post-metadata">

**Author:** ![TijmenWartenberg](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tijmenwartenberg/32/913_2.png) [@TijmenWartenberg](https://mne.discourse.group/u/TijmenWartenberg)\
**Post date:** [October 29, 2021, 7:38am UTC](https://mne.discourse.group/t/help-with-the-spacing-parameter-in-mne-setup-source-space/3867/3 "2021-10-29T07:38:02Z")

</div>

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.
