Ejemplo n.º 1
0
def correct1(dm):

    return srs.baseline(dm.y,
                        dm.y,
                        BASELINE[0],
                        BASELINE[1],
                        reduce_fnc=REDUCEFNC)
Ejemplo n.º 2
0
def preprocess(dm):

    """
	desc:
		Performs pupil preprocessing, and removes trials where pupil size was
		unrealistic.
	"""

    dm.pupil = series.blinkreconstruct(dm.ptrace_target)
    dm.pupil.depth = 3000
    dm.pupil = series.smooth(dm.pupil, winlen=51)
    dm.pupil = series.baseline(dm.pupil, dm.pupil, 0, 1)
    # Remove all trials where pupil size has unrealistic values
    dm.pupilmax = FloatColumn
    dm.pupilmin = FloatColumn
    for row in dm:
        row.pupilmin = min(row.pupil)
        row.pupilmax = max(row.pupil)
    plot.new()
    # plot.histogram(dm.pupilmin, bins=100, range=(0, 5), color=red[1], alpha=.5)
    # plot.histogram(dm.pupilmax, bins=100, range=(0, 5), color=green[1], alpha=.5)
    plt.hist(dm.pupilmin, bins=100, range=(0, 5), color=red[1], alpha=0.5)
    plt.hist(dm.pupilmax, bins=100, range=(0, 5), color=green[1], alpha=0.5)
    l0 = len(dm)
    dm = (dm.pupilmin > PUPILRANGE[0]) & (dm.pupilmax < PUPILRANGE[1])
    l1 = len(dm)
    s = "%d of %d unrealistic values" % (l0 - l1, l0)
    plt.title(s)
    plot.save("pupil-peaks")
    print(s)
    return dm
def test_baseline():

    dm = DataMatrix(length=2)
    dm.series = SeriesColumn(depth=3)
    dm.series[0] = range(3)
    dm.series[1] = range(1, 4)
    dm.baseline = SeriesColumn(depth=3)
    dm.baseline[0] = range(1, 4)
    dm.baseline[1] = range(3)
    dm.norm = series.baseline(dm.series, dm.baseline)
    check_series(dm.norm, [[-2, -1, 0], [0, 1, 2]])
    check_integrity(dm)
Ejemplo n.º 4
0
def preprocess(dm):

	"""
	desc:
		Do basic data preprocessing.

	arguments:
		dm:
			type: DataMatrix

	returns:
		type:	DataMatrix
	"""

	dm.pupil.depth = 540
	dm.pupil = series.baseline(dm.pupil, baseline=dm.pupil, bl_start=50,
		bl_end=90)
	dm.pupil = series.smooth(dm.pupil, winlen=11)
	dm.rename('snelheid', 'velocity')
	dm.log_velocity = np.log10(dm.velocity)
	return dm
Ejemplo n.º 5
0
    run.clear()
else: 
    if os.path.isdir(path + "/.memoize/"):
        print("Using existing parsed data (unless new files have been added).")
    else: print("No existing directory with parsed data! Parsing files, this will take some time...")

dm = run()
print(dm)

# Here we set up the baseline to remove NaN values
dm.pupil = srs.endlock(dm.ptrace_rsvp) 

dm.pupil = srs.baseline(
    series= dm.pupil,
    baseline=dm.ptrace_rsvp,
    bl_start=0,
    bl_end=2,
    method='subtractive'
)

# Splitting datamatrix between the two type of stimuli
blueDM, redDM = ops.split(dm.target_object, "blue", "red")

# Plot for preprocessed trace
plt.figure()
plt.title('Preprocesed trace')
for tone, cdm in ops.split(redDM.tone_red):
    colour = "#FF3333" if tone == "bright" else "#8B0000"
    plot.trace(cdm.pupil, color=colour)
    
for tone, cdm in ops.split(blueDM.tone_blue):