====== Virtual Lab Direction of Progression Method 2 ====== This script is explained in the Virtual Lab Direction of Progression tutorial. This script outlines [[Visual3D:Documentation:Modeling:Virtual_Lab:Virtual_Lab_Direction_of_Progression#Method_2|Method 2]]. Before running this script: * A static trial must be loaded into the workspace * A model template (with modified virtual lab) must be loaded into the workspace * A dynamic trial must be loaded into the workspace NOTE: A modified virtual lab follows the same outline as the [[Visual3D:Tutorials:Modeling:Virtual_Laboratory_#Example:_Creating_a_virtual_laboratory_that_changes_with_the_direction_of_walking|Dynamic Virtual Lab]], except instead of using the Lab_X landmark, the Dir_Prog_X landmark is used. An example of this model template can be found here. \\ **__Add_a_Comment__** ! /COMMENT= 1. Get the initial position of the origin of the pelvis (RPVo) ; ! Get the position of the pelvis at the start of the trial Event_Explicit /EVENT_NAME=TRIAL_START /FRAME=20 ! /TIME= ; Metric_Signal_Value_At_Event /RESULT_METRIC_NAME=RPV_START ! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE /RESULT_METRIC_FOLDER=PROG /SIGNAL_TYPES=KINETIC_KINEMATIC /SIGNAL_NAMES=CGPos /SIGNAL_FOLDER=RPV ! /SIGNAL_COMPONENTS= /COMPONENT_SEQUENCE=ALL /EVENT_NAME=TRIAL_START /GENERATE_MEAN_AND_STDDEV=FALSE ! /APPEND_TO_EXISTING_VALUES=FALSE ! /GENERATE_VECTOR_LENGTH_METRIC=FALSE ! /RETAIN_NO_DATA_VALUES=FALSE ; ! Project the pelvis location onto the floor Evaluate_Expression /EXPRESSION=VECTOR ( METRIC::PROG::RPV_START::1 , METRIC::PROG::RPV_START::2 , 0 ) /RESULT_NAME=RPV_START_PROJ /RESULT_TYPE=METRIC /RESULT_FOLDER=PROG ; ! Create a time based signal from the metric location of the projected pelvis Evaluate_Expression /EXPRESSION=METRIC::PROG::RPV_START_PROJ * ( (FRAME_NUMBERS::ORIGINAL::FRAMES * 0 + 1 ) ) /RESULT_NAME=RPV_START_VEC /RESULT_TYPE=DERIVED /RESULT_FOLDER=PROG ; **__Add_a_Comment__** ! /COMMENT= ; ! 2. Create a vector from the origin of the pelvis that offset in the -Y direction of the lab (-Y) Evaluate_Expression /EXPRESSION=( VECTOR ( 0 , -1 , 0 ) * ( (FRAME_NUMBERS::ORIGINAL::FRAMES * 0+1 ) ) ) + DERIVED::PROG::RPV_START_VEC /RESULT_NAME=RPV_START_VEC_X /RESULT_TYPE=DERIVED /RESULT_FOLDER=PROG ; ! 3. Project the pelvis origin onto the floor Evaluate_Expression /EXPRESSION=VECTOR (KINETIC_KINEMATIC::RPV::PROXENDPOS::X , KINETIC_KINEMATIC::RPV::PROXENDPOS::Y , 0) /RESULT_NAME=RPV_ORIGIN /RESULT_TYPE=DERIVED /RESULT_FOLDER=PROG ; ! 4. Calculate the angle between the origin of the pelvis at t=0, the -Y direction of the lab, and the direction of progression (DOP) at each time point in the trial Compute_Planar_Angle /SIGNAL_TYPES=DERIVED /SIGNAL_FOLDER=PROG /SIGNAL_NAMES=RPV_START_VEC_X+RPV_START_VEC+RPV_ORIGIN /RESULT_FOLDER=PROG /RESULT_NAME=RPV_ORIENTATION ! /COMPUTE_3PT_ANGLE=TRUE ! /NORMALX= ! /NORMALY= ! /NORMALZ= ! /REFERENCE_SEGMENT=LAB ! /PROJECTION_PLANE=XY ! /USE_RIGHT_HAND_RULE=TRUE /USE_0_TO_360_DEGREES=FALSE ; ! 5. Calculate the metric direction of progression based on the angle (Theta Y) between the direction of progression and the Y Axis Metric_Median /RESULT_METRIC_FOLDER=PROG /RESULT_METRIC_NAME=_MED /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE /SIGNAL_TYPES=DERIVED /SIGNAL_FOLDER=PROG /SIGNAL_NAMES=RPV_ORIENTATION /SIGNAL_COMPONENTS= /COMPONENT_SEQUENCE=ALL /EVENT_SEQUENCE= /EXCLUDE_EVENTS= ! /SEQUENCE_PERCENT_START=0 ! /SEQUENCE_PERCENT_END=100 ! /GENERATE_MEAN_AND_STDDEV=TRUE ! /APPEND_TO_EXISTING_VALUES=FALSE ; **__Add_a_Comment__** ! /COMMENT= Define the virtual lab based on theta Y ; Set_Pipeline_Parameter_From_Expression /PARAMETER_NAME=ANGLE /EXPRESSION=GLOBAL::METRIC::PROG::RPV_ORIENTATION_MED_MEAN ! /AS_INTEGER=TRUE ; Add_Landmark /LANDMARK_NAME=Dir_Prog_X ! /CALIBRATION_FILE= ! /USER_GENERATED=TRUE ! /USE_PERCENTAGE=FALSE ! /CALIBRATION_ONLY=FALSE ! /USE_TARGETS=FALSE /SEGMENT_NAME=LAB ! /TARGET_TYPES= ! /TARGET_NAMES= /MCS_ML= - 0.1 * SIN ( ( 90 - &::ANGLE& ) * pi()/180 ) /MCS_AP= - 0.1* COS ( ( 90 - &::ANGLE& ) * pi()/180 ) /MCS_AXIAL=0 ! /LANDMARK_LOCATION= ! /REFERENCE_LOCATION_TYPE= ! /REFERENCE_LOCATION_NAME= ! /USE_REFERENCE_LOCATION=FALSE ; Build_Model ! /CALIBRATION_FILE= ! /REBUILD_ALL_MODELS=FALSE ! /DISPLAY_RESULTS=TRUE ; Recalc ;