visual3d:documentation:pipeline:expressions:examples
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
visual3d:documentation:pipeline:expressions:examples [2024/07/16 19:28] – created sgranger | visual3d:documentation:pipeline:expressions:examples [2024/11/25 20:02] (current) – [Compute the magnitude of a vector] wikisysop | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Examples ====== | ====== Examples ====== | ||
- | ==== Examples ==== | + | ==== Create signal using another signal component |
- | + | ||
- | === Example: | + | |
Extract the z-component of a target. | Extract the z-component of a target. | ||
+ | < | ||
Evaluate_Expression | Evaluate_Expression | ||
/ | / | ||
Line 12: | Line 10: | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: Add two ANALOG signals === | + | </ |
+ | ==== Add two ANALOG signals ==== | ||
+ | |||
+ | < | ||
Evaluate_Expression | Evaluate_Expression | ||
/ | / | ||
Line 20: | Line 21: | ||
! / | ! / | ||
! / | ! / | ||
- | **;** | + | ; |
- | === Example: Divide the components of a signal === | + | </ |
+ | ==== Divide the components of a signal ==== | ||
+ | |||
+ | < | ||
Evaluate_Expression | Evaluate_Expression | ||
/ | / | ||
Line 28: | Line 32: | ||
! / | ! / | ||
! / | ! / | ||
- | **;** | + | ; |
- | === Example: Create a vector between two locations === | + | </ |
- | A Vector is created by subtracting one location from another. | + | ==== Create a vector between two locations ==== |
+ | A vector is created by subtracting one location from another. | ||
+ | |||
+ | < | ||
Evaluate_Expression | Evaluate_Expression | ||
/ | / | ||
Line 38: | Line 45: | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: Average several TARGET signals === | + | </ |
+ | ==== Average several TARGET signals ==== | ||
+ | |||
+ | < | ||
Evaluate_Expression | Evaluate_Expression | ||
/ | / | ||
Line 46: | Line 56: | ||
! / | ! / | ||
! / | ! / | ||
- | **;** | + | ; |
- | === Example: Distance between a TARGET and a LANDMARK === | + | </ |
+ | ==== Distance between a TARGET and a LANDMARK ==== | ||
+ | |||
+ | < | ||
Evaluate_Expression | Evaluate_Expression | ||
/ | / | ||
Line 54: | Line 67: | ||
! / | ! / | ||
! / | ! / | ||
- | **;** | + | ; |
- | === Example: Perpendicular distance - LANDMARK to VECTOR === | + | </ |
- | Compute the perpendicular | + | ==== Perpendicular |
- | LANDMARK:: | + | |
- | To a vector between the Hip Joint Center and Ankle Joint Center | + | |
- | LANDMARK:: | + | |
- | LANDMARK:: | + | |
- | \\ | + | |
+ | Compute the perpendicular distance from the Knee Joint Center (LANDMARK:: | ||
+ | < | ||
! create a unit_vector from the hip joint landmark (RIGHT_HIP) to the ankle joint landmark (RT_ANKLE) | ! create a unit_vector from the hip joint landmark (RIGHT_HIP) to the ankle joint landmark (RT_ANKLE) | ||
Evaluate_Expression | Evaluate_Expression | ||
Line 71: | Line 81: | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
! create a vector from the hip joint landmark (RIGHT_HIP) to the knee joint landmark (RT_KNEE) | ! create a vector from the hip joint landmark (RIGHT_HIP) to the knee joint landmark (RT_KNEE) | ||
Evaluate_Expression | Evaluate_Expression | ||
Line 78: | Line 89: | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
! compute the perpendicular distance from the RT_KNEE to the vector from the HIP to the ANKLE | ! compute the perpendicular distance from the RT_KNEE to the vector from the HIP to the ANKLE | ||
Evaluate_Expression | Evaluate_Expression | ||
Line 85: | Line 97: | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: | + | </ |
+ | |||
+ | ==== Get the actual start time of the C3D file ==== | ||
Visual3D always treats the first frame of data in the C3D file as Frame 1. If the original c3d file was truncated, so that the first frame is not 1, Visual3D retains that information and stores it in the Visual3D Parameter Group. If a user wants to compute the actual start time for the file, the following command can be used. | Visual3D always treats the first frame of data in the C3D file as Frame 1. If the original c3d file was truncated, so that the first frame is not 1, Visual3D retains that information and stores it in the Visual3D Parameter Group. If a user wants to compute the actual start time for the file, the following command can be used. | ||
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: Copying a signal === | + | </ |
- | **Evaluate_Expression** | + | ==== Copying a signal ==== |
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | Note that the Result_Folder cannot be ORIGINAL because we frown on artificially labelling a signal as ORIGINAL. If ORIGINAL is specified, the data is automatically stored in the PROCESSED folder | + | </ |
+ | |||
+ | **Note:** The Result_Folder cannot be ORIGINAL because we frown on artificially labelling a signal as ORIGINAL. If ORIGINAL is specified, the data is automatically stored in the PROCESSED folder | ||
- | === Example: | + | ==== Copy a signal to the Global Workspace |
In order to pass data between files, it is necessary to use the [[Visual3D: | In order to pass data between files, it is necessary to use the [[Visual3D: | ||
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: Copy a signal to a different signal type === | + | </ |
- | **Evaluate_Expression** | + | ==== Copy a signal to a different signal type ==== |
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | Note: the PROCESSED signal is at the sampling rate of the Analog signal. | + | </ |
- | === Example: Subtracting Two Metrics === | + | **Note:** The PROCESSED signal is at the sampling rate of the Analog signal. |
- | Subtract two metric signals. | + | ==== Subtracting Two Metrics ==== |
- | **Evaluate_Expression** | + | Subtract two metric values. |
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: Subtract Global Mean Value from Signal === | + | </ |
- | The evaluate_expression | + | === Subtract Global Mean Value from Signal === |
+ | |||
+ | The Evaluate_Expression | ||
< | < | ||
Line 144: | Line 173: | ||
! Select a specific trial and compute mean values | ! Select a specific trial and compute mean values | ||
! ----------------------------------------------- | ! ----------------------------------------------- | ||
- | </ | ||
- | < | ||
! Select OFFSET_TRIAL as active file | ! Select OFFSET_TRIAL as active file | ||
Select_Active_File | Select_Active_File | ||
Line 196: | Line 223: | ||
</ | </ | ||
- | === Example: | + | ==== Create a vector |
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | **Evaluate_Expression** | + | |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: Set 2 components of a vector to zero === | + | </ |
- | set the x and z components of a vector to zero | + | ==== Set 2 components of a vector to zero ==== |
- | **Evaluate_Expression** | + | Set the x and z components of a vector to zero |
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: Compute the magnitude of a vector === | + | </ |
- | **Evaluate_Expression** | + | ==== Compute the magnitude of a vector ==== |
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: Create a 2x2 matrix === | + | </ |
- | **Evaluate_Expression** | + | ==== Compute the maximum value of the speed of the COG ==== |
+ | |||
+ | Compute the maximum value of the speed of the Center of Mass of the model between two events | ||
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | ; | ||
+ | </ | ||
+ | ==== Create a 2x2 matrix ==== | ||
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
+ | </ | ||
The output of this command will be: | The output of this command will be: | ||
- | < | + | ^Frame ^X ^Y ^ |
- | Frame | + | |1 |11.0000 |
- | 1 | + | |2 |21.0000 |
- | 2 | + | |
- | </ | + | |
- | === Example: | + | ==== Create a 1 Hz Sine wave ==== |
Create the signal at the POINT rate. | Create the signal at the POINT rate. | ||
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
+ | </ | ||
+ | |||
Create the signal at the ANALOG rate. | Create the signal at the ANALOG rate. | ||
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: Compute the cross product of two vectors === | + | </ |
- | **Evaluate_Expression** | + | ==== Compute the cross product of two vectors ==== |
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | \\ | + | </ |
- | === Example: | + | ==== Compute the angle between two unit vectors |
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | The resulting values will be expressed in Radians. | + | </ |
- | The equivalent command that will have the result | + | The resulting values |
- | **Evaluate_Expression** | + | The equivalent command that will have the result expressed in degrees is: |
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example Integrate a Signal between Events === | + | </ |
- | Integrate a force signal | + | ==== Integrate a signal between |
- | **Evaluate_Expression** | + | Integrate signal FORCE:: |
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: Create a binary signal === | + | </ |
- | Based on a threshold | + | ==== Create |
- | **Evaluate_Expression** | + | Based on a threshold signal, make the newly created signal contain the value 1 when the original signal' |
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | \\ | + | </ |
+ | ==== Test whether Signal 1 greater than Signal 2 ==== | ||
- | === Example: Signal 1 greater than Signal 2 === | + | Given two signals, TARGET:: |
- | Given two signals | + | <code> |
- | TARGET:: | + | Evaluate_Expression |
- | TARGET:: | + | |
- | Use the Boolean operator | + | |
- | **Evaluate_Expression** | + | |
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
+ | </ | ||
The output signal will be 1 when RFT1::Z is greater than LFT1::Z and 0 otherwise | The output signal will be 1 when RFT1::Z is greater than LFT1::Z and 0 otherwise | ||
- | === Example: Set negative values to zero === | ||
- | Set all of the negative values | + | ==== Set negative values to zero ==== |
- | **Evaluate_Expression** | + | Set all of the negative values of a signal to 0.0. This expression uses the Boolean operator > to identify when the Y component of FP1 is greater than 0 |
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | This expression uses the Boolean operator | + | </code> |
+ | |||
Similarly, you can set the positive values to zero | Similarly, you can set the positive values to zero | ||
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: | + | </ |
+ | |||
+ | ==== Set negative values to NO_DATA | ||
If the z-component of the LELB signal is below 0 set the frame to NO_DATA | If the z-component of the LELB signal is below 0 set the frame to NO_DATA | ||
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: | + | </ |
+ | |||
+ | ==== If one tracking marker is no_data, make all tracking markers no_data | ||
When tracking markers drop out or go missing through out a trial, there is often an artifact in the segment pose. | When tracking markers drop out or go missing through out a trial, there is often an artifact in the segment pose. | ||
This artifact is related to two issues: | This artifact is related to two issues: | ||
- | |||
- The filtered signal isn't very good at the point of dropout | - The filtered signal isn't very good at the point of dropout | ||
- The best fit to the tracking marker template changes when the template changes. | - The best fit to the tracking marker template changes when the template changes. | ||
- | The following are different solutions that could be used:\\ | + | The following are different solutions that could be used: |
- | + | ||
- **Solution One:** Remove all signal processing until the very end. In other words filter the LINK_MODEL_BASED signals, but don't filter the TARGET or ANALOG signals. This option is consistent with Ton van den Bogert' | - **Solution One:** Remove all signal processing until the very end. In other words filter the LINK_MODEL_BASED signals, but don't filter the TARGET or ANALOG signals. This option is consistent with Ton van den Bogert' | ||
- **Solution Two:** Filter the data, and apply a median filter to the LINK_MODEL_BASED signals. This removes artifacts but we aren't sure if this is appropriate. | - **Solution Two:** Filter the data, and apply a median filter to the LINK_MODEL_BASED signals. This removes artifacts but we aren't sure if this is appropriate. | ||
Line 395: | Line 474: | ||
</ | </ | ||
- | === Example: | + | ==== Conditional Statement |
Implement a conditional expression like the following: | Implement a conditional expression like the following: | ||
+ | < | ||
for i=1:nframe | for i=1:nframe | ||
if y1(i,3)< y1(i,4) | if y1(i,3)< y1(i,4) | ||
Line 406: | Line 486: | ||
end | end | ||
end | end | ||
+ | </ | ||
+ | |||
Assume the signal y1 is a target **TARGET:: | Assume the signal y1 is a target **TARGET:: | ||
Line 420: | Line 502: | ||
</ | </ | ||
- | === Example: | + | ==== Rank Order a Set of Metrics |
Given a set of metric signals containing one component. | Given a set of metric signals containing one component. | ||
+ | *METRIC:: | ||
+ | *METRIC:: | ||
+ | *METRIC:: | ||
+ | *METRIC:: | ||
- | METRIC:: | ||
- | METRIC:: | ||
- | METRIC:: | ||
- | METRIC:: | ||
The result of the following command will be the RANK of the metric (**METRIC:: | The result of the following command will be the RANK of the metric (**METRIC:: | ||
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
- | === Example: Extracting one " | + | </ |
+ | |||
+ | ==== Example: Extracting one " | ||
The following command will result in the DERIVED signal TEST containing the X component values of the TARGET RFT1. | The following command will result in the DERIVED signal TEST containing the X component values of the TARGET RFT1. | ||
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
! / | ! / | ||
- | **;** | + | ; |
- | === Example: | + | </ |
+ | |||
+ | ==== Extracting one frame of data from a signal | ||
The following command will result in the METRIC signal TEST containing the values of the TARGET RFT1 from Frame 3. | The following command will result in the METRIC signal TEST containing the values of the TARGET RFT1 from Frame 3. | ||
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
! / | ! / | ||
- | **;** | + | ; |
- | This can be useful in the following situation. | + | </ |
- | + | ||
- | A signal exists that contains the mean and standard deviation of a signal over a gait cycle | + | |
- | + | ||
- | (e.g. created using [[Visual3D: | + | |
- | A mean signal is time normalized (by default to 101 frames). If you want one specific value of this signal, you cannot use an Event Label to specify the frame of data because Event Labels have no meaning for a signal that does not have a time base (e.g. a data rate). However, you can take advantage of the fact that you know exactly how many frames of data are in the signal. If you want the value at 25% of the range, you can simply | + | This can be useful in the following situation: a signal exists that contains the mean and standard deviation of a signal over a gait cycle (e.g. created using [[Visual3D: |
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
! / | ! / | ||
- | **;** | + | ; |
- | === Example: | + | </ |
+ | |||
+ | ==== Value of signal at an analog frame ==== | ||
Assume that you have an analog signal and the frame that you are looking for is based on a threshold crossing which usually doesn' | Assume that you have an analog signal and the frame that you are looking for is based on a threshold crossing which usually doesn' | ||
Line 492: | Line 580: | ||
/ | / | ||
; | ; | ||
- | </ | ||
- | < | ||
! Step 3 is to create a binary signal FZ2_BIN that is based on the analog signal (in this case FZ2). | ! Step 3 is to create a binary signal FZ2_BIN that is based on the analog signal (in this case FZ2). | ||
! Any analog frame that is greater than the metric value THRESH is set to 1 all other frames are set to 0 | ! Any analog frame that is greater than the metric value THRESH is set to 1 all other frames are set to 0 | ||
Line 559: | Line 645: | ||
</ | </ | ||
- | === Example: Create a SINE wave === | + | ==== Representing the equation R= (Y - M*X - B)^2 ==== |
- | + | ||
- | The following command creates a sine wave of frequency 1 Hz | + | |
- | + | ||
- | **Evaluate_Expression** | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | **;** | + | |
- | This command takes advantage of the FRAME_NUMBERS data type, which stores FRAMES and TIME. | + | |
- | + | ||
- | This data type is hidden in all versions of Visual3D prior to version 4.1 | + | |
- | + | ||
- | If the frequency was stored as a METRIC signal (e.g. METRIC:: | + | |
- | + | ||
- | **Evaluate_Expression** | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | **;** | + | |
- | === Representing the equation R= (Y - M*X - B)^2 === | + | |
Consider a DERIVED signal named TEST that is stored in the processed folder and has 2 or more component (X, Y, ....). | Consider a DERIVED signal named TEST that is stored in the processed folder and has 2 or more component (X, Y, ....). | ||
+ | *X => DERIVED:: | ||
+ | *Y => DERIVED:: | ||
- | X => DERIVED:: | ||
- | Y => DERIVED:: | ||
- | \\ | ||
Consider M and B to be two Metric signals with one component | Consider M and B to be two Metric signals with one component | ||
+ | *M => METRIC:: | ||
+ | *B => METRIC:: | ||
- | M => METRIC:: | ||
- | B => METRIC:: | ||
- | \\ | ||
The expression is represented as: | The expression is represented as: | ||
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
+ | </ | ||
The resulting signal is named RESULT and stored in the PROCESSED folder | The resulting signal is named RESULT and stored in the PROCESSED folder | ||
- | === Example: | + | ==== Comparing a model metric with a string |
Consider a model metric that is defined as a string. | Consider a model metric that is defined as a string. | ||
- | **Set_Model_Metric** | + | < |
+ | Set_Model_Metric | ||
! / | ! / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
+ | </ | ||
Now compare it to the text string " | Now compare it to the text string " | ||
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
! / | ! / | ||
- | **;** | + | ; |
+ | </ | ||
The text strings should be equal so the resulting signal contains a 1 | The text strings should be equal so the resulting signal contains a 1 | ||
- | === Example: | + | ==== Exporting a model metric |
Model metrics cannot be exported directly. You can, however, copy the model metric to a regular metric signal that can be exported. It is probably safest to create the new metric signal as a global metric because it isn't associated with any particular movement trial. For example the commands below will export the length of the right thigh segment. | Model metrics cannot be exported directly. You can, however, copy the model metric to a regular metric signal that can be exported. It is probably safest to create the new metric signal as a global metric because it isn't associated with any particular movement trial. For example the commands below will export the length of the right thigh segment. | ||
Line 650: | Line 721: | ||
</ | </ | ||
- | === Example | + | ==== Store a Model Metric in the Data Tree ==== |
Model metrics are stored with the model, but the data can be moved to each C3D file (stored in the data tree). This example will multiply the model metrics for mass and height to use for normalizing a signal. The resulting metric is called MASS_X_HEIGHT and will be stored in the METRIC:: | Model metrics are stored with the model, but the data can be moved to each C3D file (stored in the data tree). This example will multiply the model metrics for mass and height to use for normalizing a signal. The resulting metric is called MASS_X_HEIGHT and will be stored in the METRIC:: | ||
Line 663: | Line 734: | ||
</ | </ | ||
- | === Example: | + | ==== Quasi Case Statement |
Given a group of unilaterally affected subjects. The Left side calculations could be the " | Given a group of unilaterally affected subjects. The Left side calculations could be the " | ||
Line 671: | Line 742: | ||
< | < | ||
! Define Side Parameters | ! Define Side Parameters | ||
- | </ | ||
- | < | ||
Set_Pipeline_Parameter | Set_Pipeline_Parameter | ||
/ | / | ||
Line 732: | Line 801: | ||
</ | </ | ||
- | === Example: | + | ==== Get Time At Event ==== |
Get the event times for the label **ONSET** and place them in the metric folder | Get the event times for the label **ONSET** and place them in the metric folder |
visual3d/documentation/pipeline/expressions/examples.1721158089.txt.gz · Last modified: 2024/07/16 19:28 by sgranger