# brainiak.searchlight package¶

Distributed Searchlight

## brainiak.searchlight.searchlight module¶

class brainiak.searchlight.searchlight.Searchlight(sl_rad=1, max_blk_edge=10, shape=<class ‘brainiak.searchlight.searchlight.Cube’>)

Bases: object

Distributed Searchlight

Run a user-defined function over each voxel in a multi-subject dataset.

Optionally, users can define a block function which runs over larger portions of the volume called blocks.

broadcast(bcast_var)

Distribute data to processes

Parameters: bcast_var (shared data which is broadcast to all processes) –
distribute(subjects, mask)

Distribute data to MPI ranks

Parameters: subjects (list of 4D arrays containing data for one or more subjects.) – Each entry of the list must be present on at most one rank, and the other ranks contain a “None” at this list location. For example, for 3 ranks you may lay out the data in the following manner: Rank 0: [Subj0, None, None] Rank 1: [None, Subj1, None] Rank 2: [None, None, Subj2] Or alternatively, you may lay out the data in this manner: Rank 0: [Subj0, Subj1, Subj2] Rank 1: [None, None, None] Rank 2: [None, None, None] mask (3D array with “True” entries at active vertices) –
run_block_function(block_fn, extra_block_fn_params=None)

Perform a function for each block in a volume.

Parameters: block_fn – Parameters data: list of 4D arrays containing subset of subject data, which is padded with sl_rad voxels. mask: 3D array containing subset of mask data sl_rad: radius, in voxels, of the sphere inscribed in the cube bcast_var: shared data which is broadcast to all processes extra_params: extra parameters
extra_block_fn_params: tuple
Extra parameters to pass to the block function
run_searchlight(voxel_fn, pool_size=None)

Perform a function at each voxel which is set to True in the user-provided mask. The mask passed to the searchlight function will be further masked by the user-provided searchlight shape.

Parameters: voxel_fn – Must be serializeable using pickle. Parameterssubj: list of 4D arrays containing subset of subject data mask: 3D array containing subset of mask data sl_rad: radius, in voxels, of the sphere inscribed in the cube bcast_var: shared data which is broadcast to all processes
pool_size: Number of parallel processes in shared memory
process pool
Returns: A volume which is the same size as the mask, however a number of voxels equal to the searchlight radius has been removed from each border of the volume. This volume contains the values returned from the searchlight function at each voxel which was set to True in the mask, and None elsewhere.