# approx_tensors: Tensor Interpolation In astamm/fdatractography: Functional Data Analysis for Tractography in R

## Description

The function `approx_tensors` is the analog to the `approx` function for interpolating `tensor`-valued data.

## Usage

 ```1 2``` ```approx_tensors(x, tensors, xout, method = "linear", n = 50, yleft, yright, rule = 1, ties = mean) ```

## Arguments

 `x` Numeric vector specifying the locations at which tensors are defined. `tensors` List of `tensor` objects to be interpolated. `xout` An optional set of numeric values specifying where interpolation is to take place. `method` Specifies the interpolation method to be used. Choices are "linear" [default] or "log" for interpolating in the log-Euclidean space. `n` If `xout` is not specified, interpolation takes place at `n` equally spaced points spanning the interval ```[min(x), max(x)]```. Default is `n = 50`. `yleft` The value to be returned when input `x` values are less than `min(x)`. The default is defined by the value of `rule` given below. `yright` The value to be returned when input `x` values are greater than `max(x)`. The default is defined by the value of `rule` given below. `rule` An integer (of length 1 or 2) describing how interpolation is to take place outside the interval `[min(x), max(x)]`. If `rule` is 1 then `NA`s are returned for such points and if it is 2, the value at the closest data extreme is used. Use, e.g., `rule = 2:1`, if the left and right side extrapolation should differ. `ties` Handling of tied `x` values. Either a function with a single vector argument returning a single number result or the string `"ordered"`.

## Details

If `method == "linear"`, it performs linear tensor interpolation according to the paper by Gahm, J. K., Wisniewski, N., Kindlmann, G., Kung, G. L., Klug, W. S., Garfinkel, A., & Ennis, D. B. (2012, October). Linear invariant tensor interpolation applied to cardiac diffusion tensor MRI. In International Conference on Medical Image Computing and Computer-Assisted Intervention (pp. 494-501). Springer, Berlin, Heidelberg. If ```method == "log"```, it performs log-Euclidean tensor interpolation according to the paper by Arsigny, V., Fillard, P., Pennec, X. and Ayache, N. (2006) ‘Log-Euclidean metrics for fast and simple calculus on diffusion tensors.’, Magnetic resonance in medicine : official journal of the Society of Magnetic Resonance in Medicine / Society of Magnetic Resonance in Medicine, 56(2), pp. 411–21. doi: 10.1002/mrm.20965.

## Value

A `list` with components `x` and `y`, containing `n` coordinates which interpolate the given data points according to the `method` (and `rule`) desired.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15``` ```theta <- c(0, pi/6, pi/4, pi/3, pi/2) R <- NULL for (i in seq_along(theta)) { th <- theta[i] R[[i]] <- cbind( c(cos(th), sin(th), 0), c(-sin(th), cos(th), 0), c(0, 0, 1) ) } L <- diag(c(1.7, 0.3, 0.1)) D <- purrr::map(R, ~ . %*% L %*% t(.)) s <- seq(0, 1, length.out = length(theta)) approx_tensors(s, D) approx_tensors(s, D, method = "log") ```

astamm/fdatractography documentation built on May 12, 2019, 5:37 a.m.