Generic functions to read/write landmarks in any supported format

read.landmarks(f, ...)

write.landmarks(
  x,
  file,
  format = "amiralandmarks",
  ext = NULL,
  Force = FALSE,
  MakeDir = TRUE,
  ...
)

Arguments

f

Path to a file (can also be a URL)

...

Additional arguments passed on to format specific functions

x

The landmarks object to write. Can also be a plain matrix or data.frame.

file

The path to the output file. If this does not end in an extension like .landmarksAscii, then one will be added based on the value of the ext argument.

format

Character vector specifying output format. Defaults to "amiralandmarks". Partial matching is used (e.g. amira is sufficient).

ext

Optional character vector specifying a new or non-standard extension to use for output file, including the period (e.g. ext='.am'). When ext=NULL, the default, the default extension for the selected format will be added if f does not have an extension. When ext=NA, the extension will not be modified and no extension will be appended if f does not have one.

Force

Whether to overwrite an existing file

MakeDir

Whether to create directory implied by file argument.

Value

for read.landmarks a matrix or list of additional class landmarks, where the rownames specify the names of each landmark if available.

For write.landmarks the path to the written file, invisibly.

Details

Presently the supported formats are

See examples section for how to produce a listing of all currently available formats with fileformats.

Paired landmarks

Only the amiralandmarks format supports the use of paired landmarks

See also

Examples

## Listing of supported fileformats for landmarks fileformats(class = 'landmarks', rval = "info")
#> format class ext read write magic #> 1 amiralandmarks landmarks .landmarkAscii TRUE TRUE TRUE #> 2 amiralandmarks landmarks .landmarkBin TRUE TRUE TRUE #> 3 amiralandmarks landmarks .am TRUE TRUE TRUE #> 4 amiralandmarks landmarks .amiramesh TRUE TRUE TRUE #> 5 cmtklandmarks landmarks .landmarks TRUE TRUE TRUE #> 6 fijilandmarks landmarks .points TRUE TRUE TRUE
## round trip tests m=matrix(rnorm(6), ncol=3) rownames(m)=c("nose", "ear") f=write.landmarks(m, file='knee', format='cmtk') read.landmarks(f)
#> [,1] [,2] [,3] #> nose 1.8496270 -1.956250 0.4405652 #> ear 0.3366984 2.155521 1.2447120 #> attr(,"class") #> [1] "landmarks" "matrix"
# write in amira format which does not support named landmarks f2=write.landmarks(m, file='knee', format='amira') read.landmarks(f2)
#> [,1] [,2] [,3] #> [1,] 1.8496270 -1.956250 0.4405652 #> [2,] 0.3366984 2.155521 1.2447120 #> attr(,"class") #> [1] "landmarks" "matrix"
# clean up unlink(c(f,f2))