rsatoolbox.util.searchlight module¶
This code was initially inspired by the following : https://github.com/machow/pysearchlight
@author: Daniel Lindh
- rsatoolbox.util.searchlight.evaluate_models_searchlight(sl_RDM, models, eval_function, method='corr', theta=None, n_jobs=1)[source]¶
evaluates each searchlighth with the given model/models
- Parameters:
sl_RDM ([rsatoolbox.rdm.RDMs]) – RDMs object
rsatoolbox.util.searchlight.get_searchlight_RDMs (as computed by) –
([rsatoolbox.model] (models) – models to evaluate - can also be list of models
eval_function (rsatoolbox.inference evaluation-function) – [description]
method (str, optional) – see rsatoolbox.rdm.compare for specifics. Defaults to ‘corr’.
n_jobs (int, optional) – how many jobs to run. Defaults to 1.
- Returns:
list of with the model evaluation for each searchlight center
- Return type:
list
- rsatoolbox.util.searchlight.get_searchlight_RDMs(data_2d, centers, neighbors, events, method='correlation', verbose=True)[source]¶
Iterates over all the searchlight centers and calculates the RDM
- Parameters:
data_2d (2D numpy array) – brain data,
n_channels (shape n_observations x) –
centers (1D numpy array) – center indices for all searchlights as provided
rsatoolbox.util.searchlight.get_volume_searchlight (as provided by) –
neighbors (list) – list of lists with neighbor voxel indices for all searchlights
rsatoolbox.util.searchlight.get_volume_searchlight –
events (1D numpy array) – 1D array of length n_observations
method (str, optional) – distance metric,
'correlation'. (see rsatoolbox.rdm.calc for options. Defaults to) –
verbose (bool, optional) – Defaults to True.
- Returns:
- RDMs object with the RDM for each searchlight
the RDM.rdm_descriptors[‘voxel_index’] describes the center voxel index each RDM is associated with
- Return type:
RDM [rsatoolbox.rdm.RDMs]
- rsatoolbox.util.searchlight.get_volume_searchlight(mask, radius=2, threshold=1.0)[source]¶
Searches through the non-zero voxels of the mask, selects centers where proportion of sphere voxels >= self.threshold.
- Parameters:
mask ([numpy array]) – binary brain mask
radius (int, optional) – the radius of each searchlight, defined in voxels.
2. (Defaults to) –
threshold (float, optional) – Threshold of the proportion of voxels that need to
be (be inside the brain mask in order for it to) –
center. (considered a good searchlight) –
that (Values go between 0.0 - 1.0 where 1.0 means) –
inside (100% of the voxels need to be) –
mask. (the brain) –
1.0. (Defaults to) –
- Returns:
array of centers of size n_centers x 3
list: list of lists with neighbors - the length of the list will correspond to: n_centers x 3 x n_neighbors
- Return type:
numpy array