Beispiel #1
0
def simon(dm):
	
	"""
	"""
	

	pm = PivotMatrix(dm, ['response_hand', 'mask_side'], ['file'], dv='RT', colsWithin=False)
	pm._print()
	pm.barPlot(show=True)
	plt.title("simon effect")
Beispiel #2
0
def affordance(dm):
	
	"""
	"""
	
	dm = dm.select('symm == "asymm"')

	pm = PivotMatrix(dm, ['response_hand', 'handle_side'],['file'], dv = "RT")
	pm.barPlot(show=True)
	plt.title("affordance effect")
Beispiel #3
0
def gapEffect(dm, dv = "saccLat"):
	
	"""
	Regardless of color change...
	"""
	
	pm = PivotMatrix(dm, ['gap'],['file'],dv =dv)
	pm._print()
	pm.barPlot(show=True)
	plt.ylabel(dv)
	plt.title("gap effect")
Beispiel #4
0
def affLumCongr(dm):
	
	dm = dm.select('symm == "asymm"')

	xLabels = ["hande left", "handle right"]
	lLabels = ["control", "more contrast right", "more contrast left"]
	yLabel = "landing position: negative = left, positive = right"
	
	pm = PivotMatrix(dm, ['handle_side', 'mask_side'], ['file'], \
		dv='endX')
	pm._print()
	pm.barPlot(xLabels = xLabels, lLabels = lLabels, yLabel = yLabel, show=True)
	plt.title("overlap between contrast and affordance")
Beispiel #5
0
def vfDiff(dm,dv = "RT"):

	pm = PivotMatrix(dm, ['visual_field'],['file'], dv = dv)
	pm.barPlot(show=True)
	plt.ylabel(dv)
	plt.title("visual field difference")
Beispiel #6
0
def ovp(dm, rt = "rtFromLanding", ws = True, nRows = 1, nCols = 8, nBin = 5, \
	binVar = "endX1Norm", binVar2 = None, figSize = (15,4), onlyControl = True):
	
	"""
	Plots OVP effects as a function of binned initial landing position.
	
	Arguments:
	dm			--- data matrix
	rt			--- variable for RT
	ws 			--- Vincentize or not.
	binVar		--- variable for first row of OVP plots
	binVar2		--- variable for second row of OVP plots (optional)
	onlyControl	--- exclude contrast manipulation. Default = True
	
	"""
	
	# If wanted, exclude the contrast manipulation:
	if onlyControl:
		dm = dm.select("mask_side == 'control'")
	
	# Determine whether or not to first split data per participant
	# (i.e. to make within-subjects bins):
	if ws:
		keys = ['file']
	else:
		keys = None

	# Determine exp:
	exp = dm["exp"][0]
	

	# Add factors containing bins:
	binnedVar = "binned_%s"%binVar
	dm = dm.addField(binnedVar)
	dm = dm.calcPerc(binVar, binnedVar,keys = keys, nBin = nBin)
	
	factorList = [binnedVar]
	
	if binVar2 != None:
		binnedVar2 = "binned_%s" % binVar2
		dm = dm.addField(binnedVar2)
		dm = dm.calcPerc(binVar2, binnedVar2, keys = keys, nBin = nBin)
		factorList.append(binnedVar2)
	
	# Create figure:
	fig = plt.figure(figsize = figSize)
	plt.subplots_adjust(wspace = .5)
	figName = "%s: OVP effects as a function of binned %s - WS = %s" % (exp, factorList, ws)
	plt.suptitle(figName)

	plotCount = 0

	# Define keys:
	subjectID = ["file"]
	dvList = [rt, "durationFix1", "refixProb", "saccCount", "gazeDur", "durationFix2", \
		"endX2Norm", "saccLat1"]
	
	for factors in factorList:
		for dv in dvList:

			plotCount +=1
			
			# Exclude trials on which the dv does not exist:
			_dm = dm.select("%s != ''"%dv)
			
			plt.subplot(nRows, nCols, plotCount)
			plt.title(dv)
			pm = PivotMatrix(_dm, factors, subjectID, dv, colsWithin = True)
			pm.barPlot(fig = fig)
			
			if dv == 'endX2Norm':
				plt.axhline(0, linestyle = '--', color = 'gray')
				
			# Determine ylim's:
			if exp == "004A":
				if dv == "rtFromLanding":
					plt.ylim(500,550)
				if dv == "durationFix1":
					plt.ylim(260, 300)
				if dv == "durationFix2":
					plt.ylim(315, 355)
				if dv == "refixProb":
					plt.ylim(0.58, 0.72)
				if dv == "saccCount":
					plt.ylim(1.75, 1.94)
				if dv == "endX2Norm":
					plt.ylim(-.2, .2)
				if dv == "gazeDur":
					plt.ylim(500, 600)
				if dv == "saccLat1":
					plt.ylim(150, 200)
			
			if exp == "004B":
				
				if dv == "rtFromLanding":
					plt.ylim(400,500)
				if dv == "durationFix1":
					plt.ylim(260, 300)
				if dv == "durationFix2":
					plt.ylim(270, 300)
				if dv == "refixProb":
					plt.ylim(0.4, 0.65)
				if dv == "saccCount":
					plt.ylim(1.6, 2.)
				if dv == "endX2Norm":
					plt.ylim(-.2, .2)
				if dv == "gazeDur":
					plt.ylim(450, 510)
				if dv == "saccLat1":
					plt.ylim(150, 250)
			
			
			#plt.ylabel(dv)
			plt.xticks([])

	plt.savefig("%s RT = %s nBin = %s.png"%(figName,rt, nBin))
Beispiel #7
0
def landWithoutContrast(factor = ["handle_side"], nRows = 3, nCols = 4, saccNr = "1", \
	yLim = [-.1, .1], pp = ["file"], stats = True, colsWithin = True, sepPlots = True, exclY = True):
	
	"""
	Plots effect of handle side on landing-position variable. Only trials without
	contrast manipulation are included.
	
	Arguments:
	dm
	
	Keyword arguments:
	saccNr		--- nth saccade of interest (default = first, "1")
	sepPlots	--- save and return as separate plots or as subplots of one main figure
	"""

	# Create figure:
	# Experiment 004A:
	exp = "004A"
	dm1 = getDM.getDM(exp = exp, driftCorr = True)
	
	# Only use objects without contrast manipulation
	dm1 = dm1.select("mask_side == 'control'", verbose = False)
	figList = []
	
	if not sepPlots:
		
		fig = plt.figure(figsize = (10,2))
		nRows = 1
		nCols = 3
		plotNr = 0
	
	for dv in ["endX%sNorm" % saccNr, "endX%sCorrNorm" % saccNr]:
		
		if sepPlots:
			
			fig = plt.figure(figsize = (10,3))
			figName = "exp %s dv %s colsWithin = %s - exclY = %s" % (exp, dv, colsWithin, exclY)
		
		else:
			plotNr +=1
			plt.subplot(nRows,nCols,plotNr)
			
		_dm = dm1

		# Only trials where variable has a value:
		_dm = _dm.select("%s != ''"%dv)
		
		# Only on-object EM's:
		_dm = _dm.select('endX%sNorm < .5' % saccNr)
		_dm = _dm.select('endX%sNorm > -.5' % saccNr)

		if exclY:
			_dm = _dm.select('endY%sNorm < .5' % saccNr)
			_dm = _dm.select('endY%sNorm > -.5' % saccNr)
		
	
		# Trim:
		_dm = _dm.selectByStdDev(keys = factor + pp, dv = dv)
		
		
		#plt.subplot2grid((nRows,nCols), (plotCount, 0))
		pm = PivotMatrix(_dm, factor, pp, dv, colsWithin=colsWithin, err='se')
		#plt.axhline(0, linestyle = "--", color = "#555753")
		#plt.ylim(yLim)
		#pm.barPlot(fig=fig)
		
		pm.barPlot(fig = fig, _dir='right')
		plt.axvline(0, linestyle = "--", color = "#555753")
		plt.axhline(0.5, linestyle = "-", color = "#555753")
		plt.xlim(yLim)
		
		if sepPlots:
			if "Corr" in dv:
				plt.xlabel("corrected horizontal landing position")
			else:
				plt.xlabel("horizontal landing position")
		else:
			plt.xticks([])
		if stats:
			am = AnovaMatrix(_dm, factors = factor, dv = dv, \
				subject = pp[0])._print(maxLen=7, ret=True)
			print am
		#plt.subplot2grid((nRows,nCols), (plotCount, 1), colspan=3)
		#plt.title("Exp = %s DV = %s" % (exp, dv))
		#plt.text(0.05,0.1,am, family='monospace')
		#plt.xticks([])
		#plt.yticks([])
		#plotCount +=1
		
		if sepPlots:
			plt.savefig("%s.svg"%figName)
			plt.savefig("%s.png"%figName)
			#plt.show()
			figList.append(fig)
		
	# For experiment 004B we plot only the normalised landing position.
	# Correcting for CoG doesn't make sense here!
	
	
	exp = "004B"

	
	# Get dm:
	dm2 = getDM.getDM(exp = exp, driftCorr = True)
	
	# Only trials without contrast manipulation:
	dm2 = dm2.select("mask_side == 'control'")
	
	# Only trials where variable has a value:
	dm2 = dm2.select("%s != ''"%dv)
	
	# Only on-object eye movements:
	dm2 = dm2.select('endX%sNorm < .5' % saccNr)
	dm2= dm2.select('endX%sNorm > -.5' % saccNr)
	
	if exclY:
		dm2 = dm2.select('endY%sNorm < .5' % saccNr)
		dm2= dm2.select('endY%sNorm > -.5' % saccNr)
			
				 
	# Pivot matrix and stats:
	dv = "endX%sNorm" % saccNr


	# Trim:
	dm2 = dm2.selectByStdDev(keys = factor + pp, dv = dv)
	
	if sepPlots:
		fig = plt.figure(figsize = (10,3))
		figName = "exp %s dv %s colsWithin = %s - exclY = %s" % (exp, dv, colsWithin, exclY)
	
	else:
		plt.subplot(nRows,nCols,3)

	pm = PivotMatrix(dm2, factor, pp, dv = dv, colsWithin = colsWithin, err = 'se')
	#plt.subplot2grid((nRows,nCols), (plotCount, 0))
	
	pm.barPlot(fig = fig, _dir='right')
	plt.axvline(0, linestyle = "--", color = "#555753")
	plt.axhline(0.5, linestyle = "-", color = "#555753")
	plt.xlim(yLim)
	if sepPlots:
		plt.xlabel("horizontal landing position")
	
	else:
		plt.xticks([])
	if stats:
		am = AnovaMatrix(dm2, factors = factor, dv = dv, \
			subject = pp[0])._print(maxLen=7, ret=True)
		print am
	#plt.subplot2grid((nRows,nCols), (plotCount, 1), colspan=3)
	#plt.title("Exp = %s DV = %s" % (exp, dv))
	#plt.text(0.05,0.1,am, family='monospace')
	#plt.xticks([])
	#plt.yticks([])
	
	if sepPlots:
		plt.savefig("%s.png"%figName)
		plt.savefig("%s.svg"%figName)
		
		figList.append(fig)
		
		return figList
	else:
		return fig
Beispiel #8
0
def splitHeavy(factor = ["corrDirection", "handle_side"], nRows = 3, nCols = 4, saccNr = "1", \
	yLim = [-.5, .5], pp = ["file"], stats = True, colsWithin = True, sepPlots = True, exclY = True):
	
		# Create figure:
	# Experiment 004A:
	exp = "004A"
	dm1 = getDM.getDM(exp = exp, driftCorr = True)
	
	dm1 = dm1.select("corrDirection != 'correction smaller than 8'")
	
	for corr in dm1.unique("corrDirection"):
		print corr
		tmp = dm1.select("corrDirection == '%s'" % corr)
		print "Corr direction = ", corr
		print tmp.unique("object")

	
	# Only use objects without contrast manipulation
	dm1 = dm1.select("mask_side == 'control'", verbose = False)
	figList = []
	
	if not sepPlots:
		
		fig = plt.figure(figsize = (10,2))
		nRows = 1
		nCols = 3
		plotNr = 0
	
	for dv in ["endX%sNorm" % saccNr, "endX%sCorrNorm" % saccNr]:
		
		if sepPlots:
			
			fig = plt.figure(figsize = (10,3))
			figName = "split by heavy side exp %s dv %s colsWithin = %s - exclY = %s" % (exp, dv, colsWithin, exclY)
		
		else:
			plotNr +=1
			plt.subplot(nRows,nCols,plotNr)
			
		_dm = dm1

		# Only trials where variable has a value:
		_dm = _dm.select("%s != ''"%dv)
		
		# Only on-object EM's
		_dm = _dm.select('endX%sNorm < .5' % saccNr)
		_dm = _dm.select('endX%sNorm > -.5' % saccNr)
		
		if exclY:
			_dm = _dm.select('endY%sNorm < .5' % saccNr)
			_dm = _dm.select('endY%sNorm > -.5' % saccNr)
	
	
		# Trim:
		_dm = _dm.selectByStdDev(keys = factor + pp, dv = dv)
		
		
		#plt.subplot2grid((nRows,nCols), (plotCount, 0))
		pm = PivotMatrix(_dm, factor, pp, dv, colsWithin=colsWithin, err='se')
		#plt.axhline(0, linestyle = "--", color = "#555753")
		#plt.ylim(yLim)
		#pm.barPlot(fig=fig)
		
		pm.barPlot(fig = fig, _dir='right', legendTitle = "handle side")
		plt.axvline(0, linestyle = "--", color = "#555753")
		plt.axhline(0.5, linestyle = "-", color = "#555753")
		plt.xlim(yLim)
		
		if sepPlots:
			if "Corr" in dv:
				plt.xlabel("corrected horizontal landing position")
			else:
				plt.xlabel("horizontal landing position")
		else:
			plt.xticks([])
		if stats:
			am = AnovaMatrix(_dm, factors = factor, dv = dv, \
				subject = pp[0])._print(maxLen=7, ret=True)
			print am
		#plt.subplot2grid((nRows,nCols), (plotCount, 1), colspan=3)
		#plt.title("Exp = %s DV = %s" % (exp, dv))
		#plt.text(0.05,0.1,am, family='monospace')
		#plt.xticks([])
		#plt.yticks([])
		#plotCount +=1
		
		if sepPlots:
			plt.savefig("%s.svg"%figName)
			plt.savefig("%s.png"%figName)
			#plt.show()
			figList.append(fig)
		
	# For experiment 004B we plot only the normalised landing position.
	# Correcting for CoG doesn't make sense here!
	
	exp = "004B"

	# Get dm:
	dm2 = getDM.getDM(exp = exp, driftCorr = True)
	
	# Only trials without contrast manipulation:
	dm2 = dm2.select("mask_side == 'control'")
	dm2 = dm2.select("corrDirection != 'correction smaller than 8'")
	
	# Only trials where variable has a value:
	dm2 = dm2.select("%s != ''"%dv)
	
	# Only on-object eye movements:
	dm2 = dm2.select('endX%sNorm < .5' % saccNr)
	dm2= dm2.select('endX%sNorm > -.5' % saccNr)
	
	if exclY:
		dm2 = dm2.select('endY%sNorm < .5' % saccNr)
		dm2= dm2.select('endY%sNorm > -.5' % saccNr)
			
	
	# Pivot matrix and stats:
	dv = "endX%sNorm" % saccNr
				 
	# Trim:
	dm2 = dm2.selectByStdDev(keys = factor + pp, dv = dv)
	
	if sepPlots:
		fig = plt.figure(figsize = (10,3))
		figName = "split by heavy side exp %s dv %s colsWithin = %s" % (exp, dv, colsWithin)
	
	else:
		plt.subplot(nRows,nCols,3)

	pm = PivotMatrix(dm2, factor, pp, dv = dv, colsWithin = colsWithin, err = 'se')
	#plt.subplot2grid((nRows,nCols), (plotCount, 0))
	
	pm.barPlot(fig = fig, _dir='right')
	plt.axvline(0, linestyle = "--", color = "#555753")
	plt.axhline(0.5, linestyle = "-", color = "#555753")
	plt.xlim(yLim)
	if sepPlots:
		plt.xlabel("horizontal landing position")
	
	else:
		plt.xticks([])
	if stats:
		am = AnovaMatrix(dm2, factors = factor, dv = dv, \
			subject = pp[0])._print(maxLen=7, ret=True)
		print am
	#plt.subplot2grid((nRows,nCols), (plotCount, 1), colspan=3)
	#plt.title("Exp = %s DV = %s" % (exp, dv))
	#plt.text(0.05,0.1,am, family='monospace')
	#plt.xticks([])
	#plt.yticks([])
	
	if sepPlots:
		plt.savefig("%s.png"%figName)
		plt.savefig("%s.svg"%figName)
		
		figList.append(fig)
		
		return figList
	else:
		plt.savefig('per corrDir.png')
		return fig
Beispiel #9
0
def allSaccLats(dm, direction, figTitle = True, trim = True, cousineau = True, nBin = 15, usePm = True, err = 'se'):
	
	"""
	Throw all saccades latencies (since stim onset) in for bin analysis, irrespective of saccade count
	
	Arguments:
	dm
	direction --- {"ToHandle", "ToContrast"}, variable on the y axis
	
	Keyword arguments:
	
	Returns fig list
	
	
	"""
	figList = []
	print '\n\tdirection = %s \n' % direction
	
	if direction == "ToHandle":
		start_dm = dm.select("contrast_side == 'control'")
	if direction == "ToContrast":
		start_dm = dm.select("contrast_side != 'control'")
	
	exp = start_dm['exp'][0]
	
	lDm = []
	
	if exp == "004A":
		# Max sacc count = 4
		lSacc = range(1,5)
	if exp == "004B":
		# Max sacc count = 3
		lSacc = range(1,4)
		
	for saccCount in lSacc:
		
		# Create dms containing all latencies (i.e., the to-be-binned variable) 
		# of a given saccade count, e.g.
		# almost all trials for the first saccade, and less and less for the
		# subsequent saccades.
		# Do the same for the landing positions (dv's on the y-axis):
		
		# Select one saccade:
		dm_sacc = dm.select("saccLat%s != ''" % str(saccCount))
		
		# Create new column containing sacc count:
		dm_sacc = dm_sacc.addField("saccNr", dtype = str)
		dm_sacc["saccNr"] = "sacc%s" % saccCount
		
		# Create new column containing IV and DV's, but without the
		# sacc count in the column header:
		dm_sacc = dm_sacc.addField("absSaccLat", dtype = float)
		dm_sacc["absSaccLat"] = dm_sacc["saccLat%s" % str(saccCount)]
		
		dm_sacc = dm_sacc.addField("abs%s" % direction, dtype = float)
		dm_sacc["abs%s" % direction] = dm_sacc["endX%sNorm%s"%(str(saccCount), direction)]
		
		dm_sacc = dm_sacc.addField("absCorr%s" % direction, dtype = float)
		dm_sacc["absCorr%s" % direction] = dm_sacc["endX%sCorrNorm%s"%(str(saccCount), direction)]
		
		# Add the dm to the list of dm's
		lDm.append(dm_sacc)

	# Combine all dm's into one big dm:
	merged_dm = lDm[0]
	
	for dm in lDm[1:]:
		merged_dm = merged_dm + dm
	
		corrList = ["corrected", "uncorrected"]
	
	for corr in corrList:
	
		fig = plt.figure(figsize = (3,7))
		title = "Landing (%s) %s as a function of ALL binned sacc lats exp %s cousineau = %s trim = %s usePm = %s" \
			% (corr, direction, exp, cousineau, trim, usePm)
			
		if figTitle:
			plt.title(title)
			
		if corr == "uncorrected":
			dv = "abs%s" % direction
		elif corr == "corrected":
			dv = "absCorr%s" % direction
			
		print "\tDV = %s\n" % dv
		
		# There should be no ''s in the dm anymore, but off-object saccades are still
		# possible, so this filtering remains necessary:
		dv_dm = onObject(merged_dm,dv)
			
		saccLat = "absSaccLat"

		# Trim the data matrix such that the most extreme latencies are excluded:
		print "\n\ttrim = %s\n" % trim
		if trim:
			trimmed_dm = dv_dm.selectByStdDev(keys = ["file"], dv = saccLat)
		else:
			trimmed_dm = dv_dm
		
		# Withinize sacc latencies, if wanted:
		print "\n\tcousineau = %s\n" % cousineau
		if cousineau:
			
			_dm = trimmed_dm.addField("cousineau_%s"%saccLat, dtype = None)
			_dm = _dm.withinize(saccLat, "cousineau_%s"%saccLat, "file", verbose = True, whiten=False)
			saccLat = "cousineau_%s"%saccLat
		else:
			_dm = dv_dm
				
		# Make bins, only for the first dv (for the second dv, the binned variable is the same and
		# therefore already exists:
		varToBin = saccLat
		binnedVar = "binnend%s" % varToBin
		binned_dm = _dm.addField(binnedVar)
		binned_dm = binned_dm.calcPerc(varToBin, binnedVar ,keys = ["file"], nBin = nBin)
		
		if not usePm:
			
			lX = []
			lY = []
			
			for _bin in binned_dm.unique(binnedVar):  
			
			# Filter out all but one bin
				dm_one_bin = binned_dm.select('%s == %f' % (binnedVar, _bin))
		
				# Get the mean sacc lat and the mean landing position (for x and y axis, respectively):
				# NOTE: withinising doesn't make any real difference for the overall pattern. 
		
				yMean = dm_one_bin[dv].mean()
				xMean = dm_one_bin[varToBin].mean()
				
				lX.append(xMean)
				lY.append(yMean)
			
			
			plt.plot(lX, lY, color = "#3465a4", marker = 'o')
			plt.xlabel("binned saccade latencies from stimulus onset")
			plt.ylabel("landing position (%s) %s" % (corr,direction))
			plt.ylim(-.2, .2)
			plt.axhline(0, color = "#555753", linestyle = "--", linewidth = 2)
			plt.savefig(os.path.join(dst,'%s.png' % title))
		
		if usePm:
			
			pm = PivotMatrix(binned_dm, binnedVar, "file", dv, colsWithin = True, err = 'se')
			#pm.plot(nLvl1=1, fig = fig, xLabel = "binned saccade latencies from stimulus onset", \
			#	yLabel = "landing position (%s) %s" % (corr,direction))
			
			pm.barPlot(fig = fig, xLabel = "binned saccade latencies from stimulus onset", \
				yLabel = "landing position (%s) %s" % (corr,direction))
			
			plt.ylim(-.2, .2)
			plt.axhline(0, color = "#555753", linestyle = "--", linewidth = 2)
			plt.savefig(os.path.join(dst,'%s.png' % title))
			
			plt.savefig(os.path.join(dst,'%s.png' % title))
			
		
		figList.append(fig)

	return figList
Beispiel #10
0
def oneFactor(dm, dv, factor, subjectID = ["file"], trim = True, 
		printStats = True, showFig=False, saveFig = True,  figName = None, 
		saveExt = ".jpg", xLabel = None, xLabels = None, yLabel = None, 
		yLim = None, exControlMask = False, exFiller = False, exMask = False):
	
	"""
	Performs and plots a one-factorial ANOVA.
	
	NOTE: The resulting plots are bar plots because 'pm.linePlot()' doesn't
	work with one factor yet.
	
	Arguments:
	dm			--- Data matrix.
	dv			--- Dependent variable.
	factor	 	--- Independent variable.
	
	Keyword arguments:
	subjectID	--- Default = ["file"]
	showFig		--- Boolean indicating whether or not to show the plots. Default 
					= False.
	saveFig		--- Boolean indicating whehter or not to save the plot. Default = 
					True.
	printStats	--- TODO Boolean indicating whether or not to print stats.
	figName	--- Will be used as suptitle and save path, of provided. 
					Default = None.
	saveExt		---
	xLabel		---
	xLabels		---
	yLabel		---
	yLim		--- 
	"""
	
	# Check whether 'factor' and 'dv' are column headers in the spread sheet:
	vNames = dm.asArray()[0]
	
	if exMask:
		dm = dm.select("mask_side == 'control'")

	
	if not factor in vNames:
		msg.userMsg.userMsg("The factor %s is not a column header."%factor,\
			__file__)
		return
	
	if not dv in vNames:
		msg.userMsg.userMsg("The dv %s is not a column header."%dv, __file__)
		return
	
	driftCorr = dm["driftCorr"][0]

	
	if exControlMask:
		dm = dm.select("mask_side != 'control'")
	
	if exFiller:
		dm = dm.select("symm == 'asymm'")

	# If wanted, trim the data:
	if trim:
		dm = dm.selectByStdDev(keys = factor + subjectID, dv = dv)

	# Get pivot matrix:
	pm = PivotMatrix(dm, factor, subjectID, dv=dv, colsWithin=True)
	
	# Get anova matrix:
	am = AnovaMatrix(dm, factors = factor, dv = dv, \
		subject = subjectID[0])
	
	stats = prettyStats(am)
		
	if printStats:
		print am
	
	# Create figure:
	fig = plt.figure()
	if figName == None:
		name = "%s effect on %s - trim = %s exControlMask = %s exFiller = %s driftCorr = %s"%(\
			factor, dv, trim, exControlMask, exFiller, driftCorr)
	else:
		name = figName
	
	plt.suptitle(stats)
	
	# Plot the effect:
	#plt.subplot(121)
	
	# Determine some plot properties:
	if yLabel == None:
		yLabel = dv
	if xLabel == None:
		xLabel = factor

	# Change the labels if one of the factors is 'mask_side':
	if factor == ["mask_side"]:
		if "control" in np.unique(dm["mask_side"]):
			xLabels = ["control", "more contrast right", "more contrast left"]
		else:
			xLabels = ["more contrast right", "more contrast left"]

	pm.barPlot(fig = fig, yLabel = yLabel, xLabel = xLabel, xLabels = xLabels, \
		yLim = yLim)
	
	if dv in ["endX", "endXCorr", "endXCorrMask", "endXDegr","endXCorrDegr", "endXCorrMaskDegr"]:
		plt.axhline(0, linestyle = "--", color = "#555753")
	
	#statSubplot(am, nRows = 1, nCols = 2, plotNr = 2)

	if showFig:
		plt.show()
		saveFig = False
	if saveFig:
		plt.savefig(os.path.join(outputFolder,"%s%s"%(name,saveExt)))
Beispiel #11
0
src = 'selected_dm_%s_WITH_drift_corr_onlyControl_False.csv' % exp
main_dm = CsvReader(src).dataMatrix()
main_dm = main_dm.select("contrast_side != 'control'")


dv = "endX1NormToContrast"
dm = main_dm.select("%s != ''" % dv)
dm = dm.selectByStdDev(["file"], dv)
dm = dm.removeField("__dummyCond__")
dm = dm.removeField("__stdOutlier__")
dm = dm.selectByStdDev(["file"], "saccLat1")

fig = plt.figure()
pm = PivotMatrix(dm, cols = ["visual_field"], \
	rows = ["file"], dv = dv, colsWithin=True)
pm.barPlot(fig = fig)

for vf in ["upper", "lower"]:
	
	_dm = dm.select("visual_field == '%s'" % vf)
	cm = _dm.collapse(["file"], dv)
	m = cm["mean"].mean()
	se = cm['mean'].std() / np.sqrt(len(cm))
	print "VISUAL FIELD = ", vf
	print "DV = ", dv
	print "M = ", m
	print "SE = ", se

plt.savefig("VF_effect.png")