Hi David,

Not sure what the file actually looks like since you’ve not included a sample 
here. However I suggest taking a look at the readland functions in geomorph R 
package to see how we tackle the different types. If you want, send it through 
to us and we can take a look. If there’s a lot of people using AVIZO for 
digitising, we can include a function in geomorph.

Regarding a read function writing? Nope, never heard of that.

Em

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Emma Sherratt, PhD.
Lecturer in Zoology,
Zoology Division, School of Environmental and Rural Science, 
Room L112 Bldg C02, 
University of New England, 
Armidale, NSW, Australia, 2351
Tel: +61 2 6773 5041
email: [email protected]
Twitter: @DrEmSherratt

Caecilians are legless amphibians...
                      __
    (\   .-.   .-.   /_")
     \\_//^\\_//^\\_//
      `"`   `"`   `"`
learn more about them here: www.emmasherratt.com/caecilians

On 20 January 2016 at 14:50:38, David Katz ([email protected]) wrote:

Hi everyone, 

I've collected 3D landmarks on a series of cranial surface models in Avizo. 
Avizo's landmark editor outputs .landmarkAscii files, which I would like to 
read into R. The way I've done the reading has the following very unexpected 
effect: sometimes, it writes additional data to my .landmarkAscii files. I'd 
like to understand why, but am mostly interested in finding a solution.

To read in the landmark files for a specimen...

# Below, avz.file is the filepath for the .landmarkAscii  
# file for a single specimen.
# The code reads the .landmarkAscii file with read.csv. 
# This is useful because the object created lays out 
# the informational data that precedes the coordinate data 
# predictably. This makes it easy to lop off the 
# informational data. 
  read.lms <- read.csv(avz.file, header=FALSE)[,1]

  # The last row of informational data will contain the 
  # text "@1" and nothing else. 
  lm.start <- which(read.lms=="@1")+1

  # Now it is possible to create an object with landmark 
  # data only. R interprets each landmark (all three 
  # coordinates together) as a factor. I convert the factor 
  # vector to a character vector.
  lm.char <-
     as.character(droplevels(
         read.lms[(lm.start):length(read.lms)]))

  # Then I create an empty matrix for the landmark data    
  lm.mat <- matrix(NA, nrow=length(lm.char), ncol=3)

  # Then fill lm.mat with the landmark data. As mentioned, 
  # lm.char is a vector. Each element of that vector 
  # contains the X, Y, and Z coordinate for a landmark.
  # The coordinates are separated by spaces 
  # (or maybe tabs)
  for(i in 1:nrow(lm.mat))
     {lm.mat[i,] <- 
         as.numeric(unlist(strsplit(ctlm.char[i], " ")))}
 
That's it. The code above will read in the data and make a landmark matrix. 
Unfortunately, it sometimes also writes additional lines to the .landmarkAscii 
file. The first added element is "@2." Thereafter, the landmark file adds as 
many three-coordinate triplets as there are landmarks in the original data 
file. The values of these triplets are 0,0,1 (or maybe 1,0,0).

This is really strange behavior. A read function shouldn't write. 

My issue may be better suited to an R forum, but I am hoping someone here has 
reliable code for reading Avizo landmarks into R.

Thanks in advance. 

David


--
David Katz
University of California, Davis
--
MORPHMET may be accessed via its webpage at http://www.morphometrics.org
---
You received this message because you are subscribed to the Google Groups 
"MORPHMET" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].

-- 
MORPHMET may be accessed via its webpage at http://www.morphometrics.org
--- 
You received this message because you are subscribed to the Google Groups 
"MORPHMET" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].

Reply via email to