Expressions: Difference between revisions
mNo edit summary |
|||
Line 5: | Line 5: | ||
|} | |} | ||
Many (but not all) edit boxes and pipeline command parameters allow the use of expressions instead of numerical values. Visual3D uses a common expression parser, so the following syntax is common. | Many (but not all) edit boxes and pipeline command parameters allow the use of expressions instead of numerical values. Visual3D uses a common expression parser, so the following syntax is common across all command parameters that allow expressions. | ||
Revision as of 18:45, 17 October 2023
Language: | English • français • italiano • português • español |
---|
Many (but not all) edit boxes and pipeline command parameters allow the use of expressions instead of numerical values. Visual3D uses a common expression parser, so the following syntax is common across all command parameters that allow expressions.
Evaluate_Expression Command
The Evaluate_Expression command allows the users to include expressions for defining the processing of the signals.
- Evaluate_Expression
- /Expression=
- !/Signal_Type=
- !/Signal_Folder=
- !/Signal_Name=
- /Result_Type=
- /Result_Folder=
- /Result_Name=
- !/Apply_as_suffix_to_signal_name=FALSE
- ;
Expression Syntax
This expression syntax is used wherever Visual3D allows an expression.
Mathematical Operators
+ | add | ||
- | subtract | ||
* | multiply | ||
/ | divide | ||
^ | power -> for example, x^2 = x to the power 2 | ||
| | logical OR -> the adjective NOT is allowed | ||
& |
logical AND-> the adjective NOT is allowed | ||
<> or >< | not equals | ||
== | equals | ||
>= or => | greater than or equal to |
Using the Adjective NOT
NOT can be used with the logical AND and logical OR
Example: Given a workspace containing 3 trials (*trial1.c3d, *trial2.c3d, and *trial3.c3d)
All trials are assigned a TAG labeled WALK
- trial1.c3d is also assigned a TAG labeled BAD
- Select_Active_File
- /FILE_NAME=WALK
- /QUERY=BAD
- ;
This command results in *trial1.c3d being active
- Select_Active_File
- /FILE_NAME=WALK
- /QUERY=NOT(BAD)
- ;
This command results in *trial2.c3d and *trial3.c3d being active.
Boolean Operator equals
= Boolean Operator equals
Example: Comparing a model metric with a string
- Consider a model metric that is defined as a string.
- Set_Model_Metric
- ! /CALIBRATION_FILE=
- /METRIC_NAME=TEST
- /METRIC_VALUE="TTT"
- ;
- Now compare it to the text string "TTT"
- Evaluate_Expression
- /EXPRESSION=MODEL::METRIC::TEST="TTT"
- /RESULT_NAME=SCOTT
- /RESULT_TYPE=METRIC
- ! /RESULT_FOLDER=PROCESSED
- ;
- The text strings should be equal so the resulting signal contains a 1
Boolean Operator less than
< Boolean Operator less than
Example:
- Given two signals
- TARGET::ORIGINAL::RFT1
- TARGET::ORIGINAL::LFT1
- Use the Boolean operator < to identify when the Z component of RFT1 is less than the Z component of LFT1
- Evaluate_Expression
- /EXPRESSION= TARGET::ORIGINAL::RFT1::Z < TARGET::ORIGINAL::LFT1::Z
- /RESULT_NAME=RFT1_GREATER
- /RESULT_TYPE=DERIVED
- /RESULT_FOLDER=PROCESSED
- ;
- The output signal will be 1 when RFT1::Z is less than LFT1::Z and 0 otherwise
Boolean Operator less than or equal to
! style="text-align:left;" | <= or =< Boolean Operator less than or equal to
Example:
- Given two signals
- TARGET::ORIGINAL::RFT1
- TARGET::ORIGINAL::LFT1
- Use the Boolean operator <= or the boolean operative =< to identify when the Z component of RFT1 is less than or equal to the Z component of LFT1
- Evaluate_Expression
- /EXPRESSION= TARGET::ORIGINAL::RFT1::Z <= TARGET::ORIGINAL::LFT1::Z
- /RESULT_NAME=RFT1_GREATER
- /RESULT_TYPE=DERIVED
- /RESULT_FOLDER=PROCESSED
- ;
- The output signal will be 1 when RFT1::Z is less than or equal toLFT1::Z and 0 otherwise
Boolean Operator greater than
> Boolean Operator greater than
Example:
- Given two signals
- TARGET::ORIGINAL::RFT1
- TARGET::ORIGINAL::LFT1
- Use the Boolean operator > to identify when the Y component of RFT1 is greater than the Y component of LFT1
- Evaluate_Expression
- /EXPRESSION= TARGET::ORIGINAL::RFT1::Y > TARGET::ORIGINAL::LFT1::Y
- /RESULT_NAME=RFT1_GREATER
- /RESULT_TYPE=DERIVED
- /RESULT_FOLDER=PROCESSED
- ;
- The output signal will be 1 when RFT1::Y is greater than LFT1::Y and 0 otherwise
Note: Visual3D parses the mathematical operators before it parses the signal names. If you have a signal name that contains a mathematical operator (e.g. R-Foot1), Visual3D will probably not be able to parse the equation expression properly.
Brackets
- Parenthesis ( and ) are used to contain the parameters in a function
Square Brackets
Square Brackets [ and ] specify frame numbers and components
- Square Brackets [ and ] are used at the end of a function call or parenthesis ( ) to specify the frames numbers and components
- Example, add two signals and retrieve the component 1 from frame 5
- Evaluate_Expression
- /Expression= (TARGET::ORIGINAL::RFT1 + TARGET::ORIGINAL::RFT2)[5,1]
- /Result_Name=RFT_ADD_X
- /Result_Type=DERIVED
- /Result_Folder=PROCESSED
- ;
- for example, add two signals and retrieve the component 1 for all frames
- Evaluate_Expression
- /Expression= (TARGET::ORIGINAL::RFT1 + TARGET::ORIGINAL::RFT2)[-1,1]
- /Result_Name=RFT_ADD_X
- /Result_Type=DERIVED
- /Result_Folder=PROCESSED
- ;
- NOTE a frame of -1 means all frames
Extracting one "component" of data from signal
- The following command will result in the DERIVED signal TEST containing the X component values of the TARGET RFT1.
- Evaluate_Expression
- /EXPRESSION=TARGET::ORIGINAL::RFT1::X
- /RESULT_NAME=TEST
- /RESULT_TYPE=DERIVED
- ! /RESULT_FOLDER=PROCESSED
- ;
Using Square Brackets and Boolean Operators
- In this example, project a collection of markers onto the floor
- whenever the z-component of a marker is less than a threshold (e.g. 0.08 in this example)
- otherwise set the resulting frame to NO_DATA
- Evaluate_Expression
- /EXPRESSION=(((CURRENT_SIGNAL[-1,3])<0.08)/((CURRENT_SIGNAL[-1,3])<0.08))*VECTOR(1,1,0)*CURRENT_SIGNAL
- /SIGNAL_TYPES=TARGET
- /SIGNAL_FOLDER=ORIGINAL
- /SIGNAL_NAMES=LFT1+LFT2+LFT3+RFT1+RFT2+RFT3
- /RESULT_TYPES=TARGET
- /RESULT_FOLDERS=GROUND
- ! /RESULT_NAME=
- /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
- ;
NO_DATA (NAN)
NAN
NAN is a reserved string used to designate "Not a Number".
Visual3D commands refer to NO_DATA or DATA_NOT_FOUND as NAN
- For example, the expression 1/0 results in NAN
isNAN
isNAN(expression) tests values against NAN - If the number is NAN the result is 1, otherwise the result is 0
- [Set_Pipeline_Parameter_From_Expression]
- /PARAMETER_NAME= NAN_TEST
- /EXPRESSION=ISNAN(1/0)
- /AS_INTEGER=TRUE
- ;
- ::NAN_TEST = 1
- [Set_Pipeline_Parameter_From_Expression]
- /PARAMETER_NAME= NAN_TEST
- /EXPRESSION=ISNAN(-999999.000000)
- /AS_INTEGER=TRUE
- ;
- ::NAN_TEST = 1
Returns "1" because -999999 is equal to Data Not Found in Visual3D.
- [Set_Pipeline_Parameter_From_Expression]
- /PARAMETER_NAME= NAN_TEST
- /EXPRESSION=ISNAN(15)
- /AS_INTEGER=TRUE
- ;
- ::NAN_TEST = 0
Example: Set negative values to NO_DATA
If the z-component of the LELB signal is below 0 set the frame to NO_DATA
- Evaluate_Expression
- /EXPRESSION=(TARGET::ORIGINAL::LELB::Z>0)/(TARGET::ORIGINAL::LELB::Z>0)*TARGET::ORIGINAL::LELB
- /RESULT_NAME=LELB
- /RESULT_TYPE=TARGET
- /RESULT_FOLDER=PROCESSED
- ;
Pipeline parameters using + as delimiter
Visual3D's pipeline parameters assume that a + is a delimiter between entries.
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.
- add(a,b) -- adds two expressions.
Visual3D Reserved Operators
There are five characters that cause the equation parser considerable trouble. We have introduced reserved pipeline commands that can be used in the place of these characters.
AMP
! style="text-align:left;" | AMP = &
For example, if the desired pipeline command were as follows:
- Select_Active_File
- /FILE_NAME=ALL_FILES
- /QUERY= TAG1 & TAG2
- ;
If the tags TAG1 and TAG2 exist then all files that have been assigned both tags will be active.
If, however, we want to use pipeline parameters in place of the text TAG1 and TAG2, we have a problem because there is no way to stop Visual3D from using the & character to concatenate the text. The solution was to introduce a reserved parameter ::AMP.
The following pipeline would result
Set_Pipeline_Parameter
- Set_Pipeline_Parameter
- /PARAMETER_NAME=A
- /PARAMETER_VALUE=TAG1
- ;
- Set_Pipeline_Parameter
- /PARAMETER_NAME=B
- /PARAMETER_VALUE=TAG2
- ;
- Select_Active_File
- /FILE_NAME=ALL_FILES
- /QUERY= ::A&::AMP&::B
- ;
This would result in Visual3D interpreting the query
- /QUERY=TAG1 & TAG2
For more: Examples of Using the AMP Operator
COLON
COLON = :
SEMICOLON
SEMICOLON = ;
PLUS
PLUS = +
FSLASH
FSLASH = /
CURRENT_SIGNAL
Used to refer to a specific signal with a simple syntax
Compute the length of one signal.
The legacy syntax is:
- Evaluate_Expression
- /EXPRESSION=LENGTH(TARGET::ORIGINAL::RFT1)
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=_LENGTH
- /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
- ;
The legacy syntax can get complicated if Pipeline_Parameters are used in the signal name because of the order in which equations are parsed.
- ! Create a pipeline parameter containing the marker name
- Set_Pipeline_Parameter
- /PARAMETER_NAME=MARKER
- /PARAMETER_VALUE=RFT1
- ;
- Evaluate_Expression
- /EXPRESSION=LENGTH(TARGET::ORIGINAL&:&:&::MARKER&)
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=_LENGTH
- ;
This gets even more complicate if the folder is also a pipeline parameter.
An alternative is the following
- Evaluate_Expression
- /EXPRESSION=LENGTH(CURRENT_SIGNAL)
- /SIGNAL_TYPES=TARGET
- /SIGNAL_FOLDER=ORIGINAL
- /SIGNAL_NAMES=::MARKER
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=_LENGTH
- /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
- ;
Used to allow multiple signals to be specified in an expression
Compute the length of TARGETS RFT1, RFT2, and RFT3 in the ORIGINAL folder
The legacy implementation requires a For_Each statement
- For_Each
- /Iteration_Parameter_Name= MARKERS
- /Items= RFT1+RFT2+RFT3
- ;
- Evaluate_Expression
- /EXPRESSION=LENGTH(TARGET::ORIGINAL&:&:&::MARKERS&)
- /SIGNAL_TYPES=TARGET
- /SIGNAL_FOLDER=ORIGINAL
- /SIGNAL_NAMES=
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=::MARKERS
- /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
- ;
- End_For_Each
- /Iteration_Parameter_Name=MARKERS
- ;
Using CURRENT_SIGNAL
- Evaluate_Expression
- /EXPRESSION=LENGTH(CURRENT_SIGNAL)
- /SIGNAL_TYPES=TARGET
- /SIGNAL_FOLDER=ORIGINAL
- /SIGNAL_NAMES=RFT1+RFT2+RFT3
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=_LENGTH
- /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
- ;
Used to Specifying all signals of a given TYPE
Compute the length of all TARGETS in the ORIGINAL folder
The legacy implementation requires a For_Each command and a command to get the names of all of the TARGETS
- Set_Pipeline_Parameter_To_List_Of_Signal_Names
- /PARAMETER_NAME=ALL_TARGETS
- /SIGNAL_TYPE=TARGET
- /SIGNAL_FOLDER=ORIGINAL
- ;
- For_Each
- /Iteration_Parameter_Name= MARKERS
- /Items= ::ALL_TARGETS
- ;
- Evaluate_Expression
- /EXPRESSION=LENGTH(TARGET::ORIGINAL&:&:&::MARKERS&)
- /SIGNAL_TYPES=TARGET
- /SIGNAL_FOLDER=ORIGINAL
- /SIGNAL_NAMES=
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=::MARKERS
- /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
- ;
- End_For_Each
- /Iteration_Parameter_Name=MARKERS
- ;
Using CURRENT_SIGNAL
- Evaluate_Expression
- /EXPRESSION=LENGTH(CURRENT_SIGNAL)
- /SIGNAL_TYPES=TARGET
- /SIGNAL_FOLDER=ORIGINAL
- /SIGNAL_NAMES=
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=_LENGTH
- /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
- ;
APPLY_AS_SUFFIX_TO_SIGNAL_NAME
If APPLY_AS_SUFFIX_TO_SIGNAL_NAME is true, OR RESULT_NAMES.size() == SIGNAL_NAMES.size()
Compute the length of all TARGETS in the ORIGINAL folder
- Evaluate_Expression
- /EXPRESSION=LENGTH(CURRENT_SIGNAL)
- /SIGNAL_TYPES=TARGET
- /SIGNAL_FOLDER=ORIGINAL
- /SIGNAL_NAMES=
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=_LENGTH
- /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
- ;
Compute the length of Two TARGETS (RFT1 and RFT2) in the ORIGINAL folder
- Evaluate_Expression
- /EXPRESSION=LENGTH(CURRENT_SIGNAL)
- /SIGNAL_TYPES=TARGET
- /SIGNAL_FOLDER=ORIGINAL
- /SIGNAL_NAMES=RFT1+RFT2
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=_LENGTH
- /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
- ;
Compute a Best_Plane_Fit for multiple signals at each frame of data
- Evaluate_Expression
- /EXPRESSION=Best_Fit_Plane(CURRENT_SIGNAL)
- /SIGNAL_TYPES=TARGET
- /SIGNAL_FOLDER=ORIGINAL
- /SIGNAL_NAMES=LSK_1+LSK_2+LSK_3
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=LSK_PLANE
- /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
- ;
If APPLY_AS_SUFFIX_TO_SIGNAL_NAME is false, AND RESULT_NAMES.size() == 1
Compute the length of one TARGET (TARGET::ORIGINAL::RFT1)
- Evaluate_Expression
- /EXPRESSION=LENGTH(TARGET::ORIGINAL::RFT1)
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=RFT1_LENGTH
- ;
Using Pipeline Parameters in an Expression
The syntax for using a pipeline parameter as part of an expression is a bit unusual and takes an understanding of how Visual3D parses parameters and pre-processes commands.
The ampersand & is used in pipeline commands to concatenate strings together, and thus is a separator for the parser to find the pieces that need to be parsed separately.
For example, to use a pipeline parameter LP_FREQ:
- /EXPRESSION=2*pi()*&::LP_FREQ
The ampersand tells the parser to take the 2*pi()* and the ::LP_FREQ separately through the pre-parser. The first part is just taken as is since it doesn't have a prefix of ::. The value after the & does have a :: prefix, so it is substituted with the pipeline parameter.
If you have more complex expressions, you might need to surround each pipeline parameter with an ampersand
- &::LP_FREQ&*&::MULTIPLIER&-&::CONSTANT which may evaluate to something like: 60*1.4-90.0 once all the pipeline parameters are substituted.
The general rule is to surround the pipeline parameter with ampersands.
Using a pipeline parameter as part of a signal definition
The syntax is a little funky when it comes to using pipeline parameters in the middle of a signal definition because of the order in which equations are parsed.
The following subtracts two signals.
- Evaluate_Expression
- /EXPRESSION=ANALOG::FILTERED&:&:&::INDEX&:&:&X&-METRIC::PROCESSED&:&:&::INDEX&_zero
- /RESULT_NAME=::INDEX
- /RESULT_TYPE=ANALOG
- /RESULT_FOLDER=OFFSET
- ;
Expressions in Model Metrics
Model metrics have a simpler syntax. The Signal Type and Signal Folder need not be specified because there is only one version of a signal.
Creating a Landmark at the center of a ball
- Given 6 markers placed on the surface of a round ball
- BALL1, BALL2, BALL3, BALL4, BALL5, BALL6
- Create a model metric at the center of a best fit sphere to the ball.
- Metric Name= BALL
- Metric Expression = Best_Fit_Sphere(List(BALL1, BALL2, BALL3, BALL4, BALL5, BALL6))
- The resulting metric will have 3 values separated by a comma (e.g. the 3 components of the center)
- As an example a center value of (0.5, 0.6, 0.7) would appear as
- 0.5,0.6,0.7
- Create a landmark using this metric data
- Note the syntax for the offsets
- BALL[1,1]
- The syntax may seem a little strange, but [1,1] refers to the first element of the first frame
Specifying a Data Tree signal
Signals should be placed into the expression in the form:
- SIGNAL_TYPE::SIGNAL_FOLDER::SIGNAL_NAME
To define a specific element of a signal (e.g. the X Component)
- SIGNAL_TYPE::SIGNAL_FOLDER::SIGNAL_NAME::X
To define a specific frame of a data of signal (e.g. Frame 2)
- SIGNAL_TYPE::SIGNAL_FOLDER::SIGNAL_NAME[2]
Data stored in the GLOBAL Workspace should be expressed as follows:
- GLOBAL::SIGNAL_TYPE::SIGNAL_FOLDER::SIGNAL_NAME
NOTE: Global signals can be accessed regardless of the ACTIVE FILES.
Examples for Specifying a Data Tree Signal
- TARGET::ORIGINAL::RFT1 = Signal RFT1 in the TARGET type and ORIGINAL folder
- ANALOG::PROCESSED::FX1 = Signal FX1 in the ANALOG type and PROCESSED folder
- PARAMETER::ANALOG::RATE= Parameter RATE in the ANALOG group of the C3D PARAMETERS
Specifying a TAG
TAGS can be expressed as follows:
- TAG::TAG_NAME
C3D Parameters can be expressed as follows:
- PARAMETER::GROUP::PARAMETER_NAME
Specifying an item from a model
The following Model data is available.
- MODEL::METRIC::NAME
- MODEL::SEGMENT::segname::LENGTH
- MODEL::SEGMENT::segname::DEPTH
- MODEL::SEGMENT::segname::CENTER_OF_MASS
- MODEL::SEGMENT::segname::IXX
- MODEL::SEGMENT::segname::IYY
- MODEL::SEGMENT::segname::IZZ
- MODEL::SEGMENT::segname::MASS
- MODEL::SEGMENT::segname::PROXIMAL_RADIUS
- MODEL::SEGMENT::segname::DISTAL_RADIUS
- MODEL::SEGMENT::segname::ORIGIN
To refer to a marker
- MODEL::TARGET::MARKER_NAME
If you want to refer to a specific component of a signal
- MODEL::TARGET::MARKER_NAME::X
To refer to a landmark
- MODEL::LANDMARK::LANDMARK_NAME
To refer to a force. NOTE This will be available in version 5.0
- MODEL::FORCE::FP1
The following command will create a global signal containing the average value of the signal FORCE::FP1 over the range of frames specified for the model (e.g. if a range is not specified, all frames will be used).
The command is executed once for each active file, so the resulting signal will continually be overwritten and the last file processed will correspond to the resulting signal.
- Evaluate_Expression
- /EXPRESSION=MODEL::FORCE::FP1
- /RESULT_NAME=GLOBAL::SCOTT
- /RESULT_TYPE=DERIVED
- ! /RESULT_FOLDER=PROCESSED
- ;
If you edit commands in the text editor, which is the only way to use evaluate_expression at the moment, you need to use the 3 letter acronyms for the names.
[Default (Internal) Segment Names]
Specifying String Data
Quotes are to be used around string data in an expression to differentiate it from variable names. ie; subject_name="John Smith". Parameters in the pipeline that are strings, are not quoted (i.e.; EXPRESSION is a string, but you don't need quotes around it). Within EXPRESSION, our expression parser parses the variables, data and operators out of the expression. Data can be doubles or strings. If it is a string, Visual3D has no way to recognize the difference between a string and a variable name reference, except to quote the string data.
For example, there is a problem with the following evaluate_expression:
- Evaluate_Expression
- /EXPRESSION=(::HandChoice="LEFT")
- /RESULT_NAME=TEST_4
- ! /RESULT_TYPE=DERIVED
- ! /RESULT_FOLDER=PROCESSED
- ;
This uses a pipeline parameter in the middle of a string parameter (the EXPRESSION). Global parameters cannot be evaluated in the middle of a string, so to recognize that a pipeline parameter, you need to concatenate it into the expression as follows:
- Evaluate_Expression
- /EXPRESSION=(&::HandChoice&="LEFT")
- /RESULT_NAME=TEST_4
- ! /RESULT_TYPE=DERIVED
- ! /RESULT_FOLDER=PROCESSED
- ;
Currently, the operators are only parsed as a single character, so the use of "/=" (not equals) cannot be used yet. You can do NOT(item1=item2) in order to process a not equals currently, but this will change shortly to allow "/=", "!=" cannot be used because the "!" is our start comment character for the pipeline commands.
Modifying String Data
- STRING_TO_UPPER(string)
- STRING_TO_LOWER(string)
!Converting To_Upper and To_Lower String Data (more...)
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST
- /EXPRESSION=STRING_TO_LOWER("XXXXXX")
- /AS_INTEGER=FALSE
- ;
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST
- /EXPRESSION=STRING_TO_UPPER("yyyyyyy")
- /AS_INTEGER=FALSE
- ;
- Select_Active_File
- /FILE_NAME=GLOBAL
- ! /QUERY=
- ;
- Create_Text_Data
- /SIGNAL_FOLDER=SCOTT
- /SIGNAL_NAMES=NAME
- /TEXT_DATA=Hello World
- ! /TEXT_FILE_NAME=
- ! /PROMPT_ON_EMPTY=TRUE
- ;
- Evaluate_Expression
- /EXPRESSION=STRING_TO_UPPER(TEXT_DATA::SCOTT::NAME)
- ! /SIGNAL_TYPES=
- ! /SIGNAL_FOLDER=ORIGINAL
- ! /SIGNAL_NAMES=
- /RESULT_TYPES=TEXT_DATA
- /RESULT_FOLDERS=SCOTT
- /RESULT_NAME=SCOTT_UPPER
- ! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE
- ;
- Evaluate_Expression
- /EXPRESSION=STRING_TO_LOWER(TEXT_DATA::SCOTT::NAME)
- ! /SIGNAL_TYPES=
- ! /SIGNAL_FOLDER=ORIGINAL
- /SIGNAL_NAMES=
- /RESULT_TYPES=TEXT_DATA
- /RESULT_FOLDERS=SCOTT
- /RESULT_NAME=SCOTT_LOWER
- ! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE
- ;
Parsing String Data
Given a pipeline parameter that is a string. For internal reasons, the string cannot be a number, or it will be interpreted as a number.
There are 3 commands that extract a portion of a string.
- STRING_LEFT(string,index)
- STRING_RIGHT(string,index)
- STRING_MID(string,index1,index2)
- STRING_LENGTH(string)
- STRING_FIND(string, substring, start)
NOTE: When referencing strings, the string should be surrounded by quotes. This identifies to Visual3D that you are referencing a string, and not a file name etc.
Parsing String Data (more...)
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST_STRING
- /EXPRESSION="A123456789"
- /AS_INTEGER=FALSE
- ;
The result is
- ::TEST_STRING = A123456789
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST_LEFT
- /EXPRESSION=STRING_LEFT("&::TEST_STRING&",3)
- /AS_INTEGER=FALSE
- ;
The result is
- ::TEST_LEFT = A12
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST_RIGHT
- /EXPRESSION=STRING_RIGHT("&::TEST_STRING&",3)
- /AS_INTEGER=FALSE
- ;
The result is
- ::TEST_RIGHT = 789
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST_MID
- /EXPRESSION=STRING_MID("&::TEST_STRING&",3,3)
- /AS_INTEGER=FALSE
- ;
The result is
- ::TEST_MID = 345
Note: For STRING_MID the number values are zero based
Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST_LENGTH
- /EXPRESSION=STRING_LENGTH("&::TEST_STRING&")
- /AS_INTEGER=TRUE
- ;
The result is
- ::TEST_LENGTH = 10
Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST_INDEX
- /EXPRESSION=STRING_FIND("&::TEST_STRING&",234,0)
- /AS_INTEGER=TRUE
- ;
The result is
- ::TEST_INDEX = 2
Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST_INDEX
- /EXPRESSION=STRING_FIND("&::TEST_STRING&",234,5)
- /AS_INTEGER=TRUE
- ;
The result is
- ::TEST_INDEX = -1
Example: Extract text (more...)
- Given the following Text_Data loaded from a file store in a signal TEXT_DATA::SCOTT:TEST
Random Stuff <Subject>Scott</Subject> More Random Stuff
- Extract the name of the subject.
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=F1
- /EXPRESSION=9+STRING_FIND(TEXT_DATA::SCOTT::TEST, "<Subject>", 0)
- /AS_INTEGER=TRUE
- ;
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=F2
- /EXPRESSION=STRING_FIND(TEXT_DATA::SCOTT::TEST, "</Subject>", 0)-&::F1
- /AS_INTEGER=TRUE
- ;
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=SUBJECT
- /EXPRESSION=String_Mid(TEXT_DATA::SCOTT::TEST,&::F1&,&::F2&)
- /AS_INTEGER=FALSE
- ;
- The resulting pipeline parameter contains "Scott"
Available Functions
Visual3D has pre-defined functions imbedded in the pipeline to help you out. These functions are commonly used or have been added based on customer use. The functions are separated into 7 categories:
Metric Functions
Signal Functions
Least Squares Fitting of Data
Intersection Functions
Assigned Force Functions
Trigonometric Functions
Array and Matrix Functions
- Vector, Unit_Vector, List
Mathematical Constants
- pi() - returns 3.14159265358979323846
- gravity() - returns the gravity vector in the workspace laboratory coordinate system.
- For a z-up coordinate system returns (0,0,-9.81)
Common Math Expressions
- int(a) - truncate each component to the nearest integer
- round(a) - round each component to the nearest integer
- fmod(y,x) - Returns the floating-point remainder of y/x
- => y and x must be one dimensional signals; returns a one dimensional signal
- abs(a) - absolute value
- sign(a)= sign of the signal ((a<0)=-1, (a>0)=1, (a==0) = 0
- sqrt(a) - square root
- exp(a) - exponent
- log(a) - natural log
- log10(a) - log base 10
Random
! style="text-align:left;" | rand(lo_value,hi_value,signal) - random number in the range (lo_value,hi_value)
- Example : rand() will generate a random number in the range 0 to 1
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST1
- /EXPRESSION=RAND()
- /AS_INTEGER=FALSE
- ;
- ::TEST1 = 0.220525
- Example : rand(lo_value,hi_value) will generate a random number in the range lo_value to hi_value
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST2
- /EXPRESSION=RAND(2,3)
- /AS_INTEGER=FALSE
- ;
- ::TEST2 = 2.232995
- Example : rand(lo_value,hi_value,signal) will generate a random number in the range lo_value to hi_value with the same number of components and frames as signal.
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST3
- /EXPRESSION=RAND(2,3,FRAME_NUMBERS::ORIGINAL::FRAMES)
- /AS_INTEGER=FALSE
- ;
- ::TEST3 = 2.808424+2.582592+2.346721+2.697052+2.662510+2.861250+2.843808+...(to number of frames)
- Example : rand(lo_value,hi_value,signal). If signal is a number, that number of values are returned.
- Set_Pipeline_Parameter_From_Expression
- /PARAMETER_NAME=TEST4
- /EXPRESSION=RAND(2,3,3)
- /AS_INTEGER=FALSE
- ;
- ::TEST4 = 2.446495 + 2.718410 + 2.201863
- Example : Create a TARGET with random values between 0 and 1
- Create_Target
- /SIGNAL_NAMES=TEST5
- ! /SIGNAL_DESCRIPTION=
- /EXPRESSION=RAND(0,1,TARGET::ORIGINAL::LFT1)
- ! /INCLUDE_CALFILE=FALSE
- ;
- Example: create a TARGET with random values between 0 and 1.
- Create_Target
- /SIGNAL_NAMES=TEST6
- ! /SIGNAL_DESCRIPTION=
- /EXPRESSION=VECTOR(RAND(0,1,FRAME_NUMBERS::ORIGINAL::FRAMES),RAND(0,1,FRAME_NUMBERS::ORIGINAL::FRAMES),RAND(0,1,FRAME_NUMBERS::ORIGINAL::FRAMES))
- ! /INCLUDE_CALFILE=FALSE
- ;
Note that all components contain different values
- Example : Create a TARGET where each frame is on a random location on the surface of a sphere of radius 1
- Evaluate_Expression
- /EXPRESSION=RAND(-PI(),PI(),FRAME_NUMBERS::ORIGINAL::FRAMES)
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=RADIUS
- /RESULT_NAME=VERTICAL
- ! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE
- ;
- Evaluate_Expression
- /EXPRESSION=RAND(0,2*PI(),FRAME_NUMBERS::ORIGINAL::FRAMES)
- /RESULT_TYPES=DERIVED
- /RESULT_FOLDERS=RADIUS
- /RESULT_NAME=HORIZONTAL
- ! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE
- ;
- Create_Target
- /SIGNAL_NAMES=SPHERE
- ! /SIGNAL_DESCRIPTION=
- /EXPRESSION=VECTOR(
- COS(DERIVED::RADIUS::VERTICAL)*COS(DERIVED::RADIUS::HORIZONTAL),
- -COS(DERIVED::RADIUS::VERTICAL)*SIN(DERIVED::RADIUS::HORIZONTAL),
- SIN(DERIVED::RADIUS::VERTICAL))
- ! /INCLUDE_CALFILE=FALSE
- ;
Length
length(x) -- creates the length (magnitude) of a vector
Distance
distance(a,b) -- distance between two signals.
- Example
- Evaluate_Expression
- /Expression= distance(LANDMARK::ORIGINAL::RIGHT_HIP , TARGET::ORIGINAL::LHIP)
- /Result_Name=PROX_THIGH_RADIUS
- ! /Result_Type=DERIVED
- ! /Result_Folder=PROCESSED
- ;
Add
add(a,b) -- add two expressions
- Visual3D's pipeline parameters assume that a + is a delimiter between entries.
- 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.
- Example. Adding two signals could be accomplished equally well by the following two commands.
- Evaluate_Expression
- /Expression= LANDMARK::ORIGINAL::RIGHT_HIP + TARGET::ORIGINAL::LHIP
- /Result_Name=TEST1
- ! /Result_Type=DERIVED
- ! /Result_Folder=PROCESSED
- ;
- Evaluate_Expression
- /Expression= add(LANDMARK::ORIGINAL::RIGHT_HIP , TARGET::ORIGINAL::LHIP)
- /Result_Name=TEST2
- ! /Result_Type=DERIVED
- ! /Result_Folder=PROCESSED
- ;
Dot
dot (a, b) -- creates the dot product of a and b
Cross
- cross (a, b) -- creates the cross product of a and b
- NOTE: Often you will want to do dot (a, b)/ length (b), or cross (a, b) / length (b)
Derivatives
- First_Derivative(a) -- creates the first derivative of the signal
- Second_Derivative(a) -- creates the second derivative of the signal
Frame Count
Frame_Count(a) -- return the number of frames in the signal
- Example. Extract the last 3 frames of data from a metric signal
- Create a test metric signal
- Metric_Explicit
- ! /RESULT_METRIC_FOLDER=PROCESSED
- /RESULT_METRIC_NAME=AA
- /METRIC_VALUE=LIST(1,2,3,4)
- ;
- Create a new signal from the last 3 frames of this metric sigal
- Evaluate_Expression
- /EXPRESSION=SNIP(METRIC::PROCESSED::AA,FRAME_COUNT(METRIC::PROCESSED::AA)-2,FRAME_COUNT(METRIC::PROCESSED::AA))
- ! /SIGNAL_TYPES=
- ! /SIGNAL_FOLDER=ORIGINAL
- ! /SIGNAL_NAMES=
- /RESULT_TYPES=METRIC
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=AB
- ! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE
- ;
- Note that in this case this is equivalent to:
- Evaluate_Expression
- /EXPRESSION=SNIP(METRIC::PROCESSED::AA,2,4)
- ! /SIGNAL_TYPES=
- ! /SIGNAL_FOLDER=ORIGINAL
- ! /SIGNAL_NAMES=
- /RESULT_TYPES=METRIC
- /RESULT_FOLDERS=PROCESSED
- /RESULT_NAME=AB
- ! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE
- ;
Expression Examples
Examples of using Evaluate_Expressions can be found here: Expressions Examples