Forráskód Böngészése

Revert: 延长判决步长是无效的方法,回退到原先的0.1s步长

dk 1 éve
szülő
commit
724545d4f7
3 módosított fájl, 10 hozzáadás és 7 törlés
  1. 1 1
      backend/free_grasp.psyexp
  2. 8 5
      backend/free_grasp.py
  3. 1 1
      backend/online_sim.py

+ 1 - 1
backend/free_grasp.psyexp

@@ -169,7 +169,7 @@
         <Param val="time (s)" valType="str" updates="None" name="startType"/>
         <Param val="0" valType="code" updates="None" name="startVal"/>
         <Param val="duration (s)" valType="str" updates="None" name="stopType"/>
-        <Param val="config_info['buffer_length']" valType="code" updates="constant" name="stopVal"/>
+        <Param val="0.1" valType="code" updates="constant" name="stopVal"/>
         <Param val="True" valType="bool" updates="None" name="syncScreenRefresh"/>
         <Param val="height" valType="str" updates="None" name="units"/>
       </ProgressComponent>

+ 8 - 5
backend/free_grasp.py

@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 """
 This experiment was created using PsychoPy3 Experiment Builder (v2023.2.3),
-    on Wed Dec 13 11:12:24 2023
+    on Sat Dec 16 23:08:01 2023
 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) 
@@ -614,7 +614,7 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
         
         # --- Run Routine "decision" ---
         routineForceEnded = not continueRoutine
-        while continueRoutine:
+        while continueRoutine and routineTimer.getTime() < 0.1:
             # get current time
             t = routineTimer.getTime()
             tThisFlip = win.getFutureFlipTime(clock=routineTimer)
@@ -645,7 +645,7 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
             # if feedback_bar is stopping this frame...
             if feedback_bar.status == STARTED:
                 # is it time to stop? (based on global clock, using actual start)
-                if tThisFlipGlobal > feedback_bar.tStartRefresh + config_info['buffer_length']-frameTolerance:
+                if tThisFlipGlobal > feedback_bar.tStartRefresh + 0.1-frameTolerance:
                     # keep track of stop time/frame for later
                     feedback_bar.tStop = t  # not accounting for scr refresh
                     feedback_bar.frameNStop = frameN  # exact frame index
@@ -681,8 +681,11 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
             if hasattr(thisComponent, "setAutoDraw"):
                 thisComponent.setAutoDraw(False)
         thisExp.addData('decision.stopped', globalClock.getTime())
-        # the Routine "decision" was not non-slip safe, so reset the non-slip timer
-        routineTimer.reset()
+        # using non-slip timing so subtract the expected duration of this Routine (unless ended on request)
+        if routineForceEnded:
+            routineTimer.reset()
+        else:
+            routineTimer.addTime(-0.100000)
         
         # --- Prepare to start Routine "feedback" ---
         continueRoutine = True

+ 1 - 1
backend/online_sim.py

@@ -224,7 +224,7 @@ if __name__ == '__main__':
                                              event_id, 
                                              model=model_hmm, 
                                              epoch_length=config_info['buffer_length'],
-                                             step_length=config_info['buffer_length'],
+                                             step_length=0.1,
                                              event_trial_length=trial_time)
     fig_pred.savefig(os.path.join(data_dir, 'pred.pdf'))   
     logger.info(f'With HMM: precision: {metric_hmm[0]:.4f}, recall: {metric_hmm[1]:.4f}, f1_score: {metric_hmm[2]:.4f}, accuracy: {metric_hmm[3]:.4f}')