Exemple #1
0
def circ_psth(rast_, rr, npips, onset = 0.05, bins = 20, color = 'b', remove_first = False, ax = None):
	'''
	Input:
		rast_ : subset of block raster corresponding to only the stimuli you want plotted
		rr : the repetition rate
		npips : number of pips presented at this rate
		onset : in seconds, onset time of first pip
		bins : number of bins to include
		remove_first : exclude the respose to the first pip
	'''
	
	spktimes_ = Spikes.rast2spktimes(rast_)
	period = 1. / rr
	train_end = float(npips) / rr
	spktimes_chunk = spktimes_ - onset
	spktimes_chunk = spktimes_chunk[spktimes_chunk > 0]
	spktimes_chunk = spktimes_chunk[spktimes_chunk < train_end]
	if remove_first:
		spktimes_chunk = spktimes_chunk[spktimes_chunk > period]
	spktimes_pol = spktimes_chunk * 2*np.pi * rr # convert to radians
	spktimes_pol = np.mod(spktimes_pol, 2*np.pi) # force range 0-2pi
	nspks = spktimes_pol.size

	r, V, theta = circ_stat(spktimes_pol)
	
	ax, fig = misc.axis_check(ax, polar = True)
	if spktimes_pol.size > 0:
		ax.hist(spktimes_pol, bins = bins, color = color, histtype = 'stepfilled')
		ax.plot([0, theta], [0, V], 'r.-')
		ax.plot([0, 0], [0, V*np.cos(theta)], 'r.-')

	return r, V, theta
Exemple #2
0
def calc_vs(rast_, rr, npips, onset = 0.05, analysistype = 'mean', remove_first = False):

	ix_times = np.arange(rast_.shape[1]) / 1000.
	spktimes_ = Spikes.rast2spktimes(rast_, ix_times)
	spktimes_ = spktimes_ - onset
	train_end = npips / rr # end at last pip
	if remove_first:
		train_start = 1./rr
	else:
		train_start = 0.
	spktimes_chunk = spktimes_[np.logical_and(train_start<spktimes_, spktimes_<train_end)]

	v = np.exp(1j * 2*np.pi * rr * spktimes_chunk)
	# v = np.cos(2 * np.pi * rr * spktimes_chunk) + 1j * np.sin(2 * np.pi * rr * spktimes_chunk)

	if analysistype == 'mean':
		vs = np.abs(v.mean()) #/ duration
	if analysistype == 'sum':
		vs = np.abs(v.sum())

	alpha = np.angle(v)
	p = rayleigh_test(np.angle(v))
	
	return vs, p