efourier
computes Elliptical Fourier Analysis (or Transforms or EFT)
from a matrix (or a list) of (x; y) coordinates. efourier_norm
normalizes Fourier coefficients.
Read Details carefully.
efourier(x, ...)# S3 method for default
efourier(x, nb.h, smooth.it = 0, ...)
# S3 method for Out
efourier(x, nb.h, smooth.it = 0, norm = TRUE, start = FALSE, ...)
# S3 method for list
efourier(x, ...)
efourier_norm(ef, start = FALSE)
For efourier
, a list with components: an
, bn
, cn
, dn
harmonic coefficients, plus ao
and co
.
The latter should have been named a0
and c0
in Claude (2008) but I (intentionnaly) propagated the error.
For efourier_norm
, a list with components: A
, B
, C
, D
for harmonic coefficients, plus size
, the magnitude of the semi-major axis of the first
fitting ellipse, theta
angle, in radians, between the starting and the semi-major axis
of the first fitting ellipse, psi
orientation of the first fitting ellipse, ao
and do
, same as above,
and lnef
that is the concatenation of coefficients.
A list
or a matrix
of coordinates or a Out
object
useless here
integer
. The number of harmonics to use. If missing, 12 is used on shapes;
99 percent of harmonic power on Out objects, both with messages.
integer
. The number of smoothing iterations to
perform.
whether to normalize the coefficients using efourier_norm
logical
. For efourier
whether to consider the first point as homologous;
for efourier_norm
whether to conserve the position of the first
point of the outline.
list
with a_n
, b_n
, c_n
and
d_n
Fourier coefficients, typically returned by efourier
For the maths behind see the paper in JSS.
Normalization of coefficients has long been a matter of trouble,
and not only for newcomers. There are two ways of normalizing outlines: the first,
and by far the most used, is to use a "numerical" alignment, directly on the
matrix of coefficients. The coefficients of the first harmonic are consumed
by this process but harmonics of higher rank are normalized in terms of size
and rotation. This is sometimes referred as using the "first ellipse", as the
harmonics define an ellipse in the plane, and the first one is the mother of all
ellipses, on which all others "roll" along. This approach is really convenient
as it is done easily by most software (if not the only option) and by Momocs too.
It is the default option of efourier
.
But here is the pitfall: if your shapes are prone to bad aligments among all
the first ellipses, this will result in poorly (or even not at all) "homologous" coefficients.
The shapes particularly prone to this are either (at least roughly) circular and/or with a strong
bilateral symmetry. You can try to use stack
on the Coe
object
returned by efourier
. Also, and perhaps more explicitely, morphospace usually show a mirroring symmetry,
typically visible when calculated in some couple of components (usually the first two).
If you see these upside-down (or 180 degrees rotated) shapes on the morphospace,
you should seriously consider aligning your shapes before the efourier step,
and performing the latter with norm = FALSE
.
Such a pitfall explains the (quite annoying) message when passing efourier
with just the Out
.
You have several options to align your shapes, using control points (or landmarks),
by far the most time consuming (and less reproducible) but possibly the best one too
when alignment is too tricky to automate.
You can also try Procrustes alignment (see fgProcrustes
) through their calliper
length (see coo_aligncalliper
), etc. You should also make the first
point homologous either with coo_slide
or coo_slidedirection
to minimize any subsequent problems.
I will dedicate (some day) a vignette or a paper to this problem.
Claude, J. (2008) Morphometrics with R, Use R! series, Springer 316 pp. Ferson S, Rohlf FJ, Koehn RK. 1985. Measuring shape variation of two-dimensional outlines. Systematic Biology 34: 59-68.
Other efourier:
efourier_i()
,
efourier_shape()
# single shape
coo <- bot[1]
coo_plot(coo)
ef <- efourier(coo, 12)
# same but silent
efourier(coo, 12, norm=TRUE)
# inverse EFT
efi <- efourier_i(ef)
coo_draw(efi, border='red', col=NA)
# on Out
bot %>% slice(1:5) %>% efourier
Run the code above in your browser using DataLab