Ejemplo n.º 1
0
def refixLaunch(exp,corr=False, trim=True, bins=8):
	
	"""
	"""
	
	src = 'selected_dm_%s_WITH_drift_corr_onlyControl_True.csv' % exp
	dm = CsvReader(src).dataMatrix()
	
	lat1 = "saccLat1"
	lat2 = "saccLat2"
	if corr:
		fix1 = "endX1CorrNormToHandle"
		fix2 = "endX2CorrNormToHandle"
	else:
		fix1 = "endX1NormToHandle"
		fix2 = "endX2NormToHandle"
		
	for var in [lat1, lat2, fix1, fix2]:
		dm = dm.select("%s != ''" % var)
	
	# Trim the data
	if trim:
	
		dm = dm.selectByStdDev(["file"],lat2, 
			verbose=False)
		dm = dm.removeField("__dummyCond__")
		dm = dm.removeField("__stdOutlier__")
		dm = dm.selectByStdDev(["file"], fix2,
			verbose=False)
	
	dm = dm.addField('saccLat2_perc', dtype=float)
	dm = dm.calcPerc(lat2, 'saccLat2_perc', nBin=bins)
	cmLat1 = dm.collapse(['saccLat2_perc'], lat1)	
	cmX = cmLat2 = dm.collapse(['saccLat2_perc'], lat2)
	cmFix1 = dm.collapse(['saccLat2_perc'], fix1)
	cmFix2 = dm.collapse(['saccLat2_perc'], fix2)
	
	fig = plt.figure(figsize = (3,6))
	plt.subplots_adjust(left=.2, bottom=.15)
		
	colList = [orange[1], blue[1]]
	nRows = 3
	nCols = 1
	nPlot = 0
	lTitles = ["Landing pos 2", "Landing pos 1"]
	lTitles.reverse()
	for cmY in [cmFix2, cmFix1]:#, cmLat1]:
		#nPlot +=1
		#plt.subplot(nRows, nCols, nPlot)
		color = colList.pop()
		plt.plot(cmX['mean'], cmY['mean'], marker = 'o', color=color, \
			markerfacecolor='white', markeredgecolor=color, \
			markeredgewidth=1)
		plt.xlabel("Sacc lat 2")

	plt.legend(lTitles, frameon=False, loc='best')
	plt.axhline(0, linestyle = "--", color = gray[3])
	
	plt.savefig("Launch_site_refixations_%s_corr_%s.png" % (exp, corr))
Ejemplo n.º 2
0
def ovp(exp,corr=False, trim=True, bins=8):
	
	"""
	"""
	
	src = 'selected_dm_%s_WITH_drift_corr_onlyControl_True.csv' % exp
	dm = CsvReader(src).dataMatrix()

	lat1 = "saccLat1"
	lat2 = "saccLat2"
	prob = "saccCount"
	dur1 = "durationFix1"
	dur2 = "durationFix2"
	total = "gazeDur"
	rt = "rtFromStim"
	
	if corr:
		fix1 = "endX1CorrNormToHandle"
		fix2 = "endX2CorrNormToHandle"
	else:
		fix1 = "endX1NormToHandle"
		fix2 = "endX2NormToHandle"
		
	for var in [lat1, lat2, fix1, fix2, dur1, dur2, total, rt]:
		dm = dm.select("%s != ''" % var)
	
	# Trim the data
	if trim:
	
		dm = dm.selectByStdDev(["file"],lat2, 
			verbose=False)
		dm = dm.removeField("__dummyCond__")
		dm = dm.removeField("__stdOutlier__")
		dm = dm.selectByStdDev(["file"], fix2,
			verbose=False)
	
	dm = dm.addField('land2_perc', dtype=float)
	dm = dm.calcPerc(fix2, 'land2_perc', nBin=bins)
	cmLat1 = dm.collapse(['land2_perc'], lat1)	
	cmLat2 = dm.collapse(['land2_perc'], lat2)
	cmFix1 = dm.collapse(['land2_perc'], fix1)
	cmX = cmFix2 = dm.collapse(['land2_perc'], fix2)
	cmProb = dm.collapse(['land2_perc'], prob)
	cmDur1 = dm.collapse(['land2_perc'], dur1)
	cmDur2 = dm.collapse(['land2_perc'], dur2)
	cmTotal = dm.collapse(['land2_perc'], total)
	cmRt = dm.collapse(['land2_perc'], rt)
	fig = plt.figure(figsize = (3,10))
	plt.subplots_adjust(left=.2, bottom=.15, hspace = .2)
		

	lTitles = ["dur 1", "prob", "land 1", "rt", "total", "lat 1", "lat 2", "dur 2"]
	lTitles.reverse()
	nRows = len(lTitles)
	nCols = 1
	nPlot = 0

	for cmY in [cmDur1, cmProb, cmFix1, cmRt, cmTotal, \
		cmLat1, cmLat2, cmDur2]:
			
		nPlot +=1
		ax = plt.subplot(nRows, nCols, nPlot)
		#color = colList.pop()
		color = blue[1]
		plt.plot(cmX['mean'], cmY['mean'], marker = 'o', color=color, \
			markerfacecolor='white', markeredgecolor=color, \
			markeredgewidth=1)
		plt.ylabel(lTitles.pop())

		plt.axvline(0, linestyle = "--", color = gray[3])
			
		if nPlot == nRows:
			plt.xlabel("Second landing position")
		else:
			ax.xaxis.set_ticklabels([])

	plt.savefig("ovp2_%s_corr_%s.png" % (exp, corr))
Ejemplo n.º 3
0
def plotContrast(exp = "004B", trim=True, inclSim=True,stats=True,norm=False):
	
	
	"""
	Plots landing positions as a function of contrats manipulation per saccade,
	for Exp 1 and Exp 2, relative to CoG.
	
	Keyword arguments:
	trim		--- (default=True)
	"""
	

	# Get dm:
	src = 'selected_dm_%s_WITH_drift_corr_onlyControl_False.csv' % exp
	dm = CsvReader(src).dataMatrix()

	colList = ["#f57900", "#3465a4"]
	lLegend = ["Saccade 1", "Saccade 2"]

	fig = plt.figure(figsize = (3,4))
	plt.subplots_adjust(left=.2, bottom=.15)
	yLim = [-.07, .12]
	

	for sacc in ["1", "2"]:
		dv = "endX%sNorm" % sacc
		saccVar = "saccLat%s" % sacc

		# Get dm:	
		# Only on-object:
		dm = onObject.onObject(dm, sacc,verbose=False)
		
		if trim:
			dm = dm.removeField("__dummyCond__")
			dm = dm.removeField("__stdOutlier__")
			dm = dm.selectByStdDev(keys = ["file"], \
			dv = dv,verbose=False)
			dm = dm.removeField("__dummyCond__")
			dm = dm.removeField("__stdOutlier__")
			dm = dm.selectByStdDev(keys = ["file"], dv = saccVar,\
				verbose=False)

		
		# Collect mean and error bar per saccade:
		lM = []
		lErr = []
		
		if norm:
			# Normalize across handle side:
			dm = dm.removeField("normDV")
			dm= dm.addField("normDV", dtype = float)
			dm= dm.withinize(dv, "normDV", \
					["handle_side"], whiten=False)
			dv = "normDV"

	
		for contrast in dm.unique("contrast_side"):
			contrast_dm = dm.select("contrast_side == '%s'" % contrast,\
				verbose = False)
			
			cm = contrast_dm.collapse(["file"], dv)

			M = cm["mean"].mean()
			SE = cm['mean'].std() / np.sqrt(len(cm))
			CI = SE * critVal
			lM.append(M)
			lErr.append(CI)
		if stats:
			# Run a full LME
			print "Exp = ", exp
			print "DV = ", dv
			print "trim = ", trim
			print "norm = ", norm
			print "saccVar = ", saccVar
			lmeContrast(R, dm, dv, saccVar, exp=exp)
			#raw_input()
				
			xData = range(len(lM))
			yData = lM
			yErr = lErr

		col = colList.pop()
		plt.errorbar(xData, yData, yerr=yErr, fmt='o-', marker = "o", \
			color = col, markerfacecolor='white', markeredgecolor=col, \
			markeredgewidth=1)
	plt.axhline(0, linestyle = "--")
	plt.ylim(yLim)
	plt.ylabel(yTitle)
	#ax.yaxis.set_ticklabels([])
	plt.legend(lLegend, frameon = False)
	plt.axhline(0, color = "black", linestyle = "--")
	plt.xlabel("High-contrast side")
	spacing = 0.5
	xTicks = range(0,3)
	xLabels = ["Left", "Control", "Right"]
	plt.xticks(xTicks, xLabels, rotation = .5)
	plt.xlim(min(xTicks)-spacing, max(xTicks)+spacing)
	plt.savefig(os.path.join(dst,"Contrast_Effect_%s_trim_%s_norm_%s.png") \
		% (exp, trim, norm))
	plt.show()
Ejemplo n.º 4
0
def plotGap(exp, dv = "saccLat1", trim = False, norm=True, nBins = 50, \
	exclFastSacc = False):
	
	"""
	"""
	
	src = 'selected_dm_%s_WITH_drift_corr_onlyControl_True.csv' % exp
	dm = CsvReader(src).dataMatrix()

	# Determine sacc:
	sacc = [int(x.group()) for x in re.finditer(r'\d+', dv)][0]
	dm = onObject.onObject(dm, sacc)
	
	# Exclude very fast saccades:
	dm = dm.select("%s > 80" % dv)	
	
	colList = [orange[1], blue[1]]

	# Trim the data
	if trim:
		
		dm = dm.removeField("__dummyCond__")
		dm = dm.removeField("__stdOutlier__")

		dm = dm.selectByStdDev(["file"], dv, \
			verbose=False)
		dm = dm.removeField("__dummyCond__")
		dm = dm.removeField("__stdOutlier__")
		dm = dm.selectByStdDev(["file"], "endX%sNormToHandle" % sacc, \
			verbose=False)
		
		if exp == "004A":
			dm = dm.removeField("__dummyCond__")
			dm = dm.removeField("__stdOutlier__")
			dm = dm.selectByStdDev(["file"], "endX%sCorrNormToHandle" % sacc, \
				verbose=False)
				
	else:
		dm = dm.select("%s < 1000" % dv)
	
	# Normalize saccade latencies 
	if norm:
		dm= dm.addField("normSacc", dtype = float)
		dm= dm.withinize(dv, "normSacc", \
				["file"], whiten=False)
		dv = "normSacc"
		
	for gap in dm.unique("gap"):
		
		_dm = dm.select("gap == '%s'" % gap)

		samp = _dm[dv]
	
		y, edges = np.histogram(samp, bins = nBins)
		y = normY(y)
				
		x = .5*edges[1:] + .5*edges[:-1]
		col = colList.pop()
		plt.plot(x, y, color = col)
		plt.fill_between(x, 0, y, alpha=.3, color=col)	
	plt.legend(dm.unique("gap"))
	plt.ylim([0,1.1])