-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1back.py
executable file
·66 lines (54 loc) · 2.18 KB
/
1back.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/python2
# -*- coding: utf-8 -*-
###############################################################################
# Written by: Forrest Koch ([email protected])
# Organization: Centre for Healthy Brain Ageing (UNSW)
# PyschoPy Version: 1.85.3
# Python Version: 2.7.5
###############################################################################
import os
import serial
from psychopy import core, gui, data, logging, visual, clock
from psychoblocks import const, experiment, routines
if (__name__ == '__main__'):
app = experiment.Experiment('1back')
# add routines to the app
app.addRoutine(routines.OneBackInstructions(app))
app.addRoutine(routines.CountdownSequence(app))
# build the trial sequence and add to the app
runCSV = data.importConditions('1back/runs/run1.csv')
firstBlock = True
for line in runCSV:
if firstBlock:
firstBlock = False
else:
# after each block there should be a rest block
app.addRoutine(routines.RestBlock(app, duration = 15.0))
blockCSV = data.importConditions(line['blockFile'])
# discriminate between 0 and 1 back
if (int(line['is0back']) == 1):
is0 = True
# a silly way to find the target image
targetStim = None
for trial in blockCSV:
if trial['TargetType'] == 'target':
target=os.path.join(const.DEFAULT_STIMULI_FOLDER,trial['Stimulus'])
break
app.addRoutine(routines.ZeroBackCue(app,target))
else:
is0 = False
app.addRoutine(routines.OneBackCue(app))
firstTrial = True
for trial in blockCSV:
image=os.path.join(const.DEFAULT_STIMULI_FOLDER,trial['Stimulus'])
trialRoutine = routines.NBackTrial(app,image,None)
# after each trial there should be a brief fixation
if firstTrial:
firstTrial = False
else:
app.addRoutine(routines.Fixation(app,duration = 0.5))
app.addRoutine(trialRoutine)
# ready freddy go!
app.run()
# write out the logfile
logging.flush()