# Can searchlight be a cube?

We are running a classification analysis and were wondering about the field cfg.searchlight.spherical. How are the voxels considered to be part of the sphere? Specifically around the edges. Additionally, by making cfg.searchlight.spherical = 0, does the searchlight become a cube?

Thanks for any insights!

Hi Ricardo,

Thatâ€™s a great question! All voxels are included that are less than radius from the searchlight center (not less or equal). This means that there arenâ€™t 6 â€śspikesâ€ť looking out of all searchlights, this choice makes them slightly rounder.

Regarding the spherical part: Data are often acquired with a slice gap or non-isotropic voxels. For example, your data may be collected in 2x2x3mm. Since a voxel just counts as a voxel, a regular searchlight would then be larger along the z-axis, i.e. while it is spherical in voxel space, it would be elongated in world space. To correct for this, you can set cfg.searchlight.spherical = 1. It will then use world space and squeeze searchlights along the elongated dimensions, always using the smallest dimension as a reference.

Other searchlight shapes are currently not supported.

Hope this helps!
Martin

1 Like

Hi Martin,

How can we check the number of voxels included in a searchlight? Our guess is that the field cfg.searchlight.size (res_cfg.mat from the resulting files) contains that value, but we havenâ€™t managed to calculate it ourselves. Specifically, with a radius of 3 (voxel units) we get a cfg.searchlight.size = 93.

And could you provide more details about how the searchlight is squeezed?

Thanks for the insights!

That is correct. You can calculate this yourself (this mimicks the process of creating our searchlight):
`sl_size = 3;`
`[x,y,z] = ndgrid(-sl_size:sl_size); % distances in a grid around a center 0 in coordinates x,y,z, we just pick the minimum size for a given radius, it could also be any larger number really, i.e. this is only for computational reasons`
`sl_mask = (x.^2+y.^2+z.^2) < sl_size^2; % this is squared euclidean distance, in your case SL is size 3`
`disp(sum(sl_mask(:))) % this will provide the number of entries where mask is positive`

`mask = x.^2 + y.^2 + f*z.^2 < sl_size^2;`