Пример #1
0
def drawAnswerKey(trialdata):
    xspace = 1024 / len(acceptedkeys)
    for i in range(0, len(acceptedkeys)):
        ridx = trialdata['SRmap_%d' % i]
        drawer.drawThumb(i, ((ridx + 0.5) * xspace - 1024 / 2, 360))
        drawer.writeText('%d (%s)' % ((ridx + 1), acceptedkeys[ridx]),
                         ((ridx + 0.5) * xspace - 20, 680), fgcol)
Пример #2
0
def showFeedback(fbtext, delay):
    drawer.fillScreen((0, 0, 0))
    for i in range(0, len(fbtext)):
        drawer.writeText(fbtext[i], (5, 100 + 30 * i))
    if delay == 0:
        drawer.writeText('Press any button to continue',
                         (5, 100 + 30 * len(fbtext)))
        drawer.flip()
        waitforkey()
    else:
        drawer.writeText('Waiting %d miliseconds...' % delay,
                         (5, 100 + 30 * len(fbtext)))
        drawer.flip()
        time.sleep(delay / 1000)
        drawer.writeText('Press any button to continue',
                         (5, 100 + 30 * (len(fbtext) + 1)))
        drawer.flip()
        waitforkey()
Пример #3
0
def oneTrial(trialdata):
    # clear events
    trialtimer = timer.Timer()
    found = processEvents(pygame.event.get(), (None, ))
    if -999 in found:
        quit()

    if trialdata['condition'] == 'E+' or trialdata['condition'] == 'E-':
        trialdata['ms-prestimblank'] = 1000
        trialdata['ms-precue'] = 1000
    else:
        trialdata['ms-prestimblank'] = 2000
        trialdata['ms-precue'] = 0

    trialdata['curstim'] = random.sample([0, 1, 2, 3, 4, 5], 1)[0]
    trialdata['correct_response'] = trialdata['SRmap_%d' %
                                              trialdata['curstim']]

    # draw initial fixation / blank screen
    drawer.fillScreen((255, 255, 255))
    drawer.drawFixation((0, 0), [0, 0, 0])
    drawer.flip()
    trialtimer.start()

    # blank screen
    drawer.fillScreen((255, 255, 255))
    drawer.drawFixation((0, 0), [0, 0, 0])
    drawer.flip()
    trialtimer.record('cueblank')
    trialtimer.record('precue')
    time.sleep(trialdata['ms-prestimblank'] / 1000)

    if trialdata['condition'] == 'E+' or trialdata['condition'] == 'E-':
        # display pre-cue
        drawer.fillScreen((255, 255, 255))
        curletter = acceptedkeys[trialdata['SRmap_%d' % trialdata['curstim']]]
        drawer.writeText('prepare to make response %s' % curletter, (300, 600),
                         (0, 0, 0))
        drawer.flip()
        trialtimer.record('precue')
        time.sleep(trialdata['ms-precue'] / 1000)

    # blank screen
    drawer.fillScreen((255, 255, 255))
    drawer.drawImage(trialdata['curstim'], (0, 0))
    drawer.flip()
    trialtimer.record('stimon')

    response = waitforresp(acceptedkeys)
    trialtimer.record('response')

    trialdata['RT'] = trialtimer.getreltime('response', 'stimon') * 1000

    if response == -999:
        quit()
    elif trialdata['correct_response'] == response:
        trialdata['response'] = response
        trialdata['correct'] = 1
        feedbacktext = [
            'Correct!',
            'Your response time was %d milliseconds' % int(trialdata['RT']),
            'Go as fast as you can!'
        ]
        delay = 0
    else:
        trialdata['response'] = response
        trialdata['correct'] = 0
        feedbacktext = [
            'Wrong.',
            'The correct response was %s' %
            int(acceptedkeys[trialdata['correct_response']]),
            'Make sure to hit the right button.'
        ]
        delay = 3000

    time.sleep(1)

    showFeedback(feedbacktext, delay)

    return trialdata
Пример #4
0
def showFeedback(fbtext, xstart=5, ystart=100):
	drawer.fillScreen((0,0,0))
	for i in range(0,len(fbtext)):
		drawer.writeText(fbtext[i], (xstart,ystart+30*i))
	drawer.flip()
	waitforkey()
Пример #5
0
def oneTrial(trialdata):
	# clear events
	trialtimer = timer.Timer()
	found = processEvents(pygame.event.get(), (None,))
	if -999 in found:
		quit()
	
	if trialdata['type']=='train' and (trialdata['condition']=='E+' or trialdata['condition']=='E-'):
		trialdata['ms-prestimblank'] = 600
		trialdata['ms-precue'] = 400
	elif trialdata['type']=='train' and (trialdata['condition']=='M'):
		trialdata['ms-prestimblank'] = 1000
		trialdata['ms-precue'] = 0
	else:
		trialdata['ms-prestimblank'] = 1000
		trialdata['ms-precue'] = 0
	
	trialdata['curstim'] = random.sample([0,1,2,3,4,5],1)[0]
	trialdata['correct_response'] = trialdata['SRmap_%d'%trialdata['curstim']]
	
	# draw initial fixation / blank screen
	drawer.fillScreen(bgcol)
	drawer.drawFixation((0,0), fgcol)
	drawer.flip()
	trialtimer.start()
	
	# blank screen
	drawer.fillScreen(bgcol)
	drawer.drawFixation((0,0), fgcol)
	drawer.flip()
	trialtimer.record('cueblank')
	trialtimer.record('precue')
	time.sleep(trialdata['ms-prestimblank']/1000)
	
	drawer.fillScreen(bgcol)
	if trialdata['condition']=='E+' or trialdata['condition']=='E-' or trialdata['condition']=='M':
		# display pre-cue
		curletter = acceptedkeys[trialdata['SRmap_%d'%trialdata['curstim']]]
		print trialdata['correct_response']
		print trialdata['correct_response']+1
		drawer.writeText('Button: %d ...'%(trialdata['correct_response']+1), (400,450), fgcol)
		drawer.flip()
		trialtimer.record('precue')
		time.sleep(trialdata['ms-precue']/1000)
	
	found = processEvents(pygame.event.get(), (None,))
	if -999 in found:
		quit()
	# blank screen
	if trialdata['condition'] != 'M':
		drawer.drawImage(trialdata['curstim'], (0,0))
		drawAnswerKey(trialdata)
		drawer.flip()
	
	trialtimer.record('stimon')
	
	response = waitforresp(acceptedkeys)
	trialtimer.record('response')
	
	trialdata['RT'] = trialtimer.getreltime('response', 'stimon')*1000
	
	if response == -999:
		quit()
	elif trialdata['correct_response'] == response:
		trialdata['response'] = response
		trialdata['correct'] = 1
		drawer.writeText('Correct!', (fbsx,fbsy+fbiy*0), corcol)
		drawer.writeText('Your response time was %d milliseconds'%int(trialdata['RT']), (fbsx,fbsy+fbiy*1), corcol)
		drawer.writeText('Go as fast as you can!', (fbsx,fbsy+fbiy*2), corcol)
		drawer.flip()
		time.sleep(1)
		
		found = processEvents(pygame.event.get(), (None,))
		if -999 in found:
			quit()
		drawer.writeText('Press any button to continue', (fbsx,fbsy+fbiy*3), corcol)
		drawer.flip
		waitforkey()
		
	else:
		trialdata['response'] = response
		trialdata['correct'] = 0
		drawer.writeText('Wrong button!', (fbsx,fbsy+fbiy*0), wrocol)
		drawer.writeText('Make sure to make the correct response', (fbsx,fbsy+fbiy*2), wrocol)
		drawer.flip()
		time.sleep(3)
		
		found = processEvents(pygame.event.get(), (None,))
		if -999 in found:
			quit()
		drawer.writeText('Press any button to continue', (fbsx,fbsy+fbiy*3), wrocol)
		drawer.flip
		waitforkey()
	
	return trialdata
Пример #6
0
def showFeedback(fbtext, delay):
	# drawer.fillScreen(bgcol)
	for i in range(0,len(fbtext)):
		drawer.writeText(fbtext[i], (textsx,textsy+textiy*i), fgcol)
	drawer.flip()
	waitforkey()
def showFeedback(fbtext, xstart=5, ystart=100):
    drawer.fillScreen((0, 0, 0))
    for i in range(0, len(fbtext)):
        drawer.writeText(fbtext[i], (xstart, ystart + 30 * i))
    drawer.flip()
    waitforkey()