fixLMtps: estimate missing landmarks

View source: R/fixLMtps.r

fixLMtpsR Documentation

estimate missing landmarks

Description

Missing landmarks are estimated by deforming a sample average or a weighted estimate of the configurations most similar onto the deficient configuration. The deformation is performed by a Thin-plate-spline interpolation calculated by the available landmarks.

Usage

fixLMtps(data, comp = 3, weight = TRUE, weightfun = NULL)

Arguments

data

array containing landmark data

comp

integer: select how many of the closest observations are to be taken to calculate an initial estimate.

weight

logical: requests the calculation of an estimate based on the procrustes distance. Otherwise the sample's consensus is used as reference.

weightfun

custom function that operates on a vector of distances (see examples) and generates weights accordingly.

Details

This function tries to estimate missing landmark data by mapping weighted averages from complete datasets onto the missing specimen. The weights are the inverted Procrustes (see proc.weight) distances between the 'comp' closest specimen (using the available landmark configuration).

Value

out

array containing all data, including fixed configurations - same order as input

mshape

meanshape - calculated from complete datasets

checklist

list containing information about missing landmarks

check

vector containing position of observations in data where at least one missing coordinate was found

Note

Be aware that these estimates might be grossly wrong when the missing landmark is quite far off the rest of the landmarks (due to the radial basis function used in the Thin-plate spline interpolation.

Author(s)

Stefan Schlager

References

Bookstein FL. 1989. Principal Warps: Thin-plate splines and the decomposition of deformations IEEE Transactions on pattern analysis and machine intelligence 11.

See Also

proc.weight, tps3d

Examples

if (require(shapes)) {
data <- gorf.dat
### set first landmark of first specimen to NA
data[1,,1] <- NA
repair <- fixLMtps(data,comp=5)
### view difference between estimated and actual landmark
plot(repair$out[,,1],asp=1,pch=21,cex=0.7,col=2)#estimated landmark
points(gorf.dat[,,1],col=3,pch=20)#actual landmark
}
## 3D-example:
data(boneData)
data <- boneLM
### set first and 5th landmark of first specimen to NA
data[c(1,5),,1] <- NA
repair <- fixLMtps(data,comp=10)
##  view difference between estimated and actual landmark
## Not run: 
deformGrid3d(repair$out[,,1], boneLM[,,1],ngrid=0)

## End(Not run)

## Now use a gaussian kernel to compute the weights and use all other configs
gaussWeight <- function(r,sigma=0.05) {
   sigma <- 2*sigma^2
   return(exp(-r^2/ sigma))
}
repair <- fixLMtps(data,comp=79,weightfun=gaussWeight)


Morpho documentation built on June 22, 2024, 7:19 p.m.