Utility Functions

Utility functions for SRSF Manipulations

moduleauthor:: Derek Tucker <dtucker@stat.fsu.edu>

utility_functions.SqrtMean(gam)[source]

calculates the srsf of warping functions with corresponding shooting vectors

Parameters:gam – numpy ndarray of shape (M,N) of M warping functions with N samples
Return type:2 numpy ndarray and vector
Return mu:Karcher mean psi function
Return gam_mu:vector of dim N which is the Karcher mean warping function
Return psi:numpy ndarray of shape (M,N) of M SRSF of the warping functions
Return vec:numpy ndarray of shape (M,N) of M shooting vectors
utility_functions.SqrtMeanInverse(gam)[source]

finds the inverse of the mean of the set of the diffeomorphisms gamma

Parameters:gam – numpy ndarray of shape (M,N) of M warping functions with N samples
Return type:vector
Return gamI:inverse of gam
utility_functions.cumtrapzmid(x, y, c)[source]

cummulative trapzodial numerical integration taken from midpoint

Parameters:
  • x – vector of size N descibing the time samples
  • y – vector of size N describing the function
  • c – midpoint
Return type:

vector

Return fa:

cummulative integration

utility_functions.elastic_distance(f1, f2, time, lam=0.0)[source]

” calculates the distnaces between function, where f1 is aligned to f2. In other words caluclates the elastic distances

Parameters:
  • f1 – vector of size N
  • f2 – vector of size N
  • time – vector of size N describing the sample points
  • lam – controls the elasticity (default = 0.0)
Return type:

scalar

Return Dy:

amplitude distance

Return Dx:

phase distance

utility_functions.f_to_srvf(f, time)[source]

converts f to a square-root slope function (SRSF)

Parameters:
  • f – vector of size N samples
  • time – vector of size N describing the sample points
Return type:

vector

Return q:

srsf of f

utility_functions.gradient_spline(time, f)[source]

This function takes the gradient of f using b-spline smoothing

Parameters:
  • time – vector of size N describing the sample points
  • f – numpy ndarray of shape (M,N) of M functions with N samples
Return type:

tuple of numpy ndarray

Return f0:

smoothed functions functions

Return g:

first derivative of each function

Return g2:

second derivative of each function

utility_functions.invertGamma(gam)[source]

finds the inverse of the diffeomorphism gamma

Parameters:gam – vector describing the warping function
Return type:vector
Return gamI:inverse of gam
utility_functions.optimum_reparam(q1, time, q2, lam=0.0)[source]

calculates the warping to align srsf q2 to q1

Parameters:
  • q1 – vector of size N or array of NxM samples of first SRSF
  • time – vector of size N describing the sample points
  • q2 – vector of size N or array of NxM samples samples of second SRSF
  • lam – controls the amount of elasticity (default = 0.0)
Return type:

vector

Return gam:

describing the warping function used to align q2 with q1

utility_functions.outlier_detection(q, time, mq, k=1.5)[source]

calculates outlier’s using geodesci distnaces of the SRSFs from the median

Parameters:
  • q – numpy ndarray of N x M of M SRS functions with N samples
  • time – vector of size N describing the sample points
  • mq – median calculated using time_warping.srsf_align()
  • k – cutoff threshold (default = 1.5)
Returns:

q_outlier: outlier functions

utility_functions.rgam(N, sigma, num)[source]

Generates random warping functions

Parameters:
  • N – length of warping function
  • sigma – variance of warping functions
  • num – number of warping functions
Returns:

gam: numpy ndarray of warping functions

utility_functions.smooth_data(f, sparam)[source]

This function smooths a collection of functions using a box filter

Parameters:
  • f – numpy ndarray of shape (M,N) of M functions with N samples
  • sparam – Number of times to run box filter (default = 25)
Return type:

numpy ndarray

Return f:

smoothed functions functions

Previous topic

Functional Principal Component Analysis

This Page