Multiple Sclerosis
100,000
Statistics for studying 3D object orientations over time
Department of Mathematics Jean Leray, UMR CNRS 6629, Nantes University, Ecole Centrale de Nantes, France
2024-07-11
Two key numbers in France
Multiple Sclerosis
100,000
Parkinson's disease
160,000
Two key observations
Unit quaternions
Unit quaternions are hypercomplex numbers (Hamilton) of unit norm that encode a 3D rotation via:
\[ \mathbf{q} = (q_w, q_x, q_y, q_z) = \left(\cos \frac{\theta}{2}, i v_x \sin \frac{\theta}{2}, j v_y \sin \frac{\theta}{2}, k v_z \sin \frac{\theta}{2} \right), \]
where:
Algebra of unit quaternion
Usual addition and scalar multiplication do not apply.
\[ \| q_1 + q_2 \| \ne 1 \quad \| \lambda q \| \ne 1 \]
Multiplication follows Hamilton’s rule:
\[ \mathbf{p} \mathbf{q} = \begin{pmatrix} p_w q_w + p_x q_x + p_y q_y + p_z q_z \\ p_w q_x - p_x q_w - p_y q_z + p_z q_y \\ p_w q_y + p_x q_z - p_y q_w - p_z q_x \\ p_w q_z - p_x q_y + p_y q_x - p_z q_w \end{pmatrix} \]
Lie group of unit quaternions
Sola, Deray, and Atchuthan (2018)
Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.
Quaternion class
How to use Eigen in R?
The qts
class
A tibble with 5 columns:
time
: Time points at which quaternions were collected;w
: 1st coord. of each quaternion;x
: 2nd coord. of each quaternion;y
: 3rd coord. of each quaternion;z
: 4th coord. of each quaternion.An example
time | w | x | y | z |
---|---|---|---|---|
0 | 0.9942745 | 0.0797319 | 0.0698791 | 0.0133386 |
1 | 0.9948330 | 0.0745706 | 0.0676322 | 0.0131288 |
2 | 0.9954224 | 0.0693108 | 0.0645704 | 0.0126874 |
3 | 0.9960205 | 0.0639757 | 0.0609104 | 0.0118434 |
4 | 0.9965184 | 0.0594915 | 0.0574216 | 0.0107045 |
5 | 0.9969400 | 0.0557187 | 0.0540293 | 0.0093213 |
6 | 0.9972854 | 0.0527473 | 0.0507937 | 0.0077156 |
An example
# A tibble: 101 × 5
time w x y z
<int> <dec:.5!> <dec:.5!> <dec:.5!> <dec:.5!>
1 0 0.97621 0.16129 0.14303 0.02323
2 1 0.97856 0.15079 0.13832 0.02344
3 2 0.98096 0.14017 0.13241 0.02327
4 3 0.98339 0.12929 0.12539 0.02235
5 4 0.98557 0.11930 0.11828 0.02086
6 5 0.98744 0.11058 0.11124 0.01875
7 6 0.98894 0.10387 0.10465 0.01602
8 7 0.99017 0.09883 0.09812 0.01261
9 8 0.99126 0.09487 0.09128 0.00851
10 9 0.99225 0.09158 0.08394 0.00386
# ℹ 91 more rows
The qts_sample
class is a list of qts
objects.
List of methods
as_qts_sample()
, is_qts_sample()
, [
;append()
;rnorm_qts()
;scale()
;mean()
, median()
;autoplot()
, plot()
.A number of methods which can be applied to both the qts
and qts_sample
classes.
List of selected methods
log()
and exp()
: maps from and to the Lie algebra;normalize()
: ensures that all quaternions in the time series are unit quaternions;resample()
: performs uniform resampling using SLERP;smooth()
: performs smoothing of a QTS by SLERP interpolation;moving_average()
: performs QTS smoothing via moving average;hemispherize()
: ensures that there are no discontinuities in QTS due to quaternion flips since two unit quaternions \(\mathbf{q}\) and \(-\mathbf{q}\) encode the same rotation.Original manifold \(\mathbb{S}^3\)
\[ \scriptsize{ \begin{array}{rccc} \mathbf{q}: & [0,1] & \to & \mathbb{S}^3 \\ & s & \mapsto & \mathbf{q}(s) \end{array} } \]
Tangent space \(\mathcal{T}\mathbb{S}^3 \approx \mathbb{R}^3\)
\[ \scriptsize{ \begin{array}{rccc} \mathbf{t}: & [0,1] & \to & \mathbb{R}^3 \\ & s & \mapsto & \log(\mathbf{q}(s)) = (\theta(s) / 2) \mathbf{v}(s) \end{array} } \]
Square-root velocity space \(L^2 \left( [0, 1], \mathbb{R}^3 \right)\) (Srivastava and Klassen 2016)
\[ \scriptsize{ \begin{array}{rccc} \mathbf{g}: & [0,1] & \to & \mathbb{R}^3 \\ & s & \mapsto & \begin{cases} \frac{\mathbf{t}^\prime(s))}{\sqrt{\| \mathbf{t}^\prime(s)) \|}} & \text{if } \mathbf{t}^\prime(s) \neq 0 \\ 0 & \text{otherwise} \end{cases} \end{array} } \]
Clustering - Deps: fdacluster, fdasrvf, dbscan (Sangalli et al. 2010; Vantini 2012)
S3
impl. of kmeans()
, hclust()
and dbscan()
for qts_sample
objects;qtsclust
;S3
impl. of autoplot()
and plot()
for qtsclust
objects for visualization.PCA - Deps: MFPCA (Happ and Greven 2018; Happ-Kurz 2020)
S3
impl. of prcomp()
for qts_sample
objects;prcomp_qts
;S3
impl. of autoplot()
, plot()
and predict()
for prcomp_qts
objects for easy visualizations and prediction.km <- kmeans(
x = vespa64$igp, # object of class qts_sample
n_clusters = 2, # number of clusters to find
seeding_strategy = "kmeans++", # various seeding strategies
is_domain_interval = TRUE, # are curves defined on a fixed common interval?
transformation = "srsf", # transformation to apply to the curves
warping_class = "bpd", # warping class to use
metric = "l2" # distance metric to use
)
The squat package currently allows you to analyze time series of 3D object orientations
exp()
and log()
maps.Do not hesitate to create an issue on the GitHub repository if you want other statistical analyses to be implemented in the same way as the clustering and PCA.
userR! 2024 - Salzburg - aymeric.stamm@cnrs.fr