|
@@ -2,7 +2,7 @@
|
|
# -*- coding: utf-8 -*-
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
"""
|
|
This experiment was created using PsychoPy3 Experiment Builder (v2023.2.3),
|
|
This experiment was created using PsychoPy3 Experiment Builder (v2023.2.3),
|
|
- on 十二月 18, 2023, at 10:48
|
|
|
|
|
|
+ on 十二月 21, 2023, at 18:41
|
|
If you publish work using this script the most relevant publication is:
|
|
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)
|
|
Peirce J, Gray JR, Simpson S, MacAskill M, Höchenberger R, Sogo H, Kastman E, Lindeløv JK. (2019)
|
|
@@ -39,7 +39,7 @@ import time
|
|
from device.fubo_pneumatic_finger import FuboPneumaticFingerClient
|
|
from device.fubo_pneumatic_finger import FuboPneumaticFingerClient
|
|
from device.trigger_box import TriggerNeuracle
|
|
from device.trigger_box import TriggerNeuracle
|
|
from settings.config import settings
|
|
from settings.config import settings
|
|
-
|
|
|
|
|
|
+import random
|
|
|
|
|
|
# get train params
|
|
# get train params
|
|
|
|
|
|
@@ -177,7 +177,7 @@ def setupData(expInfo, dataDir=None):
|
|
thisExp = data.ExperimentHandler(
|
|
thisExp = data.ExperimentHandler(
|
|
name=expName, version='',
|
|
name=expName, version='',
|
|
extraInfo=expInfo, runtimeInfo=None,
|
|
extraInfo=expInfo, runtimeInfo=None,
|
|
- originPath='D:\\Graduate\\kraken\\backend\\grasp_data_collection_no_release.py',
|
|
|
|
|
|
+ originPath='D:\\Graduate\\Research\\kraken_project\\backend\\grasp_data_collection_no_release.py',
|
|
savePickle=True, saveWideText=True,
|
|
savePickle=True, saveWideText=True,
|
|
dataFileName=dataDir + os.sep + filename, sortColumns='time'
|
|
dataFileName=dataDir + os.sep + filename, sortColumns='time'
|
|
)
|
|
)
|
|
@@ -902,6 +902,11 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
|
|
# Run 'Begin Routine' code from code_3
|
|
# Run 'Begin Routine' code from code_3
|
|
win.callOnFlip(trigger.send_trigger, settings.FINGERMODEL_IDS['hold'])
|
|
win.callOnFlip(trigger.send_trigger, settings.FINGERMODEL_IDS['hold'])
|
|
# hold trigger(图片)后5s,出现extend图片
|
|
# hold trigger(图片)后5s,出现extend图片
|
|
|
|
+
|
|
|
|
+ # 生成3~10s的随机持续时间
|
|
|
|
+ random_duration = random.uniform(3, 10)
|
|
|
|
+ thisExp.addData('random_duration', random_duration)
|
|
|
|
+ #print(f"Holding duration is {random_duration} seconds.")
|
|
hold_wav.setSound('static/audios/hold.wav', secs=2.5, hamming=True)
|
|
hold_wav.setSound('static/audios/hold.wav', secs=2.5, hamming=True)
|
|
hold_wav.setVolume(1.0, log=False)
|
|
hold_wav.setVolume(1.0, log=False)
|
|
hold_wav.seek(0)
|
|
hold_wav.seek(0)
|
|
@@ -921,7 +926,7 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
|
|
|
|
|
|
# --- Run Routine "hold" ---
|
|
# --- Run Routine "hold" ---
|
|
routineForceEnded = not continueRoutine
|
|
routineForceEnded = not continueRoutine
|
|
- while continueRoutine and routineTimer.getTime() < 5.0:
|
|
|
|
|
|
+ while continueRoutine:
|
|
# get current time
|
|
# get current time
|
|
t = routineTimer.getTime()
|
|
t = routineTimer.getTime()
|
|
tThisFlip = win.getFutureFlipTime(clock=routineTimer)
|
|
tThisFlip = win.getFutureFlipTime(clock=routineTimer)
|
|
@@ -948,19 +953,13 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
|
|
if hold_img.status == STARTED:
|
|
if hold_img.status == STARTED:
|
|
# update params
|
|
# update params
|
|
pass
|
|
pass
|
|
|
|
+ # Run 'Each Frame' code from code_3
|
|
|
|
+ current_time = t
|
|
|
|
|
|
- # if hold_img is stopping this frame...
|
|
|
|
- if hold_img.status == STARTED:
|
|
|
|
- # is it time to stop? (based on global clock, using actual start)
|
|
|
|
- if tThisFlipGlobal > hold_img.tStartRefresh + 5-frameTolerance:
|
|
|
|
- # keep track of stop time/frame for later
|
|
|
|
- hold_img.tStop = t # not accounting for scr refresh
|
|
|
|
- hold_img.frameNStop = frameN # exact frame index
|
|
|
|
- # add timestamp to datafile
|
|
|
|
- thisExp.timestampOnFlip(win, 'hold_img.stopped')
|
|
|
|
- # update status
|
|
|
|
- hold_img.status = FINISHED
|
|
|
|
- hold_img.setAutoDraw(False)
|
|
|
|
|
|
+ if current_time < random_duration:
|
|
|
|
+ continueRoutine = True
|
|
|
|
+ else:
|
|
|
|
+ continueRoutine = False
|
|
|
|
|
|
# if hold_wav is starting this frame...
|
|
# if hold_wav is starting this frame...
|
|
if hold_wav.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
|
|
if hold_wav.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
|
|
@@ -1019,11 +1018,8 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
|
|
thisComponent.setAutoDraw(False)
|
|
thisComponent.setAutoDraw(False)
|
|
thisExp.addData('hold.stopped', globalClock.getTime())
|
|
thisExp.addData('hold.stopped', globalClock.getTime())
|
|
hold_wav.pause() # ensure sound has stopped at end of Routine
|
|
hold_wav.pause() # ensure sound has stopped at end of Routine
|
|
- # using non-slip timing so subtract the expected duration of this Routine (unless ended on request)
|
|
|
|
- if routineForceEnded:
|
|
|
|
- routineTimer.reset()
|
|
|
|
- else:
|
|
|
|
- routineTimer.addTime(-5.000000)
|
|
|
|
|
|
+ # the Routine "hold" was not non-slip safe, so reset the non-slip timer
|
|
|
|
+ routineTimer.reset()
|
|
|
|
|
|
# --- Prepare to start Routine "extend" ---
|
|
# --- Prepare to start Routine "extend" ---
|
|
continueRoutine = True
|
|
continueRoutine = True
|