Skip to content

Instantly share code, notes, and snippets.

@wmvanvliet
Last active April 23, 2020 05:59
Show Gist options
  • Save wmvanvliet/84443d47c45a0cdb061491c1901ca9c0 to your computer and use it in GitHub Desktop.
Save wmvanvliet/84443d47c45a0cdb061491c1901ca9c0 to your computer and use it in GitHub Desktop.
import mne
import numpy as np
import mne_rsa
dsms_file = np.load('pilot2_dsms.npz')
meg_dsms = dsms_file['dsms']
model_dsms = ... # Up to you to create
# RSA: compare all MEG DSMs to all model DSMs
rsa_results = mne_rsa.rsa(meg_dsms, model_dsms, metric='spearman')
rsa_results = rsa_results.reshape(202, 71) # Reshape into sensors x times
# Pack the RSA results into an MNE-Python Evoked object in order to visualize it
info = mne.io.read_info('info_template.fif') # Contains sensor names and locations
rsa_results = mne.EvokedArray(rsa_results, info, tmin=dsms_file['times'][0])
# Plot
rsa_results.plot_topo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment