Write a 3D data object to an AmiraMesh format file

write.amiramesh(
  x,
  file,
  enc = c("binary", "raw", "text", "hxzip"),
  dtype = c("float", "byte", "short", "ushort", "int", "double"),
  endian = .Platform$endian,
  WriteNrrdHeader = FALSE
)

Arguments

x

The image data to write (an im3d, or capable of being interpreted as such)

file

Character vector describing a single file

enc

Encoding of the data. NB "raw" and "binary" are synonyms.

dtype

Data type to write to disk

endian

Endianness of data block. Defaults to current value of .Platform$endian.

WriteNrrdHeader

Whether to write a separate detached nrrd header next to the AmiraMesh file allowing it to be opened by a NRRD reader. See details.

Details

Note that only 'raw' or 'text' format data can accommodate a detached NRRD format header since Amira's HxZip format is subtly different from NRRD's gzip encoding. There is a full description of the detached NRRD format in the help for write.nrrd.

Examples

d=array(rnorm(1000), c(10, 10, 10))
tf=tempfile(fileext='.am')
write.amiramesh(im3d(d, voxdims=c(0.5,0.5,1)), file=tf, WriteNrrdHeader=TRUE)
d2=read.nrrd(paste(tf, sep='', '.nhdr'))
all.equal(d, d2, tol=1e-6)
#> [1] "Attributes: < Length mismatch: comparison on first 1 components >"