Skip to content
Snippets Groups Projects
Commit 154b2585 authored by Tibor Auer's avatar Tibor Auer
Browse files

ENH - optional dedicated reponse "?"

parent 934149b0
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ if __name__ == '__main__': ...@@ -42,6 +42,7 @@ if __name__ == '__main__':
('sample retention time','[1.5, 1.5]'), # delay after sample ('sample retention time','[1.5, 1.5]'), # delay after sample
('match type', ['single','multi']), # match type ("single" - ~Alekseichuk or "multi" - ~Berger) ('match type', ['single','multi']), # match type ("single" - ~Alekseichuk or "multi" - ~Berger)
('match number',1), # number of matches per sample ('match number',1), # number of matches per sample
('dedicated response period "?"', False),
('scanner mode', False), # Is it inside the scanner ('scanner mode', False), # Is it inside the scanner
('stimulation', False), # Run tES ('stimulation', False), # Run tES
('trigger port', ['none']+listSerial()), ('trigger port', ['none']+listSerial()),
...@@ -81,7 +82,9 @@ if __name__ == '__main__': ...@@ -81,7 +82,9 @@ if __name__ == '__main__':
matchDuration = 1 matchDuration = 1
responseJitterRange = [0, 0] # jitter between events responseJitterRange = [0, 0] # jitter between events
responseDuration = 0 # maximum duration of response on top of matchDuration, 0 for no "?" responseDuration = 1 # maximum duration of response on top of matchDuration
if not(expInfo['dedicated response period "?"']): # , 0 for no "?"
responseDuration = 0
stimRamp = 3 # stimulation rampup and rampdown stimRamp = 3 # stimulation rampup and rampdown
...@@ -98,7 +101,7 @@ if __name__ == '__main__': ...@@ -98,7 +101,7 @@ if __name__ == '__main__':
sampleDuration+ sampleDuration+
array(matchJitterRange).mean()+ array(matchJitterRange).mean()+
nMatch*( nMatch*(
sampleDuration + matchDuration +
array(responseJitterRange).mean()+ array(responseJitterRange).mean()+
responseDuration responseDuration
) )
...@@ -163,7 +166,7 @@ if __name__ == '__main__': ...@@ -163,7 +166,7 @@ if __name__ == '__main__':
else: else:
infoStr = [ infoStr = [
"You will perform a visual-spatial match-to-sample test, which is commonly used to assess spatial working memory.\n\nThe test takes about {:.1f} minute(s) and consists of {} trials. In each trial, first, you will see a sample stimulus: {} dots within a grid. This is followed by a mask stimulus, which is the same grid filled with grey dots.\n\nPress 'Yes' to continue.".format(tTot, nConditionBlock*nTrialBlock*nSample, sampleNum), "You will perform a visual-spatial match-to-sample test, which is commonly used to assess spatial working memory.\n\nThe test takes about {:.1f} minute(s) and consists of {} trials. In each trial, first, you will see a sample stimulus: {} dots within a grid. This is followed by a mask stimulus, which is the same grid filled with grey dots.\n\nPress 'Yes' to continue.".format(tTot, nConditionBlock*nTrialBlock*nSample, sampleNum),
"Then, after shorter or longer delay, you will be presented with {} set(s) of test. The tests include a test stimulus, appearance of a single dot\n\nYou will have {:.1f} second(s) to press 'Yes' or 'No' indicating whether the location of the dot in the test stimulus matches any of those in the sample stimulus.\n\nPress 'Yes' when ready to start.".format(nMatch,responseDuration) "Then, after shorter or longer delay, you will be presented with {} set(s) of test. The tests include a test stimulus, appearance of a single dot\n\nYou will have {:.1f} second(s) to press 'Yes' or 'No' indicating whether the location of the dot in the test stimulus matches any of those in the sample stimulus.\n\nPress 'Yes' when ready to start.".format(nMatch,matchDuration)
] ]
infoImg = [ infoImg = [
...@@ -451,7 +454,7 @@ if __name__ == '__main__': ...@@ -451,7 +454,7 @@ if __name__ == '__main__':
elementTex=None, elementMask="circle", colors=colour, colorSpace='rgb', autoLog=False) elementTex=None, elementMask="circle", colors=colour, colorSpace='rgb', autoLog=False)
recallForm.status == NOT_STARTED recallForm.status == NOT_STARTED
while trialClock.getTime() < (jitter + sampleDuration): while trialClock.getTime() < (jitter + matchDuration):
# get current time # get current time
t = trialClock.getTime() t = trialClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame) frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
...@@ -479,6 +482,8 @@ if __name__ == '__main__': ...@@ -479,6 +482,8 @@ if __name__ == '__main__':
recallForm.status = STARTED recallForm.status = STARTED
win.logOnFlip(level=logging.EXP, msg='Match - STARTED - ' + array2string(thisMatch['match'])) win.logOnFlip(level=logging.EXP, msg='Match - STARTED - ' + array2string(thisMatch['match']))
if doTrigger: trigger.send(TRIGGER['testBase']+loopMatch.thisTrialN+1) if doTrigger: trigger.send(TRIGGER['testBase']+loopMatch.thisTrialN+1)
if responseDuration == 0:
SSO.wait_for_button(no_block=True)
if fullForm.status == STARTED: if fullForm.status == STARTED:
fullForm.draw() fullForm.draw()
...@@ -487,44 +492,45 @@ if __name__ == '__main__': ...@@ -487,44 +492,45 @@ if __name__ == '__main__':
recallForm.draw() recallForm.draw()
win.flip() win.flip()
interimClock.reset((jitter + sampleDuration) - trialClock.getTime()) interimClock.reset((jitter + matchDuration) - trialClock.getTime())
if recallForm.status == STARTED: if recallForm.status == STARTED:
recallForm.status = STOPPED recallForm.status = STOPPED
win.logOnFlip(level=logging.EXP, msg='Match - STOPPED') win.logOnFlip(level=logging.EXP, msg='Match - STOPPED')
# Response # Response
trialClock.reset(-interimClock.getTime()) if responseDuration > 0:
jitter = thisMatch['onsetResponse'] trialClock.reset(-interimClock.getTime())
jitter = thisMatch['onsetResponse']
responseStim.status = NOT_STARTED
SSO.reset_buttons()
while trialClock.getTime() < (jitter + responseDuration):
# get current time
t = trialClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame responseStim.status = NOT_STARTED
gridForm.draw() SSO.reset_buttons()
# *sampleForm* updates while trialClock.getTime() < (jitter + responseDuration):
if t >= jitter and responseStim.status == NOT_STARTED: # get current time
# keep track of start time/frame for later t = trialClock.getTime()
responseStim.tStart = t frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
responseStim.frameNStart = frameN # exact frame index
responseStim.setAutoDraw(True)
win.logOnFlip(level=logging.EXP, msg='Response - STARTED')
if doTrigger: trigger.send(TRIGGER['responseBase']+loopMatch.thisTrialN+1)
SSO.wait_for_button(no_block=True)
win.flip() # update/draw components on each frame
interimClock.reset((jitter + responseDuration)-trialClock.getTime()) gridForm.draw()
if responseStim.status == STARTED: # *sampleForm* updates
responseStim.status = STOPPED if t >= jitter and responseStim.status == NOT_STARTED:
responseStim.setAutoDraw(False) # keep track of start time/frame for later
win.logOnFlip(level=logging.EXP, msg='Response - STOPPED') responseStim.tStart = t
responseStim.frameNStart = frameN # exact frame index
responseStim.setAutoDraw(True)
win.logOnFlip(level=logging.EXP, msg='Response - STARTED')
if doTrigger: trigger.send(TRIGGER['responseBase']+loopMatch.thisTrialN+1)
SSO.wait_for_button(no_block=True)
win.flip()
interimClock.reset((jitter + responseDuration)-trialClock.getTime())
if responseStim.status == STARTED:
responseStim.status = STOPPED
responseStim.setAutoDraw(False)
win.logOnFlip(level=logging.EXP, msg='Response - STOPPED')
if len(SSO.buttonpresses): # no - SSO.buttonpresses[-1][0] = bNo; yes - SSO.buttonpresses[-1][0] = bYes if len(SSO.buttonpresses): # no - SSO.buttonpresses[-1][0] = bNo; yes - SSO.buttonpresses[-1][0] = bYes
logging.log(level=logging.EXP, msg='Button - {:.3f} - {}'.format(SSO.buttonpresses[-1][1],SSO.buttonpresses[-1][0])) logging.log(level=logging.EXP, msg='Button - {:.3f} - {}'.format(SSO.buttonpresses[-1][1],SSO.buttonpresses[-1][0]))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment