Ejemplo n.º 1
0
def add_to_study(study):
    subject = study.add_subject(1, 72.85)

    cond_args = dict()
    subject.cond_args = cond_args

    static = subject.add_condition('static')
    static_trial = static.add_trial(1, omit_trial_dir=True)

    # `os.path.basename(__file__)` should be `subject01.py`.
    scale_setup_task = subject.add_task(
        osp.TaskScaleSetup,
        init_time=0,
        final_time=0.5,
        mocap_trial=static_trial,
        edit_setup_function=scale_setup_fcn,
        addtl_file_dep=['dodo.py', os.path.basename(__file__)])

    subject.add_task(
        osp.TaskScale,
        scale_setup_task=scale_setup_task,
        #scale_max_isometric_force=True,
    )

    subject.add_task(tasks.TaskScaleMuscleMaxIsometricForce)
    marker_adjustments = dict()
    marker_adjustments['RTOE'] = (1, 0.0170717)
    marker_adjustments['RMT5'] = (1, 0.011679)
    marker_adjustments['LTOE'] = (1, 0.0170708)
    marker_adjustments['LMT5'] = (1, 0.0116779)
    subject.add_task(tasks.TaskAdjustScaledModelMarkers, marker_adjustments)
    subject.scaled_model_fpath = os.path.join(subject.results_exp_path,
                                              '%s_final.osim' % subject.name)

    ## walk1 condition
    walk1 = subject.add_condition('walk1', metadata={'walking_speed': 1.00})

    # GRF gait landmarks
    # walk1_trial_temp = walk1.add_trial(99, omit_trial_dir=True)
    # walk1_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk1_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    gait_events = dict()
    gait_events['right_strikes'] = [0.487, 1.757, 3.020, 4.302]
    gait_events['left_toeooffs'] = [0.716, 1.980, 3.256]
    gait_events['left_strikes'] = [1.125, 2.393, 3.663]
    gait_events['right_toeoffs'] = [1.351, 2.624, 3.886]

    walk1_trial = walk1.add_trial(
        1,
        gait_events=gait_events,
        omit_trial_dir=True,
    )

    # walk1: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk1_trial)
    helpers.generate_exotopology_tasks(walk1_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk1_trial, mrs_setup_tasks)

    ## walk2 condition
    walk2 = subject.add_condition('walk2', metadata={'walking_speed': 1.25})

    # GRF gait landmarks
    # walk2_trial_temp = walk2.add_trial(99, omit_trial_dir=True)
    # walk2_trial_temp.add_task(osp.TaskGRFGaitLandmarks)

    # Trial to use
    gait_events = dict()
    gait_events['right_strikes'] = [1.179, 2.282, 3.361, 4.488]  #, 5.572]
    gait_events['left_toeooffs'] = [1.368, 2.471, 3.578]  #, 4.680]
    gait_events['left_strikes'] = [1.728, 2.836, 3.943]  #, 5.051]
    gait_events['right_toeoffs'] = [1.934, 3.033, 4.137]  #, 5.252]

    walk2_trial = walk2.add_trial(
        1,
        gait_events=gait_events,
        omit_trial_dir=True,
    )
    walk2_trial.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    # walk2: main study tasks
    helpers.generate_sensitivity_tasks(walk2_trial)
    mrs_setup_tasks = helpers.generate_main_tasks(walk2_trial)
    helpers.generate_exotopology_tasks(walk2_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk2_trial, mrs_setup_tasks)

    ## walk3 condition
    walk3 = subject.add_condition('walk3', metadata={'walking_speed': 1.50})

    # GRF gait landmarks
    # walk3_trial_temp = walk3.add_trial(99, omit_trial_dir=True)
    # walk3_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk3_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    gait_events = dict()
    gait_events['right_strikes'] = [0.911, 1.934, 3.978, 5.008]
    gait_events['left_toeoffs'] = [1.081, 2.089, 4.146]
    gait_events['left_strikes'] = [1.428, 2.440, 4.495]
    gait_events['right_toeoffs'] = [1.598, 2.614, 4.661]
    gait_events['stride_times'] = [1.934 - 0.911, 3.978 - 2.934, 5.008 - 3.978]
    walk3_trial = walk3.add_trial(
        1,
        gait_events=gait_events,
        omit_trial_dir=True,
    )

    # walk3: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk3_trial)
    helpers.generate_exotopology_tasks(walk3_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk3_trial, mrs_setup_tasks)

    ## walk4 condition
    walk4 = subject.add_condition('walk4', metadata={'walking_speed': 1.75})

    # GRF gait landmarks
    # walk4_trial_temp = walk4.add_trial(99, omit_trial_dir=True)
    # walk4_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk4_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    gait_events = dict()
    gait_events['right_strikes'] = [1.156, 2.112, 3.069, 4.033]
    gait_events['left_toeooffs'] = [1.307, 2.257, 3.218]
    gait_events['left_strikes'] = [1.646, 2.594, 3.532]
    gait_events['right_toeoffs'] = [1.801, 2.754, 3.714]

    walk4_trial = walk4.add_trial(
        1,
        gait_events=gait_events,
        omit_trial_dir=True,
    )

    # walk4: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk4_trial)
    helpers.generate_exotopology_tasks(walk4_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk4_trial, mrs_setup_tasks)

    # multi-phase parameter calibration (trial does not matter)
    calibrate_setup_task = walk3_trial.add_task(
        tasks.TaskCalibrateParametersMultiPhaseSetup,
        ['walk1', 'walk2', 'walk3', 'walk4'], ['cycle01'],
        study.param_dict,
        study.cost_dict,
        passive_precalibrate=True)

    walk3_trial.add_task(tasks.TaskCalibrateParametersMultiPhase,
                         calibrate_setup_task)

    walk3_trial.add_task(tasks.TaskCalibrateParametersMultiPhasePost,
                         calibrate_setup_task)
Ejemplo n.º 2
0
def add_to_study(study):
    subject = study.add_subject(19, 68.50)

    cond_args = dict()
    cond_args['walk100'] = (1, '_newCOP3')
    cond_args['walk125'] = (1, '_newCOP3')
    cond_args['walk150'] = (1, '_newCOP3')
    cond_args['walk175'] = (1, '_newCOP3')
    cond_args['run200'] = (1, '_newCOP3')
    cond_args['run300'] = (1, '_newCOP3')
    cond_args['run400'] = (1, '_newCOP3')
    cond_args['run500'] = (1, '_newCOP3')
    subject.cond_args = cond_args

    static = subject.add_condition('static')
    static_trial = static.add_trial(1, omit_trial_dir=True)

    # `os.path.basename(__file__)` should be `subject19.py`.
    scale_setup_task = subject.add_task(osp.TaskScaleSetup,
            init_time=0.41667,
            final_time=6.14167,
            mocap_trial=static_trial,
            edit_setup_function=scale_setup_fcn,
            addtl_file_dep=['dodo.py', os.path.basename(__file__)])

    subject.add_task(osp.TaskScale,
            scale_setup_task=scale_setup_task,
            #scale_max_isometric_force=True,
            )

    subject.add_task(tasks.TaskScaleMuscleMaxIsometricForce)
    marker_adjustments = dict()
    # marker_adjustments['RTOE'] = (1, 0.0170717)
    # marker_adjustments['RMT5'] = (1, 0.011679)
    # marker_adjustments['LTOE'] = (1, 0.0170708)
    # marker_adjustments['LMT5'] = (1, 0.0116779)
    subject.add_task(tasks.TaskAdjustScaledModelMarkers, marker_adjustments)
    subject.scaled_model_fpath = os.path.join(subject.results_exp_path,
        '%s_final.osim' % subject.name)

    ## walk1 condition
    walk1 = subject.add_condition('walk1', metadata={'walking_speed': 1.00})

    # GRF gait landmarks
    # walk1_trial_temp = walk1.add_trial(99, omit_trial_dir=True)
    # walk1_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk1_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)
    
    gait_events = dict()
    gait_events['right_strikes'] = [0.503, 2.934, 4.134, 5.361]
    gait_events['left_toeoffs'] = [0.720, 3.148, 4.340] 
    gait_events['left_strikes'] = [1.103, 3.516, 4.744] 
    gait_events['right_toeoffs'] = [1.309, 3.746, 4.959] 
    gait_events['stride_times'] = [1.738-0.503, 4.134-2.934, 5.361-4.134]
    walk1_trial = walk1.add_trial(1,
            gait_events=gait_events,
            omit_trial_dir=True,
            )

    # walk1: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk1_trial)
    helpers.generate_exotopology_tasks(walk1_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk1_trial, mrs_setup_tasks)

    ## walk2 condition
    walk2 = subject.add_condition('walk2', metadata={'walking_speed': 1.25})

    # walk2_trial = walk2.add_trial(1, omit_trial_dir=True)
    # walk2_trial.add_task(tasks.TaskUpdateGroundReactionColumnLabels)
    # walk2_trial.add_task(osp.TaskGRFGaitLandmarks, threshold=10)

    # Trial to use
    gait_events = dict()
    gait_events['right_strikes'] = [0.599, 1.653, 2.718, 3.790] #, 4.857]
    gait_events['left_toeoffs'] = [0.782, 1.839, 2.896] #, 3.962]
    gait_events['left_strikes'] = [1.124, 2.183, 3.256] #, 4.331]
    gait_events['right_toeoffs'] = [1.302, 2.368, 3.423] #, 4.504]
    walk2_trial = walk2.add_trial(1,
            gait_events=gait_events,
            omit_trial_dir=True,
            )
    walk2_trial.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    # walk2: main study tasks
    helpers.generate_sensitivity_tasks(walk2_trial)
    mrs_setup_tasks = helpers.generate_main_tasks(walk2_trial)
    helpers.generate_exotopology_tasks(walk2_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk2_trial, mrs_setup_tasks)

    ## walk3 condition
    walk3 = subject.add_condition('walk3', metadata={'walking_speed': 1.50})

    # GRF gait landmarks
    # walk3_trial_temp = walk3.add_trial(99, omit_trial_dir=True)
    # walk3_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk3_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)
    
    gait_events = dict()
    gait_events['right_strikes'] = [0.103, 1.081, 2.082, 3.068]
    gait_events['left_toeoffs'] = [0.264, 1.252, 2.243] 
    gait_events['left_strikes'] = [0.597, 1.592, 2.568] 
    gait_events['right_toeoffs'] = [0.774, 1.762, 2.740] 
    walk3_trial = walk3.add_trial(1,
            gait_events=gait_events,
            omit_trial_dir=True,
            )

    # walk3: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk3_trial)
    helpers.generate_exotopology_tasks(walk3_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk3_trial, mrs_setup_tasks)

    ## walk4 condition
    walk4 = subject.add_condition('walk4', metadata={'walking_speed': 1.75})

    # GRF gait landmarks
    # walk4_trial_temp = walk4.add_trial(99, omit_trial_dir=True)
    # walk4_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk4_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)
    
    gait_events = dict()
    gait_events['right_strikes'] = [0.123, 1.026, 1.970, 2.886]
    gait_events['left_toeoffs'] = [0.271, 1.189, 2.120] 
    gait_events['left_strikes'] = [0.589, 1.506, 2.439] 
    gait_events['right_toeoffs'] = [0.738, 1.694, 2.591]
    walk4_trial = walk4.add_trial(1,
            gait_events=gait_events,
            omit_trial_dir=True,
            )

    # walk4: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk4_trial)
    helpers.generate_exotopology_tasks(walk4_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk4_trial, mrs_setup_tasks)

    # multi-phase parameter calibration (trial does not matter)
    calibrate_setup_task = walk3_trial.add_task(
        tasks.TaskCalibrateParametersMultiPhaseSetup,
        ['walk1','walk2','walk3','walk4'],
        ['cycle01'],
        study.param_dict,
        study.cost_dict,
        passive_precalibrate=True)

    walk3_trial.add_task(
        tasks.TaskCalibrateParametersMultiPhase,
        calibrate_setup_task)

    walk3_trial.add_task(
        tasks.TaskCalibrateParametersMultiPhasePost,
        calibrate_setup_task)
Ejemplo n.º 3
0
def add_to_study(study):
    subject = study.add_subject(4, 80.30)

    cond_args = dict()
    cond_args['walk175'] = (3, '_newCOP3')
    cond_args['run500'] = (4, '_newCOP3')
    subject.cond_args = cond_args

    static = subject.add_condition('static')
    static_trial = static.add_trial(1, omit_trial_dir=True)

    # `os.path.basename(__file__)` should be `subject02.py`.
    scale_setup_task = subject.add_task(osp.TaskScaleSetup,
            init_time=0.73,
            final_time=3.89, 
            mocap_trial=static_trial,
            edit_setup_function=scale_setup_fcn,
            addtl_file_dep=['dodo.py', os.path.basename(__file__)])

    subject.add_task(osp.TaskScale,
            scale_setup_task=scale_setup_task,
            #scale_max_isometric_force=True,
            )

    subject.add_task(tasks.TaskScaleMuscleMaxIsometricForce)
    marker_adjustments = dict()
    marker_adjustments['RTOE'] = (1, 0.0029271)
    marker_adjustments['RMT5'] = (1, -0.003)
    marker_adjustments['LTOE'] = (1, 0.0029261)
    marker_adjustments['LMT5'] = (1, -0.003)
    subject.add_task(tasks.TaskAdjustScaledModelMarkers, marker_adjustments)
    subject.scaled_model_fpath = os.path.join(subject.results_exp_path,
        '%s_final.osim' % subject.name)

    ## walk1 condition
    walk1 = subject.add_condition('walk1', metadata={'walking_speed': 1.00})

    # GRF gait landmarks
    # walk1_trial_temp = walk1.add_trial(99, omit_trial_dir=True)
    # walk1_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk1_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)
    
    gait_events = dict()
    gait_events['right_strikes'] = [1.361, 2.516, 3.767, 4.985]
    gait_events['left_toeoffs'] = [1.555, 2.704, 3.983]
    gait_events['left_strikes'] = [1.946, 3.131, 4.332]
    gait_events['right_toeoffs'] = [2.165, 3.353, 4.546]
    walk1_trial = walk1.add_trial(1,
            gait_events=gait_events,
            omit_trial_dir=True,
            )

    # walk1: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk1_trial)
    helpers.generate_exotopology_tasks(walk1_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk1_trial, mrs_setup_tasks)

    ## walk2 condition
    walk2 = subject.add_condition('walk2', metadata={'walking_speed': 1.25})

    # GRF gait landmarks
    # walk2_trial = walk2.add_trial(1, omit_trial_dir=True)
    # walk2_trial.add_task(tasks.TaskUpdateGroundReactionColumnLabels)
    # walk2_trial.add_task(osp.TaskGRFGaitLandmarks, threshold=25)

    # Trial to use
    gait_events = dict()
    gait_events['right_strikes'] = [0.269, 1.408, 4.741, 5.902]
    gait_events['left_toeoffs'] = [0.419, 1.565, 4.882]
    gait_events['left_strikes'] = [0.813, 1.952, 5.317]
    gait_events['right_toeoffs'] = [0.966, 2.104, 5.479]
    gait_events['stride_times'] = [1.408-0.269, 2.519-1.408, 5.902-4.741]
    walk2_trial = walk2.add_trial(1,
            gait_events=gait_events,
            omit_trial_dir=True,
            )
    walk2_trial.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    # walk2: main study tasks
    helpers.generate_sensitivity_tasks(walk2_trial)
    mrs_setup_tasks = helpers.generate_main_tasks(walk2_trial)
    helpers.generate_exotopology_tasks(walk2_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk2_trial, mrs_setup_tasks)

    ## walk3 condition
    walk3 = subject.add_condition('walk3', metadata={'walking_speed': 1.50})

    # GRF gait landmarks
    # walk3_trial_temp = walk3.add_trial(99, omit_trial_dir=True)
    # walk3_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk3_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)
    
    gait_events = dict()
    gait_events['right_strikes'] = [2.351, 3.386, 4.422, 5.457]
    gait_events['left_toeoffs'] = [2.525, 3.534, 4.589]
    gait_events['left_strikes'] = [2.859, 3.894, 4.936]
    gait_events['right_toeoffs'] = [3.060, 4.045, 5.104]
    walk3_trial = walk3.add_trial(1,
            gait_events=gait_events,
            omit_trial_dir=True,
            )

    # walk3: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk3_trial)
    helpers.generate_exotopology_tasks(walk3_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk3_trial, mrs_setup_tasks)

    ## walk4 condition
    walk4 = subject.add_condition('walk4', metadata={'walking_speed': 1.75})

    # GRF gait landmarks
    # walk4_trial_temp = walk4.add_trial(99, omit_trial_dir=True)
    # walk4_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk4_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)
    
    gait_events = dict()
    gait_events['right_strikes'] = [1.028, 2.006, 2.990, 3.965]
    gait_events['left_toeoffs'] = [1.169, 2.156, 3.142]
    gait_events['left_strikes'] = [1.514, 2.503, 3.465]
    gait_events['right_toeoffs'] = [1.661, 2.634, 3.619]

    walk4_trial = walk4.add_trial(1,
            gait_events=gait_events,
            omit_trial_dir=True,
            )

    # walk4: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk4_trial)
    helpers.generate_exotopology_tasks(walk4_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk4_trial, mrs_setup_tasks)

    # multi-phase parameter calibration (trial does not matter)
    calibrate_setup_task = walk3_trial.add_task(
        tasks.TaskCalibrateParametersMultiPhaseSetup,
        ['walk1','walk2','walk3','walk4'],
        ['cycle01'],
        study.param_dict,
        study.cost_dict,
        passive_precalibrate=True)

    walk3_trial.add_task(
        tasks.TaskCalibrateParametersMultiPhase,
        calibrate_setup_task)

    walk3_trial.add_task(
        tasks.TaskCalibrateParametersMultiPhasePost,
        calibrate_setup_task)
Ejemplo n.º 4
0
def add_to_study(study):
    subject = study.add_subject(2, 76.48)

    cond_args = dict()
    cond_args['walk100'] = (5, '_newCOP3')
    cond_args['walk125'] = (4, '_newCOP3')
    subject.cond_args = cond_args

    static = subject.add_condition('static')
    static_trial = static.add_trial(1, omit_trial_dir=True)

    # `os.path.basename(__file__)` should be `subject02.py`.
    scale_setup_task = subject.add_task(
        osp.TaskScaleSetup,
        init_time=0,
        final_time=0.4,
        mocap_trial=static_trial,
        edit_setup_function=scale_setup_fcn,
        addtl_file_dep=['dodo.py', os.path.basename(__file__)])

    subject.add_task(
        osp.TaskScale,
        scale_setup_task=scale_setup_task,
        #scale_max_isometric_force=True,
    )

    subject.add_task(tasks.TaskScaleMuscleMaxIsometricForce)
    marker_adjustments = dict()
    marker_adjustments['RTOE'] = (1, 0.0159575)
    marker_adjustments['RMT5'] = (1, 0.0109378)
    marker_adjustments['LTOE'] = (1, 0.0159567)
    marker_adjustments['LMT5'] = (1, 0.0109368)
    subject.add_task(tasks.TaskAdjustScaledModelMarkers, marker_adjustments)
    subject.scaled_model_fpath = os.path.join(subject.results_exp_path,
                                              '%s_final.osim' % subject.name)

    ## walk1 condition
    walk1 = subject.add_condition('walk1', metadata={'walking_speed': 1.00})

    # GRF gait landmarks
    # walk1_trial_temp = walk1.add_trial(99, omit_trial_dir=True)
    # walk1_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk1_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    gait_events = dict()
    gait_events['right_strikes'] = [1.001, 2.268, 3.479, 4.766]
    gait_events['left_toeoffs'] = [1.219, 2.497, 3.750]
    gait_events['left_strikes'] = [1.625, 2.895, 4.116]
    gait_events['right_toeoffs'] = [1.864, 3.118, 4.364]

    walk1_trial = walk1.add_trial(
        1,
        gait_events=gait_events,
        omit_trial_dir=True,
    )

    # walk1: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk1_trial)
    helpers.generate_exotopology_tasks(walk1_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk1_trial, mrs_setup_tasks)

    ## walk2 condition
    walk2 = subject.add_condition('walk2', metadata={'walking_speed': 1.25})

    # GRF gait landmarks
    # walk2_trial= walk2.add_trial(1, omit_trial_dir=True)
    # walk2_trial.add_task(tasks.TaskUpdateGroundReactionColumnLabels)
    # walk2_trial.add_task(osp.TaskGRFGaitLandmarks, threshold=10)

    # Trial to use
    gait_events = dict()
    gait_events['right_strikes'] = [0.761, 1.921, 3.084, 4.257]  #, 5.406]
    gait_events['left_toeoffs'] = [0.939, 2.101, 3.268]  #, 4.446]
    gait_events['left_strikes'] = [1.349, 2.516, 3.667]  #, 4.851]
    gait_events['right_toeoffs'] = [1.548, 2.709, 3.842]  #, 5.031]
    walk2_trial = walk2.add_trial(
        1,
        gait_events=gait_events,
        omit_trial_dir=True,
    )
    walk2_trial.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    # walk2: main study tasks
    helpers.generate_sensitivity_tasks(walk2_trial)
    mrs_setup_tasks = helpers.generate_main_tasks(walk2_trial)
    helpers.generate_exotopology_tasks(walk2_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk2_trial, mrs_setup_tasks)

    ## walk3 condition
    walk3 = subject.add_condition('walk3', metadata={'walking_speed': 1.50})

    # GRF gait landmarks
    # walk3_trial_temp = walk3.add_trial(99, omit_trial_dir=True)
    # walk3_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk3_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    gait_events = dict()
    gait_events['right_strikes'] = [0.724, 1.789, 2.823, 3.906]
    gait_events['left_toeoffs'] = [0.915, 1.956, 3.000]
    gait_events['left_strikes'] = [1.245, 2.303, 3.375]
    gait_events['right_toeoffs'] = [1.431, 2.479, 3.552]

    walk3_trial = walk3.add_trial(
        1,
        gait_events=gait_events,
        omit_trial_dir=True,
    )

    # walk3: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk3_trial)
    helpers.generate_exotopology_tasks(walk3_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk3_trial, mrs_setup_tasks)

    ## walk4 condition
    walk4 = subject.add_condition('walk4', metadata={'walking_speed': 1.75})

    # GRF gait landmarks
    # walk4_trial_temp = walk4.add_trial(99, omit_trial_dir=True)
    # walk4_trial_temp.add_task(osp.TaskGRFGaitLandmarks, threshold=10)
    # walk4_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    gait_events = dict()
    gait_events['right_strikes'] = [0.829, 1.847, 2.857, 3.824]
    gait_events['left_toeoffs'] = [0.917, 1.983, 2.997]
    gait_events['left_strikes'] = [1.337, 2.340, 3.337]
    gait_events['right_toeoffs'] = [1.484, 2.480, 3.472]

    walk4_trial = walk4.add_trial(
        1,
        gait_events=gait_events,
        omit_trial_dir=True,
    )

    # walk4: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk4_trial)
    helpers.generate_exotopology_tasks(walk4_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk4_trial, mrs_setup_tasks)

    # multi-phase parameter calibration (trial does not matter)
    calibrate_setup_task = walk3_trial.add_task(
        tasks.TaskCalibrateParametersMultiPhaseSetup,
        ['walk1', 'walk2', 'walk3', 'walk4'], ['cycle01'],
        study.param_dict,
        study.cost_dict,
        passive_precalibrate=True)

    walk3_trial.add_task(tasks.TaskCalibrateParametersMultiPhase,
                         calibrate_setup_task)

    walk3_trial.add_task(tasks.TaskCalibrateParametersMultiPhasePost,
                         calibrate_setup_task)
Ejemplo n.º 5
0
def add_to_study(study):
    subject = study.add_subject(18, 64.09)

    cond_args = dict()
    cond_args['walk100'] = (1, '_newCOP3')
    cond_args['walk125'] = (1, '_newCOP3')
    cond_args['walk150'] = (1, '_newCOP3')
    cond_args['walk175'] = (1, '_newCOP3')
    cond_args['run200'] = (1, '_newCOP3')
    cond_args['run300'] = (1, '_newCOP3')
    cond_args['run400'] = (1, '_newCOP3')
    cond_args['run500'] = (1, '_newCOP3')
    subject.cond_args = cond_args

    static = subject.add_condition('static')
    static_trial = static.add_trial(1, omit_trial_dir=True)

    # `os.path.basename(__file__)` should be `subject02.py`.
    scale_setup_task = subject.add_task(
        osp.TaskScaleSetup,
        init_time=0.042,
        final_time=3.908,
        mocap_trial=static_trial,
        edit_setup_function=scale_setup_fcn,
        addtl_file_dep=['dodo.py', os.path.basename(__file__)])

    subject.add_task(
        osp.TaskScale,
        scale_setup_task=scale_setup_task,
        #scale_max_isometric_force=True,
    )

    subject.add_task(tasks.TaskScaleMuscleMaxIsometricForce)
    marker_adjustments = dict()
    marker_adjustments['RTOE'] = (1, 0.0012659)
    marker_adjustments['RMT5'] = (1, -0.004)
    marker_adjustments['LTOE'] = (1, 0.0012651)
    marker_adjustments['LMT5'] = (1, -0.004)
    subject.add_task(tasks.TaskAdjustScaledModelMarkers, marker_adjustments)
    subject.scaled_model_fpath = os.path.join(subject.results_exp_path,
                                              '%s_final.osim' % subject.name)

    ## walk1 condition
    walk1 = subject.add_condition('walk1', metadata={'walking_speed': 1.00})

    # GRF gait landmarks
    # walk1_trial_temp = walk1.add_trial(99, omit_trial_dir=True)
    # walk1_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk1_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    gait_events = dict()
    gait_events['right_strikes'] = [0.602, 1.777, 2.945, 4.118]
    gait_events['left_toeoffs'] = [0.792, 1.984, 3.160]
    gait_events['left_strikes'] = [1.183, 2.366, 3.519]
    gait_events['right_toeoffs'] = [1.391, 2.554, 3.733]

    walk1_trial = walk1.add_trial(
        1,
        gait_events=gait_events,
        omit_trial_dir=True,
    )

    # walk1: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk1_trial)
    helpers.generate_exotopology_tasks(walk1_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk1_trial, mrs_setup_tasks)

    ## walk2 condition
    walk2 = subject.add_condition('walk2', metadata={'walking_speed': 1.25})

    # walk2_trial = walk2.add_trial(1, omit_trial_dir=True)
    # walk2_trial.add_task(tasks.TaskUpdateGroundReactionColumnLabels)
    # walk2_trial.add_task(osp.TaskGRFGaitLandmarks, threshold=10)

    # Trial to use
    gait_events = dict()
    gait_events['right_strikes'] = [0.292, 1.376, 2.441, 3.508]
    gait_events['left_toeoffs'] = [0.458, 1.541, 2.605]
    gait_events['left_strikes'] = [0.832, 1.908, 2.968]
    gait_events['right_toeoffs'] = [1.005, 2.080, 3.142]
    walk2_trial = walk2.add_trial(
        1,
        gait_events=gait_events,
        omit_trial_dir=True,
    )
    walk2_trial.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    # walk2: main study tasks
    helpers.generate_sensitivity_tasks(walk2_trial)
    mrs_setup_tasks = helpers.generate_main_tasks(walk2_trial)
    helpers.generate_exotopology_tasks(walk2_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk2_trial, mrs_setup_tasks)

    ## walk3 condition
    walk3 = subject.add_condition('walk3', metadata={'walking_speed': 1.50})

    # GRF gait landmarks
    # walk3_trial_temp = walk3.add_trial(99, omit_trial_dir=True)
    # walk3_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk3_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    gait_events = dict()
    gait_events['right_strikes'] = [0.551, 1.558, 2.568, 3.573]
    gait_events['left_toeoffs'] = [0.699, 1.720, 2.728]
    gait_events['left_strikes'] = [1.041, 2.067, 3.068]
    gait_events['right_toeoffs'] = [1.204, 2.219, 3.224]

    walk3_trial = walk3.add_trial(
        1,
        gait_events=gait_events,
        omit_trial_dir=True,
    )

    # walk3: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk3_trial)
    helpers.generate_exotopology_tasks(walk3_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk3_trial, mrs_setup_tasks)

    ## walk4 condition
    walk4 = subject.add_condition('walk4', metadata={'walking_speed': 1.75})

    # GRF gait landmarks
    # walk4_trial_temp = walk4.add_trial(99, omit_trial_dir=True)
    # walk4_trial_temp.add_task(osp.TaskGRFGaitLandmarks)
    # walk4_trial_temp.add_task(tasks.TaskUpdateGroundReactionColumnLabels)

    gait_events = dict()
    gait_events['right_strikes'] = [0.301, 2.246, 3.209, 4.167]
    gait_events['left_toeoffs'] = [0.436, 2.377, 3.346]
    gait_events['left_strikes'] = [0.787, 2.729, 3.686]
    gait_events['right_toeoffs'] = [0.934, 2.870, 3.381]
    gait_events['stride_times'] = [1.270 - 0.301, 3.209 - 2.246, 4.167 - 3.209]
    walk4_trial = walk4.add_trial(
        1,
        gait_events=gait_events,
        omit_trial_dir=True,
    )

    # walk4: main study tasks
    mrs_setup_tasks = helpers.generate_main_tasks(walk4_trial)
    helpers.generate_exotopology_tasks(walk4_trial, mrs_setup_tasks)
    helpers.generate_coupled_controls_tasks(walk4_trial, mrs_setup_tasks)

    # multi-phase parameter calibration (trial does not matter)
    calibrate_setup_task = walk3_trial.add_task(
        tasks.TaskCalibrateParametersMultiPhaseSetup,
        ['walk1', 'walk2', 'walk3', 'walk4'], ['cycle01'],
        study.param_dict,
        study.cost_dict,
        passive_precalibrate=True)

    walk3_trial.add_task(tasks.TaskCalibrateParametersMultiPhase,
                         calibrate_setup_task)

    walk3_trial.add_task(tasks.TaskCalibrateParametersMultiPhasePost,
                         calibrate_setup_task)