Skip to content

Searchlight spheres exclude edge voxels (< instead of <=) #450

Description

@alexeperon

Hi all,

In the function _get_searchlight_neighbors , in searchlight.py, edge voxels are excluded from spheres by using exclusive less than. This means that for small spheres, fewer voxels are selected than you might intuitively expect. For a mask with a radius of 1, for example, only the centre voxel is included. For a radius of 2, this means choosing 27 instead of 33.

This might not be a big practical issue, but seems somewhat unintuitive.

To solve, I suggest changing these lines

x = x[abs(x - cx) < radius]
y = y[abs(y - cy) < radius]
z = z[abs(z - cz) < radius]

return tuple(data[distance <radius].T.tolist())

To the following:

x = x[abs(x - cx) <= radius]
y = y[abs(y - cy) <= radius]
z = z[abs(z - cz) <= radius]

return tuple(data[distance <=radius].T.tolist())

best wishes,
Alex

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions