Browse Source

Feat: 增加新控制参数,增加数据记录,删除患者姓名

dk 1 year ago
parent
commit
523d96d819

+ 3 - 2
.vscode/launch.json

@@ -12,12 +12,13 @@
             "console": "integratedTerminal",
             "console": "integratedTerminal",
             "cwd": "${workspaceFolder}/backend",
             "cwd": "${workspaceFolder}/backend",
             "justMyCode": true,
             "justMyCode": true,
-            "args": ["--subj", "ylj", 
+            "args": ["--subj", "XW01", 
             "--n-trials", "15", 
             "--n-trials", "15", 
             "--com", "COM3", 
             "--com", "COM3", 
             "-fm", "flex", 
             "-fm", "flex", 
             "-vfr", "1.0", 
             "-vfr", "1.0", 
-            "--model-path", "./static/models/ylj/baseline_rest+cylinder_11-16-2023-16-38-32.pkl"]
+            "-scth", "0.75",
+            "--model-path", "./static/models/XW01/baseline_rest+cylinder_11-16-2023-16-38-32.pkl"]
         },
         },
         {
         {
             "name": "Python: 当前文件",
             "name": "Python: 当前文件",

File diff suppressed because it is too large
+ 0 - 0
backend/general_grasp_training.psyexp


+ 16 - 2
backend/general_grasp_training.py

@@ -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 Mon Nov 20 16:11:17 2023
+    on Mon Nov 20 21:55:44 2023
 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) 
@@ -88,6 +88,13 @@ def parse_args():
         type=float
         type=float
     )
     )
     parser.add_argument(
     parser.add_argument(
+        '--state-change-threshold',
+        '-scth',
+        dest='state_change_threshold',
+        help='Threshold for HMM state change',
+        type=float
+    )
+    parser.add_argument(
         '--model-path',
         '--model-path',
         dest='model_path',
         dest='model_path',
         help='Path to model file',
         help='Path to model file',
@@ -111,7 +118,9 @@ trigger = TriggerNeuracle()
 hand_device = FuboPneumaticFingerClient({'port': args.com})
 hand_device = FuboPneumaticFingerClient({'port': args.com})
 
 
 # build bci controller
 # build bci controller
-controller = Controller(args.virtual_feedback_rate, args.model_path, state_change_threshold=0.8)
+controller = Controller(args.virtual_feedback_rate, 
+                        args.model_path, 
+                        state_change_threshold=args.state_change_threshold)
 # Run 'Before Experiment' code from decision
 # Run 'Before Experiment' code from decision
 
 
 
 
@@ -872,6 +881,11 @@ def run(expInfo, thisExp, win, inputs, globalClock=None, thisSession=None):
             data_from_buffer = receiver.get_trial_data(clear=False)
             data_from_buffer = receiver.get_trial_data(clear=False)
             decision = controller.step_decision(data_from_buffer, current_true_label)
             decision = controller.step_decision(data_from_buffer, current_true_label)
             decision_buffer.append(decision)
             decision_buffer.append(decision)
+            
+            # write decision to data
+            thisExp.addData('decision.class', decision)
+            if controller.real_feedback_model is not None:
+                thisExp.addData('decision.prob', controller.real_feedback_model.probability)
             # using non-slip timing so subtract the expected duration of this Routine (unless ended on request)
             # using non-slip timing so subtract the expected duration of this Routine (unless ended on request)
             if routineForceEnded:
             if routineForceEnded:
                 routineTimer.reset()
                 routineTimer.reset()

+ 1 - 1
backend/training.py

@@ -107,7 +107,7 @@ def model_saver(model, model_path, model_type, subject_id, event_id):
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
     # TODO: argparse
     # TODO: argparse
-    subj_name = 'ylj'
+    subj_name = 'XW01'
     model_type = 'baseline'
     model_type = 'baseline'
     # TODO: load subject config
     # TODO: load subject config
 
 

+ 1 - 1
backend/validation.py

@@ -101,7 +101,7 @@ def _event_to_stim_channel(events, time_length):
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
     # TODO: argparse
     # TODO: argparse
-    subj_name = 'ylj'
+    subj_name = 'XW01'
     # TODO: load subject config
     # TODO: load subject config
 
 
     data_dir = f'./data/{subj_name}/'
     data_dir = f'./data/{subj_name}/'

Some files were not shown because too many files changed in this diff