zarquon42b / Morpho

R-package providing a toolset for (3D-based) Geometric Morphometrics
51 stars 16 forks source link

Cannot seem to get place patch code working. please help #36

Open k-moff opened 1 year ago

k-moff commented 1 year ago

Hi, I am trying to get the placePatch code working to semiautomatically place patch landmarks on my specimens.

I am receiving the following error:

patchtest <- placePatch(pseudatlas, testdata, path = "C:/Users/katem/OneDrive/Documents/pseudlm/meshes", prefix = '', fileext=".ply", inflate=5)

Removed 0 duplicate 73 unreferenced vertices and 4 duplicate faces Removed 0 duplicate 73 unreferenced vertices and 4 duplicate faces Warning messages: 1: In place.patch(dat.array, path, atlas.mesh = atlas$mesh, atlas.lm = atlas$landmarks, : matching for specimen 1 failed with: Error in intI(j, n = x@Dim[2], dn[[2]], give.dn = FALSE): index larger than maximal 0

2: In place.patch(dat.array, path, atlas.mesh = atlas$mesh, atlas.lm = atlas$landmarks, : matching for specimen 2 failed with: Error in intI(j, n = x@Dim[2], dn[[2]], give.dn = FALSE): index larger than maximal 0

Could you please help? Below is the code and is working up until this point...

Thank you very much, Any help would be greatly appreciated.

library(Morpho) library(geomorph) library(Rvcg) library(rgl) library(devtools)

import 3D surface as a mesh file - my template 3d mesh

template.mesh <- file2mesh("C:/Users/katem/OneDrive/Documents/pseudlm/pseudlmtesttemp.ply", clean = TRUE, readcol = FALSE)

import landmarks and the patch defined on the template

template.pts <- read.pts("C:/Users/katem/OneDrive/Documents/pseudlm/pseudlmtesttemp.pts")

create atlas

extract info about fixed landmarks, curves, patches from an atlas created by idav checkpoint

cExtract (template.pts)

create atlas needed for placing patch semilandmarks

pseudatlas <- createAtlas(template.mesh, landmarks = template.pts[c(1:56,57:64,65:69,70:74,75:79,80:84,85:92),], patch = template.pts[-c(1:56,57:64,65:69,70:74,75:79,80:84,85:92),], corrCurves = list(c(57:64),c(65:69),c(70:74),c(75:79),c(80:84),c(85:92)))

plotAtlas(pseudatlas)

read pts files from landmarks on specimens i want to place patch on

testpts1 <- read.pts("C:/Users/katem/OneDrive/Documents/pseudlm/pseudlmtest.pts")

testpts2 <- read.pts("C:/Users/katem/OneDrive/Documents/pseudlm/pseudlmtest2.pts")

cExtract(testpts1)

cExtract(testpts2)

create landmark array for fixed landmarks

testdata <- bindArr(testpts1, testpts2, along=3) dimnames(testdata)[[3]] <- c("pseudlmtest", "pseudlmtest2")

testpts1.mesh <- file2mesh("C:/Users/katem/OneDrive/Documents/pseudlm/meshes/pseudlmtest.ply", clean = TRUE, readcol = FALSE) testpts2.mesh <- file2mesh("C:/Users/katem/OneDrive/Documents/pseudlm/meshes/pseudlmtest2.ply", clean = TRUE, readcol = FALSE)

checkLM(testdata)

writemeshtodisk

mesh2ply(testpts1.mesh, filename="pseudlmtest") mesh2ply(testpts2.mesh, filename="pseudlmtest2")

place patch

patchtest <- placePatch(pseudatlas, testdata, path = "C:/Users/katem/OneDrive/Documents/pseudlm/meshes", prefix = '', fileext=".ply", inflate=5)

RECEIVE ERROR PLEASE SEE ABOVE. THANKS