Description Usage Arguments Details Value Methods Author(s) References See Also Examples
This function saves a NIfTI-class object to a single binary file in NIfTI format.
1 2 3 4 5 6 7 8 9 | ## S4 method for signature 'nifti'
writeNIfTI(nim, filename, onefile = TRUE, gzipped = TRUE,
verbose = FALSE, warn = -1)
## S4 method for signature 'anlz'
writeNIfTI(nim, filename, onefile = TRUE, gzipped = TRUE,
verbose = FALSE, warn = -1)
## S4 method for signature 'array'
writeNIfTI(nim, filename, onefile = TRUE, gzipped = TRUE,
verbose = FALSE, warn = -1)
|
nim |
is an object of class |
filename |
is the path and file name to save the NIfTI file (.nii) without the suffix. |
onefile |
is a logical value that allows the scanning of
single-file (.nii) or dual-file format (.hdr and .img) NIfTI files
(default = |
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 |
The writeNIfTI
function utilizes the internal writeBin
and writeChar
command to write information to a binary file.
Current acceptable data types include
DT BINARY (1 bit per voxel)
DT SIGNED SHORT (16 bits per voxel)
DT SINGED INT (32 bits per voxel)
DT FLOAT (32 bits per voxel)
DT DOUBLE (64 bits per voxel)
DT UNSIGNED SHORT (16 bits per voxel)
Nothing.
Convert ANALYZE object to class nifti
and write the NIfTI volume to disk.
Convert array to class nifti
and write
the NIfTI volume to disk.
Write NIfTI volume to disk.
Brandon Whitcher bwhitcher@gmail.com,
Volker Schmid volkerschmid@users.sourceforge.net
NIfTI-1
http://nifti.nimh.nih.gov/
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 | 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.nifti <- nifti(img) # create NIfTI object
writeNIfTI(img.nifti, "test-nifti-image-uint8", verbose=TRUE)
## These files should be viewable in, for example, FSLview
## Make sure you adjust the min/max values for proper visualization
data <- readNIfTI("test-nifti-image-uint8", verbose=TRUE)
image(img.nifti, oma=rep(2,4), bg="white")
image(data, oma=rep(2,4), bg="white")
abs.err <- abs(data - img.nifti)
image(as(abs.err, "nifti"), zlim=range(img.nifti), 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-nifti-image-", datatypes$name[i], sep="")
rm(img.nifti)
img.nifti <- nifti(img, datatype=datatypes$code[i])
writeNIfTI(img.nifti, fname, verbose=TRUE)
equal[[i]] <- all(readNIfTI(fname) == img)
}
names(equal) <- datatypes$name
unlist(equal)
## End(Not run)
|
oro.nifti 0.7.2
writing data at byte = 352
fname = test-nifti-image-uint8
files = test-nifti-image-uint8.nii.gz
nii = test-nifti-image-uint8.nii.gz
vox_offset = 352
seek(fid) = 352
# reorient = Method 1
## performPermutation
trans =
[,1] [,2] [,3]
[1,] 1 0 0
[2,] 0 1 0
[3,] 0 0 1
sum(T != 0) = 3
det(T) = 1
sum(T != 0) == 3 && det(T) != 0 is TRUE
## else {
## real.dimensions = 32 32 32
## dim(out) = 32 32 32
writing data at byte = 352
writing data at byte = 352
writing data at byte = 352
writing data at byte = 352
writing data at byte = 352
uint8 int16 int32 float double
TRUE TRUE TRUE TRUE TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.