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)

Arguments

x

dataframe of gait kinematics values. Must have columns curve_id, 0, 1, ..., 100

...

the columns of x which .f should apply to. It should really be the time domain. E.g. `60`:`100` (including the back tick).

.f

a function to summarize the kinematics. See

.dir

a single string. Either >(=),<(=),%o%, or %w%. This represents the comparative direction of the clause. The last two values represent 'outside' and 'within' respectively.

.c

numeric. The comparative threshold. See Details.

k

numeric, the number of standard deviation used to form the comparative threshold. Ignored if .c is specified.

clDesc

a character string which describes this clause. It must begin with "Cl:" which stands for 'Clause:'. If NULL (default) it is automatically constructed as Cl:f(...).dir.c

TC

a matrix of typical feature curves. Each row represent each curve, and the columns must be 0,1,...,100. See Details.

cond

a custom condition statement. See Details.

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.

Value

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.

Details

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:

  1. Select the kinematics at the relevant time points as specified by ..., call this x[...].

  2. Apply .f to x[...] and the reference curve.

  3. If .c is not specified, compute it. (e.g. mean(reference curve stats)+kstandard deviation).

  4. 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.

Functions

  • corr: correlation clause

  • custom: custom clause

  • finish: finish

Examples

library(dplyr)
#> #> Attaching package: ‘dplyr’
#> The following object is masked from ‘package:testthat’: #> #> matches
#> The following objects are masked from ‘package:stats’: #> #> filter, lag
#> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union
.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