コード例 #1
0
def problem_controller(f_abs):
    if f_abs == 1:
        onset = time.time()
        ser = serial.Serial(port=0, baudrate=19200)
        ser.write('\xa0\xe0')
        x = chr(0)

        while ser.isOpen():
            x = ser.read()
            if ord(x) == 32:
                offset = time.time()
                #end signal
                RT = offset - onset
                subject.inputData(trial, "RT", RT)
                p.parameters.go_duration = (0, 'frames')
                ser.close()
コード例 #2
0
ファイル: Pre.py プロジェクト: CrossGini/OpenPsyc
def problem_controller(f_abs):
	if f_abs == 1:
		onset = time.time()
		ser = serial.Serial(port=0, baudrate=19200)
		ser.write('\xa0\xe0')
		x=chr(0)

		while ser.isOpen():
			x = ser.read()
			if ord(x) == 32:
				offset = time.time()
				#end signal
				RT = offset - onset
				subject.inputData(trial, "RT", RT)
				p.parameters.go_duration = (0, 'frames')
				ser.close()
コード例 #3
0
ファイル: Task1.py プロジェクト: unshur/OpenPsyc
def showStimulus(screen, text, colour, useLPT=True):
	word, viewport = printWord(screen, text, 200, colour)
	p = Presentation(go_duration=(stroopDuration,'seconds'),viewports=[viewport])
	
	if useLPT:
		p.go()
		start = time.clock()
		exit = 0
		while not exit:
			data = raw_lpt_module.inp(0x379) & 0x20		
			#print data
			if not data:
				#print "hello"
				RT = time.clock()
				p.parameters.go_duration = (blank, 'seconds')
				subject.inputData(trial, "text", text)
				subject.inputData(trial, "colour", colour)
				subject.inputData(trial, "RT", RT)
				exit = 1
			else:
				pass
コード例 #4
0
ファイル: Pre.py プロジェクト: CrossGini/OpenPsyc
			if n1 == n2:
				badProblem = True

			if sum(ns) > 100:
				n1 = n1 / 2
				n2 = n2 /2
				badProblem = True

			badCycles += 1
			#if we are stuck in an infinite loop
			if badCycles >= maxCycles:
				print "Breaking loop"
				badProblem = False

	subject.inputData(trial, "n1", ns[0])
	subject.inputData(trial, "n2", ns[1])
	solution = str(ns[0] + ns[1])

	random.shuffle(ns)
	ns1 = str(ns[0])
	ns2 = str(ns[1])

	problemString = "%s+%s" % (ns1, ns2)

	if len(ns1) == 1:
		ns1 = " %s" % ns1
	if len(ns2) == 1:
		ns2 = " %s" % ns2	

	problem = "   %s\n+ %s" % (ns1, ns2)
コード例 #5
0
ファイル: profiler.py プロジェクト: CrossGini/OpenPsyc
	else:
		problem = Problem([n1, n2])

	if problem:
		print phase, trial, problem

		#get problem info and data
		ns = problem.row['ns']
		n1 = ns[0]
		n2 = ns[1]
		soln = problem.row['solution']	
		lastSoln = copy.deepcopy(soln)

		#record problem operands, solution, and id
		subject.inputData(trial, "n1", n1)
		subject.inputData(trial, "n2", n2)
		subject.inputData(trial, "problem", "%s" % problem)
		subject.inputData(trial, "solution", soln)

		#prep the problem for display
		random.shuffle(ns)
		problem_string = "%s %s %s = ?" % (ns[0], operation, ns[1])

		#select the distractor
		distractor = problem.getDistractor()
		side = random.choice(['l', 'r'])
		if side == "l":
			correct = "left"
			L = str(soln)
			R = distractor
コード例 #6
0
            if n1 == n2:
                badProblem = True

            if sum(ns) > 100:
                n1 = n1 / 2
                n2 = n2 / 2
                badProblem = True

            badCycles += 1
            #if we are stuck in an infinite loop
            if badCycles >= maxCycles:
                print "Breaking loop"
                badProblem = False

    subject.inputData(trial, "n1", ns[0])
    subject.inputData(trial, "n2", ns[1])
    solution = str(ns[0] + ns[1])

    random.shuffle(ns)
    ns1 = str(ns[0])
    ns2 = str(ns[1])

    if len(ns1) == 1:
        ns1 = " %s" % ns1
    if len(ns2) == 1:
        ns2 = " %s" % ns2

    problem = "   %s\n+ %s" % (ns1, ns2)
    subject.inputData(trial, "problem", problem)
コード例 #7
0
fixText, fixCross = printText(screen, '', 60, (255, 255, 255))

print "PRESS SPACE TO START"

pause = Presentation(go_duration=('forever', ), viewports=[fixCross])
pause.parameters.handle_event_callbacks=[(pygame.locals.KEYDOWN, pause_handler)]  
pause.go()

for p in problems:
		
	n1 = p[0][0]
	n2 = p[0][1]
	problem = "%s + %s" % (n1, n2)


	subject.inputData(trial, "n1", n1)
	subject.inputData(trial, "n2", n2)
	subject.inputData(trial, "trained", p[1])
	subject.inputData(trial, "orig_strat", p[2])
	subject.inputData(trial, "problem", problem)

	#format problem
	solution = str(n1 + n2)
	print "----------------------"
	print "PROBLEM: %s" % problem
	print "SOLUTION: %s " % solution
	print "----------------------"

	ns = [n1, n2]

	#default values for misfiring voice key
コード例 #8
0
ファイル: aVer3.py プロジェクト: unshur/OpenPsyc
for dist, side, strategy in zip(dists, sides, strategies):

	if strategy == "mem":
		prob = memProblems.pop()
		trained = prob[1]
		prob = prob[0]
	elif strategy == "calc":
		prob = calcProblems.pop()
		trained = prob[1]
		prob = prob[0]

	problem = "%s + %s = ?" % (prob[0], prob[1])
	solution = str(prob[0] + prob[1])
	distractor = str(prob[0] + prob[1] + dist)
	
	subject.inputData(trial, "n1", prob[0])
	subject.inputData(trial, "n2", prob[1])
	subject.inputData(trial, "orig_strat", strategy)
	subject.inputData(trial, "distractor", distractor)
	subject.inputData(trial, "dist_side", side)
	subject.inputData(trial, "dist_offset", dist)
	subject.inputData(trial, "trained", trained)
	
	if side == "l":
		correct = "left"
		L = solution
		R = distractor
	elif side == "r":
		correct = "right"
		L = distractor
		R = solution
コード例 #9
0
    #reset state vars
    misfire = 0
    verify = 0
    problem = None
    soln = None
    orig_strat = ns[1]

    problem = Problem(ns[0])

    ns = problem.row['ns']
    n1 = ns[0]
    n2 = ns[1]
    soln = problem.row['solution']

    #record some problem info
    subject.inputData(trial, "n1", n1)
    subject.inputData(trial, "n2", n2)
    subject.inputData(trial, "problem", "%s" % problem)
    subject.inputData(trial, "solution", soln)

    random.shuffle(ns)

    lastSoln = copy.deepcopy(soln)

    problem_string = "%s + %s = ?" % (ns[0], ns[1])

    #DISTRACTOR CONFIG
    dist = random.choice(problem.row['distractors'])
    op = random.choice(["+", "-"])

    distractor = eval("%s %s %s" % (soln, op, dist))
コード例 #10
0
ファイル: Training.py プロジェクト: unshur/OpenPsyc
        if len(ns2) == 1:
            ns2 = " %s" % ns2

        problem = "   %s\n+ %s" % (ns1, ns2)
        problemString = "%s + %s" % (numbers[0], numbers[1])

        #format problem
        print "----------------------"
        print "PROBLEM: %s" % problemString
        print "SOLUTION: %s " % solution
        print "----------------------"

        expText, expPort = printText(screen, problem, fontsize,
                                     (255, 255, 255))

    subject.inputData(trial, "comparison", comparison)
    subject.inputData(trial, "n1", n1)
    subject.inputData(trial, "n2", n2)
    subject.inputData(trial, "problem", problemString)
    subject.inputData(trial, "type", stim)

    ns = [n1, n2]

    #default values for misfiring voice key
    misfire = 0
    ACC = 1

    #BLOCK 1 - Problem & RESPONSE

    p = Presentation(go_duration=('forever', ), viewports=[expPort])
    p.add_controller(
コード例 #11
0
ファイル: Mag.py プロジェクト: unshur/OpenPsyc
    p.go()

    #BLOCK 2 - STRATEGY SELECTION & GRADING
    p2 = Presentation(go_duration=(1.5, 'seconds'), viewports=[fixCross])
    p2.parameters.handle_event_callbacks = [(pygame.locals.KEYDOWN,
                                             key_handler)]
    p2.go()

    if ACC == 0:
        problemQ = [n1, n2, stim]
        error = Presentation(go_duration=(1, 'seconds'), viewports=[errorPort])
        error.go()
    else:
        problemQ = []

    subject.inputData(trial, "misfire", misfire)
    subject.inputData(trial, "ACC", ACC)

    trial = trial + 1

    subject.printData()

#save sub
subject.printData()

fileName = subject.fname
dbName = "magnitude"
tableName = "mag_pre"

reader = ReadTable(fileName=fileName,
                   dbName=dbName,
コード例 #12
0
ファイル: Mag.py プロジェクト: CrossGini/OpenPsyc
	p.add_controller(None, None, FunctionController(during_go_func=problem_controller, temporal_variables = FRAMES_ABSOLUTE))
	p.go()

	#BLOCK 2 - STRATEGY SELECTION & GRADING
	p2 = Presentation(go_duration=(1.5, 'seconds'), viewports=[fixCross])
	p2.parameters.handle_event_callbacks=[(pygame.locals.KEYDOWN, key_handler)]        
	p2.go()

	if ACC == 0:
		problemQ = [n1, n2, stim]
		error = Presentation(go_duration=(1, 'seconds'), viewports=[errorPort])
		error.go()
	else:
		problemQ = []

	subject.inputData(trial, "misfire", misfire)
	subject.inputData(trial, "ACC", ACC)

	trial = trial + 1

	subject.printData()

#save sub
subject.printData()

fileName = subject.fname
dbName = "magnitude"
tableName = "mag_pre"

reader = ReadTable(fileName = fileName, dbName=dbName, tableName = tableName, clear=False)
コード例 #13
0
            #don't want problems where both operands are the same
            if len(set(ns)) == 1:
                badProblem = True

            #don't want problem with the same solution as the last one
            if lastSoln == (n1 + n2):
                badProblem = True

            badCycles += 1
            #if we are stuck in an infinite loop
            if badCycles >= 100000:
                print "Breaking loop"
                badProblem = False

    subject.inputData(trial, "n1", ns[0])
    subject.inputData(trial, "n2", ns[1])

    random.shuffle(ns)

    problem = Problem(ns)

    lastSoln = problem.solution

    subject.inputData(trial, "problem", "%s" % problem)

    problem_string = "%s + %s = ?" % (ns[0], ns[1])

    #DISTRACTOR CONFIG
    dist = random.choice(problem.distractors)
    op = random.choice(["+", "-"])
コード例 #14
0
ファイル: VertMag.py プロジェクト: victorpitron/OpenPsyc
        n1 = p[0]
        n2 = p[1]
        symbol = "  OR  "
        solution = str(max([n1, n2]))

        # Make Rectangles and numbers
    x = screen.size[0] / 4
    y = screen.size[1] / 2

    numbers = [n1, n2]
    random.shuffle(numbers)

    problem = "%s   OR   %s" % (numbers[0], numbers[1])
    expText, expPort = printText(screen, problem, 80, (255, 255, 255))

    subject.inputData(trial, "n1", n1)
    subject.inputData(trial, "n2", n2)
    subject.inputData(trial, "problem", problem)

    # format problem
    print "----------------------"
    print "PROBLEM: %s" % problem
    print "SOLUTION: %s " % solution
    print "----------------------"

    ns = [n1, n2]

    # default values for misfiring voice key
    misfire = 0
    ACC = 1
コード例 #15
0
ファイル: Training.py プロジェクト: CrossGini/OpenPsyc
		if len(ns2) == 1:
			ns2 = " %s" % ns2	

		problem = "   %s\n+ %s" % (ns1, ns2)
		problemString = "%s + %s" % (numbers[0], numbers[1])

		#format problem
		print "----------------------"
		print "PROBLEM: %s" % problemString
		print "SOLUTION: %s " % solution
		print "----------------------"


		expText, expPort = printText(screen, problem, fontsize, (255, 255, 255))

	subject.inputData(trial, "comparison", comparison)
	subject.inputData(trial, "n1", n1)
	subject.inputData(trial, "n2", n2)
	subject.inputData(trial, "problem", problemString)
	subject.inputData(trial, "type", stim)



	ns = [n1, n2]

	#default values for misfiring voice key
	misfire = 0
	ACC = 1

	#BLOCK 1 - Problem & RESPONSE
コード例 #16
0
        n1 = p[0]
        n2 = p[1]
        symbol = "  OR  "
        solution = str(max([n1, n2]))

    #Make Rectangles and numbers
    x = screen.size[0] / 4
    y = screen.size[1] / 2

    numbers = [n1, n2]
    random.shuffle(numbers)

    problem = "%s   OR   %s" % (numbers[0], numbers[1])
    expText, expPort = printText(screen, problem, 80, (255, 255, 255))

    subject.inputData(trial, "n1", n1)
    subject.inputData(trial, "n2", n2)
    subject.inputData(trial, "problem", problem)

    #format problem
    print "----------------------"
    print "PROBLEM: %s" % problem
    print "SOLUTION: %s " % solution
    print "----------------------"

    ns = [n1, n2]

    #default values for misfiring voice key
    misfire = 0
    ACC = 1
コード例 #17
0
ファイル: StratVer.py プロジェクト: CrossGini/OpenPsyc
			#don't want problems where both operands are the same
			if len(set(ns)) == 1:
				badProblem = True

			#don't want problem with the same solution as the last one
			if lastSoln == (n1 + n2):
				badProblem = True

			badCycles += 1
			#if we are stuck in an infinite loop
			if badCycles >= 100000:
				print "Breaking loop"
				badProblem = False

	subject.inputData(trial, "n1", ns[0])
	subject.inputData(trial, "n2", ns[1])

	random.shuffle(ns)

	problem = Problem(ns)

	lastSoln = problem.solution

	subject.inputData(trial, "problem", "%s" % problem)

	problem_string = "%s + %s = ?" % (ns[0], ns[1])


	#DISTRACTOR CONFIG
	dist = random.choice(problem.distractors)