visual3d:documentation:pipeline:expressions:signal_functions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
visual3d:documentation:pipeline:expressions:signal_functions [2024/08/30 21:34] – [Data_Exists] wikisysop | visual3d:documentation:pipeline:expressions:signal_functions [2024/11/15 19:27] (current) – [Point_Tracked_By_3Points] wikisysop | ||
---|---|---|---|
Line 28: | Line 28: | ||
**add(a, | **add(a, | ||
- | Visual3D' | + | |
+ | Visual3D' | ||
If the user wants to use an expression containing a + in a command that allows multiple signals, Visual3D will interpret this plus sign incorrectly. | If the user wants to use an expression containing a + in a command that allows multiple signals, Visual3D will interpret this plus sign incorrectly. | ||
The workaround is to use a mathematical function add() to express the addition. | The workaround is to use a mathematical function add() to express the addition. | ||
+ | |||
Example. Adding two signals could be accomplished equally well by the following two commands. | Example. Adding two signals could be accomplished equally well by the following two commands. | ||
+ | |||
+ | < | ||
Evaluate_Expression | Evaluate_Expression | ||
/ | / | ||
Line 37: | Line 41: | ||
! / | ! / | ||
! / | ! / | ||
- | **;** | + | ; |
Evaluate_Expression | Evaluate_Expression | ||
/ | / | ||
Line 43: | Line 48: | ||
! / | ! / | ||
! / | ! / | ||
- | **;** | + | ; |
+ | </ | ||
==== Sort ==== | ==== Sort ==== | ||
**sort(signal, | **sort(signal, | ||
+ | < | ||
sort(target:: | sort(target:: | ||
sort(target:: | sort(target:: | ||
Line 53: | Line 60: | ||
sort(target:: | sort(target:: | ||
sort(target:: | sort(target:: | ||
+ | </ | ||
==== Transpose ==== | ==== Transpose ==== | ||
Line 60: | Line 68: | ||
Example of it's use, creates a list of metrics of the mean of the z component of the target rft1 from RTO to RHS. (note, the spline didn't have to be done here, but it is here just to show it's use). | Example of it's use, creates a list of metrics of the mean of the z component of the target rft1 from RTO to RHS. (note, the spline didn't have to be done here, but it is here just to show it's use). | ||
- | **Evaluate_Expression** | + | < |
+ | Evaluate_Expression | ||
/ | / | ||
! / | ! / | ||
Line 69: | Line 78: | ||
/ | / | ||
! / | ! / | ||
- | **;** | + | ; |
+ | </ | ||
==== First_Derivative ==== | ==== First_Derivative ==== | ||
+ | [[visual3d: | ||
==== Second_Derivative ==== | ==== Second_Derivative ==== | ||
+ | [[visual3d: | ||
==== Interpolate ==== | ==== Interpolate ==== | ||
Line 89: | Line 99: | ||
For example, | For example, | ||
+ | < | ||
Resolve_Discontinuity(link_model_based:: | Resolve_Discontinuity(link_model_based:: | ||
Resolve_Discontinuity(link_model_based:: | Resolve_Discontinuity(link_model_based:: | ||
Resolve_Discontinuity(link_model_based:: | Resolve_Discontinuity(link_model_based:: | ||
+ | </ | ||
+ | |||
**Note that the event label requires the full signal path. i.e. event_label:: | **Note that the event label requires the full signal path. i.e. event_label:: | ||
+ | |||
One of the interesting consequences of this decision is that the command is actually looking for an array of "frame times" so you could actually use a number or a metric signal or an expression. | One of the interesting consequences of this decision is that the command is actually looking for an array of "frame times" so you could actually use a number or a metric signal or an expression. | ||
Example, a figure skater spinning has a rotation angle that continues to increase; a double jump may cover 720 degrees. | Example, a figure skater spinning has a rotation angle that continues to increase; a double jump may cover 720 degrees. | ||
Line 107: | Line 121: | ||
Resolve_Discontinuity(signal, | Resolve_Discontinuity(signal, | ||
+ | |||
The range represents the range of motion of the signal. In the figure skating example above, the range is 360 degrees. | The range represents the range of motion of the signal. In the figure skating example above, the range is 360 degrees. | ||
The value of the signal at the specified instance of the event_label is assumed to be "in the range" | The value of the signal at the specified instance of the event_label is assumed to be "in the range" | ||
Line 113: | Line 128: | ||
Resolve_Discontinuity(signal, | Resolve_Discontinuity(signal, | ||
+ | |||
The first instance of the event is used. | The first instance of the event is used. | ||
if the instance and the event_label are omitted: | if the instance and the event_label are omitted: | ||
Resolve_Discontinuity(signal, | Resolve_Discontinuity(signal, | ||
+ | |||
the first valid frame is used | the first valid frame is used | ||
\\ | \\ | ||
Example: the angle of a golf club to the anterior direction of the golfer (LINK_MODEL_BASED:: | Example: the angle of a golf club to the anterior direction of the golfer (LINK_MODEL_BASED:: | ||
- | The has a discontinuity as the signal goes beyond the range possible for computing the Cardan Sequence. | + | The has a discontinuity as the signal goes beyond the range possible for computing the Cardan Sequence.\\ |
- | The following expression adds 360 at the point of discontinuity | + | The following expression adds 360 at the point of discontinuity\\ |
- | At the Event_Label **TAKEAWAY** the club angle is assumed to be " | + | At the Event_Label **TAKEAWAY** the club angle is assumed to be " |
- | The command is looking for the time of the event, so it is important to use the full signal name EVENT_LABEL:: | + | The command is looking for the time of the event, so it is important to use the full signal name EVENT_LABEL:: |
- | At a discontinuity 360 degrees is either added or subtracted from the value depending on the direction of the discontinuity. | + | At a discontinuity 360 degrees is either added or subtracted from the value depending on the direction of the discontinuity.\\ |
- | **Evaluate_Expression** | + | |
+ | < | ||
+ | Evaluate_Expression | ||
/ | / | ||
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
+ | </ | ||
==== Indefinite Integral ==== | ==== Indefinite Integral ==== | ||
Line 138: | Line 158: | ||
[[Visual3D: | [[Visual3D: | ||
+ | < | ||
Example; | Example; | ||
Indefinite_Integral(target:: | Indefinite_Integral(target:: | ||
Line 143: | Line 164: | ||
Indefinite_Integral(target:: | Indefinite_Integral(target:: | ||
Indefinite_Integral(target:: | Indefinite_Integral(target:: | ||
+ | </ | ||
+ | |||
+ | **Note that the event label requires the full signal path. i.e. event_label:: | ||
+ | |||
+ | ==== Cumulative_Sum ==== | ||
+ | |||
+ | **Cumulative_Sum(signal, | ||
+ | |||
+ | < | ||
+ | Example; | ||
+ | Cumulative_Sum(target:: | ||
+ | Cumulative_Sum(target:: | ||
+ | Cumulative_Sum(target:: | ||
+ | Cumulative_Sum(target:: | ||
+ | Cumulative_Sum(target:: | ||
+ | </ | ||
+ | |||
**Note that the event label requires the full signal path. i.e. event_label:: | **Note that the event label requires the full signal path. i.e. event_label:: | ||
==== Point Relative to 3 Points ==== | ==== Point Relative to 3 Points ==== | ||
Line 152: | Line 190: | ||
Consider the hypothetical situation. | Consider the hypothetical situation. | ||
+ | < | ||
There are two sets of motion trials, tagged condition1 and condition2 | There are two sets of motion trials, tagged condition1 and condition2 | ||
there are two static files (e.g. two models) | there are two static files (e.g. two models) | ||
Line 160: | Line 199: | ||
/ | / | ||
! /QUERY= | ! /QUERY= | ||
- | **;** | + | ; |
! determine the offsets of marker RLKNEE relative to the three markers RTH1, RTH2, and RTH3 | ! determine the offsets of marker RLKNEE relative to the three markers RTH1, RTH2, and RTH3 | ||
! and save as a pipeline parameter | ! and save as a pipeline parameter | ||
- | **Set_Pipeline_Parameter_From_Expression** | + | Set_Pipeline_Parameter_From_Expression |
/ | / | ||
/ | / | ||
Line 169: | Line 209: | ||
**;** | **;** | ||
! making condition2 active will make model2 active. | ! making condition2 active will make model2 active. | ||
- | \\ | ||
- | + | Select_Active_File | |
- | **Select_Active_File** | + | |
/ | / | ||
! /QUERY= | ! /QUERY= | ||
- | **;** | + | ; |
! now create a landmark for RLKNEE in the second model | ! now create a landmark for RLKNEE in the second model | ||
- | **Add_Landmark** | + | Add_Landmark |
/ | / | ||
! / | ! / | ||
Line 194: | Line 233: | ||
! / | ! / | ||
! / | ! / | ||
- | **;** | + | ; |
- | \\ | + | </ |
+ | ==== Point_Tracked_By_3Points ==== | ||
+ | |||
+ | **Point_Tracked_By_3Points(Point1, | ||
+ | |||
+ | This function was implemented to used DERIVED signals as tracking markers for a point relative to these tracking markers. | ||
+ | |||
+ | In other words, this is mimics a LANDMARK in which a point is tracked by three TARGETS or LANDMARKS in a model. | ||
+ | |||
+ | The difference is that a model isn't required. | ||
+ | |||
+ | Why would this be useful?\\ | ||
+ | The c3d format specifies that the lowest sampling rate is the POINT rate (i.e. the marker rate)\\ | ||
+ | Marker based tracking, however, often has possible sampling rates that are much higher than video rates used by markerless tracking.\\ | ||
+ | In a situation like baseball batting or golf many users record marker and markerless synchronously and merge the files.\\ | ||
+ | The markers are used to track the club or bat at a higher sampling rate than the video\\ | ||
+ | Then the c3d format, and Visual3D' | ||
+ | When merging the two files, Visual3D automatically downsamples the POINT rate to the ROTATION rate.\\ | ||
+ | To compensate (at least somewhat), Visual3D stores a copy of the POINT data as a DERIVED signal at the original POINT rate\\ | ||
+ | The data is preserved, but the model and model based items cannot refer to the DERIVED signals\\ | ||
+ | The workaround is to perform some calculations only on the DERIVED signals independent of any model.\\ | ||
+ | **As as aside, for some applications, | ||
+ | |||
+ | Example: | ||
+ | locate a point in the model relative to 3 markers\\ | ||
+ | then track this point in the movement trial | ||
+ | |||
+ | < | ||
+ | Evaluate_Expression | ||
+ | / | ||
+ | | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ; | ||
+ | </ | ||
==== Snip ==== | ==== Snip ==== | ||
Line 218: | Line 292: | ||
=== Example === | === Example === | ||
- | This example | + | Example 1 demonstrates how the Snip expression can be used to extract the last 3 frames of data from a metric signal. |
< | < | ||
Line 256: | Line 330: | ||
</ | </ | ||
+ | Example 2 demonstrates how the Snip expression in conjunction with spline, and several other functions | ||
+ | |||
+ | < | ||
+ | The following pipeline resulted from a support email.\\ | ||
+ | The request was to compare several different methods for defining the hip and knee angles\\ | ||
+ | Signals were created by pairwise subtracting one signal from another signal\\ | ||
+ | Each of the difference signals in several files were parsed into regions defined by an event sequence\\ | ||
+ | Each region was then time normalized to 101 points\\ | ||
+ | The RMS for each region was then computed.\\ | ||
+ | Each file, therefore, contained a number of RMS values\\ | ||
+ | The RMS signals from each file were then concatenated into a signal GLOBAL signal containing values from all files | ||
+ | |||
+ | Select_Active_File | ||
+ | / | ||
+ | ! /QUERY= | ||
+ | ! / | ||
+ | ; | ||
+ | |||
+ | ! difference signals were stored as DERIVED:: | ||
+ | ! Create a pipeline parameter containing a list of the signal names in this folder | ||
+ | |||
+ | Set_Pipeline_Parameter_To_List_Of_Signal_Names | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | ; | ||
+ | |||
+ | ! Use a For_Each command to iteratively act on each signal in the list | ||
+ | |||
+ | For_Each | ||
+ | / | ||
+ | ! / | ||
+ | / | ||
+ | ; | ||
+ | |||
+ | ! While it might be possible to provide a solution with a single expression, it would | ||
+ | ! take some time to modify Visual3D | ||
+ | ! the following the commands (one for each of x, y, z) do 3 things | ||
+ | ! isolates the data with the event sequence selected | ||
+ | ! resamples the data to 101 points using a cubic spline | ||
+ | ! create a resulting signal that has a column for each event sequence in the file time normalized to 101 frames | ||
+ | |||
+ | Evaluate_Expression | ||
+ | / | ||
+ | SPLINE( | ||
+ | SNIP(CURRENT_SIGNAL, | ||
+ | ) | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ; | ||
+ | |||
+ | Evaluate_Expression | ||
+ | / | ||
+ | SPLINE( | ||
+ | SNIP(CURRENT_SIGNAL, | ||
+ | ) | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ; | ||
+ | |||
+ | Evaluate_Expression | ||
+ | / | ||
+ | SPLINE( | ||
+ | SNIP(CURRENT_SIGNAL, | ||
+ | ) | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ; | ||
+ | |||
+ | ! the following command consolidates the above information | ||
+ | ! the RMS value of each column is computed | ||
+ | ! the signal is transposed so that each RMS value for each event sequence is on a different line | ||
+ | ! x,y, and z values for the RMS are then stored in one signal | ||
+ | | ||
+ | Evaluate_Expression | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | ; | ||
+ | |||
+ | End_For_Each | ||
+ | / | ||
+ | ; | ||
+ | |||
+ | ! Create a pipeline containing the names of the metric signals just created | ||
+ | |||
+ | Set_Pipeline_Parameter_To_List_Of_Signal_Names | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | ; | ||
+ | |||
+ | ! Concatenate the RMS metric signals into one GLOBAL signal containing all RSM values | ||
+ | ! across all files | ||
+ | ! Make the GLOBAL workspace active and you should see the results. | ||
+ | |||
+ | For_Each | ||
+ | / | ||
+ | ! / | ||
+ | / | ||
+ | ; | ||
+ | |||
+ | Evaluate_Expression | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | ; | ||
+ | |||
+ | End_For_Each | ||
+ | / | ||
+ | ; | ||
+ | </ | ||
==== Spline ==== | ==== Spline ==== | ||
Line 268: | Line 486: | ||
This takes the signal list, and appends each signal into one signal as new components. | This takes the signal list, and appends each signal into one signal as new components. | ||
+ | |||
**Append_As_Frames(signal_list)** | **Append_As_Frames(signal_list)** | ||
This takes a signal list, and appends each signal to the end of the previous signal to create the result with each signal appended to each other as new frames | This takes a signal list, and appends each signal to the end of the previous signal to create the result with each signal appended to each other as new frames | ||
- | \\ | + | |
**Append_As_Frames** Example: | **Append_As_Frames** Example: | ||
+ | < | ||
Open any cmz file with more than 1 file | Open any cmz file with more than 1 file | ||
- | [[Visual3D: | + | Select_Active_File |
/ | / | ||
! /QUERY= | ! /QUERY= | ||
**;** | **;** | ||
+ | |||
! Create a metric signal with 3 components and 1 frame | ! Create a metric signal with 3 components and 1 frame | ||
- | [[Visual3D: | + | Metric_Explicit |
/ | / | ||
/ | / | ||
/ | / | ||
- | **;** | + | ; |
!The following command will concatenate the metric signal from each file | !The following command will concatenate the metric signal from each file | ||
!into a GLOBAL metric signal. | !into a GLOBAL metric signal. | ||
Line 296: | Line 518: | ||
/ | / | ||
! / | ! / | ||
- | **;** | + | ; |
+ | </ | ||
visual3d/documentation/pipeline/expressions/signal_functions.1725053644.txt.gz · Last modified: 2024/08/30 21:34 by wikisysop