Digital Euler Characteristic Transform: Abstract
Digital Euler Characteristic Transform: Abstract
Digital Euler Characteristic Transform: Abstract
1. Introduction
Shapes are difficult to analyze statistically, because they have no obvious metric
structure needed for statistical machinery. Without a metric structure, we can not
define such basic statistical quantities like mean of two shapes. A standard idea
in shape analysis is to pick points on the shapes, declare correspondence between
them, and define the distance between shapes to be the distance between the ma-
trices defined by the landmarks, modulo appropriate Euclidean actions. This leads
to what is called the Kendall Shape Space. Using landmarks leads to loss of in-
formation, because shapes are not point clouds, and there is no canonical choice
for picking the correspondence between the landmarks. This is especially relevant
for the modern age, where our shape data are represented in high fidelity in online
repositories.
Another idea is that of diffeomorphism-based shape alignment. This corresponds
to a digitalization of Kendall Shape Space as in this approach the shapes are rep-
resented as surfaces and their distances are studied via correspondence maps, con-
tinuous objects that can achieve arbitrary precision. A key restriction for there
to be such a correspondence map is that the shapes must be diffeomorphic. This
assumption is not realistic for a multitude of shape data, such as skulls that may
have different number of cavities or medical data such as brain MRI.
A third idea for shape analysis is based on integral geometry and geometric
measure theory. A powerful tool in this is the Euler Characteristic Transform
(ECT), which is mathematically a topological Radon transform. This transform
is the subject of this work. This framework allows for statistical analysis beyond
landmarks without relying on the diffeomorphism assumption.
All existing methods for computing the ECT rely on evaluating the ECT on a
discrete grid of directions, and most of the time, also the heights. This is somewhat
undesirable if our goal is to define a digital tool for shape analysis - such an approach
still requires us to pick a discrete set of directions, and our inference is based on
these, a setup much similar as with landmarks. While there is a theoretical notion
of a Moduli space for shapes that can be told apart from each other by finitely
many directions [5], this number is very large, indeed much larger than what is
used in practice. Also, the result states that such transform is injective for these
shapes, but there is to date even a theoretical guarantee on how many directions
give a good notion of distance for a given collection of shapes. In practice, this
can be only solved by picking more and more directions until the distances seem to
stabilize.
In this work we introduce the Ectoplasm, a fully-digital shape analysis tool
for dissimilar shapes. The work relies heavily on the observations made in [5] and
folklore results regarding the analytic form of the transform. We push these results
further to develop a fully digital ECT algorithm for shape analysis. In some regard,
this work complements the theoretical approach to unify shape theory via sheafifi-
cation presented in [1], with the distinction that from a theoretical perspective the
Persistent Homology Transform (PHT) has nicer properties than the ECT, which
is preferable from applied perspective and subject of this work.
The main advantages of this framework are threefold: First, the downstream
analysis, for example statistical inference, is improved, because the digital trans-
form makes use of all the data. This is especially relevant for getting accurate
information on which shapes are closest to each other, a key ingredient in mani-
fold learning applications that rely on small distances to approximate the tangent
space. Second, not having to discretize the transform obviates the problem of hav-
ing to choose the discretization parameters, a major headache for the practitioners.
Third, as the transform is computed in its exact form, the rich mathematical struc-
ture of the transform can be exploited to its full extent. For example, the digital
algorithm allows for a genuine O(d)-invariant action. We will discuss these dis-
cretization related issues and ways to circumvent them in Section 2. Finally, the
digital approach also gives us a ground truth, which can be used to assess how
accurate a given discretization is.
The paper is organized as follows: in Section 2 we review some of the background
on ECT and its typical use cases. In Section 3 we give a simplified, brute-force ver-
sion of the digitalization algorithm in two dimensions.This serves as an introduction
to Section 4, where we present the 3D-algorithm. The technical details pertaining
to spherical integrals are in A. In Section 5 we apply the the algorithm to perform
exploratory data analysis on a real life data set, and compare the results against the
conventional, discretization based method, as well as previously published methods
based on landmarks and diffeomorphisms. In Section 6, we study the two aforemen-
tioned solutions to the alignment problem that the digital transformation allows
for.
DIGITAL TOOLS FOR NON-DIFFEOMORPHIC SHAPES 3
2.1. The ECT distance. With the ECT, we can define the ECT inner product
between two meshes X and Y as
Z 1 Z
(1) ⟨X, Y ⟩ = ECTX (v, h)ECTY (v, h) dvdh .
−1 S d−1
This of course gives us a notion of norm, or distance between two meshes:
(2) ||X − Y ||2 = ⟨X − Y, X − Y ⟩ = ⟨X, X⟩ − 2⟨X, Y ⟩ + ⟨Y, Y ⟩.
The expression (2) of squared distance above is especially convenient for our
purposes. We note of the equivalent expression, which is more common in the
literature:
Z 1 Z
2 1/2
(3) dECT (X, Y ) = ECTX (v, h) − ECTY (v, h) dvdh .
−1 S d−1
Computing the distances in Equation (3) seems like a daunting task, for the
integral is taken over the sphere. In practice, this expression is always approximated
via some sort of discretization. While the integral indeed is very complicated, with
the help of a computer it can be computed analytically. An effective algorithm for
doing so is the main result of this paper. Before introducing this algorithm, we will
make a few comments on the discretization and its properties.
2.2. Discretization of ECT. A straightforward way to discretize the transform
and to make Equation (3) computable is to pick a set of direction v1 , v2 , . . . , vn
and a set of heights h1 , . . . , hm and then represent the (discretized) transform as
an n × m vector (or matrix). For these discretized objects, (3) is nothing more
than the L2 norm of the matrices. If we hook this idea back to landmarks, we are
ultimately performing a similar analysis: Our inference is based on matrices, that
represent finitely many directions evaluated at finitely many heights. This bears
resemblance to the landmark problem - how do we choose the directions? We will
discuss the merits and demerits of the approximation in this subsection.
One of the main results in this direction is the complexity class result in [5],
Theorem 7.14. – that there is an upper bound on how many directions are required
to tell two shapes in a certain complexity class apart. This is a mathematical
result, meaning that by picking that many directions guarantees that the discretized
transform is injective on the complexity class. This result, being one of the only
ones in the literature, is important, but we don’t have sufficient understanding on
what is the best procedure to pick the discretization in practice for a collection of
shapes. We can not, for example, make statements that N many directions explain
99% of the variability in distance, or to say which directions should be chosen for
best representation of the shapes if we can only afford n many directions. The lack
of these type of results makes using these methods harder, because there is no clear
cut way to choose the discretization parameters.
This problem is exacerbated when the statistical question is something more
complicated than regression or classification. If our only goal is to do classifica-
tion, and we use a kernel method, we only need to worry about approximating
the distance matrix well, because all of our inference is based on that. Then the
conventional wisdom to pick n and m as large as possible, and pick the directions
(and heights) as uniformly as possible, seems to be a reasonable advice. On the
6 HENRY KIRVESLAHTI AND XIAOHAN WANG
other hand, if we are interested in performing a more complicated task, such as fea-
ture selection, which was done in [14], then the choice of discretization parameters
becomes a double-edged sword. One one hand, we would like to increase n and m
to make the distances more accurate. But on the other hand, if we pick n and m
too large, the variation in the n × m regression parameters can too homogeneous,
causing at best multicollinearity, and at worst, making the parameters not even
estimable.
The digitalization procedure proposed in this work alleviates these two prob-
lems: By not using a discretization, the distances are computed (up to computer
precision) in closed form, so we know our inference is as good as it can get. Also,
the digitalization obviates the need to choose the discretization parameters in the
first place, so that multicollinearity of features will not be an issue. Of course, one
needs to rework all the statistical machinery for variable selection, because with
the digital transform we replace vectors with functions, so that the statistical ma-
chinery must involve functional data analysis. This interesting problem is left for
future research.
Another advantage that the digital version has is that it is better suited for
capturing small differences in the meshes. This is especially relevant for applica-
tions that make use of tangent space approximations, such as ISOMAP. Because
smaller distances are used for constructing the tangent space, a method that is more
accurate in getting the small distances right will give more accurate inference.
Furthermore, the discretized version suffers a small inconvenience when it comes
equivariance. Mathematically, the ECT is an O(d)-equivariant transform, meaning
that for a rotation matrix (possibly including reflection) A, we have
A 7→ −2⟨X, AY ⟩
is, for generic meshes X and Y , almost everywhere differentiable. This phenom-
enon has been discussed in e.g. [9]. This means that in theory, with the digital
transform, the alignment problem is amenable to a gradient descent type solution
(rather than grid search). We study this further in Section 6.
Finally, the discretized version has no hope of using the Schapira’s inversion
formula to go from transforms back to shapes. With the digitalized version of the
transform, it is conceivable that Schapira-type inversion formula could be used for
pulling back evidence back on the original problem.
3. The Algorithm
The purpose of this Section is to explain how we can evaluate Expression (3) ana-
lytically. To do so, we first introduce a brute force algorithm for the 2D case, where
the formulae are simpler and the transform is easier to visualize. We postpone the
DIGITAL TOOLS FOR NON-DIFFEOMORPHIC SHAPES 7
Z θ
IPk (p) = cos(t)x + sin(t)y dt
τ
= cos(τ ) − cos(θ) y + sin(θ) − sin(τ ) x.
Z 1 Z X nk
M X
a2i,k 1≥⟨v,bk,i ⟩ (h)1≤⟨v,bk,i+1 ⟩ (h) dv dh
⟨X, X⟩ =
−1 S d−1 k=1 i=1
M Z
X 1 Z nk
X
a2i,k 1≥⟨v,bk,i ⟩ (h)1≤⟨v,bk,i+1 ⟩ (h) dv dh
=
k=1 −1 Pk i=1
M nk
X X
= a2nk ,k (θk+1 − θk ) − a21,k IPk (b1,k ) + IPk (bi,k ) a2i+1,k − a2i,k .
k=1 i=2
Here IPk (bi,k ) is the integral over the height function of the vertex bi,k over
polygon Pk , which was explicitly computed in Proposition 3.4. The integral is then
just a sum of trigonometric functions, and analytically tractable.
DIGITAL TOOLS FOR NON-DIFFEOMORPHIC SHAPES 9
Similar reasoning applies for the other two terms, but note that the cross-product
term in the middle requires us to overlay the pieces Pk of X and Qk Y to a common
subdivision. See Example 3.5 for an explicit computation.
Note that the algorithm that we have described in this section is just for illustra-
tion purposes. In fact, it is very inefficient. For
two meshes with n and m vertices,
we would first need to compute n2 and m
2 pairwise intersections to get Pk , Qk ,
and then we still have to perform the expensive operation of overlaying these two
triangulations. Luckily, this complexity can be greatly reduced. As a matter of fact,
we don’t have to compute all the pairwise intersections, and we can also make the
pieces Pk larger than what was described here. We will discuss these improvements
in the next section, where we also introduce the algorithm for 3 dimensions, which
is also more interesting from the perspective of real-life applications.
0
−2
−4
0 1 2 3 4 5 6
angle
Example 3.5. In this example we compute the ECT inner product of a 2D-triangle
by hand, following the brute force algorithm. Let Σ be an abstract simplicial complex
{(123, 234)}, and consider its geometric realization X given by map fX : e1 7→
(−2, −1), e2 7→ (0, 1), e3 7→ (0, 4) and e4 7→ (2, 0). For simplicity of computations,
we will not scale X to the unit ball (nor center it), instead we shall carry the
integration out over the origin-centered ball of radius 4.
We first proceed by solving the equi-height angles. For two pairs of vertices
−x2
(x1 , y1 ) and (x2 , y2 ), these are given by θ = atan(D) = atan xy21 −y 1
These are
given in the Table 1 below, and also depicted in Figure 1.
Ordering the angles from table 1, and investigating the order bk of the vertices
xi inside each Pk together with the Euler characteristic ak , we can represent the
ECT of X in a table (Table 2), with Pk = [θk , θk+1 ]:
10 HENRY KIRVESLAHTI AND XIAOHAN WANG
x1 y1 x2 y2 D Name
−2 −1 0 1 −1 D12
−2 −1 0 4 − 25 D13
−2 −1 2 0 −4 D14
0 1 0 4 0 D23
0 1 2 0 2 D24
1
0 4 2 0 2 D34
Table 2 contains all the information to compute ⟨X, X⟩. This decomposition
contains a lot of polygons and the expression could be much simplified. This ineffi-
ciency is a consequence of using the brute force algorithm. In fact, we see that the
integrand is 1 except for parts between p2 and p4 in polygon P3 and between p2 and
p1 in polygon P4 .
From Table 2, we can readily compute ⟨X, X⟩. The integrand is 1 from the
minimum vertex until height 4, except for the two polygons P3 and P4 where the
squared Euler characteristic is 4 after p1 (in P3 ) and p4 (in P4 ) up until p2 . In
DIGITAL TOOLS FOR NON-DIFFEOMORPHIC SHAPES 11
other words:
Z 4 Z X 4
12 X
a2i,k 1≥⟨v,bk,i ⟩ (h)1≤⟨v,bk,i+1 ⟩ (h) dv dh
⟨X, X⟩ =
−4 S d−1 k=1 i=1
12 Z θk+1 h Z θ3 Z θ4
X i
= 4 − min(pi · v) dv + 4 p2 · v − p4 · v dv + p2 · v − p1 · v dv
θk i θ2 θ3
k=1
h i
= 4 2π + IP3 (p2 ) + IP4 (p2 ) − IP3 (p4 ) − IP4 (p1 )
X 7
X 11
X
− IPk (p1 ) − IPk (p4 ) − IPk (p3 )
k={1,2,3,12} k=4 k=8
1 1 1 1 4 2
= 8π + 4 √ + √ +4 − √ + √ −8 √ − √
5 17 17 2 17 5
1 4 −1 1 9 9 2 8 8 20
+8 √ − √ +4 √ + √ + √ + √ + √ + √ + √ + √
2 17 17 2 17 29 5 17 5 29
√ √ √ √
= 8 π + 2 + 3 2 5 − 17 + 29
≈ 42.878.
4. 3D Algorithm
In this Section, we describe an algorithm for computing Expression (2) for 3D-
meshes X and Y . The algorithm proceeds as follows: Input: Mesh X with vertices
{x1 , . . . , xn }.
(1) For each vertex xi , compute its star si .
(2) For each star si , compute the triple intersection points; that is, for all
xj ∈ si , xk ∈ si , xj ̸= xk ̸= xi ̸= xj , solve v · xi = v · xj = v · xk , get a
collection of antipodal points on S d−1 , one pair for each triplet. Label each
such point with the triplet (i, j, k) that generated it
(3) Triangulate S d−1 by placing the vertices with points computed from (2).
Connect two vertices if they share two of their labels and the inner products
of the points they define is non-negative.
(4) For each triangle in the triangulation, evaluate gain in the local ECT in the
star. If this is zero, discard the triangle, otherwise record the change.
(5) Merge adjacent triangles, that is, triangles that share an edge and that have
the same gain. This results in a spherical polygon.
(6) Get: For each vertex xi a collection of polygons Pk with their local gains
ak .
This results in having the mesh X in the proto-transform format, i.e. it is repre-
sented as an indicator function of height functions over polygons, which this time,
may be overlapping. After the algorithm, the next step of this algorithm is to use
this representation to compute the distances. This resembles by and large the case
introduced in the previous section, with relevant details about spherical integra-
tion left into the Appendix A. We will use the rest of section to give mathematical
reasoning behind Algorithm 2 as well as discuss some improvement ideas.
The first difference to the brute force algorithm is that we are now computing
the polygon intersections inside each link. When mesh resolution is increased, n,
the number of vertices, increases, but the star of each vertex will have more or less
the same number of vertices, forexample for primate molars k ≈ 6. Using the links
we need to compute about n · k3 intersections, instead of the n3 intersections that
the brute force algorithm requires.
12 HENRY KIRVESLAHTI AND XIAOHAN WANG
This is based on the following, well-known, observation that allows one to com-
pute changes in Euler Characteristic solely based on local information:
Proposition 4.1. Let X be a piecewise linear mesh with vertices {x1 , . . . , xn } and
v a direction such that hi := ⟨xi , v⟩ =
̸ ⟨xj , v⟩ for i ̸= j and fv (h) the Euler curve
in direction v. Let also ϵ = mini̸=j |(hi − hj )|/2. The gain
fv (hi + ϵ) − fv (hi − ϵ)
associated to vertex xi in the Euler Curve fv is completely determined by Star(xi )
and v.
Proof. The Euler characteristic of X is the alternating sum of its simplex counts.
Any new simplices that are added to X when xi is added to it are by definition
contained in the star of xi . □
The second difference that the algorithm has is that now the spherical polygons
may or may not be disjoint. This is not much of a problem, because regardless of
which decomposition we use, we have the following:
Proposition 4.2.PnSuppose shapes K1 , K2 are
Pm compactly-supported on unit ball B d ,
let ECT(K1 ) = i=1 αi fi and ECT(K2 ) = i=1 βj gj , we denote αn+j = −βj and
fn+j = gj for simplicity, then we have
Z Z
2
d (K1 , K2 ) = (ECT(K1 ) − ECT(K2 ))2 dtdσ
S2 I
Z Z X n m
X
= ( αi fi − βj gj )2 dtdσ
S2 I i=1 j=1
Z Z m+n
X
= ( αi fi )2 dtdσ
S2 I i=1
m+n
X Z Z
= αi αj fi fj dtdσ
i,j=1 S2 I
m+n
X Z Z
= αi αj 1{Pi ∩Pj } · 1[max{x(Pi )·v, x(Pj )·v},1] dtdσ
i,j=1 S2 I
m+n
X Z
= αi αj 1 − max{x(Pi ) · v, x(Pj ) · v} dtdσ
i,j=1 Pi ∩Pj
m+n
X
= αi αj Vol(Pi ∩ Pj )
i,j=1
Z
− x(Pi ) · v dtdσ
Pi ∩Pj ∩{x(Pi )·v>x(Pj )·v}
Z
− x(Pj ) · v dtdσ .
Pi ∩Pj ∩{x(Pi )·v>x(Pj )·v}
To derive the closed formula of ECT distance, it suffices to derive the closed
formula of integral of x · v on arbitrary spherical polygons, and a formula for the
volume of the intersection of the polygons. In general, it is difficult to provide a
DIGITAL TOOLS FOR NON-DIFFEOMORPHIC SHAPES 13
closed-form formula for the former spherical integral in d dimensions. The simple
case of 2 dimensions was already addressed in the previous section (Proposition
3.4), and the three-dimensional formula, which is the most important one for appli-
cations, is presented in Appendix A. Note that in three dimensions the intersection
area can be computed with, for example, the Gauss-Bonnet Theorem.
5. Case Study
Now that we have described our algorithm, we demonstrate its utility by applying
it to a practical problem. We also compare it to the distances obtained from
landmarks as well as a diffeomorphism based method [3]. The comparison may
be of independent interest to theoreticians pondering the differences between the
continuous Procrustes distances and the one obtained from ECT, and to what
extent these two are commensurate.
5.1. The Data. The dataset comprises 116 primate molars, representing diverse
genera and dietary preferences. This dataset was first analyzed in [3].
5.1.1. Data Processing. The meshes are aligned based on landmarks using the
Auto3DGM[4, 10] algorithm, with the furthest point sampling and 128 and 256
landmarks for phases 1 and 2, respectively.
For the purpose of the ECT methods, the meshes were converted to OFF files
with meshlab, and further subsampled to 1,000 faces with its quadric edge collapse
decimation algorithm. We further center and scale the meshes to the unit ball by
a standard procedure.
5.2. Methods. We compute the Digital ECT distances based on the algorithm de-
scribed in this manuscript, using the software provided in Section 7. The discretized
ECT distances are based on 326 directions obtained from a regular subdivision of
a regular octahedron. This is a standard procedure to produce close to uniformly
spread points on the 2-sphere. For each direction, the discrete Euler Characteristic
Transform is evaluated with 100 equally spaced heights between -1 and 1, resulting
in a matrix of size 362 × 100.
The landmark distance is based on the 2nd phase of the Auto3DGM algorithm
that was used to align the meshes. This algorithm makes use of minimum spanning
tree to propagate distances, unlike our ECT distances. The continuous procrustes
distance is a verbatim copy of the results in [3], reproduced from its accompanying
code, provided here for reference.
5.3. Results. To see a high-level overview of the different distances and how they
cluster the data, multidimensional Scaling Plots of the distances are presented in
Figure 2. These are 2-D summaries of the distance matrix, projecting points to
the plane such that the global distance is distorted as little as possible. From the
plots we see that all the methods give, on high level, similar kind of clustering of
the dietary groups.
In Table 3 The mantel correlation of the distance matrices are presented. These
are standard measures of correlations between distance matrices, accounting for all
the pairwise distances. We see that all the four methods are related, as the MDS
plots in Figure 2 hint. Unsurprisingly, we see that the Digital ECT is closely related
to the Discrete one, indicating that the discretization that we chose is quite good
14 HENRY KIRVESLAHTI AND XIAOHAN WANG
at capturing the distances as a whole. Interestingly, the digital method has smaller
correlation with the two non-ECT methods than the discrete one.
In Figure 3 we also look at the t-sne plots of the collection computed with differ-
ent notions of distance. The t-sne, unlike MDS, puts emphasis on small distances,
which is a key element in, for example, manifold learning and Gaussian process
classifiers, that make use of local structure of the collection in their inference. It
is conceivable that there may be relevant small differences that yield to different
inference even if the distances are globally in great agreement. While we see some
differences between the two methods, the closest neighbors are in much agreement,
for example, the frugivores are far from insectivores, and the folivores form three
clear subclusters whose relative positions are similar in either display.
In spite of the small differences visible in t-sne plots, there is little difference in
the clustering behavior, and indeed if we tried to predict, for example, frugivores
against other classes using a local smoothing type method, we would get similar
inference.
The conclusion of this case study is that the discretization yields results that
are very accurate and the inference is for all intents and purposes just as good as
with the digital transform. This corroborates the rule of thumb that 326 uniformly
DIGITAL TOOLS FOR NON-DIFFEOMORPHIC SHAPES 15
Figure 3. t-sne plots based on the distances from the two ECT meth-
ods.
spread directions with hundred sublevel sets is typically a good enough discretiza-
tion for a collection of surface-like 3D-shapes. In general, the procedure outlined
in this section can be used to objectively assess how good a given discretization is.
One such assessment is presented in Table 4, where we report the Mantel correla-
tions against the digital algorithm against various discretizations. Ultimately, the
discretization must be chosen in terms of whatever problem is studied, what we
present here is but a single indication of the discretization error on a high level.
Z 1 Z
2 1/2
(4) dECT (X, AY ) = ECTX (v, h) − ECTAY (v, h) dvdh .
−1 S d−1
One of the immediate advantages that the digital transform has vis-à-vis the dis-
crete one is that it is automatically SO(d)-equivariant, and it is almost everywhere
differentiable.
If we are using the discrete transform, we have restricted the ECT to a finite
set of directions (v1 , . . . vn ). In particular, we do not have access to the ECT at
directions (Av1 , . . . Avn ), so we are required to approximate the action of A by a
permutation of the directions (v1 , . . . vn ). For example, in [14] this problem was
solved by discretizing SO(3) to a grid of size 16,000, which were approximated by
a permutations of the set of 2,918 directions. For each of the 16,000 actions Ai , we
would then solve the linear assignment problem
n
X
p̃i = arg minp:[n]→[n] (pvj − Ai vj )2 ,
j=1
(α, β, γ) ≃ (α + 2π, β, γ)
(α, β, γ) ≃ (α, β + 2π, γ)
(α, β, γ) ≃ (α+, β, γ + 2π)
(α, β, γ) ≃ (α + π, β + π, γ + π).
The angles α, β, γ are the axis-aligned rotations, and we can associate to each a
rotation matrix for example as follows:
cos α − sin α 0 cos β 0 sin β 1 0 0
Aα,β,γ = sin α cos α 0 0 1 0 0 cos γ − sin γ .
0 0 1 − sin β 0 cos β 0 sin γ cos γ
Next we pick an initial grid to start our search. We choose a grid of 8×8×5 = 320
points. Concretely, the grid is the cCrtesian product of the following values for
parameters α, β and γ:
trace(AATi ) − 1
d(A, Ai ) = arccos .
2
From Table 5 we see that the inner product is inversely proportional to the
SO(3) Distance, so that the inner product is in practice a useful metric for the
shape alignment problem, and the algorithm does not, for example, seek a local
minimum. The method seems to be able to find the correct alignments using
relatively fast.
18 HENRY KIRVESLAHTI AND XIAOHAN WANG
6.2. Gradient Descent. The digital version of the shape alignment problem is, in
theory, almost differentiable, and the piecewise components of it are easily described
with even pen and paper. However, writing the gradient down exactly is quite a
complicated task. To this end, we also implement an auto-differentiable version
of the code, which allows us to compute the gradient by abusing the simplicity of
individual operators in conjunction with the chain rule. In order to do this, we
provide a proof-of-concept implementation of the algorithm with torch functions,
a popular machine-learning framework that has built-in automatic differentials for
basic operations. Due to the cost of the computational resources required for an
efficient implementation, we demonstrate a proof-of-concept of this procedure by
applying the algorithm on a simple non-convex polyhedron on 9 vertices and 14
faces obtained from simplifying a shape studied in the previous section. This is a
mesh with high curvature.
The ECT representation introduced in this paper and implemented in the code
package Ectoplasm allows for straightforward implementation of both vanilla gra-
dient descent and also stochastic gradient descent. Pn
In terms of this
Pn representation, write ECTX (v, h) = i=1 αi P (xi , vi ) and
ECTY (v, h) = j=1 αj P (yj , vj ), the alignment problem corresponds to finding the
optimal A that maximizes
Z 1 Z
⟨X, AY ⟩ = ECTX (v, h)ECTAY (v, h) dvdh
−1 S d−1
Z 1 Z n
X m
X
= αi P (xi , vi ) αj P (Ayj , Avj ) dvdh.
−1 S d−1 i=1 j=1
The gradient of this expression with respect to the vector angles (α, β, γ) is then
readily available through auto-differentiation, and we can seek the optimum via
gradient ascent.
For the stochastic gradient, we have an additional choice to make. We could
divide up the double sum over one index or the other, or even both of them. The
DIGITAL TOOLS FOR NON-DIFFEOMORPHIC SHAPES 19
latter is not necessarily a good option1, because then we would at each iteration
compute the gradient based on the intersection of two sparse sets of spherical poly-
gons on S 2 . The gradient would then point out to whichever direction maximizes
the overlap between these two sets. This type of sampling would lead to large
volatility that would override the signal. By subsetting only one index, we ensure
the other set of polygons is full, i.e., there is a polygon (possibly several) in each
direction, so that the intersection cannot be maximized solely by seeking maximal
overlap.
We seek the alignment by vanilla gradient ascent, which we initialize with angles
θ0 := (α, β, γ) = (0, 0, 0). We update the angles θi of alignment Ai with the gradient
ascent
∇θi
θi+1 = θi + λ ,
||∇θi ||
with λ = 1 for the first 30 iterations and 0.1 after the 20 following iterations and
0.01 thereafter. The results are presented in Table 6.
While the gradient ascent seems to find the correct alignment without very com-
plicated optimization of λ, it does suffer from the fact that there are many local
minima, which in part due to the high curvature of the mesh. From the oscillation
of the loss in Table 6 there are signs that λ is set too high, but this is somewhat
necessary so as to allow enough movement past local minima. The gradient ascent
therefore seems much more useful in determining the fine alignment, after a cruder
alignment from, for example, the adaptive grid search.
7. Code availability
The Ectoplasm code is available on:
https://github.com/hkirvesl/ECTOPLASM.
Acknowledgements
The authors would like to thank Nicolas Berkouk, Sayan Mukherjee, Justin
Curry, Shreya Arya, Kathryn Hess, Robert Ravier, Wojciech Chachólski and Heather
Harrington for helpful discussions and comments.
HK developed a 2-dimensional prototype of the algorithm during his visit to the
Quantum Center at University of Southern Denmark in 2022. The author would
like to thank the Center for their hospitality. The bulk of the work was carried out
at EPFL.
References
[1] Shreya Arya, Justin Curry, and Sayan Mukherjee. A sheaf-theoretic construction of shape
space. Foundations of Computational Mathematics, pages 1–51, 2024.
[2] Mladen Bestvina and Noel Brady. Morse theory and finiteness properties of groups. Inven-
tiones mathematicae, 129:445–470, 1997.
[3] Doug M Boyer, Yaron Lipman, Elizabeth St. Clair, Jesus Puente, Biren A Patel, Thomas
Funkhouser, Jukka Jernvall, and Ingrid Daubechies. Algorithms to automatically quantify the
geometric similarity of anatomical surfaces. Proceedings of the National Academy of Sciences,
108(45):18221–18226, 2011.
[4] Doug M Boyer, Jesus Puente, Justin T Gladman, Chris Glynn, Sayan Mukherjee, Gabriel S
Yapuncich, and Ingrid Daubechies. A new fully automated approach for aligning and com-
paring shapes. The Anatomical Record, 298(1):249–276, 2015.
DIGITAL TOOLS FOR NON-DIFFEOMORPHIC SHAPES 21
[5] Justin Curry, Sayan Mukherjee, and Katharine Turner. How many directions determine a
shape and other sufficiency results for two topological transforms, 05 2018.
[6] Robert Israel (https://mathoverflow.net/users/13650/robert israel). Clairaut’s re-
lation and the equation of great circle in spherical coordinates. MathOverflow.
URL:https://mathoverflow.net/q/247336 (version: 2016-08-12).
[7] Lyman M. Kells, Willis F. Kern, and James R. Bland. Plane And Spherical Trigonometry.
McGraw Hill Book Company, Inc., 1940. Retrieved July 13, 2018.
[8] Henry Kirveslahti and Sayan Mukherjee. Representing fields without correspondences: the
lifted euler characteristic transform. Journal of Applied and Computational Topology, 8(1):1–
34, 2024.
[9] Jacob Leygonie, Steve Oudot, and Ulrike Tillmann. A framework for differential calculus on
persistence barcodes. Foundations of Computational Mathematics, pages 1–63, 2022.
[10] Jesus Puente. Distances and algorithms to compare sets of shapes for automated biological
morphometrics, 2013.
[11] Pierre Schapira. Tomography of constructible functions. In Gérard Cohen, Marc Giusti, and
Teo Mora, editors, Applied Algebra, Algebraic Algorithms and Error-Correcting Codes, pages
427–435, Berlin, Heidelberg, 1995. Springer Berlin Heidelberg.
[12] Katharine Turner, Sayan Mukherjee, and Doug M. Boyer. Persistent homology transform for
modeling shapes and surfaces. Information and Inference: A Journal of the IMA, 3(4):310–
344, 2014.
[13] Lou van den Dries. Tame Topology and O-minimal Structures. London Mathematical Society
Lecture Note Series. Cambridge University Press, 1998.
[14] Bruce Wang, Timothy Sudijono, Henry Kirveslahti, Tingran Gao, Douglas M Boyer, Sayan
Mukherjee, and Lorin Crawford. A statistical pipeline for identifying physical features that
differentiate classes of 3d shapes. The Annals of Applied Statistics, 15(2):638–661, 2021.
With this parametrization for great circles, we can compute the following spherical
integration we need for spherical polygons.
Proposition A.2. Given a spherical polygon SPi = {(ϕ1 , τ1 ), (ϕ2 , τ2 ), ..., (ϕn , τn )}
and associated vertex pi = (ϕi , τi ), the ordering of vertices of SPi is compatible with
∂ ∂
the orientation of the polygon, namely [ ∂ϕ , ∂τ ]. If (SPi , pi ) satisfies
1. pi ∈
/ I;
2. SPi does not intersect with I, equator and any meridian.
we denote ϕn+1 = ϕ1 and then have
Z n
X 1 1 1
I(pi ) = opi · v dϕdτ = sin τi · Ik1 − cos τi · Ik2 − cos τi · Ik3 ,
SPi 4 4 2
k=1
Proof. According to [7], the angle σ between direction vector v = (ϕ, τ ) and opi
satisfies
cos σ = sin τi sin τ + cos τi cos τ cos(ϕ − ϕi ).
Notice that opi · v = cos σ, we have
Z Z
opi · v dϕdτ = sin τi sin τ + cos τi cos τ cos(ϕ − ϕi ) dϕdτ.
SPi SPi
where ek is the edge of SPi from (ϕk , τk ) to (ϕk+1 , τk+1 ). We then use the tangent
half-angle formula to replace cos 2τ , sin 2τ by tan τ and plug the parametrization
in lemma A.1 into ω.
1 − tan2 τ
Z Z 1 1 2 tan τ 1
ω= sin τi · 2τ
− cos τi 2τ
cos (ϕ − ϕi ) − cos τi · τ · cos (ϕ − ϕi ) dϕ
ek ek 4 1 + tan 4 1 + tan 2
1 1 1
= sin τi · Ik1 − cos τi · Ik2 − cos τi · Ik3 .
4 4 2
□
As we can see, there are restrictions on the choice of (SPi , pi ) to make the coor-
dinate system and parametrization applicable. In practice, it is always possible
and efficient to apply a rotation to (SPi , pi ) to satisfy the restrictions. Hence the
DIGITAL TOOLS FOR NON-DIFFEOMORPHIC SHAPES 23
formula above is enough for us to compute the desired integration on any kind of
spherical polygon.
Laboratory for Topology and Neuroscience, EPFL, Lausanne, Switzerland; IMADA
& Center for Quantum Mathematics, University of Southern Denmark, Odense, Den-
mark
Email address: hklahti@imada.sdu.dk