Learn R Programming

StereoMorph (version 1.6.7)

readLandmarksToList: Reads landmark file(s) into a list

Description

Reads landmarks from one or more files into a list. This function is useful when dealing with curves (semilandmarks) since curve points can be grouped by curve name for other operations.

Usage

readLandmarksToList(file, semilandmark.pattern = "[0-9]+$", ...)

Arguments

file

a single landmark file or vector of landmark files to be read. Each file should contain a single landmark matrix with row names.

semilandmark.pattern

a regular expression pattern passed to sub() for identifying and grouping curve points. The default is landmark names ending in one or more numbers.

...

further arguments to be passed to read.table().

Value

a landmark list.

Details

This function will read a landmark matrix from one or more files and use the row names in each matrix to match corresponding landmarks into list elements, ordered first by the landmark name and then numbered by the index of the file (in file) from which the landmark was read. Landmark lists are the required input format for dltMatchCurvePoints. Landmark lists are also one of three possible input formats for dltReconstruct and allow for curve points to be easily pulled out of a landmark set for curve fitting.

semilandmark.pattern is a regular expression passed to sub() to identify semilandmarks (curve points). By default, the regular expression "[0-9]+$" identifies row names that end in more than one digit (e.g. 'tomium_R004') as curve points. sub() removes the part of the string identified by semilandmark.pattern in order to group all curve points under one curve name (e.g. 'tomium_R004' would be grouped under 'tomium_R'). Curve grouping can be turned off by setting semilandmark.pattern to "". Once grouped, curve points are sorted only by the numeric portion of their row name (identified by semilandmark.pattern using regexpr). Preceding zeros are not necessary. For example, after sorting, the order of the following curve points would be: tomium_R1, tomium_R02, tomium_R9, tomium_R10. Note that if these were sorted simply by row name, the order would be: tomium_R02, tomium_R1, tomium_R10, tomium_R9. Landmarks missing from one or more files are given the value NULL.

The landmark files are read by read.file() and should thus conform to all requirements of read.file(). Arguments for read.file() can be passed through readLandmarksToList() (e.g. header, row.names, etc.).

See Also

readLandmarksToArray, readLandmarksToMatrix, readCheckerboardsToArray,

dltMatchCurvePoints

Examples

Run this code
# NOT RUN {
## GET FILE DIRECTORY FOR PACKAGE FILES
fdir <- paste0(path.package("StereoMorph"), "/extdata/")

## SET FILES TO LOAD - TWO DIFFERENT 3D POINT SETS
file <- paste0(fdir, "lm_3d_even_a", 1:2, ".txt")

## READ LANDMARKS INTO A LIST
lm.list <- readLandmarksToList(file=file, row.names=1)

## CURVE POINTS
## CURVE POINTS ARE ABSENT FROM FIRST POINT SET
lm.list[['tomium_R']]

## LANDMARKS PRESENT IN BOTH POINT SETS
lm.list[['quadrate_jugal_R']]

## LANDMARK MISSING FROM SECOND POINT SET
lm.list[['foramen_magnum_inf']]
# }

Run the code above in your browser using DataLab