Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions wordTask_psychopy/word_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# info about the screen
win = visual.Window(size = [1280,768],
color = "white",
fullscr = False,
fullscr = True, allowGUI=False,
units = "pix")

# Set up text displays
Expand Down Expand Up @@ -42,7 +42,7 @@
font = "Arial",
autoLog=True)

instruct_txt = visual.TextStim(win, text = " In this experiment you will be reading words.\n Please, read them carefully.\n Press the space bar when you are ready to continue.",
instruct_txt = visual.TextStim(win, text = " In this experiment you will be reading words.\n Please read them carefully.\n Press the button when you are ready to continue.",
pos = [0.0,0.0],
color = "black",
height = 24,
Expand All @@ -53,7 +53,7 @@
autoLog=True)

#get some startup information from the user
info = {'participant_id':'', 'session': '1'}
info = {'participant_id':'', 'session': ''}
dlg = gui.DlgFromDict(info, title = 'Word Task Startup')
if not dlg.OK:
core.quit()
Expand All @@ -66,7 +66,7 @@
#win.logonFlip(msg=' ', level=logging.DATA)
# in the data source, there are three columns: Time, StimType and Stim
# load in our stimulus timing xlsx file
TRIAL_LIST = data.importConditions(fileName = parent_dir + "RunTest.xlsx")
TRIAL_LIST = data.importConditions(fileName = parent_dir + "Run" + info['session'] + ".xlsx")
totalTrials = len(TRIAL_LIST)

def check_exit():
Expand All @@ -83,6 +83,7 @@ def check_exit():
win.flip()
#waiting for space bar to continue
keys =event.waitKeys(keyList=['space'], timeStamped=globalClock)
check_exit()
#show waiting for scanner until keypress
ScannerWait_txt.draw()
win.flip()
Expand All @@ -92,7 +93,8 @@ def check_exit():
#creating variable for flip duration
flip_duration= 21
# header for data log
data = np.hstack(("Stim","StimType","onset"))
#data = np.hstack(("Stim","StimType","onset"))
data = [0,0]
# Goal for this section: Check what time it is. If the time matches a value in the column "Time"
# then present the text display from that same row for 1.25 seconds and then go back to blank
for index in range(len(TRIAL_LIST)):
Expand Down Expand Up @@ -120,16 +122,17 @@ def check_exit():
autoLog=True)
stim.draw();
win.flip()
onset = globalClock.getTime()
logging.log("Datalog.log",level=logging.EXP)
win.logOnFlip("Datalog.log",level=logging.EXP)
onset = globalClock.getTime()
core.wait(1.25-(globalClock.getTime()-onset))
onset_tr = onset - t0
core.wait(1.0-(globalClock.getTime()-onset))
null_txt.draw()
win.flip()
onset = globalClock.getTime()
core.wait(1.25-(globalClock.getTime()-onset))
core.wait(1.5-(globalClock.getTime()-onset))
# store data into the numpy array
data = np.vstack((data, np.hstack((TRIAL_LIST[index]["Stim"],TRIAL_LIST[index]['StimType'],onset,))))# round the onset time (in seconds) to the third decimal place
data = np.vstack((data, np.hstack((TRIAL_LIST[index]['StimType'],onset_tr,))))
#clear screen
null_txt.draw()
win.flip()
Expand All @@ -141,7 +144,7 @@ def check_exit():

### SAVE DATA ###
np.savetxt(parent_dir+prefix+"_onsets.tsv",
data, fmt='%s', delimiter='\t', newline='\n',
data, fmt='%f', delimiter='\t', newline='\n',
header='', footer='', comments='# ')
# close everything
win.close()
Expand Down
Binary file modified wordTask_psychopy/word_task.pyc
Binary file not shown.