# [FieldTrip] Neighborhood of voxels in the volume source space

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Mon Mar 22 17:58:58 CET 2021

```Hi Lin,

Not exactly. Apologies that I was not clear enough. What I meant with  'the neighbourhood is implicit in their order’ is the following:

if you take the spatial dimension of your data - including the outsiders - and you would reshape it into the 3D volume, by doing something like reshape(datavector, source.dim); then for a given dipole indexed with the triplet of volumetric indices (ix,iy,iz) has its neighbours at (ix+1,iy,iz), (ix, iy+1, iz), (ix, iy, iz+1) etc.

Now, if you want to manually define for each of the dipole positions their (6 18 or 26? neighbours, depending on whether you include only the center faces, the edges or the corners of the 3x3x3 cube) you probably would want to loop through the three dimensions and identify for each of the dipoles which are the indices of their direct neighbours. To this end, you could start with creating a ‘dummy’ variable that contains the dipole indices in a volume, i.e. reshape(1:5780, [17 20 17]), and then loop through all positions in the volume to identify the neighbours

neighbours = cell([17 20 17]);
for i = 2:16
for j = 2:19
for k =2:16

tmp = dummy(i+[-1:1], j+[-1:1],k+[-1:1]); % this needs to be adjusted according to which part of the cube you desire in your searchlight
neighbours{i,j,k} = tmp(:);

end
end
end

On a side note, I would think that doing a spatial searchlight on source reconstructed MEG data is a little bit of an overkill, unless you have reason to suspect that you have some local very high spatial resolution. As an alternative, you could consider chunking your data into parcels -e.g. based on a(n) (refined) anatomical atlas- and use those parcels as your spatial searchlight.

Best wishes,
Jan-Mathijs

On 22 Mar 2021, at 17:19, Lin Wang <wanglinsisi at gmail.com<mailto:wanglinsisi at gmail.com>> wrote:

Hi Jan-Mathijs,

Thank you very much for your response.

I defined the dipole positions with a regular 3D grid, with a dimension of 17*20*17 (following https://www.fieldtriptoolbox.org/tutorial/sourcemodel/). This gives me 5780 grid points in total, with 2982 grid points inside of the brain.

You mentioned that 'the neighbourhood is implicit in their order', so can I do the following for the searchlight type of analysis:
(1) select only the activation of the 2982 grid points
(2) conduct analysis to every 10 grid points that are next to each other
(3) loop through all the 2982 grid points

Thank you again for your input!
Lin

On Fri, 19 Mar 2021 at 03:57, Schoffelen, J.M. (Jan Mathijs) <jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>> wrote:
Hi Lin,

The answer to your question depends on the topology of the source space.
If the dipole positions are defined on a regular 3D grid, the neighbourhood is implicit in their order.
If the dipole positions are defined on a cortical mesh (that includes a triangulation), the neighbourhood can be determined from the triangulation.

Best wishes,
Jan-Mathijs

On 18 Mar 2021, at 01:59, Lin Wang <wanglinsisi at gmail.com<mailto:wanglinsisi at gmail.com>> wrote:

Hi field excerpts,

I'd like to implement a searchlight type of multivariate analysis in the MEG source localized data, but I don’t know where to find the information about neighboring voxels for each voxel.

I guess this is also relevant to the definition of the neighborhood when conducting cluster-based permutation tests in the source space.

Could anyone help me?

Thank you very much!
Lin
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210322/78d074ac/attachment.htm>
```