Software

This page will contain R scripts and other small programs for carrying out various quantitative analyses on stone artifacts from digitized photographs. As new scripts are properly debugged and annotated they will be uploaded here.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[Update] I just became aware that Julien Claude and colleagues now provide an R package for carrying out most of the analyses from his book, and more. Check it out on CRAN here.

Data acquisition

I usually start my analysis by having a photograph of each artifact in a folder with the landmark that interests me (e.g., the tip) to the right of the image. I use Photoshop, (Gimp or any other image manipulation program can be used) to extract the background so that the artifact is black on a white background. I then use Fiji (which is, as its name suggests, ‘just’ ImageJ) to extract a .txt file for each image to a folder of my choosing (see the annotations in the file SaveArtifactXYPathWriter.ijm below). I use Photoshop and Fiji together, because Photoshop does a better initial job of capturing the outline automatically, but cannot do as good of an export as Fiji. The next step is to fix this data for Elliptical Fourier Analysis, by running through the folder and

  1. resampling the outline with fewer points, as specified by user (Fiji exports the coordinates of each pixel),
  2. making the right-most point the first point (i.e., standardizing the trace outline),
  3. scaling by area and translating the outline so the centroid is 0, and
  4. plotting the new outlines in a PDF for inspection, with the starting point in green, the 10th outline point in red, and the 11th in blue. This helps check that all outlines are counterclockwise and reasonably standardized for starting point.

All of this is done using the fixxydata.R script provided below. The script (written by Shannon McPherron and myself) is annotated and can be changed according to needs. In order to change the parameters for the script, you have to change them in the wrapper section at the bottom of the script. All of this is explained in the annotation. This script has two outputs. The first is a table-object in R‘s memory called m. m is just 3 columns, X, Y, and the ID name, which is whatever the original photo’s name was, and kN rows, where N is the number of specimens, and k is the number of points chosen for the resampling. This table can be used by the script EFA.R (written by me, using code from Julien Claude‘s excellent book, Morphometrics with R), which should be run right after fixxydata.R and which carries out the Elliptical Fourier Analysis.

SaveArtifactXY.ijm

fixxydata.R

elliptical Fourier analysis (EFA)

EFA.R is more complicated, so be sure to read the annotations to the code.

EFA.R