Professional Documents
Culture Documents
This tutorial summarizes the basic steps of digitizing 2D GM data using the R-package StereoMorph, and then
importing them to geomorph. As StereoMorph uses Shiny to allow the user to digitize, it is interactive, so you
need to run the code to gain hands-on experience on the details of how digitizing proceeds.
install.packages("StereoMorph")
library(StereoMorph)
library(geomorph)
First, let´s see how one can digitize fixed landmarks. These correspond to well-defined anatomical points on
your structure of interest. You will need a folder with the pictures you will digitize (Images, in our example) In this
script, digitized data are stored in another folder, called Shapes To digitize, e.g., five fixed landmarks, run:
digitizeImages(image.file='Images', shapes.file='Shapes',
landmarks.ref=paste("LM", c(1:5), sep=""))
NOTE: one has the ability to copy all landmarks to each image, and then move them to the desired
1 de 10 14-06-2019 8:41
01.1: Digitizing Landmarks in StereoMorph https://deanadams.github.io/2019-Chile/Labs/01.1-Digitizing-StereoMor...
locations. This can be useful so that landmarks remain in the correct order.
Important detail! Any specimen with missing data (e.g., a broken specimen) may still be digitized. In this case,
simply leave the missing landmarks BLANK. They will be treated as NA and can be estimated in subsequent
data-processing steps.
To scale landmark coordinates during superimposition and obtain accurate estimates of the relative size of the
studied objects, you need to define the scaling of the images used, i.e. to indicate the correspondence of picture
pixels with a “true” size measurement. For this:
The easiest way to obtain sliding semilandmarks to describe the shape of curves, is by first digitizing a curve in
StereoMorph and then sampling the desired number of points from it. Curves are digitized in StereoMorph using
a Bezier approximation. For this you need to:
1. Specify curve names and start/end landmarks (see example_curve.txt) NOTE: do not use spaces or
strings used to name landmarks when naming the curves
2. Re-open the digitizer to record the curves
digitizeImages(image.file='Images', shapes.file='Shapes',
landmarks.ref=paste("LM", c(1:5), sep=""),
curves.ref = "example.curves.txt")
Add points to the curve by selecting an empty line (with “-”) and double clicking on the image
After the first point, you need to add control points two at a time, to keep the curve continuous
Navigate across points with “n” and “p” and move them to adjust the curve
Once the curve is digitized, you can subsample a desired number of semilandmarks from it. This is
accomplished easiest with the function, readland.shapes. This is a geomorph function that reads in data from a
class shapes object. (In geomorph, there are several readland.___ functions for different landmark file types.)
Before using readland.shapes , a shapes object must be created (a Stereomorph function).
# Perform GPA
Y.gpa <- gpagen(shapesGM, print.progress = FALSE)
plot(Y.gpa)
2 de 10 14-06-2019 8:41
01.1: Digitizing Landmarks in StereoMorph https://deanadams.github.io/2019-Chile/Labs/01.1-Digitizing-StereoMor...
When one has completed a serious digitizing effort, the readland.shapes function offers extreme flexibility for
choosing the sets of landmarks to use as a definition of “shape”. It must be stated that for those of us who
have spent some years in GMM, this is profoundly amazing! Not too long ago, one must have had an a
priori definition of a landmark configuration and digitize every specimen according to a preformed plan. Now,
one can experiment and find an optimal landmark configuration, post-digitizing.
Too demonstrate this, let’s use a digitizing set with 11 landmarks and 9 curves. First we need to define how
many landmarks should be in each curve.
# curves include eye, head, tail 1, tail end, tail 2, anal fin,
# pectoral fin, opercle, pre-opercle
curves.list <- c(20, 24, 24, 16, 12, 8, 8, 24, 16)
Then use readland.shapes to read the data into a useable format for geomorph.
Every curve needs to have at least three landmarks (or it is not a curve). Other than that, one can vary the
number for every curve. The set chosen is hypothetical. Let’s see what it looks like following generalized
Procrustes Analysis (GPA).
3 de 10 14-06-2019 8:41
01.1: Digitizing Landmarks in StereoMorph https://deanadams.github.io/2019-Chile/Labs/01.1-Digitizing-StereoMor...
The density of semilandmarks might be a little too great. We can reduce it by 50%, for example, in one line of
code:
4 de 10 14-06-2019 8:41
01.1: Digitizing Landmarks in StereoMorph https://deanadams.github.io/2019-Chile/Labs/01.1-Digitizing-StereoMor...
Later it might impress you that no arguments for gpagen are needed when reading data in with
readland.shapes . Class geomorphShapes objects also have various attributes that can be exported for other
uses.
class(shapesGM)
## [1] "geomorphShapes"
attributes(shapesGM)
## $names
## [1] "landmarks" "fixed" "sliders" "curves" "n" "p"
## [7] "k" "scaled"
##
## $class
## [1] "geomorphShapes"
## [1] 1 2 3 4 5 6 7 8 9 10 11 12
5 de 10 14-06-2019 8:41
01.1: Digitizing Landmarks in StereoMorph https://deanadams.github.io/2019-Chile/Labs/01.1-Digitizing-StereoMor...
6 de 10 14-06-2019 8:41
01.1: Digitizing Landmarks in StereoMorph https://deanadams.github.io/2019-Chile/Labs/01.1-Digitizing-StereoMor...
7 de 10 14-06-2019 8:41
01.1: Digitizing Landmarks in StereoMorph https://deanadams.github.io/2019-Chile/Labs/01.1-Digitizing-StereoMor...
## curveLM.62 61 62 63
## curveLM.63 62 63 64
## curveLM.64 63 64 10
## curveLM.65 11 65 66
## curveLM.66 65 66 67
## curveLM.67 66 67 68
## curveLM.68 67 68 69
## curveLM.69 68 69 70
## curveLM.70 69 70 10
shapesGM$landmarks[[1]] # specimen 1
8 de 10 14-06-2019 8:41
01.1: Digitizing Landmarks in StereoMorph https://deanadams.github.io/2019-Chile/Labs/01.1-Digitizing-StereoMor...
## [,1] [,2]
## LM1 59.10605 -41.32745
## LM2 74.27244 -37.38964
## LM3 87.95729 -38.09143
## LM4 88.15223 -41.52239
## LM5 81.21233 -42.26316
## LM6 77.97632 -44.09561
## LM7 66.82570 -42.73102
## LM8 67.29356 -44.29055
## LM9 66.16291 -40.78161
## LM10 63.74564 -44.56347
## LM11 64.01856 -40.70364
## LM12 62.80992 -39.37804
## curveLM.13 63.35576 -40.20925
## curveLM.14 63.23879 -41.18580
## curveLM.15 62.56849 -41.91977
## curveLM.16 61.58884 -42.10721
## curveLM.17 60.79722 -41.57606
## curveLM.18 60.50962 -40.63789
## curveLM.19 60.90162 -39.76580
## curveLM.20 61.76877 -39.41703
## curveLM.21 60.09664 -40.23578
## curveLM.22 61.23111 -39.43632
## curveLM.23 62.59470 -38.96945
## curveLM.24 64.00739 -38.67625
## curveLM.25 65.44277 -38.38270
## curveLM.26 66.87240 -38.13042
## curveLM.27 68.38092 -38.01345
## curveLM.28 69.85046 -37.93548
## curveLM.29 71.32668 -37.74054
## curveLM.30 72.78007 -37.54560
## curveLM.31 75.48816 -37.55269
## curveLM.32 76.68105 -37.77086
## curveLM.33 77.89008 -38.00519
## curveLM.34 79.15621 -38.10168
## curveLM.35 80.41810 -38.20840
## curveLM.36 81.69189 -38.28637
## curveLM.37 82.98184 -38.24738
## curveLM.38 84.20719 -38.44232
## curveLM.39 85.39355 -38.20840
## curveLM.40 86.65119 -38.09143
## curveLM.41 88.78695 -38.10234
## curveLM.42 89.43884 -38.53892
## curveLM.43 89.63378 -39.32465
## curveLM.44 89.78973 -40.12653
## curveLM.45 89.59479 -40.91226
## curveLM.46 88.93127 -41.36644
## curveLM.47 86.70989 -41.56138
## curveLM.48 85.26756 -41.60037
## curveLM.49 83.89652 -41.75632
9 de 10 14-06-2019 8:41
01.1: Digitizing Landmarks in StereoMorph https://deanadams.github.io/2019-Chile/Labs/01.1-Digitizing-StereoMor...
10 de 10 14-06-2019 8:41