|
@@ -2,7 +2,7 @@
|
|
|
# -*- coding: utf-8 -*-
|
|
|
"""
|
|
|
This experiment was created using PsychoPy3 Experiment Builder (v2023.2.3),
|
|
|
- on 十一月 14, 2023, at 14:23
|
|
|
+ on 十一月 14, 2023, at 15:00
|
|
|
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)
|
|
@@ -30,7 +30,6 @@ from numpy.random import random, randint, normal, shuffle, choice as randchoice
|
|
|
import os # handy system and path functions
|
|
|
import sys # to get file system encoding
|
|
|
|
|
|
-import psychopy.iohub as io
|
|
|
from psychopy.hardware import keyboard
|
|
|
|
|
|
# Run 'Before Experiment' code from config
|
|
@@ -238,9 +237,9 @@ def setupWindow(expInfo=None, win=None):
|
|
|
if win is None:
|
|
|
# if not given a window to setup, make one
|
|
|
win = visual.Window(
|
|
|
- size=(1024, 768), fullscr=True, screen=0,
|
|
|
+ size=[1493, 933], fullscr=True, screen=0,
|
|
|
winType='pyglet', allowStencil=False,
|
|
|
- monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
|
|
|
+ monitor='testMonitor', color=[1,1,1], colorSpace='rgb',
|
|
|
backgroundImage='', backgroundFit='none',
|
|
|
blendMode='avg', useFBO=True,
|
|
|
units='height'
|
|
@@ -250,7 +249,7 @@ def setupWindow(expInfo=None, win=None):
|
|
|
expInfo['frameRate'] = win.getActualFrameRate()
|
|
|
else:
|
|
|
# if we have a window, just set the attributes which are safe to set
|
|
|
- win.color = [0,0,0]
|
|
|
+ win.color = [1,1,1]
|
|
|
win.colorSpace = 'rgb'
|
|
|
win.backgroundImage = ''
|
|
|
win.backgroundFit = 'none'
|
|
@@ -281,18 +280,10 @@ def setupInputs(expInfo, thisExp, win):
|
|
|
# --- Setup input devices ---
|
|
|
inputs = {}
|
|
|
ioConfig = {}
|
|
|
-
|
|
|
- # Setup iohub keyboard
|
|
|
- ioConfig['Keyboard'] = dict(use_keymap='psychopy')
|
|
|
-
|
|
|
- ioSession = '1'
|
|
|
- if 'session' in expInfo:
|
|
|
- ioSession = str(expInfo['session'])
|
|
|
- ioServer = io.launchHubServer(window=win, **ioConfig)
|
|
|
- eyetracker = None
|
|
|
+ ioSession = ioServer = eyetracker = None
|
|
|
|
|
|
# create a default keyboard (e.g. to check for escape)
|
|
|
- defaultKeyboard = keyboard.Keyboard(backend='iohub')
|
|
|
+ defaultKeyboard = keyboard.Keyboard(backend='ptb')
|
|
|
# return inputs dict
|
|
|
return {
|
|
|
'ioServer': ioServer,
|
|
@@ -332,7 +323,7 @@ def pauseExperiment(thisExp, inputs=None, win=None, timers=[], playbackComponent
|
|
|
# make sure we have a keyboard
|
|
|
if inputs is None:
|
|
|
inputs = {
|
|
|
- 'defaultKeyboard': keyboard.Keyboard(backend='ioHub')
|
|
|
+ 'defaultKeyboard': keyboard.Keyboard(backend='PsychToolbox')
|
|
|
}
|
|
|
# check for quit (typically the Esc key)
|
|
|
if inputs['defaultKeyboard'].getKeys(keyList=['escape']):
|
|
@@ -399,14 +390,14 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
|
|
|
text='训练部位:右手',
|
|
|
font='Open Sans',
|
|
|
pos=(0, 0), height=0.05, wrapWidth=None, ori=0.0,
|
|
|
- color='white', colorSpace='rgb', opacity=None,
|
|
|
+ color='black', colorSpace='rgb', opacity=None,
|
|
|
languageStyle='LTR',
|
|
|
depth=0.0);
|
|
|
instruction = visual.TextStim(win=win, name='instruction',
|
|
|
text='准备进行一般抓握训练,\n按回车键继续',
|
|
|
font='Open Sans',
|
|
|
pos=(0, 0), height=0.05, wrapWidth=None, ori=0.0,
|
|
|
- color='white', colorSpace='rgb', opacity=None,
|
|
|
+ color='black', colorSpace='rgb', opacity=None,
|
|
|
languageStyle='LTR',
|
|
|
depth=-1.0);
|
|
|
key_resp = keyboard.Keyboard()
|
|
@@ -416,7 +407,7 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
|
|
|
text='请准备开始尝试运动',
|
|
|
font='Open Sans',
|
|
|
pos=(0, 0), height=0.05, wrapWidth=None, ori=0.0,
|
|
|
- color='white', colorSpace='rgb', opacity=None,
|
|
|
+ color='black', colorSpace='rgb', opacity=None,
|
|
|
languageStyle='LTR',
|
|
|
depth=-1.0);
|
|
|
|
|
@@ -437,7 +428,7 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
|
|
|
text=None,
|
|
|
font='Open Sans',
|
|
|
pos=(0, 0), height=0.05, wrapWidth=None, ori=0.0,
|
|
|
- color='white', colorSpace='rgb', opacity=None,
|
|
|
+ color='black', colorSpace='rgb', opacity=None,
|
|
|
languageStyle='LTR',
|
|
|
depth=0.0);
|
|
|
|
|
@@ -456,7 +447,7 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
|
|
|
text='结束实验',
|
|
|
font='Open Sans',
|
|
|
pos=(0, 0), height=0.05, wrapWidth=None, ori=0.0,
|
|
|
- color='white', colorSpace='rgb', opacity=None,
|
|
|
+ color='black', colorSpace='rgb', opacity=None,
|
|
|
languageStyle='LTR',
|
|
|
depth=0.0);
|
|
|
|
|
@@ -525,7 +516,7 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
|
|
|
# if train_position is stopping this frame...
|
|
|
if train_position.status == STARTED:
|
|
|
# is it time to stop? (based on global clock, using actual start)
|
|
|
- if tThisFlipGlobal > train_position.tStartRefresh + content["train_right"]["welcome_duration"]-frameTolerance:
|
|
|
+ if tThisFlipGlobal > train_position.tStartRefresh + 2-frameTolerance:
|
|
|
# keep track of stop time/frame for later
|
|
|
train_position.tStop = t # not accounting for scr refresh
|
|
|
train_position.frameNStop = frameN # exact frame index
|
|
@@ -574,7 +565,7 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
|
|
|
win.callOnFlip(key_resp.clock.reset) # t=0 on next screen flip
|
|
|
win.callOnFlip(key_resp.clearEvents, eventType='keyboard') # clear events on next screen flip
|
|
|
if key_resp.status == STARTED and not waitOnFlip:
|
|
|
- theseKeys = key_resp.getKeys(keyList=['return'], ignoreKeys=["escape"], waitRelease=False)
|
|
|
+ theseKeys = key_resp.getKeys(keyList=['space'], ignoreKeys=["escape"], waitRelease=False)
|
|
|
_key_resp_allKeys.extend(theseKeys)
|
|
|
if len(_key_resp_allKeys):
|
|
|
key_resp.keys = _key_resp_allKeys[-1].name # just the last key pressed
|
|
@@ -893,7 +884,7 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
|
|
|
# Run 'Begin Routine' code from collect_decisions
|
|
|
cnt = 0
|
|
|
for d in decision_buffer:
|
|
|
- if d == decision_buffer:
|
|
|
+ if d == current_true_label:
|
|
|
cnt += 1
|
|
|
|
|
|
if cnt >= 3:
|