Пример #1
0
def windowPlot(dm, standalone=True, color=blue[1], label=None):

    """
	desc:
		Creates a graph in which the effect of pupil size on saliency is shown
		separately for each temporal displacement. I.e. the effect of pupil size
		on trial N on saliency on trial N+1, etc.

	arguments:
		dm:
			type:	DataMatrix

	keywords:
		standalone:
			desc:	Indicates whether this is a standalone plot, in which case
					it will create and save the plot, or not.
			type:	bool
		color:
			desc:	Plot color.
			type:	[str, unicode]
		label:
			desc:	Line label.
			type:	[str, unicode]
	"""

    if standalone:
        Plot.new(widePlot)
    dm = dm.intertrialer(["file", "trialId", "saccNr"], "salFrom", _range=windowRange)
    xData = []
    yData = []
    eData = []
    for r in windowRange:
        if r == 0:
            _dv = "salFrom"
        elif r < 0:
            _dv = "salFrom_m%d" % (-1 * r)
        else:
            _dv = "salFrom_p%d" % r
        print "dv = %s" % _dv
        s, t, lo, up = stats.effectSlope(dm, dv=_dv)
        print s
        xData.append(r)
        yData.append(s)
        eData.append([lo, up])
    xData = np.array(xData)
    yData = np.array(yData)
    eData = np.array(eData)
    plt.fill_between(xData, eData[:, 0], eData[:, 1], color=color, alpha=0.1)
    plt.plot(windowRange, yData, "o-", color=color, label=label)
    plt.axhline(linestyle="--", color="black")
    plt.xlabel("Pupil-size timepoint relative to saliency timepoint")
    plt.xticks(windowRange)
    plt.xlim(windowRange[0], windowRange[-1])
    plt.ylabel("Partial slope")
    plt.yticks(slopeTicks[exp])
    plt.ylim(slopeLim[exp])
    if standalone:
        Plot.save("windowPlot", folder=exp, show=show)
Пример #2
0
def exp2InstructionPlot(dm):

	"""
	desc:
		Plots the effect of pupil size on saliency for different task
		instructions.

	arguments:
		dm:
			type:	DataMatrix
	"""

	assert(exp == 'exp2')
	Plot.new(size=smallPlot)
	for color, fmt, sceneType in [(fractalCol, 'o-', 'fractal'),
		(sceneCol, 's:', 'scene')]:
		lSlope = []
		if sceneType == 'fractal':
			x = -.1
		else:
			x = .1
		lX = []
		for inst in ['free', 'search', 'memory']:
			lX.append(x)
			_dm = dm.select('inst == "%s"' % inst).select(
				'sceneType == "%s"' % sceneType)
			s, t, lo, up = stats.effectSlope(_dm)
			lSlope.append(s)
			plt.plot([x, x], [lo, up], '-', color=color)
			x += 1
		plt.plot(lX, lSlope, fmt, color=color, label=sceneType.capitalize()+'s')
	plt.xticks(range(0,3), ['Free', 'Search', 'Memory'])
	plt.yticks([0, 2, 4, 6])
	plt.ylabel('Partial slope')
	plt.xlabel('Task')
	plt.xlim(-.5, 2.5)
	plt.ylim(slopeLim)
	plt.axhline(0, color='black', linestyle='--')
	plt.legend(frameon=False, loc='upper left')
	Plot.save('instructionPlot', folder=exp, show=show)
Пример #3
0
def saccadePlot(dm, standalone=True, color=blue[1], label=None):

    """
	desc:
		Creates a graph in which the effect of pupil size on saliency is shown
		separately for each saccade in a trial.

	arguments:
		dm:
			desc:	Data
			type:

	keywords:
		standalone:
			desc:	Indicates whether this is a standalone plot, in which case
					it will create and save the plot, or not.
			type:	bool
		color:
			desc:	Plot color.
			type:	[str, unicode]
		label:
			desc:	Line label.
			type:	[str, unicode]
	"""

    if standalone:
        Plot.new(size=widePlot)
    xData = []
    yData = []
    eData = []
    for saccNr in [None] + range(1, maxSacc + 1):
        if saccNr == None:
            _dm = dm
        else:
            _dm = dm.select("saccNr == %d" % saccNr)
        s, p, lo, up = stats.effectSlope(_dm)
        if saccNr == None:
            if standalone:
                x = -1
            elif exp == "exp1":
                x = -1.2
            else:
                x = -0.8
            plt.errorbar(x, s, yerr=[[s - lo], [up - s]], capsize=0, fmt="o-", color=color)
        else:
            xData.append(saccNr)
            yData.append(s)
            eData.append([lo, up])
    xData = np.array(xData)
    yData = np.array(yData)
    eData = np.array(eData)
    plt.fill_between(xData, eData[:, 0], eData[:, 1], color=color, alpha=0.1)
    plt.plot(xData, yData, "o-", color=color, label=label)
    plt.axhline(0, linestyle="--", color="black")
    plt.xlabel("Saccade number")
    plt.xlim(-2, maxSacc + 1)
    plt.xticks([-1] + range(1, 21), ["Full"] + range(1, 21))
    plt.ylabel("Partial slope")
    plt.yticks(slopeTicks[exp])
    plt.ylim(slopeLim[exp])
    if standalone:
        Plot.save("saccadePlot", folder=exp, show=show)