Skip to content

Instantly share code, notes, and snippets.

@pravsripad
pravsripad / ica_exclude_bugs_test.py
Last active December 29, 2015 04:29
BUG: Calculating evoked ica sources after exclusion.
#!/usr/bin/env python
import matplotlib.pylab as pl
import numpy as np
import mne
from mne.fiff import Raw
from mne.preprocessing.ica import ICA
from mne.datasets import sample
data_path = sample.data_path()
@pravsripad
pravsripad / bug_epochs_avg_picks.py
Last active December 29, 2015 06:19
Bug passing picks to epochs.average()
#!/usr/bin/env python
import matplotlib.pylab as pl
import numpy as np
import mne
from mne.fiff import Raw
from mne.datasets import sample
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
@pravsripad
pravsripad / plot_circle_von_mises.py
Created June 22, 2015 12:53
Circular bar plot - von Mises distribution
#!/usr/bin/env python
# Inspired from :
# http://matplotlib.org/examples/pie_and_polar_charts/polar_bar_demo.html
''' Plot von Mises distribution as a circular bar plot. '''
import numpy as np
import matplotlib.pyplot as pl
# This file is basically JSON but allowes comment lines that
# start with the # character. Additionally, keys need not to be
# enclosed by quotes.
# Besides those exceptions this file MUST be valid JSON or the
# program will fail.
# Rainy configuration
{
# the Url, containing IP address or hostname and port on which to listen
# if the wildcard "*" is used, we listen on all addresses
1 Precentral_L 255 128 255 255
2 Precentral_R 177 18 255 255
3 Frontal_Sup_L 45 255 47 255
4 Frontal_Sup_R 106 209 255 255
5 Frontal_Sup_Orb_L 122 255 158 255
6 Frontal_Sup_Orb_R 255 87 186 255
7 Frontal_Mid_L 183 150 54 255
8 Frontal_Mid_R 216 255 159 255
9 Frontal_Mid_Orb_L 181 169 80 255
10 Frontal_Mid_Orb_R 255 152 0 255
@pravsripad
pravsripad / our_script.py
Created September 30, 2015 15:24
koln_xcorr_networks
#!usr/bin/env python
import numpy as np
import pyunicorn
import matplotlib.pyplot as pl
'''
# make a big bad ass array with all the subjects
for subj in range(1, 11):
print '>Running for subject %d' %(subj)
@pravsripad
pravsripad / compute_network_params.py
Last active October 1, 2015 15:58
koln network params
#/usr/bin/env python
import numpy as np
import pyunicorn
import matplotlib.pyplot as pl
pl.ion()
data = np.load('all_fmri_data.npy')
def compute_xcorr(data, thresh=95, binary=False):
'''
@pravsripad
pravsripad / fmri_recurrence.py
Created September 30, 2015 15:26
compute recurrence in networks
import numpy as np
from pyunicorn.timeseries import RecurrenceNetwork
from matplotlib import pyplot as pl
from mpl_toolkits.mplot3d import Axes3D
# Loading the data for 1 subject
data = np.load('all_fmri_data.npy')[0]
pl.plot(data)
pl.show()
@pravsripad
pravsripad / mutual_information.py
Created October 1, 2015 15:59
Compute average mi and xcross across the data.
import numpy as np
import pyunicorn
import matplotlib.pyplot as pl
pl.ion()
data = np.load('all_fmri_data.npy')
mi_all = np.zeros((10, 90, 90))
xcorr_all = np.zeros((10, 90, 90))
from pyunicorn import funcnet
@pravsripad
pravsripad / visualize_3d_head_surfaces.py
Created November 12, 2015 08:52
Source space observations
#!/usr/bin/env python
'''
Load a surface and visualize it using Mayavi.
'''
import mne
from mayavi import mlab
# The surfaces are usually located in $SUBJECTS_DIR/$SUBJECT/surf/*