Description Usage Arguments Details Value Methods Author(s) References See Also Examples
This function saves an Analyze-class object to a single binary file in Analyze format.
1 2 3 4 5 6 7 8 9 | ## S4 method for signature 'anlz'
writeANALYZE(
aim,
filename,
gzipped = TRUE,
verbose = FALSE,
warn = -1,
compression = 6
)
|
aim |
is an object of class |
filename |
is the path and file name to save the Analyze file pair (.hdr,img) without the suffixes. |
gzipped |
is a character string that enables exportation of compressed
(.gz) files (default = |
verbose |
is a logical variable (default = |
warn |
is a number to regulate the display of warnings (default = -1).
See |
compression |
The amount of compression to be applied when writing a
file when |
The writeANALYZE
function utilizes the internal writeBin
and
writeChar
command to write information to a binary file.
Nothing.
Write ANALYZE volume to disk.
Brandon Whitcher bwhitcher@gmail.com
Analyze 7.5
http://eeg.sourceforge.net/ANALYZE75.pdf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | norm <- dnorm(seq(-5, 5, length=32), sd=2)
norm <- (norm-min(norm)) / max(norm-min(norm))
img <- outer(outer(norm, norm), norm)
img <- round(255*img)
img[17:32,,] <- 255 - img[17:32,,]
img.anlz <- anlz(img) # create Analyze object
fname = file.path(tempdir(), "test-anlz-image-uint8")
writeANALYZE(img.anlz, fname, verbose=TRUE)
## These files should be viewable in, for example, FSLview
## Make sure you adjust the min/max values for proper visualization
data <- readANALYZE(fname, verbose=TRUE)
image(img.anlz, oma=rep(2,4), bg="white")
image(data, oma=rep(2,4), bg="white")
abs.err <- abs(data - img.anlz)
image(as(abs.err, "anlz"), zlim=range(img.anlz), oma=rep(2,4), bg="white")
## Not run:
## Loop through all possible data types
datatypes <- list(code=c(2, 4, 8, 16, 64),
name=c("uint8", "int16", "int32", "float", "double"))
equal <- vector("list")
for (i in 1:length(datatypes$code)) {
fname <- paste("test-anlz-image-", datatypes$name[i], sep="")
fname = file.path(tempdir(), fname)
rm(img.anlz)
img.anlz <- anlz(img, datatype=datatypes$code[i])
writeANALYZE(img.anlz, fname)
equal[[i]] <- all(readANALYZE(fname) == img)
}
names(equal) <- datatypes$name
unlist(equal)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.