Ejemplo n.º 1
0
def shortToyOne(ds, newpath="/rg"):
	dat = ds.getData()[:,0]
	fs = ds.fs()
	start = ds.start()
	h = {'SampleType':'timeseries', 'SamplesPerSecond':fs, 'StartTime':start}	
	k = array([0,0,0,0,-1,1,-1,1,0,0,0,0])
	ds.createSubData('/k', k, h, delete=True)
	g = cal._applyFilterWithTR(dat, k)
	g = shift(g, 6)
	g = g/g.max()
	ds.createSubData(newpath, g, h, delete=True)
Ejemplo n.º 2
0
def Filter(ds, select=(None, None, None), selectFilter=('/pca', [0], None), eventOffset=-.02, newpath='/dp'):
	'''Apply the data specified by selectFilter as a filter on the data specified by select. Store the resulting signal in newpath.'''
	filt=getSelection(ds, selectFilter)[:,0]
	#filt = reverseArray(filt[:,0])
	dat=getSelection(ds, select)[:,0]
	dat = cal._applyFilterWithTR(dat, filt)
	h=getSelectionHeader(ds, select)
	fs = h['SamplesPerSecond']
	fl = filt.shape[0] / fs
	os = (fl / 2) + eventOffset
	h['StartTime']+=os
	ds.createSubData(newpath, data=dat, head=h, delete=True)
	return ds
Ejemplo n.º 3
0
def shortToyTwo(ds, newpath="/rg"):
	dat = ds.getData()[:,0]
	fs = ds.fs()
	start = ds.start()
	h = {'SampleType':'timeseries', 'SamplesPerSecond':fs, 'StartTime':start}
	k2 = array([0,0,0,0,-1,1,-1,1,0,0,0,0])
	k1 = array([-1,1,-1,1,0,0,0,0,-1,1,-1,1])
	g = cal._applyFilterWithTR(dat, k1)
	g = shift(g, 6)
	g = g - g.min()
	g = g/g.max()
	g2 = -1*sc.match(dat, k2)
	g2 = g2 - g2.min()
	g2 = g2/g2.max()
	g =  g + 3*g2
	ds.createSubData('/k', column_stack([k1, k2]), h, delete=True)
	ds.createSubData(newpath, g, h, delete=True)
Ejemplo n.º 4
0
def compoundToy(ds, klen = 200, newpath="/rg"):
	dat = ds.getData()[:,0]
	fs = ds.fs()
	start = ds.start()
	h = {'SampleType':'timeseries', 'SamplesPerSecond':fs, 'StartTime':start}
	x=arange(klen)/fs
	k2=sin( 2*pi*100*x)
	k1=sin( 2*pi*400*x)
	g = cal._applyFilterWithTR(dat, k1)
	g = shift(g, int(klen/2))
	g = g - g.min()
	g = g/g.max()
	g2 = -1*sc.match(dat, k2)
	g2 = g2 - g2.min()
	g2 = g2/g2.max()
	g =  g + g2
	ds.createSubData('/k', column_stack([k1, k2]), h, delete=True)
	ds.createSubData(newpath, g, h, delete=True)
Ejemplo n.º 5
0
def toyWithInvariance(ds, klen = 200, noise=.05, newpath="/spikes", returnG=False):
	dat = ds.getData()[:,0]
	fs = ds.fs()
	start = ds.start()
	h = {'SampleType':'timeseries', 'SamplesPerSecond':fs, 'StartTime':start}	
	q = int(klen/4.0)
	k = zeros(klen)
	k[:2*q] = -1
	k[:q] = 1
	ds.createSubData('/k', k, h, delete=True)
	g = cal._applyFilterWithTR(dat, k)
	g = shift(g, int(klen/2))
	g = g/g.max()
	# g = zeros(ds.data.shape[0])
	# for i in range(klen, g.shape[0]):
	# 	g[i] = dat[i-2*third:i-third].mean() - dat[i-3*third:i-2*third].mean()
	if returnG:
		ds.createSubData(newpath, g, h, delete=True)
	else:
		h['SampleType']='events'
		evts = _gtoSpikes(g, noise, fs)
		ds.createSubData(newpath, evts, h, delete=True)