skbold.core.mvp module

class Mvp(X=None, y=None, mask=None, mask_thres=0)[source]

Bases: object

Mvp (multiVoxel Pattern) class. Creates an object, specialized for storing fMRI data that will be analyzed using machine learning or RSA-like analyses, that stores both the data (X: an array of samples by features, y: numeric labels corresponding to X’s classes/conditions) and the corresponding meta-data (e.g. nifti header, mask info, etc.).

Parameters:
  • X (ndarray) – A 2D numpy-array with rows indicating samples and columns indicating features.
  • y (list or ndarray) – Array/list with labels/targets corresponding to samples in X.
  • mask (str) – Absolute path to nifti-file that will mask (index) the patterns.
  • mask_thres (int or float) – Minimum value for mask (in cases of probabilistic masks).
Variables:
  • mask_shape (tuple) – Shape of mask that patterns will be indexed with.
  • nifti_header (Nifti1Header object) – Nifti-header from corresponding mask.
  • affine (ndarray) – Affine corresponding to nifti-mask.
  • voxel_idx (ndarray) – Array with integer-indices indicating which voxels are used in the patterns relative to whole-brain space. In other words, it allows to map back the patterns to a whole-brain orientation.
  • X (ndarray) – The actual patterns (2D: samples X features)
  • y (list or ndarray) – Array/list with labels/targets corresponding to samples in X.

Notes

This class is mainly meant to serve as a parent-class for MvpWithin and MvpBetween, but it can alternatively be used as an object to store a ‘custom’ multivariate-pattern set with meta-data.

update_mask(mask, threshold=0)[source]
write(path=None, name='mvp', backend='joblib')[source]

Writes the Mvp-object to disk.

Parameters:
  • path (str) – Absolute path where the file will be written to.
  • name (str) – Name of to-be-written file.
  • backend (str) – Which format will be used to save the files. Default is ‘joblib’, which conveniently saves the Mvp-object as one file. Alternatively, and if the Mvp-object is too large to be save with joblib, a data-header format will be used, in which the data (X) will be saved using Numpy and the meta-data (everythin except X) will be saved using joblib.