Jelajahi Sumber

add side args in general grasping paradigm

DESKTOP-4GKCI80\Neuracle 1 tahun lalu
induk
melakukan
0fe6c556f7

+ 4 - 4
.vscode/launch.json

@@ -12,14 +12,14 @@
             "console": "integratedTerminal",
             "cwd": "${workspaceFolder}/backend",
             "justMyCode": true,
-            "args": ["--subj", "XW01", 
+            "args": ["--subj", "TT01", 
+            "--side","left",
             "--n-trials", "15", 
             "--hand-feedback",
             "--com", "COM3", 
             "-fm", "flex", 
-            "-vfr", "0.", 
-            "--difficulty", "mid",
-            "--model-filename", "riemann_rest+flex_01-02-2024-12-04-19.pkl"]
+            "-vfr", "1.", 
+            "--difficulty", "mid"]
         },
         {
             "name": "Grasp training",

File diff ditekan karena terlalu besar
+ 1 - 1
backend/general_grasp_training.psyexp


+ 44 - 26
backend/general_grasp_training.py

@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 """
 This experiment was created using PsychoPy3 Experiment Builder (v2023.2.3),
-    on 一月 12, 2024, at 16:01
+    on 一月 14, 2024, at 20:11
 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) 
@@ -62,6 +62,13 @@ def parse_args():
         type=str
     )
     parser.add_argument(
+        '--side',
+        dest='side',
+        help='train side',
+        default=None,
+        type=str
+    )
+    parser.add_argument(
         '--n-trials',
         dest='n_trials',
         help='Trial number',
@@ -132,6 +139,8 @@ else:
 controller = Controller(args.virtual_feedback_rate, 
                         control_model, 
                         reref_method=config_info['reref'])
+
+
 # Run 'Before Experiment' code from decision
 cnt_threshold_table = {
     'easy': 3,
@@ -417,7 +426,7 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
     
     # --- Initialize components for Routine "before_mi" ---
     train_position = visual.TextStim(win=win, name='train_position',
-        text='训练部位:右手',
+        text=None,
         font='Open Sans',
         pos=(0, 0), height=0.05, wrapWidth=None, ori=0.0, 
         color='black', colorSpace='rgb', opacity=None, 
@@ -442,10 +451,10 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
         depth=-1.0);
     
     # --- Initialize components for Routine "mi_begin" ---
-    img_right = visual.ImageStim(
+    img_move = visual.ImageStim(
         win=win,
-        name='img_right', 
-        image='static/images/hand_move.png', mask=None, anchor='center',
+        name='img_move', 
+        image=None, mask=None, anchor='center',
         ori=0.0, pos=(0, 0), size=None,
         color=[1,1,1], colorSpace='rgb', opacity=None,
         flipHoriz=False, flipVert=False,
@@ -505,6 +514,11 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
     continueRoutine = True
     # update component parameters for each repeat
     thisExp.addData('before_mi.started', globalClock.getTime())
+    # Run 'Begin Routine' code from config
+    if args.side == "right":
+        train_position.text = '训练部位:右手'
+    else:
+        train_position.text = '训练部位:左手'
     key_resp.keys = []
     key_resp.rt = []
     _key_resp_allKeys = []
@@ -808,11 +822,15 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
             # update component parameters for each repeat
             thisExp.addData('mi_begin.started', globalClock.getTime())
             # Run 'Begin Routine' code from algo
+            if args.side == "right":
+                img_move.image = 'static/images/hand_move_right.png'
+            else:
+                img_move.image = 'static/images/hand_move_left.png'
             # send trigger
             current_true_label = settings.FINGERMODEL_IDS[args.finger_model]
             win.callOnFlip(trigger.send_trigger, current_true_label)
             # keep track of which components have finished
-            mi_beginComponents = [img_right]
+            mi_beginComponents = [img_move]
             for thisComponent in mi_beginComponents:
                 thisComponent.tStart = None
                 thisComponent.tStop = None
@@ -835,38 +853,38 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
                 frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
                 # update/draw components on each frame
                 
-                # *img_right* updates
+                # *img_move* updates
                 
-                # if img_right is starting this frame...
-                if img_right.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
+                # if img_move is starting this frame...
+                if img_move.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
                     # keep track of start time/frame for later
-                    img_right.frameNStart = frameN  # exact frame index
-                    img_right.tStart = t  # local t and not account for scr refresh
-                    img_right.tStartRefresh = tThisFlipGlobal  # on global time
-                    win.timeOnFlip(img_right, 'tStartRefresh')  # time at next scr refresh
+                    img_move.frameNStart = frameN  # exact frame index
+                    img_move.tStart = t  # local t and not account for scr refresh
+                    img_move.tStartRefresh = tThisFlipGlobal  # on global time
+                    win.timeOnFlip(img_move, 'tStartRefresh')  # time at next scr refresh
                     # add timestamp to datafile
-                    thisExp.timestampOnFlip(win, 'img_right.started')
+                    thisExp.timestampOnFlip(win, 'img_move.started')
                     # update status
-                    img_right.status = STARTED
-                    img_right.setAutoDraw(True)
+                    img_move.status = STARTED
+                    img_move.setAutoDraw(True)
                 
-                # if img_right is active this frame...
-                if img_right.status == STARTED:
+                # if img_move is active this frame...
+                if img_move.status == STARTED:
                     # update params
                     pass
                 
-                # if img_right is stopping this frame...
-                if img_right.status == STARTED:
+                # if img_move is stopping this frame...
+                if img_move.status == STARTED:
                     # is it time to stop? (based on global clock, using actual start)
-                    if tThisFlipGlobal > img_right.tStartRefresh + 1-frameTolerance:
+                    if tThisFlipGlobal > img_move.tStartRefresh + 1-frameTolerance:
                         # keep track of stop time/frame for later
-                        img_right.tStop = t  # not accounting for scr refresh
-                        img_right.frameNStop = frameN  # exact frame index
+                        img_move.tStop = t  # not accounting for scr refresh
+                        img_move.frameNStop = frameN  # exact frame index
                         # add timestamp to datafile
-                        thisExp.timestampOnFlip(win, 'img_right.stopped')
+                        thisExp.timestampOnFlip(win, 'img_move.stopped')
                         # update status
-                        img_right.status = FINISHED
-                        img_right.setAutoDraw(False)
+                        img_move.status = FINISHED
+                        img_move.setAutoDraw(False)
                 
                 # check for quit (typically the Esc key)
                 if defaultKeyboard.getKeys(keyList=["escape"]):

TEMPAT SAMPAH
backend/static/images/hand_move_left.png


+ 0 - 0
backend/static/images/hand_move.png → backend/static/images/hand_move_right.png


Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini