def reg_clusters_t_src(mod, IV, factor=None, c1=None, c0=None): """ Cluster permutation (src x time) t-tests on regression coefficients. Example: mod='main-VerbGivenWord', IV='LogFre' """ dr = '/Volumes/Backup/sufAmb/regression/' f = dr+'ols_'+mod+'.pickled' data = load.unpickle(f) cond = "predictor=='%s'" % IV data = data.sub(cond) # smaller ds with only the predictor of interest # cluster permutation parameters Y='beta' match='subject' samples=100 pmin=0.05 tstart=0.13 tstop=0.45 mintime=0.03 minsource=10 if factor is None: test = testnd.ttest_1samp(Y=Y, ds=data, match=match, samples=samples, pmin=pmin, tstart=tstart, tstop=tstop, mintime=mintime, minsource=minsource) elif factor == 'main': test = testnd.ttest_1samp(Y=Y, ds=data.sub("condition=='main'"), match=match, samples=samples, pmin=pmin, tstart=tstart, tstop=tstop, mintime=mintime, minsource=minsource) else: test = testnd.ttest_rel(Y=Y, ds=data, X=factor, c1=c1, c0=c0, match=match, samples=samples, pmin=pmin, tstart=tstart, tstop=tstop, mintime=mintime, minsource=minsource) print "Finished cluster test: mod=%s, IV=%s, factor=%s, c1=%s, c0=%s" % (mod, IV, factor, c1, c0) path = "/Volumes/BackUp/sufAmb/reg-cluster_time_src/ols_mod-%s_IV-%s_factor-%s_c1-%s_c0-%s.pickled" \ % (mod, IV, factor, c1, c0) save.pickle(test, path) return test
# current format: [subject1, stem, stemS, stemEd], # [subject2, stem, stemS, stemEd], # ... # # new format: [subject1, stem], # [subject1, stemS], # ... # [subject2, stem], # ... #=============================================================================== dr = '/Volumes/Backup/sufAmb/pickled/' IVs = ['VerbGivenWord_nocov', 'VerbGivenWord', 'Ambiguity', 'WrdVerbyWeighted', 'WrdBiasWeighted'] for v in IVs: fil = dr+'ols_'+v+'.pickled' data = load.unpickle(fil) c1, c3 = [], [] c2 = ['all', 'stem', 'stemS', 'stemEd']*data.n_cases for s in range(data.n_cases): c1.extend( [ data['subject'][s] ]*4 ) c3.extend( [ data['all'][s], data['stem'][s], data['stemS'][s], data['stemEd'][s] ] ) c1 = Factor(c1) c2 = Factor(c2) c3 = combine(c3) newds = Dataset(('subject',c1), ('Type',c2), ('beta',c3), info=data.info) save.pickle(newds, fil)
import os import timeit import mne from eelbrain import datasets, save mne.set_log_level('warning') fname = 'temp.pickled' if not os.path.exists(fname): ds = datasets.get_mne_sample(-0.1, 0.2, src='ico', sub="modality == 'A'") source = ds['src'].source y = ds['src'][0].x save.pickle((y, source), fname) setup = ''' from itertools import izip import numpy as np import scipy as sp from eelbrain.lab import stats, load y, source = load.unpickle(%r) out = np.empty(y.shape, np.uint32) bin_buff = np.empty(y.shape, np.bool_) int_buff = np.empty(y.shape, np.uint32) threshold = 1 tail = 0 struct = sp.ndimage.generate_binary_structure(y.ndim, 1) struct[::2] = False
import os import timeit import mne from eelbrain import datasets, save mne.set_log_level("warning") fname = "temp.pickled" if not os.path.exists(fname): ds = datasets.get_mne_sample(-0.1, 0.2, src="ico", sub="modality == 'A'") source = ds["src"].source y = ds["src"][0].x save.pickle((y, source), fname) setup = ( """ from itertools import izip import numpy as np import scipy as sp from eelbrain.lab import stats, load y, source = load.unpickle(%r) out = np.empty(y.shape, np.uint32) bin_buff = np.empty(y.shape, np.bool_) int_buff = np.empty(y.shape, np.uint32) threshold = 1 tail = 0 struct = sp.ndimage.generate_binary_structure(y.ndim, 1)
def _execute(self): job = self.generate_job() if job: save.pickle(job(), self.path)
pmin=0.15 tstart=0.13 tstop=0.45 mintime=0.03 minsource=10 X = 'Type' tests = {} for v in IVs: print v testsv = {} fil = dr+'corr_'+v+'.pickled' data = load.unpickle(fil) print 'main' testsv['main'] = testnd.ttest_1samp(Y=Y, ds=data.sub("Type=='all'"), match=match, samples=samples, pmin=pmin, tstart=tstart, tstop=tstop, mintime=mintime, minsource=minsource) print 'test 1' testsv['stemVstemS'] = testnd.ttest_rel(Y=Y, ds=data, X=X, c1='stem', c0='stemS', match=match, samples=samples, pmin=pmin, tstart=tstart, tstop=tstop, mintime=mintime, minsource=minsource) print 'test 2' testsv['stemVstemEd'] = testnd.ttest_rel(Y=Y, ds=data, X=X, c1='stem', c0='stemEd', match=match, samples=samples, pmin=pmin, tstart=tstart, tstop=tstop, mintime=mintime, minsource=minsource) print 'test 3' testsv['stemSVstemEd'] = testnd.ttest_rel(Y=Y, ds=data, X=X, c1='stemS', c0='stemEd', match=match, samples=samples, pmin=pmin, tstart=tstart, tstop=tstop, mintime=mintime, minsource=minsource) for t in testsv: name = v+'_'+t path = '/Volumes/BackUp/sufAmb/corr_cluster_timespace/corr_%s.pickled' % name save.pickle(testsv[t], path) tests[v] = testsv
''' Created on Aug 18, 2014 @author: andrew ''' from eelbrain import combine, load, save dr = '/Volumes/Backup/sufAmb/pickled/' IVs = ['VerbGivenWord_nocov', 'VerbGivenWord', 'Ambiguity', 'WrdVerbyWeighted', 'WrdBiasWeighted'] for v in IVs: fil = dr+'ols_'+v+'.pickled' data = load.unpickle(fil) for k in data.keys(): if k == 'src~all_VerbGivenWord': data[k] save.pickle(data, fil)