Group Signal Alignment

Dave Deriso · 2026

When analyzing collections of time series—whether neural recordings, motion capture data, or physiological signals—we often encounter signals that share a common underlying shape but are misaligned in time. Standard averaging smears out these temporal differences, destroying the very structure we want to study. Group signal alignment solves this by jointly finding a common reference and the time warps that best align each signal to it.

In time-warped group alignment, the goal is to estimate central tendency μ(t)\textcolor{#f97316}{\mu}(t). We solve this using GDTW with iterative refinement. Below is an illustration.

Dataset:
Computing...
Computing...

Optimization Formulation

We formulate group alignment as an optimization problem, where the warp functions ϕ1,,ϕM\phi_1, \ldots, \phi_M and the target signal μ\textcolor{#f97316}{\mu} are the variables to be chosen. Our formulation follows the pattern common in machine learning: we minimize an objective that includes a loss function measuring the alignment error between warped signals and target, plus regularization terms that penalize excessive warping of the time axis.

Loss Functional

Let L:RdRL: \mathbb{R}^d \to \mathbb{R} be a vector penalty function. We define the loss associated with a time warp function ϕi\phi_i, on signal xix_i and target μ\textcolor{#f97316}{\mu}, as

L(ϕi,μ)=01L(xi(ϕi(t))μ(t))dt,\mathcal{L}(\phi_i, \textcolor{#f97316}{\mu}) = \int_0^1 L(x_i(\phi_i(t)) - \textcolor{#f97316}{\mu}(t)) \, dt,

the average value of the penalty function of the difference between the time-warped signal and the target. The smaller L(ϕi,μ)\mathcal{L}(\phi_i, \textcolor{#f97316}{\mu}) is, the better we consider x~i=xiϕi\tilde{x}_i = x_i \circ \phi_i to approximate μ\textcolor{#f97316}{\mu}.

Group Alignment via Regularized Loss Minimization

We propose to choose ϕ1,,ϕM\phi_1, \ldots, \phi_M and μ\textcolor{#f97316}{\mu} by solving the optimization problem

minimizef(ϕ1,,ϕM,μ)=i=1M(L(ϕi,μ)+λcumlRcuml(ϕi)+λinstRinst(ϕi))subject toϕi(0)=0,ϕi(1)=1,\begin{array}{ll} \text{minimize} & f(\phi_1, \ldots, \phi_M, \textcolor{#f97316}{\mu}) = \displaystyle\sum_{i=1}^M \left( \mathcal{L}(\phi_i, \textcolor{#f97316}{\mu}) + \lambda^{\text{cuml}} \mathcal{R}^{\text{cuml}}(\phi_i) + \lambda^{\text{inst}} \mathcal{R}^{\text{inst}}(\phi_i) \right) \\ \text{subject to} & \phi_i(0)=0, \quad \phi_i(1)=1, \end{array}

where λcumlR+\lambda^{\text{cuml}} \in \mathbb{R}_+ and λinstR+\lambda^{\text{inst}} \in \mathbb{R}_+ are positive hyperparameters used to vary the relative weight of the three terms. Since regularizers RinstR^{\text{inst}} and RcumlR^{\text{cuml}} depend only on ϕ\phi, not on μ\textcolor{#f97316}{\mu}, they are identical to those used in pairwise time warping and remain unchanged in the group setting. The variables in this optimization problem are the warp functions ϕ1,,ϕM\phi_1, \ldots, \phi_M and the target signal μ\textcolor{#f97316}{\mu}.

The Iterative Solver

This problem is hard to solve exactly, but a simple iterative procedure works well in practice. We observe that if we fix the target μ\textcolor{#f97316}{\mu}, the problem splits into MM separate dynamic time warping problems that we can solve (separately, in parallel). Conversely, if we fix the warping functions ϕ1,,ϕM\phi_1, \ldots, \phi_M, we can optimize over μ\textcolor{#f97316}{\mu} by minimizing

i=1M01L(xi(ϕi(t))μ(t))dt.\sum_{i=1}^M \int_0^1 L(x_i(\phi_i(t)) - \textcolor{#f97316}{\mu}(t)) \, dt.

This is typically easy to do; for example, with square loss, we choose μ(t)\textcolor{#f97316}{\mu}(t) to be the mean of xi(ϕi(t))x_i(\phi_i(t)); with absolute value loss, we choose μ(t)\textcolor{#f97316}{\mu}(t) to be the median of xi(ϕi(t))x_i(\phi_i(t)).

We solve this problem using block coordinate descent, alternating between optimizing the warping functions and the target signal. This leads to a simple iterative procedure:

1:μ\textcolor{#f97316}{\mu} \leftarrow Initialize(choose method below)
2:repeat
3:for i=1,,Mi = 1, \ldots, M do (in parallel)
4:ϕiargminϕ01L(xi(ϕ(t))μ(t))dt+λcumlRcuml(ϕ)+λinstRinst(ϕ)\phi_i \leftarrow \underset{\phi}{\arg\min} \int_0^1 L(x_i(\phi(t)) - \textcolor{#f97316}{\mu}(t))\, dt + \lambda^{\text{cuml}} \mathcal{R}^{\text{cuml}}(\phi) + \lambda^{\text{inst}} \mathcal{R}^{\text{inst}}(\phi)
5:μ(t)median{x1(ϕ1(t)),,xM(ϕM(t))}\textcolor{#f97316}{\mu}(t) \leftarrow \text{median}\{x_1(\phi_1(t)), \ldots, x_M(\phi_M(t))\} (pointwise)
6:until convergence

Group time-warped alignment via block coordinate descent.

Dataset:
Iteration kk
Computing...
Computing...

Iterative alignment process. At k=0k=0, the original misaligned signals with the initial reference μ(0)\textcolor{#f97316}{\mu}^{(0)} highlighted in orange. Each subsequent iteration k=1,2,3k=1,2,3 shows signals converging toward alignment.

This method of alternating between updating the target μ\textcolor{#f97316}{\mu} and updating the warp functions (in parallel) typically converges quickly. However, it need not converge to the global minimum. One simple initialization is to start with no warping, i.e., ϕi(t)=t\phi_i(t) = t. Another is to choose one of the original signals as the initial value for μ\textcolor{#f97316}{\mu}.

Shaping the Results

There are two main ways to influence the behavior of this algorithm. First, we can choose a good initialization for μ(0)\textcolor{#f97316}{\mu}^{(0)}—selecting a signal that is already “central” in some sense can speed convergence and improve final alignment quality. We explore several initialization strategies below. Second, we can add constraints to the optimization problem itself, restricting the space of admissible warping functions.

The choice of initialization in line 1 is our focus. A poor choice may require more iterations or, in pathological cases, converge to a suboptimal alignment.

When aligning a group of signals to a common reference, the choice of initial reference μ(0)\textcolor{#f97316}{\mu}^{(0)} can significantly impact convergence speed and final alignment quality. While the iterative algorithm will eventually converge regardless of initialization, a good starting point can reduce the number of iterations needed and avoid local minima in non-convex settings.

Initialization Method 1: Pointwise Median

The simplest approach is the pointwise median, which computes a synthetic reference by taking the median amplitude at each time point:

μ(0)(t)=median{x1(t),,xM(t)}\textcolor{#f97316}{\mu}^{(0)}(t) = \text{median}\{x_1(t), \ldots, x_M(t)\}

This is robust to outliers at each time point and captures the “typical” amplitude. However, unlike the other methods we'll discuss, it does not select an actual signal from the group—it creates a new synthetic signal that may not correspond to any physically realizable waveform.

Limitation: If the signals are significantly misaligned, the pointwise median can have discontinuities or unnatural shapes where signals cross frequently. It may not represent any realistic signal morphology.

Dataset:
Initial μ: Pointwise medianλinst\lambda^{\text{inst}}λcuml\lambda^{\text{cuml}}Iteration kk
Computing...
Computing...
Computing...

Initialization Method 2: Exemplar

To address the limitation that the pointwise median is synthetic, the exemplar method first computes the pointwise median, then selects the actual signal that is closest to it:

μˉ=pointwise-median(x1,,xM)\bar{\textcolor{#f97316}{\mu}} = \text{pointwise-median}(x_1, \ldots, x_M)
μ(0)=xiwherei=argminixiμˉ2\textcolor{#f97316}{\mu}^{(0)} = x_{i^*} \quad \text{where} \quad i^* = \arg\min_i \| x_i - \bar{\textcolor{#f97316}{\mu}} \|_2

Improvement over pointwise median: The exemplar is always a real signal from the group, guaranteeing a physically realizable reference. It inherits the robustness of the pointwise median while producing a valid signal shape.

Limitation: The pointwise median that we're approximating may still be a poor target if signals are severely misaligned—the “closest real signal” to a bad reference is still influenced by that bad reference.

Dataset:
Initial μ: Exemplarλinst\lambda^{\text{inst}}λcuml\lambda^{\text{cuml}}Iteration kk
Computing...
Computing...
Computing...

Initialization Method 3: Warping Functional Medoid

The warping functional medoid takes a fundamentally different approach: instead of measuring distances in amplitude space, it measures distances in the time-warped metric. It selects the signal that minimizes the total DTW cost when all other signals are aligned to it:

μ(0)=argminxjij(L(ϕi,xj)+λcumlRcuml(ϕi)+λinstRinst(ϕi))\textcolor{#f97316}{\mu}^{(0)} = \arg\min_{x_j} \displaystyle\sum_{i \neq j} \left( \mathcal{L}(\phi_i^\star, x_j) + \lambda^{\text{cuml}} \mathcal{R}^{\text{cuml}}(\phi_i^\star) + \lambda^{\text{inst}} \mathcal{R}^{\text{inst}}(\phi_i^\star) \right)

where ϕi\phi_i^\star is the optimal warping function aligning xix_i to candidate reference xjx_j.

Improvement over Karcher median: While the Karcher median finds the most central signal in L2L^2 space, the warping functional medoid finds the most central signal under the DTW metric. This accounts for timing variations: a signal that is far from others in raw amplitude may actually be very similar after time alignment, making it a better reference for iterative warping.

Limitation: Computing the warping functional medoid requires M(M1)M(M-1) pairwise DTW computations, making it more expensive than the other methods. However, this cost is often worthwhile when signals have significant timing variability.

Dataset:
Initial μ: Warping functional medoidλinst\lambda^{\text{inst}}λcuml\lambda^{\text{cuml}}Iteration kk
Computing...
Computing...
Computing...

Initialization Method 4: Karcher Median

Rather than approximating a synthetic reference, the Karcher median (also called the geometric median or L1-medoid) directly finds the signal that is most central in the group:

μ(0)=xiwherei=argminijixixj2\textcolor{#f97316}{\mu}^{(0)} = x_{i^*} \quad \text{where} \quad i^* = \arg\min_i \sum_{j \neq i} \| x_i - x_j \|_2

Improvement over exemplar: Instead of finding the signal closest to an intermediate synthetic reference, the Karcher median directly optimizes for centrality by minimizing the sum of distances to all other signals. This makes it robust to outliers and ensures the selected signal is truly “central” in L2L^2 signal space.

Limitation: Euclidean distance doesn't account for temporal misalignment. A signal may be geometrically central but temporally shifted, requiring significant warping from all other signals to align.

Dataset:
Initial μ: Karcher medianλinst\lambda^{\text{inst}}λcuml\lambda^{\text{cuml}}Iteration kk
Computing...
Computing...
Computing...

Summary

MethodBest When...Complexity
Pointwise medianRobustness to outliers is critical; synthetic reference is acceptableO(MNlogM)O(MN \log M)
ExemplarYou want a real signal that approximates the “average”O(MNlogM)O(MN \log M)
Karcher medianSignals are roughly aligned; you need a fast, robust baselineO(M2N)O(M^2 N)

Time-Centered Group Alignment

Centering Constraint

In addition to regularization, we can impose an optional time-centering constraint that requires the warping functions to be evenly arranged about the identity ϕ(t)=t\phi(t) = t, such that

1Mi=1Mϕ~i(t)=t.\frac{1}{M}\sum_{i=1}^M \tilde{\phi}_i(t) = t.

We denote time-centered time-warp functions satisfying this constraint as ϕ~i\tilde{\phi}_i. The resulting centered warp functions produce a time-centered estimate of central tendancy,

μ~=μ((x1ϕ~1), ,(xMϕ~M)).\textcolor{#f97316}{\tilde{\mu}} = \mu( (x_1 \circ \tilde{\phi}_1), \ \ldots, (x_M \circ \tilde{\phi}_M) ).

Time-Centered Group Alignment via Regularized Loss Minimization

To obtain a time-centered alignment, we choose ϕ~1,,ϕ~M\tilde{\phi}_1, \ldots, \tilde{\phi}_M and μ~\textcolor{#f97316}{\tilde{\mu}} by solving the optimization problem

minimizef~(ϕ~1,,ϕ~M,μ~)=i=1M(L(ϕ~i,μ~)+λcumlRcuml(ϕ~i)+λinstRinst(ϕ~i))subject toϕ~i(0)=0,ϕ~i(1)=1,1Mi=1Mϕ~i(t)=t,\begin{array}{ll} \text{minimize} & \tilde{f}(\tilde{\phi}_1, \ldots, \tilde{\phi}_M, \textcolor{#f97316}{\tilde{\mu}}) = \displaystyle\sum_{i=1}^M \left( \mathcal{L}(\tilde{\phi}_i, \textcolor{#f97316}{\tilde{\mu}}) + \lambda^{\text{cuml}} \mathcal{R}^{\text{cuml}}(\tilde{\phi}_i) + \lambda^{\text{inst}} \mathcal{R}^{\text{inst}}(\tilde{\phi}_i) \right) \\ \text{subject to} & \tilde{\phi}_i(0)=0, \quad \tilde{\phi}_i(1)=1, \quad \frac{1}{M}\sum_{i=1}^M \tilde{\phi}_i(t) = t, \end{array}

where the tilde notation denotes centered quantities: ϕ~i\tilde{\phi}_i are the centered warp functions and μ~\textcolor{#f97316}{\tilde{\mu}} is the centered mean.

The following comparison shows standard alignment (top) versus centered alignment (bottom). Notice how in centered alignment, the warping functions are evenly distributed around the identity—some signals are warped forward in time while others are warped backward, maintaining balance around the original time axis:

Dataset:
Initial μ: Karcher medianλinst\lambda^{\text{inst}}λcuml\lambda^{\text{cuml}}Iteration kk

Standard alignment: φ(t), μ(t)

Computing...
Computing...
Computing...

Centered alignment: φ̃(t), μ̃(t)

Computing...
Computing...
Computing...

Enforcing Centering

The centering constraint can be enforced within the iterative algorithm by adding a simple projection step. After computing the unconstrained warps ϕi\phi_i in each iteration, we compute their pointwise mean ϕˉ(t)\bar{\phi}(t) and subtract the deviation from the identity to obtain centered warps ϕ~i\tilde{\phi}_i:

1:μ~\textcolor{#f97316}{\tilde{\mu}} \leftarrow Initialize(choose method)
2:repeat
3:for i=1,,Mi = 1, \ldots, M do (in parallel)
4:ϕiargminϕ01L(xi(ϕ(t))μ~(t))dt+λcumlRcuml(ϕ)+λinstRinst(ϕ)\phi_i \leftarrow \underset{\phi}{\arg\min} \int_0^1 L(x_i(\phi(t)) - \textcolor{#f97316}{\tilde{\mu}}(t))\, dt + \lambda^{\text{cuml}} \mathcal{R}^{\text{cuml}}(\phi) + \lambda^{\text{inst}} \mathcal{R}^{\text{inst}}(\phi)
5:ϕˉ(t)1Mi=1Mϕi(t)\bar{\phi}(t) \leftarrow \frac{1}{M}\sum_{i=1}^M \phi_i(t)(mean warp)
6:ϕ~i(t)ϕi(t)ϕˉ(t)+t,i=1,,M\tilde{\phi}_i(t) \leftarrow \phi_i(t) - \bar{\phi}(t) + t, \quad i = 1, \ldots, M(center)
7:μ~(t)median{x1(ϕ~1(t)),,xM(ϕ~M(t))}\textcolor{#f97316}{\tilde{\mu}}(t) \leftarrow \text{median}\{x_1(\tilde{\phi}_1(t)), \ldots, x_M(\tilde{\phi}_M(t))\} (pointwise)
8:until convergence

Time-centered group alignment. Lines 5–6 project the warps onto the centering constraint.

Lines 5–6 are the centering projection. Subtracting the mean warp ϕˉ(t)\bar{\phi}(t) and adding back the identity ensures that the centered warps satisfy 1Miϕ~i(t)=t\frac{1}{M}\sum_i \tilde{\phi}_i(t) = t at every time point. One can verify this directly:

1Mi=1Mϕ~i(t)=1Mi=1M(ϕi(t)ϕˉ(t)+t)=ϕˉ(t)ϕˉ(t)+t=t.\frac{1}{M}\sum_{i=1}^M \tilde{\phi}_i(t) = \frac{1}{M}\sum_{i=1}^M \bigl(\phi_i(t) - \bar{\phi}(t) + t\bigr) = \bar{\phi}(t) - \bar{\phi}(t) + t = t.

The projection is inexpensive—a single pass over the warps at each iteration—and does not change the structure of the solver. The only difference from the unconstrained algorithm is that the target μ~\textcolor{#f97316}{\tilde{\mu}} in line 7 is computed from the centered warps rather than the raw warps, so the reference signal stays anchored to the original time axis as the iterations progress.

Matrix Notation

It is convenient to collect signals and warps into matrices. Let X={x1,,xM}\mathbf{X} = \{x_1, \ldots, x_M\} denote the collection of original signals, Φ={ϕ1,,ϕM}\mathbf{\Phi} = \{\phi_1, \ldots, \phi_M\} the warping functions obtained from group alignment, and μ\textcolor{#f97316}{\mu} the estimated central tendency. After centering, we write

Φ~={ϕ~1,,ϕ~M}\mathbf{\tilde{\Phi}} = \{\tilde{\phi}_1, \ldots, \tilde{\phi}_M\}

for the centered warps satisfying 1Miϕ~i(t)=t\frac{1}{M}\sum_i \tilde{\phi}_i(t) = t, and

X~={x1ϕ~1,,xMϕ~M}\mathbf{\tilde{X}} = \{x_1 \circ \tilde{\phi}_1, \ldots, x_M \circ \tilde{\phi}_M\}

for the centered aligned signals—the original signals composed with the centered warps. In both cases, the tilde indicates that the centering constraint has been applied.

These two representations provide complementary views of the data: X~\mathbf{\tilde{X}} captures what the signals look like after alignment (amplitude structure), while Φ~\mathbf{\tilde{\Phi}} captures how they were warped to get there (timing structure). Together they form a complete decomposition of the original signals into shape and timing components, which can be analyzed independently or jointly via SVD.

Looking ahead

Group alignment gives us a principled way to go from a noisy collection of misaligned signals to a clean pair of structured representations—aligned shapes and the warps that produced them. The centering constraint anchors these representations to the original time axis, making the decomposition unique and directly interpretable. With X~\mathbf{\tilde{X}} and Φ~\mathbf{\tilde{\Phi}} in hand, we are ready to ask a deeper question: what are the principal modes of variation in amplitude and timing? We take this up in the next post, where we apply SVD to extract a low-dimensional basis for both.

See also: A General Optimization Framework for Dynamic Time Warping