Skip to content

Instantly share code, notes, and snippets.

View SherazKhan's full-sized avatar

Sheraz Khan SherazKhan

  • Massachusetts General Hospital (MGH), Harvard Medical School and Massachusetts Institute of Technology (MIT)
  • Boston
  • X @dr_sheraz
View GitHub Profile
import mne
import os.path as op
import glob
import numpy as np
subjects = ['CC110033', 'CC110037', 'CC110045']
subject = subjects[0]
# For Desktop
# https://www.dropbox.com/sh/zkq03rj76usd6b5/AAC4pvtWoNMUkxNwrCrzUVNRa?dl=0
@SherazKhan
SherazKhan / gaze.py
Created January 10, 2019 17:06
Gaze contingent animation using an Eyelink
import sys
import random
import time
import pygame
import pylink
class Shape:
def __init__(self, x, y, size, px_per_second):
function [cortex] = raw_cortex(data,fname_inv,nave,dSPM,pickNormal)
% data : 3D Matrix Channels x times x epochs
% fname_inv : Inverse operator file name
% nave : number of trials (for single trial should be one)
% dSPM : 0 or 1
% pickNormal : 0 (loose) or 1 (fixed)
if ~exist('pickNormal','var')
pickNormal=0;
import mne
import numpy as np
def labels2stc(labels,labels_data,stc):
stc_new = stc.copy()
stc_new.data.fill(0)
for index,label in enumerate(labels):
if labels_data.ndim==1:
if isinstance(label, str):
temp = stc.in_label(mne.read_label(label))
@SherazKhan
SherazKhan / plot_brainstorm_data.m
Created June 14, 2018 14:18 — forked from ftadel/plot_brainstorm_data.m
Calling MNE-Python in Matlab scripts
function plot_brainstorm_data()
% ============================
% Brainstorm tutorial datasets
% ============================
%
% Here we compute the evoked from raw for the Brainstorm
% tutorial dataset. For comparison, see [1]_ and:
%
% http://neuroimage.usc.edu/brainstorm/Tutorials/MedianNerveCtf
%
# Load 'pwr' package
library(pwr)
# 80% power
# Small effect size
small80p <- pwr.t.test(sig.level = 0.05, d = 0.2,
power = 0.8, type="two.sample", alternative="two.sided")
small80p
function sol = apply_inverse_raw(fname_raw,fname_inv,tmin, tmax, sel, nave,dSPM,pickNormal)
if ~exist('pickNormal','var')
pickNormal=0;
end
if ~exist('dSPM','var')
@SherazKhan
SherazKhan / merge_eeg_meg.py
Created December 4, 2017 16:41
MEG MEG and EEG files in single fif file
import pyimpress
import mne
import numpy as np
from mne import create_info
from mne.io import RawArray
mff_fname='/cluster/transcend/sheraz/data/MEG_EEG/EEG/taskforce_1_vis_20160310_063855.mff'
# mff is the class supporting mff io
import itertools
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
from matplotlib.collections import PatchCollection
import numpy as np
def main():
fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')
x = np.radians(np.arange(0, 360, 10))
import mne
import os
import numpy as np
import os.path as op
from mne.datasets import sample
from nose.tools import assert_equal
data_path = sample.data_path()