Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Reverse Digit Span Task
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NeMo
Reverse Digit Span Task
Commits
78c67b4d
Commit
78c67b4d
authored
5 years ago
by
Tibor Auer
Browse files
Options
Downloads
Patches
Plain Diff
INITIAL test
parent
41a88977
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rds_task.psyexp
+122
-0
122 additions, 0 deletions
rds_task.psyexp
rds_task_lastrun.py
+315
-0
315 additions, 0 deletions
rds_task_lastrun.py
with
437 additions
and
0 deletions
rds_task.psyexp
0 → 100644
+
122
−
0
View file @
78c67b4d
<?xml version="1.0" ?>
<PsychoPy2experiment
encoding=
"utf-8"
version=
"3.2.0"
>
<Settings>
<Param
name=
"Audio latency priority"
updates=
"None"
val=
"use prefs"
valType=
"str"
/>
<Param
name=
"Audio lib"
updates=
"None"
val=
"use prefs"
valType=
"str"
/>
<Param
name=
"Completed URL"
updates=
"None"
val=
""
valType=
"str"
/>
<Param
name=
"Data filename"
updates=
"None"
val=
"u'data/%s_%s_%s' % (expInfo['participant'], expName, expInfo['date'])"
valType=
"code"
/>
<Param
name=
"Enable Escape"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"Experiment info"
updates=
"None"
val=
"{'participant': '', 'session': '001'}"
valType=
"code"
/>
<Param
name=
"Force stereo"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"Full-screen window"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"HTML path"
updates=
"None"
val=
"html"
valType=
"str"
/>
<Param
name=
"Incomplete URL"
updates=
"None"
val=
""
valType=
"str"
/>
<Param
name=
"JS libs"
updates=
"None"
val=
"packaged"
valType=
"str"
/>
<Param
name=
"Monitor"
updates=
"None"
val=
"testMonitor"
valType=
"str"
/>
<Param
name=
"Save csv file"
updates=
"None"
val=
"False"
valType=
"bool"
/>
<Param
name=
"Save excel file"
updates=
"None"
val=
"False"
valType=
"bool"
/>
<Param
name=
"Save log file"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"Save psydat file"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"Save wide csv file"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"Screen"
updates=
"None"
val=
"1"
valType=
"num"
/>
<Param
name=
"Show info dlg"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"Show mouse"
updates=
"None"
val=
"False"
valType=
"bool"
/>
<Param
name=
"Units"
updates=
"None"
val=
"deg"
valType=
"str"
/>
<Param
name=
"Use version"
updates=
"None"
val=
""
valType=
"str"
/>
<Param
name=
"Window size (pixels)"
updates=
"None"
val=
"[1920, 1080]"
valType=
"code"
/>
<Param
name=
"blendMode"
updates=
"None"
val=
"avg"
valType=
"str"
/>
<Param
name=
"color"
updates=
"None"
val=
"$[0,0,0]"
valType=
"str"
/>
<Param
name=
"colorSpace"
updates=
"None"
val=
"rgb"
valType=
"str"
/>
<Param
name=
"expName"
updates=
"None"
val=
"rds_task"
valType=
"str"
/>
<Param
name=
"exportHTML"
updates=
"None"
val=
"on Sync"
valType=
"str"
/>
<Param
name=
"logging level"
updates=
"None"
val=
"exp"
valType=
"code"
/>
</Settings>
<Routines>
<Routine
name=
"trial"
>
<TextComponent
name=
"digits"
>
<Param
name=
"color"
updates=
"constant"
val=
"white"
valType=
"str"
/>
<Param
name=
"colorSpace"
updates=
"constant"
val=
"rgb"
valType=
"str"
/>
<Param
name=
"disabled"
updates=
"None"
val=
"False"
valType=
"bool"
/>
<Param
name=
"durationEstim"
updates=
"None"
val=
""
valType=
"code"
/>
<Param
name=
"flip"
updates=
"constant"
val=
""
valType=
"str"
/>
<Param
name=
"font"
updates=
"constant"
val=
"Arial"
valType=
"str"
/>
<Param
name=
"languageStyle"
updates=
"None"
val=
"LTR"
valType=
"str"
/>
<Param
name=
"letterHeight"
updates=
"constant"
val=
"2.5"
valType=
"code"
/>
<Param
name=
"name"
updates=
"None"
val=
"digits"
valType=
"code"
/>
<Param
name=
"opacity"
updates=
"constant"
val=
"1"
valType=
"code"
/>
<Param
name=
"ori"
updates=
"constant"
val=
"0"
valType=
"code"
/>
<Param
name=
"pos"
updates=
"constant"
val=
"(0, 0)"
valType=
"code"
/>
<Param
name=
"saveStartStop"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"startEstim"
updates=
"None"
val=
""
valType=
"code"
/>
<Param
name=
"startType"
updates=
"None"
val=
"time (s)"
valType=
"str"
/>
<Param
name=
"startVal"
updates=
"None"
val=
"1"
valType=
"code"
/>
<Param
name=
"stopType"
updates=
"None"
val=
"duration (s)"
valType=
"str"
/>
<Param
name=
"stopVal"
updates=
"constant"
val=
"1.0"
valType=
"code"
/>
<Param
name=
"syncScreenRefresh"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"text"
updates=
"constant"
val=
"3"
valType=
"str"
/>
<Param
name=
"units"
updates=
"None"
val=
"from exp settings"
valType=
"str"
/>
<Param
name=
"wrapWidth"
updates=
"constant"
val=
""
valType=
"code"
/>
</TextComponent>
</Routine>
<Routine
name=
"Instruction"
>
<TextComponent
name=
"instruction"
>
<Param
name=
"color"
updates=
"constant"
val=
"white"
valType=
"str"
/>
<Param
name=
"colorSpace"
updates=
"constant"
val=
"rgb"
valType=
"str"
/>
<Param
name=
"disabled"
updates=
"None"
val=
"False"
valType=
"bool"
/>
<Param
name=
"durationEstim"
updates=
"None"
val=
""
valType=
"code"
/>
<Param
name=
"flip"
updates=
"constant"
val=
""
valType=
"str"
/>
<Param
name=
"font"
updates=
"constant"
val=
"Arial"
valType=
"str"
/>
<Param
name=
"languageStyle"
updates=
"None"
val=
"LTR"
valType=
"str"
/>
<Param
name=
"letterHeight"
updates=
"constant"
val=
"2.5"
valType=
"code"
/>
<Param
name=
"name"
updates=
"None"
val=
"instruction"
valType=
"code"
/>
<Param
name=
"opacity"
updates=
"constant"
val=
"1"
valType=
"code"
/>
<Param
name=
"ori"
updates=
"constant"
val=
"0"
valType=
"code"
/>
<Param
name=
"pos"
updates=
"constant"
val=
"(0, 0)"
valType=
"code"
/>
<Param
name=
"saveStartStop"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"startEstim"
updates=
"None"
val=
""
valType=
"code"
/>
<Param
name=
"startType"
updates=
"None"
val=
"time (s)"
valType=
"str"
/>
<Param
name=
"startVal"
updates=
"None"
val=
"0.0"
valType=
"code"
/>
<Param
name=
"stopType"
updates=
"None"
val=
"condition"
valType=
"str"
/>
<Param
name=
"stopVal"
updates=
"constant"
val=
"False"
valType=
"code"
/>
<Param
name=
"syncScreenRefresh"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"text"
updates=
"constant"
val=
"Press SPACE to start"
valType=
"str"
/>
<Param
name=
"units"
updates=
"None"
val=
"from exp settings"
valType=
"str"
/>
<Param
name=
"wrapWidth"
updates=
"constant"
val=
""
valType=
"code"
/>
</TextComponent>
<KeyboardComponent
name=
"key_start"
>
<Param
name=
"allowedKeys"
updates=
"constant"
val=
"'space'"
valType=
"code"
/>
<Param
name=
"correctAns"
updates=
"constant"
val=
""
valType=
"str"
/>
<Param
name=
"disabled"
updates=
"None"
val=
"False"
valType=
"bool"
/>
<Param
name=
"discard previous"
updates=
"constant"
val=
"True"
valType=
"bool"
/>
<Param
name=
"durationEstim"
updates=
"None"
val=
""
valType=
"code"
/>
<Param
name=
"forceEndRoutine"
updates=
"constant"
val=
"True"
valType=
"bool"
/>
<Param
name=
"name"
updates=
"None"
val=
"key_start"
valType=
"code"
/>
<Param
name=
"saveStartStop"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"startEstim"
updates=
"None"
val=
""
valType=
"code"
/>
<Param
name=
"startType"
updates=
"None"
val=
"time (s)"
valType=
"str"
/>
<Param
name=
"startVal"
updates=
"None"
val=
"0.0"
valType=
"code"
/>
<Param
name=
"stopType"
updates=
"None"
val=
"duration (s)"
valType=
"str"
/>
<Param
name=
"stopVal"
updates=
"constant"
val=
""
valType=
"code"
/>
<Param
name=
"store"
updates=
"constant"
val=
"last key"
valType=
"str"
/>
<Param
name=
"storeCorrect"
updates=
"constant"
val=
"False"
valType=
"bool"
/>
<Param
name=
"syncScreenRefresh"
updates=
"constant"
val=
"True"
valType=
"bool"
/>
</KeyboardComponent>
</Routine>
</Routines>
<Flow>
<Routine
name=
"Instruction"
/>
<LoopInitiator
loopType=
"TrialHandler"
name=
"trials"
>
<Param
name=
"Selected rows"
updates=
"None"
val=
""
valType=
"str"
/>
<Param
name=
"conditions"
updates=
"None"
val=
"None"
valType=
"str"
/>
<Param
name=
"conditionsFile"
updates=
"None"
val=
""
valType=
"str"
/>
<Param
name=
"endPoints"
updates=
"None"
val=
"[0, 1]"
valType=
"num"
/>
<Param
name=
"isTrials"
updates=
"None"
val=
"True"
valType=
"bool"
/>
<Param
name=
"loopType"
updates=
"None"
val=
"sequential"
valType=
"str"
/>
<Param
name=
"nReps"
updates=
"None"
val=
"20"
valType=
"code"
/>
<Param
name=
"name"
updates=
"None"
val=
"trials"
valType=
"code"
/>
<Param
name=
"random seed"
updates=
"None"
val=
""
valType=
"code"
/>
</LoopInitiator>
<Routine
name=
"trial"
/>
<LoopTerminator
name=
"trials"
/>
</Flow>
</PsychoPy2experiment>
This diff is collapsed.
Click to expand it.
rds_task_lastrun.py
0 → 100644
+
315
−
0
View file @
78c67b4d
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This experiment was created using PsychoPy3 Experiment Builder (v3.2.0),
on November 04, 2019, at 16:17
If you publish work using this script the most relevant publication is:
Peirce J, Gray JR, Simpson S, MacAskill M, Höchenberger R, Sogo H, Kastman E, Lindeløv JK. (2019)
PsychoPy2: Experiments in behavior made easy Behav Res 51: 195.
https://doi.org/10.3758/s13428-018-01193-y
"""
from
__future__
import
absolute_import
,
division
from
psychopy
import
locale_setup
from
psychopy
import
prefs
from
psychopy
import
sound
,
gui
,
visual
,
core
,
data
,
event
,
logging
,
clock
from
psychopy.constants
import
(
NOT_STARTED
,
STARTED
,
PLAYING
,
PAUSED
,
STOPPED
,
FINISHED
,
PRESSED
,
RELEASED
,
FOREVER
)
import
numpy
as
np
# whole numpy lib is available, prepend 'np.'
from
numpy
import
(
sin
,
cos
,
tan
,
log
,
log10
,
pi
,
average
,
sqrt
,
std
,
deg2rad
,
rad2deg
,
linspace
,
asarray
)
from
numpy.random
import
random
,
randint
,
normal
,
shuffle
import
os
# handy system and path functions
import
sys
# to get file system encoding
from
psychopy.hardware
import
keyboard
# Ensure that relative paths start from the same directory as this script
_thisDir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
os
.
chdir
(
_thisDir
)
# Store info about the experiment session
psychopyVersion
=
'
3.2.0
'
expName
=
'
rds_task
'
# from the Builder filename that created this script
expInfo
=
{
'
participant
'
:
''
,
'
session
'
:
'
001
'
}
dlg
=
gui
.
DlgFromDict
(
dictionary
=
expInfo
,
sortKeys
=
False
,
title
=
expName
)
if
dlg
.
OK
==
False
:
core
.
quit
()
# user pressed cancel
expInfo
[
'
date
'
]
=
data
.
getDateStr
()
# add a simple timestamp
expInfo
[
'
expName
'
]
=
expName
expInfo
[
'
psychopyVersion
'
]
=
psychopyVersion
# Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc
filename
=
_thisDir
+
os
.
sep
+
u
'
data/%s_%s_%s
'
%
(
expInfo
[
'
participant
'
],
expName
,
expInfo
[
'
date
'
])
# An ExperimentHandler isn't essential but helps with data saving
thisExp
=
data
.
ExperimentHandler
(
name
=
expName
,
version
=
''
,
extraInfo
=
expInfo
,
runtimeInfo
=
None
,
originPath
=
'
D:
\\
Projects
\\
reverse-digit-span-task
\\
rds_task_lastrun.py
'
,
savePickle
=
True
,
saveWideText
=
True
,
dataFileName
=
filename
)
# save a log file for detail verbose info
logFile
=
logging
.
LogFile
(
filename
+
'
.log
'
,
level
=
logging
.
EXP
)
logging
.
console
.
setLevel
(
logging
.
WARNING
)
# this outputs to the screen, not a file
endExpNow
=
False
# flag for 'escape' or other condition => quit the exp
frameTolerance
=
0.001
# how close to onset before 'same' frame
# Start Code - component code to be run before the window creation
# Setup the Window
win
=
visual
.
Window
(
size
=
[
1920
,
1080
],
fullscr
=
True
,
screen
=
0
,
winType
=
'
pyglet
'
,
allowGUI
=
False
,
allowStencil
=
False
,
monitor
=
'
testMonitor
'
,
color
=
[
0
,
0
,
0
],
colorSpace
=
'
rgb
'
,
blendMode
=
'
avg
'
,
useFBO
=
True
,
units
=
'
deg
'
)
# store frame rate of monitor if we can measure it
expInfo
[
'
frameRate
'
]
=
win
.
getActualFrameRate
()
if
expInfo
[
'
frameRate
'
]
!=
None
:
frameDur
=
1.0
/
round
(
expInfo
[
'
frameRate
'
])
else
:
frameDur
=
1.0
/
60.0
# could not measure, so guess
# create a default keyboard (e.g. to check for escape)
defaultKeyboard
=
keyboard
.
Keyboard
()
# Initialize components for Routine "Instruction"
InstructionClock
=
core
.
Clock
()
instruction
=
visual
.
TextStim
(
win
=
win
,
name
=
'
instruction
'
,
text
=
'
Press SPACE to start
'
,
font
=
'
Arial
'
,
pos
=
(
0
,
0
),
height
=
2.5
,
wrapWidth
=
None
,
ori
=
0
,
color
=
'
white
'
,
colorSpace
=
'
rgb
'
,
opacity
=
1
,
languageStyle
=
'
LTR
'
,
depth
=
0.0
);
key_start
=
keyboard
.
Keyboard
()
# Initialize components for Routine "trial"
trialClock
=
core
.
Clock
()
digits
=
visual
.
TextStim
(
win
=
win
,
name
=
'
digits
'
,
text
=
'
3
'
,
font
=
'
Arial
'
,
pos
=
(
0
,
0
),
height
=
2.5
,
wrapWidth
=
None
,
ori
=
0
,
color
=
'
white
'
,
colorSpace
=
'
rgb
'
,
opacity
=
1
,
languageStyle
=
'
LTR
'
,
depth
=
0.0
);
# Create some handy timers
globalClock
=
core
.
Clock
()
# to track the time since experiment started
routineTimer
=
core
.
CountdownTimer
()
# to track time remaining of each (non-slip) routine
# ------Prepare to start Routine "Instruction"-------
# update component parameters for each repeat
key_start
.
keys
=
[]
key_start
.
rt
=
[]
# keep track of which components have finished
InstructionComponents
=
[
instruction
,
key_start
]
for
thisComponent
in
InstructionComponents
:
thisComponent
.
tStart
=
None
thisComponent
.
tStop
=
None
thisComponent
.
tStartRefresh
=
None
thisComponent
.
tStopRefresh
=
None
if
hasattr
(
thisComponent
,
'
status
'
):
thisComponent
.
status
=
NOT_STARTED
# reset timers
t
=
0
_timeToFirstFrame
=
win
.
getFutureFlipTime
(
clock
=
"
now
"
)
InstructionClock
.
reset
(
-
_timeToFirstFrame
)
# t0 is time of first possible flip
frameN
=
-
1
continueRoutine
=
True
# -------Run Routine "Instruction"-------
while
continueRoutine
:
# get current time
t
=
InstructionClock
.
getTime
()
tThisFlip
=
win
.
getFutureFlipTime
(
clock
=
InstructionClock
)
tThisFlipGlobal
=
win
.
getFutureFlipTime
(
clock
=
None
)
frameN
=
frameN
+
1
# number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *instruction* updates
if
instruction
.
status
==
NOT_STARTED
and
tThisFlip
>=
0.0
-
frameTolerance
:
# keep track of start time/frame for later
instruction
.
frameNStart
=
frameN
# exact frame index
instruction
.
tStart
=
t
# local t and not account for scr refresh
instruction
.
tStartRefresh
=
tThisFlipGlobal
# on global time
win
.
timeOnFlip
(
instruction
,
'
tStartRefresh
'
)
# time at next scr refresh
instruction
.
setAutoDraw
(
True
)
if
instruction
.
status
==
STARTED
:
if
bool
(
False
):
# keep track of stop time/frame for later
instruction
.
tStop
=
t
# not accounting for scr refresh
instruction
.
frameNStop
=
frameN
# exact frame index
win
.
timeOnFlip
(
instruction
,
'
tStopRefresh
'
)
# time at next scr refresh
instruction
.
setAutoDraw
(
False
)
# *key_start* updates
waitOnFlip
=
False
if
key_start
.
status
==
NOT_STARTED
and
tThisFlip
>=
0.0
-
frameTolerance
:
# keep track of start time/frame for later
key_start
.
frameNStart
=
frameN
# exact frame index
key_start
.
tStart
=
t
# local t and not account for scr refresh
key_start
.
tStartRefresh
=
tThisFlipGlobal
# on global time
win
.
timeOnFlip
(
key_start
,
'
tStartRefresh
'
)
# time at next scr refresh
key_start
.
status
=
STARTED
# keyboard checking is just starting
waitOnFlip
=
True
win
.
callOnFlip
(
key_start
.
clock
.
reset
)
# t=0 on next screen flip
win
.
callOnFlip
(
key_start
.
clearEvents
,
eventType
=
'
keyboard
'
)
# clear events on next screen flip
if
key_start
.
status
==
STARTED
and
not
waitOnFlip
:
theseKeys
=
key_start
.
getKeys
(
keyList
=
[
'
space
'
],
waitRelease
=
False
)
if
len
(
theseKeys
):
theseKeys
=
theseKeys
[
0
]
# at least one key was pressed
# check for quit:
if
"
escape
"
==
theseKeys
:
endExpNow
=
True
key_start
.
keys
=
theseKeys
.
name
# just the last key pressed
key_start
.
rt
=
theseKeys
.
rt
# a response ends the routine
continueRoutine
=
False
# check for quit (typically the Esc key)
if
endExpNow
or
defaultKeyboard
.
getKeys
(
keyList
=
[
"
escape
"
]):
core
.
quit
()
# check if all components have finished
if
not
continueRoutine
:
# a component has requested a forced-end of Routine
break
continueRoutine
=
False
# will revert to True if at least one component still running
for
thisComponent
in
InstructionComponents
:
if
hasattr
(
thisComponent
,
"
status
"
)
and
thisComponent
.
status
!=
FINISHED
:
continueRoutine
=
True
break
# at least one component has not yet finished
# refresh the screen
if
continueRoutine
:
# don't flip if this routine is over or we'll get a blank screen
win
.
flip
()
# -------Ending Routine "Instruction"-------
for
thisComponent
in
InstructionComponents
:
if
hasattr
(
thisComponent
,
"
setAutoDraw
"
):
thisComponent
.
setAutoDraw
(
False
)
thisExp
.
addData
(
'
instruction.started
'
,
instruction
.
tStartRefresh
)
thisExp
.
addData
(
'
instruction.stopped
'
,
instruction
.
tStopRefresh
)
# check responses
if
key_start
.
keys
in
[
''
,
[],
None
]:
# No response was made
key_start
.
keys
=
None
thisExp
.
addData
(
'
key_start.keys
'
,
key_start
.
keys
)
if
key_start
.
keys
!=
None
:
# we had a response
thisExp
.
addData
(
'
key_start.rt
'
,
key_start
.
rt
)
thisExp
.
addData
(
'
key_start.started
'
,
key_start
.
tStartRefresh
)
thisExp
.
addData
(
'
key_start.stopped
'
,
key_start
.
tStopRefresh
)
thisExp
.
nextEntry
()
# the Routine "Instruction" was not non-slip safe, so reset the non-slip timer
routineTimer
.
reset
()
# set up handler to look after randomisation of conditions etc
trials
=
data
.
TrialHandler
(
nReps
=
20
,
method
=
'
sequential
'
,
extraInfo
=
expInfo
,
originPath
=-
1
,
trialList
=
[
None
],
seed
=
None
,
name
=
'
trials
'
)
thisExp
.
addLoop
(
trials
)
# add the loop to the experiment
thisTrial
=
trials
.
trialList
[
0
]
# so we can initialise stimuli with some values
# abbreviate parameter names if possible (e.g. rgb = thisTrial.rgb)
if
thisTrial
!=
None
:
for
paramName
in
thisTrial
:
exec
(
'
{} = thisTrial[paramName]
'
.
format
(
paramName
))
for
thisTrial
in
trials
:
currentLoop
=
trials
# abbreviate parameter names if possible (e.g. rgb = thisTrial.rgb)
if
thisTrial
!=
None
:
for
paramName
in
thisTrial
:
exec
(
'
{} = thisTrial[paramName]
'
.
format
(
paramName
))
# ------Prepare to start Routine "trial"-------
routineTimer
.
add
(
2.000000
)
# update component parameters for each repeat
# keep track of which components have finished
trialComponents
=
[
digits
]
for
thisComponent
in
trialComponents
:
thisComponent
.
tStart
=
None
thisComponent
.
tStop
=
None
thisComponent
.
tStartRefresh
=
None
thisComponent
.
tStopRefresh
=
None
if
hasattr
(
thisComponent
,
'
status
'
):
thisComponent
.
status
=
NOT_STARTED
# reset timers
t
=
0
_timeToFirstFrame
=
win
.
getFutureFlipTime
(
clock
=
"
now
"
)
trialClock
.
reset
(
-
_timeToFirstFrame
)
# t0 is time of first possible flip
frameN
=
-
1
continueRoutine
=
True
# -------Run Routine "trial"-------
while
continueRoutine
and
routineTimer
.
getTime
()
>
0
:
# get current time
t
=
trialClock
.
getTime
()
tThisFlip
=
win
.
getFutureFlipTime
(
clock
=
trialClock
)
tThisFlipGlobal
=
win
.
getFutureFlipTime
(
clock
=
None
)
frameN
=
frameN
+
1
# number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *digits* updates
if
digits
.
status
==
NOT_STARTED
and
tThisFlip
>=
1
-
frameTolerance
:
# keep track of start time/frame for later
digits
.
frameNStart
=
frameN
# exact frame index
digits
.
tStart
=
t
# local t and not account for scr refresh
digits
.
tStartRefresh
=
tThisFlipGlobal
# on global time
win
.
timeOnFlip
(
digits
,
'
tStartRefresh
'
)
# time at next scr refresh
digits
.
setAutoDraw
(
True
)
if
digits
.
status
==
STARTED
:
# is it time to stop? (based on global clock, using actual start)
if
tThisFlipGlobal
>
digits
.
tStartRefresh
+
1.0
-
frameTolerance
:
# keep track of stop time/frame for later
digits
.
tStop
=
t
# not accounting for scr refresh
digits
.
frameNStop
=
frameN
# exact frame index
win
.
timeOnFlip
(
digits
,
'
tStopRefresh
'
)
# time at next scr refresh
digits
.
setAutoDraw
(
False
)
# check for quit (typically the Esc key)
if
endExpNow
or
defaultKeyboard
.
getKeys
(
keyList
=
[
"
escape
"
]):
core
.
quit
()
# check if all components have finished
if
not
continueRoutine
:
# a component has requested a forced-end of Routine
break
continueRoutine
=
False
# will revert to True if at least one component still running
for
thisComponent
in
trialComponents
:
if
hasattr
(
thisComponent
,
"
status
"
)
and
thisComponent
.
status
!=
FINISHED
:
continueRoutine
=
True
break
# at least one component has not yet finished
# refresh the screen
if
continueRoutine
:
# don't flip if this routine is over or we'll get a blank screen
win
.
flip
()
# -------Ending Routine "trial"-------
for
thisComponent
in
trialComponents
:
if
hasattr
(
thisComponent
,
"
setAutoDraw
"
):
thisComponent
.
setAutoDraw
(
False
)
trials
.
addData
(
'
digits.started
'
,
digits
.
tStartRefresh
)
trials
.
addData
(
'
digits.stopped
'
,
digits
.
tStopRefresh
)
thisExp
.
nextEntry
()
# completed 20 repeats of 'trials'
# Flip one final time so any remaining win.callOnFlip()
# and win.timeOnFlip() tasks get executed before quitting
win
.
flip
()
# these shouldn't be strictly necessary (should auto-save)
thisExp
.
saveAsWideText
(
filename
+
'
.csv
'
)
thisExp
.
saveAsPickle
(
filename
)
logging
.
flush
()
# make sure everything is closed down
thisExp
.
abort
()
# or data files will save again on exit
win
.
close
()
core
.
quit
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment