Пример #1
0
def plot_trial(dat, info, ax = None):
	
	ax, _ = misc.axis_check(ax)
	
	# plot the pre-track
	plot_track(dat['pre_x'], dat['pre_y'], ax = ax, color = 'b')
	ax.plot(dat['pre_x'][0], dat['pre_y'][0], marker = '*', ms = 20, color = 'b')

	# if there is a post-track, plot it
	if len(dat['post_x']) > 0:
		plot_track(dat['post_x'], dat['post_y'], ax = ax, color = 'g')
		ax.plot(dat['post_x'][0], dat['post_y'][0], marker = '*', ms = 20, color = 'g')

	# draw the target radius
	cir = mpl.patches.Circle((dat['target_x'], dat['target_y']), radius = info['target_radius'], color = 'r', fill = False, linestyle = 'dotted')
	ax.add_patch(cir)
	
	# draw the arena radius
	cir = mpl.patches.Circle((info['arena_x'], info['arena_y']), radius = info['arena_radius'], color = 'k', fill  = False)
	ax.add_patch(cir)
	misc.target(dat['target_x'], dat['target_y'], ax, color = 'r')
	misc.target(dat['spout_x'], dat['spout_y'], ax, color = 'g')
	
	# set the axis limits
	ax.set_xlim([info['arena_x']-info['arena_radius']-20, info['arena_x']+info['arena_radius']+20])
	ax.set_ylim([info['arena_y']-info['arena_radius']-20, info['arena_y']+info['arena_radius']+20])
	
	plt.show()
Пример #2
0
def plot_heatmap(data, epoch = 'pre', ax = None, gridsize = 30, rel_to_target = False):
	'''
	plots a heatmap from x and y locations in one of the trial epochs.
	uses hexagonal bins
	'''
	xy = np.empty((0, 2), dtype = np.int32)
	x_key = epoch + '_x'
	y_key = epoch + '_y'
	if rel_to_target is True:
		for dat in data:
			xy = np.vstack((xy, np.vstack((dat[x_key] - dat['target_x'], dat[y_key] - dat['target_y'])).T))

	elif rel_to_target is False:
		for dat in data:
			xy = np.vstack((xy, np.vstack((dat[x_key], dat[y_key])).T))
	
	ax, _ = misc.axis_check(ax)
	
	ax.set_aspect('equal')
	ax.hexbin(xy[:, 0], xy[:, 1], gridsize = gridsize)
	
	if rel_to_target is False:
		misc.target(data[0]['spout_x'], data[0]['spout_y'], ax)
	if rel_to_target is True:
		misc.target(0, 0, ax)

	plt.show();