skbold.postproc.mvp_results module

class MvpAverageResults(out_dir, type='classification')[source]

Bases: object

Averages results from MVPA analyses on, for example, different subjects or different ROIs.

Parameters:out_dir (str) – Absolute path to directory where the results will be saved.
compute(mvp_list, identifiers, metric='f1', h0=0.5)[source]
write(path, name='average_results')[source]
class MvpResults(mvp, n_iter, out_path=None, feature_scoring='', verbose=False)[source]

Bases: object

Class to keep track of model evaluation metrics and feature scores. See the ReadTheDocs homepage for more information on its API and use.

Parameters:
  • mvp (mvp-object) – Necessary to extract some metadata from.
  • n_iter (int) – Number of folds that will be kept track of.
  • out_path (str) – Path to save results to.
  • feature_scoring (str) – Which method to use to calculate feature-scores with. Can be: 1) ‘fwm’: feature weight mapping [1] - keep track of raw voxel-weights (coefficients) 2) ‘forward’: transform raw voxel-weights to corresponding forward- model [2].
  • verbose (bool) – Whether to print extra output.

References

[1]Stelzer, J., Buschmann, T., Lohmann, G., Margulies, D.S., Trampel, R., and Turner, R. (2014). Prioritizing spatial accuracy in high-resolution fMRI data using multivariate feature weight mapping. Front. Neurosci., http://dx.doi.org/10.3389/fnins.2014.00066.
[2]Haufe, S., Meineck, F., Gorger, K., Dahne, S., Haynes, J-D., Blankertz, B., and Biessmann, F. et al. (2014). On the interpretation of weight vectors of linear models in multivariate neuroimaging. Neuroimage, 87, 96-110.
load_model(path, param=None)[source]

Load model or pipeline from disk.

Parameters:
  • path (str) – Absolute path to model.
  • param (str) – Which, if any, specific param needs to be loaded.
save_model(model)[source]

Method to serialize model(s) to disk.

Parameters:model (pipeline or scikit-learn object.) – Model to be saved.
write(feature_viz=True, confmat=True, to_tstat=True, multiclass='ovr')[source]

Writes results to disk.

Parameters:to_tstat (bool) – Whether to convert averaged coefficients to t-tstats (by dividing them by sqrt(coefs.std(axis=0)).
class MvpResultsClassification(mvp, n_iter, feature_scoring='fwm', verbose=False, out_path=None)[source]

Bases: skbold.postproc.mvp_results.MvpResults

MvpResults class specifically for classification analyses.

Parameters:
  • mvp (mvp-object) – Necessary to extract some metadata from.
  • n_iter (int) – Number of folds that will be kept track of.
  • out_path (str) – Path to save results to.
  • feature_scoring (str) – Which method to use to calculate feature-scores with. Can be: 1) ‘coef’: keep track of raw voxel-weights (coefficients) 2) ‘forward’: transform raw voxel-weights to corresponding forward- model (see Haufe et al. (2014). On the interpretation of weight vectors of linear models in multivariate neuroimaging. Neuroimage, 87, 96-110.)
  • verbose (bool) – Whether to print extra output.
compute_scores()[source]

Computes scores across folds.

update(test_idx, y_pred, pipeline=None)[source]

Updates with information from current fold.

Parameters:
  • test_idx (ndarray) – Indices of current test-trials.
  • y_pred (ndarray) – Predictions of current test-trials.
  • values (ndarray) – Values of features for model in the current fold. This can be the entire pipeline (in this case, it is extracted automaticlly). When a pipeline is passed, the idx-parameter does not have to be passed.
  • idx (ndarray) – Index mapping the ‘values’ back to whole-brain space.
class MvpResultsRegression(mvp, n_iter, feature_scoring='', verbose=False, out_path=None)[source]

Bases: skbold.postproc.mvp_results.MvpResults

MvpResults class specifically for Regression analyses.

Parameters:
  • mvp (mvp-object) – Necessary to extract some metadata from.
  • n_iter (int) – Number of folds that will be kept track of.
  • out_path (str) – Path to save results to.
  • feature_scoring (str) – Which method to use to calculate feature-scores with. Can be: 1) ‘coef’: keep track of raw voxel-weights (coefficients) 2) ‘forward’: transform raw voxel-weights to corresponding forward- model (see Haufe et al. (2014). On the interpretation of weight vectors of linear models in multivariate neuroimaging. Neuroimage, 87, 96-110.)
  • verbose (bool) – Whether to print extra output.

:param .. warning:: Has not been tested with MvpWithin!:

compute_scores()[source]

Computes scores across folds.

update(test_idx, y_pred, pipeline=None)[source]

Updates with information from current fold.

Parameters:
  • test_idx (ndarray) – Indices of current test-trials.
  • y_pred (ndarray) – Predictions of current test-trials.
  • pipeline (scikit-learn Pipeline object) – pipeline from which relevant scores/coefficients will be extracted.