Convenient functions to integrate a clause into a feature definition.
unistat(x, ..., .f, .dir, .c, k = 1, clDesc = NULL) corr(x, ..., TC, .dir = ">=", .c = 0.8, clDesc = NULL) custom(x, ..., cond, clDesc) finish(x, featurename, fname)
x | dataframe of gait kinematics values. Must have columns curve_id, 0, 1, ..., 100 |
---|---|
... | the columns of x which |
.f | a function to summarize the kinematics. See |
.dir | a single string. Either |
.c | numeric. The comparative threshold. See |
k | numeric, the number of standard deviation used to form the comparative threshold. Ignored if |
clDesc | a character string which describes this clause. It must begin with "Cl:" which stands for 'Clause:'. If |
TC | a matrix of typical feature curves. Each row represent each curve, and the columns must be 0,1,...,100. See |
cond | a custom condition statement. See |
featurename | Character string. The human readable name of the feature. |
fname | Character string. A machine friendly version of featurename. It is recommended that you do not use any special character in this field. |
the same as x
but with an added column which indicate whether the row passes the criterion, and an inherited class as specified by the class
argument.
A feature consists of n>=1 clause(s). Each clause usually works by comparing some statistics between the curve under consideration and a reference set. Specifically, each clause works as followed:
Select the kinematics at the relevant time points as specified by ...
, call this x[...]
.
Apply .f
to x[...]
and the reference curve.
If .c
is not specified, compute it. (e.g. mean(reference curve stats)+k
standard deviation).
If .f(x[...]) .dir .c
, then it passess the clauses, thus raising a positive flag.
The unistat
function stands for univariate statistics clause. This should be the most frequently used clause.
The corr
function stands for correlation clause. A set of target curve, TC
, with which the curve under consideration will be correlated against, needs to be provided.
The .c
in this context becomes the correlation threshold so it should be between -1 and 1.
The custom
function allows user to specify other clauses that could not be (easily) specified by either unistat
or corr
.
This is useful for timing clause. e.g. custom(`60`:`100`,cond="t[which.max(angle)]>75")
.
If these convenience functions are used, then the result should always be passed to the finish
function which formats the output properly.
For example, if a feature consist of multiple clauses, the finish
function will check that each clauses are passed (i.e. positive) in order to classify the feature as being detected.
corr
: correlation clause
custom
: custom clause
finish
: finish
library(dplyr)#> #>#>#> #>#>#> #>#>#> #>.dtEPS=function(df){ df%>% filter(joint=="FootProgress"&plane=="tra")%>% unistat(`60`:`100`,.f=.ROM,.dir=">",k=2)%>% corr(`0`:`100`,TC=.tc()$ett)%>% finish(featurename = "External Foot Progression (Wave) in Swing only.",fname = "EPS") } .dtEPS(kinematics)#> # A tibble: 12 x 4 #> curve_id `Cl:.ROM(60:100)>2sd` `Cl:corr(0:100)>=0.8` EPS #> <int> <lgl> <lgl> <dbl> #> 1 29 F F 0 #> 2 30 F F 0 #> 3 59 F F 0 #> 4 60 T F 0 #> 5 89 T F 0 #> 6 90 F F 0 #> 7 119 F F 0 #> 8 120 F F 0 #> 9 149 T F 0 #> 10 150 F F 0 #> 11 179 F F 0 #> 12 180 F F 0