mvpa2.datasets.cosmo.CosmoQueryEngine

Inheritance diagram of CosmoQueryEngine

class mvpa2.datasets.cosmo.CosmoQueryEngine(mapping, a=None, fa=None)

queryengine for neighborhoods defined in CoSMoMVPA. This class behaves like a normal QueryEngine, and its use is intended with a searchlight. It differs in that it contains the dataset (.a) and feature (.fa) attributes for the output of a searchlight. This is implemented by the method set_output_dataset_attributes. Although the standard Searchlight can be used with this function, using CosmoSearchlight automatically calls this method so that the dataset attributes for the output are properly set.

Methods

from_mat(neighbors[, a, fa, origin]) Create CosmoQueryEngine from mat struct
query(**kwargs)
query_byid(id) Returns
set_output_dataset_attributes(ds) Set attributes to output dataset (e.g.
train(dataset) This method does nothing
untrain() This method does nothing
Parameters:

mapping: dict :

mapping from center ids (int) to array of feature ids (numpy array of datatype int)

a: None or dict or ArrayCollectable :

dataset attributes to be used for the output of a Searchlight

fa: None or dict or ArrayCollectable :

dataset attributes to be used for the output of a Searchlight

Methods

from_mat(neighbors[, a, fa, origin]) Create CosmoQueryEngine from mat struct
query(**kwargs)
query_byid(id) Returns
set_output_dataset_attributes(ds) Set attributes to output dataset (e.g.
train(dataset) This method does nothing
untrain() This method does nothing
a
Returns:

a : DatasetAttributesCollection

Dataset attributes for the output dataset from using this instance

fa
Returns:

fa : FeatureAttributesCollection

Feature attributes for the output dataset from using this instance. It has as many elements as self.ids

classmethod from_mat(neighbors, a=None, fa=None, origin=None)

Create CosmoQueryEngine from mat struct

Parameters:

neighbors: numpy.object :

Object from scipy’s matload; must have been a Px1 cell with in each cell a vector with indices of neighboring features in base 1. Typically this is from a CoSMoMVPA neighborhood struct.

a: None or dict or ArrayCollectable :

dataset attributes to be used for the output of a Searchlight

fa: None or dict or ArrayCollectable :

dataset attributes to be used for the output of a Searchlight

origin: :

Optional contents of .a and .fa of dataset indexed by neighbors; its content is ignored

Notes

Empty elements are ignored. Future implementations may store the origin element, and check that its contents agrees with a dataset when this instances trains on it.

ids
Returns:

keys: npndarray :

vector with feature indices that can be used as keys

query(**kwargs)
query_byid(id)
fids : np.ndarray
vector with feature indices of neighbors of the feature indexed by id
set_output_dataset_attributes(ds)

Set attributes to output dataset (e.g. after running a searchlight)

Parameters:

ds : Dataset

dataset with ds.fa.center_ids containing the center id of each feature

Returns :

ds_copy : Dataset

copy of ds, but with feature (.fa) and dataset (.a) attributes provided to the contstructor of this instance. The .fa and .a from the input ds are removed first.

train(dataset)

This method does nothing

untrain()

This method does nothing