Creating a template in R using
geomorph:
I am using morton1306 as my template
Make sure the landmark txt files is in .tps file format:
LM3: 109
x y z
x y z
x y z
Open up R:
-change the working directory to the folder with the landmark and surface files of the template
setwd("~/Documents/FinalEndocastAnalysis")
load("~/Documents/CompletedEndocastsFinal/FinalAnalysisRData")
library(geomorph)
-read in the specimen's landmarks and endocast files
morton1306_fixed_curve_landmarks <- readland.tps(file.choose())
morton1306ply <- read.ply(file.choose())
-Build the template using the buildtemplate() function.
buildtemplate(morton1306ply, morton1306_fixed_curve_landmarks, 900, ptsize=1, center=FALSE)
- This places 900 semilandmarks on the template surface and creates a template.txt file of the landmark points, an .nts file of the points and a surfslide.csv file that tells which ones slide
- read the template file into R
template <- as.matrix(read.table("template.txt", header=T, sep=" "))
To edit the template and remove landmarks you do not want:
-
use the
editTemplate() function in
geomorph
-
it will allow you to choose a set number of landmarks to remove from the template and overwrite the template.txt file
-
it will
not edit the surfslide.csv file, you will need to edit this by hand
To edit the surfslide.csv file:
-
open in excel
-
determine how many surface
semilandmarks you now have
-
edit the file so that it shows a
continous column of numbers
from the next number after your fixed and curve
semilandmarks to the number of surface
semilandmarks there are
(I have 109 fixed/curve landmarks so my
surfslide file goes from 110 to 969)
To view the endocast surface with the
semilandmarks and landmarks:
>morton1306alllandmarks<- readland.nts("morton1306ply.nts")
> morton1306alllandmarks2d <- two.d.array(morton1306alllandmarks)
>plotspec(spec=morton1306ply, digitspec=morton11306alllandmarks2d, fixed=109 centered=FALSE)
a window will pop up with the surface and landmarks
No comments:
Post a Comment