コード例 #1
0
def autoAnalysis(kwik_fullpath):
	model = KwikModel(kwik_fullpath)
	kwikPath,kwikFile = os.path.split(kwik_fullpath) 
	allsamples = []
	allspikes = []
	for j in model.channel_groups: # for statement walks through different channel_groups (i.e., those on different shanks)
		model.channel_group = j

		samples = model.spike_samples
		spikes = model.spike_clusters
		
		for i,n in enumerate(spikes):
			allsamples.append(samples[i])
			allspikes.append(spikes[i])

	alltimes = np.array(allsamples)/model.sample_rate
	allspikes = np.array(allspikes)
	
	
	#plt.figure(figsize=(15,5))
	#plt.plot(alltimes, allspikes, '|',mew=.5,color=[.5,.5,.5])
	#plt.savefig(kwikPath+'\\allSpikes.png')
	
	[di, ai] = liic.load_intan_input_channels()
	intan_trigger = di['0'][:]
	intan_camera = di['1'][:]
	
	intan_transitions = np.where(intan_trigger[:-1] != intan_trigger[1:])[0]
	
	adjustmentAmount = (intan_transitions[0])
	
	[matlab_trigger, matlab_triggerCMD, matlab_brush] = loadMatlabFile(adjustmentAmount)
	
	plt.figure(figsize=(15,10))
	plt.subplot(211)
	plt.plot(alltimes, allspikes, '|',color =[.5,.5,.5],markersize=5,mew=.4)
	plt.ylabel('unit')
	topxlim = plt.xlim()
	plt.xlim(topxlim)
	plt.subplot(212)
	plt.plot(np.arange(0,len(matlab_brush)/20000,1/20000),matlab_brush,color = [.5,.5,.5],linewidth=.5)
	plt.savefig(kwikPath+'\\brushSpikes.png')