download:


The latest version of geomorph is available for download from the CRAN website.

Tuesday, May 7, 2013

New geomorph function to digitize multiple 2d images

Hi Morphometricians!

We've enhanced geomorph's ability to continuously digitize multiple specimens' images in 2d, if these are within the same directory. This new function allows one to digitize 2d images without interruption. Thanks to Samuel Brown and Karl Fetter for suggesting the improvement.

We will incorporate this function in our next package update. I'm including demonstration code and a link to archaeological lithic specimens below. To replicate the excercise, first download zipped folder containing the images of 3 specimens from this link .

These images are of Middle and Upper Paleolithic tools from excavations at Tor Sadaf, Jordan, conducted by Dr. Nancy Coinman

Cheers,

Erik

DIgitizing instructions can be found in the geomorph package manual (pp. 11-12)


# create a folder named "2d_midpaleolithic_specs" and unzip images there
# dir.create("C:/2d_midpaleolithic_specs/")

# then set the directory to where the images are located
> setwd("C:/2d_midpaleolithic_specs/")

> # create the file name character vector named "specs"
> # ensure that only ".jpg" files are called (for future reference)
> specs<-list.files()[grep(".JPG",list.files())]
> specs
[1] "spec100.JPG" "spec143.JPG" "spec164.JPG"

> # source the function "digitize2d.multi()"
> source(url("http://www.people.fas.harvard.edu/~eotarolacastillo/software/digitze2dmulti.R"))

> # To begin digitizing images call the function with with:
> diged.imgs <- lapply(specs, digitize2d.multi, nlandmarks=3, scale=1)
Loading required package: jpeg
set scale = 1

# to set the scale, use the mouse to digitize the length of the scale in the image


select landmarks 1:3

# to select landmarks, "point-and-click" at the locations of the landmarks of interest. in this case, the ends of a preparation platform and the tip were selected.


set scale = 1
select landmarks 1:3

(figure not shown)
set scale = 1
select landmarks 1:3

# here is another example using an upper-paleolithic blade.


Monday, May 6, 2013

New fixed.angle() Function


Hello morphometricians,
Below you can find a new fixed angle function addressing the problem discovered by Fabio Machado in the morphmet mail archive. We will include this function in our next schedule update to geomorph.

Cheers,

Erik

CODE:

fixed.angle<-function(A,art.pt=NULL,angle.pts=NULL,rot.pts=NULL,angle=0){
if (length(dim(A))!=3){
stop("Data matrix 1 not a 3D array (see 'arrayspecs').") }
if(length(grep("-999",A))!=0){
stop("Data matrix 1 contains missing values. Estimate these first(see 'estimate.missing').") }
n<-dim(A)[3]; k<-dim(A)[2]; p<-dim(A)[1]
if (k!=2){
stop("Method presently implemented for two-dimensional data only.")}
if (angle>pi*2){
stop("Additional angle must be specified in radians.")}
if (angle< -pi*2){
stop("Additional angle must be specified in radians.")}
angl<-array(NA,dim=n)
for (i in 1:n){
A[,,i]<-t(t(A[,,i])-A[art.pt,,i])
angl[i]<- acos((A[angle.pts[1],,i]/sqrt(sum(A[angle.pts[1],,i]^2)))%*%(A[angle.pts[2],,i]/sqrt(sum(A[angle.pts[2],,i]^2))))
}
dev.angle<- (angl-mean(angl))+angle
if(A[angle.pts[1],1,1]<0){dev.angle<- -1*dev.angle}
for (i in 1:n){
r = matrix(c(cos(dev.angle[i]),-sin(dev.angle[i]),sin(dev.angle[i]),cos(dev.angle[i])),2)
A[rot.pts,,i] = A[rot.pts,,i]%*%r
}
return(A)
}


Monday, February 25, 2013

Plot 3D Wireframes from Morphologika


Hi morphometricians,
A quick update: a function to plot Morphologika 3D wireframes using the package geomorph. This routine (or a version of it) will be included in our next package update under the "read.morphologika" function.

Enjoy!

Example:

library(geomorph)
# create an array of 10 random 3D specimens with 6 landmarks each to GPA
data<-array(abs(rnorm(18*10)),c(6,3,5))

# create a simple wireframe, e.g., pt1 connects to pt2, 2-to-3, 3-to-4,...etc.
wireframe<-matrix(c(1,2,2,3,3,4,4,5,5,6),ncol=2,byrow=T)
wireframe
mydata.gpa<-gpagen(data) #gpa landmarks

# choose the largest and/or smallest specimen
max<-which.max(mydata.gpa$Csize) #ID specimen w/largest CS
min<-which.min(mydata.gpa$Csize) #ID specimen w/smallest CS

# wireframe function: wirefun
# Input: 2 matrices: A & W
#  A is the procrustes residualsmatrix
#  W is the wireframe matrix
wirefun<-function(A,W,...){
  plot3d(A,type="n", aspect=FALSE,...)
  for(i in 1:dim(W)[1]){
    points3d(A[W[i,],],...)
    text3d(A[W[i,],],texts=W[i,],...)
    lines3d(rbind(A[W[i,1],],A[W[i,2],]),...)
  }
}

# Plot
wirefun(A=mydata.gpa$coords[,,1],W=wireframe,size=10,adj=2.5,col="black")

Sunday, February 24, 2013

Major update to the R-package geomorph


Hi Folks,

We have just completed a major update to the R-package geomorph:
software for geometric morphometric analyses in R.  Included are several new functions to  carry out additional GM analyses, as well as enhancements of existing functions and analyses.  The major highlights of these changes are:

- New function for the analysis of bilateral symmetry (both object and matching symmetry)
- Integration and modularity functions improved
- Comparison of modular partitions can allow more than two partitions
- New function for writing tps files
- New function for adjusting articulation angles
- Expanded functionality of motion and trajectory analysis function
- Additional data output options included in plotting and analysis routines

Full details of changes can be found in the geomorph manual (found on link below).

Geomorph can be downloaded from the CRAN website and package
repository:  http://cran.r-project.org/web/packages/geomorph/

Thursday, February 14, 2013

Major update to the R-package geomorph


Hi Folks,

We have just completed a major update to the R-package geomorph:
software for geometric morphometric analyses in R.  Included are several new functions to  carry out additional GM analyses, as well as enhancements of existing functions and analyses.  The major highlights of these changes are:

- New function for the analysis of bilateral symmetry (both object and matching symmetry)
- Integration and modularity functions improved
- Comparison of modular partitions can allow more than two partitions
- New function for writing tps files
- New function for adjusting articulation angles
- Expanded functionality of motion and trajectory analysis function
- Additional data output options included in plotting and analysis routines

Full details of changes can be found in the geomorph manual (found on link below).

Geomorph can be downloaded from the CRAN website and package

Sunday, January 13, 2013

'read.morphologika' update


Update for read.morphologika function. This code will be added to geomorph on our next package update. This update fixes problems with message "object 'incoords' not found". Can be used with example data set mydata_readmorphologika. Here, I provide sample data in the Morphologika format composed of two specimens with 50 landmarks each, and with four data attributes. To import data attributes use matrix = TRUE, and make sure Morphologika attribute tags: '[labels]' and '[labelvalues]' are present, else use matrix = FALSE.The latter imports an array of landmarks only. Please see the geomorph manual for use of read.morphologika.


For example:

> setwd("C:/Programming")
> file<-"C:/Programming/mydata_readmorphologika.txt"
> mydata<-read.morphologika(file=file,matrix=T)
> head(mydata$dataframe)
  ID collector    date genus species     1      2      3      4      5      6      7      8      
1  1       EOC Jan2012     A       a 0.595 0.1679 0.2232 0.5028 1.2920 0.4237 0.5130 0.2047 
2  2       EOC Jan2012     B       b 0.743 0.3662 0.4697 1.3998 1.7515 1.8165 0.8139 2.8590 

on the other hand, "mydata$coords" provides one only with the landmarks coordinates.