Giter Site home page Giter Site logo

unexpectedrippling / mne-rsa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wmvanvliet/mne-rsa

0.0 0.0 0.0 3.92 MB

Representational Similarity Analysis on MEG and EEG data

Home Page: https://users.aalto.fi/~vanvlm1/mne-rsa

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

mne-rsa's Introduction

Representational Similarity Analysis

unit_tests build_docs

This is a Python package for performing representational similarity analysis (RSA) using MNE-Python data structures. The RSA is computed using a “searchlight” approach.

Read more on RSA in the paper that introduced the technique:

Nikolaus Kriegeskorte, Marieke Mur and Peter Bandettini (2008). Representational similarity analysis - connecting the branches of systems neuroscience. Frontiers in Systems Neuroscience, 2(4). https://doi.org/10.3389/neuro.06.004.2008

https://raw.githubusercontent.com/wmvanvliet/mne-rsa/master/doc/rsa.png

Installation

Here is how to install the package as a user:

pip install mne-rsa

Use cases

This is what the package can do for you:

  • Compute DSMs on arbitrary data
  • Compute DSMs in a searchlight across:
    • vertices/voxels and samples (source level)
    • sensors and samples (sensor level)
    • vertices/voxels only (source level)
    • sensors only (sensor level)
    • samples only (source and sensor level)
  • Use cross-validated distance metrics when computing DSMs
  • And of course: compute RSA between DSMs

Supported metrics for comparing DSMs:

  • Spearman correlation (the default)
  • Pearson correlation
  • Kendall’s Tau-A
  • Linear regression (when comparing multiple DSMs at once)
  • Partial correlation (when comparing multiple DSMs at once)

Juicy bits of the API

def compute_dsm(model, pca=False, metric='correlation', **kwargs)

def rsa_stcs(stcs, model_dsm, src, y=None,
             spatial_radius=0.04, temporal_radius=0.1,
             stc_dsm_metric='correlation', stc_dsm_params=None,
             rsa_metric='spearman',
             n_jobs=1, verbose=False)

def rsa_evokeds(evokeds, model_dsm, y=None, noise_cov=None,
                spatial_radius=0.04, temporal_radius=0.1,
                evoked_dsm_metric='correlation', evoked_dsm_params=None,
                rsa_metric='spearman',
                n_jobs=1, verbose=False)

def rsa_epochs(epochs, model_dsm, y=None, noise_cov=None,
               spatial_radius=0.04, temporal_radius=0.1,
               epochs_dsm_metric='correlation', epochs_dsm_params=None,
               rsa_metric='spearman',
               n_jobs=1, verbose=False)

def rsa_nifti(image, model_dsm, src, y=None,
              spatial_radius=0.01,
              image_dsm_metric='correlation', image_dsm_params=None,
              rsa_metric='spearman',
              n_jobs=1, verbose=False)

Example usage

Basic example on the EEG “kiloword” data:

import mne
import rsa
data_path = mne.datasets.kiloword.data_path(verbose=True)
epochs = mne.read_epochs(data_path + '/kword_metadata-epo.fif')
# Compute the model DSM using all word properties
dsm_model = rsa.compute_dsm(epochs.metadata.iloc[:, 1:].values)
evoked_rsa = rsa.rsa_epochs(epochs, dsm_model,
                            spatial_radius=0.04, temporal_radius=0.01,
                            verbose=True)

Documentation

For quick guides on how to do specific things, see the examples.

Finally, there is the API reference documentation.

Integration with other packages

I mainly wrote this package to perform RSA analysis on MEG data. Hence, integration functions with MNE-Python are provided. There is also some integration with nipy for fMRI.

Performance

This package aims to be fast and memory efficient. An important design feature is that under the hood, everything operates on generators. The searchlight routines produce a generator of DSMs which are consumed by a generator of RSA values. Parallel processing is also supported, so you can use all of your CPU cores.

Development

Here is how to set up the package as a developer:

git clone [email protected]:wmvanvliet/mne-rsa.git
cd mne-rsa
python setup.py develop --user

mne-rsa's People

Contributors

sappelhoff avatar tshimizu97 avatar wmvanvliet avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.