Title: | Data Structures and Handling for Neuroimaging Data |
---|---|
Description: | A collection of data structures that represent volumetric brain imaging data. The focus is on basic data handling for 3D and 4D neuroimaging data. In addition, there are function to read and write NIFTI files and limited support for reading AFNI files. |
Authors: | Bradley R. Buchsbaum |
Maintainer: | Bradley Buchsbaum <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.0 |
Built: | 2024-11-06 05:13:51 UTC |
Source: | https://github.com/bbuchsbaum/neuroim |
BrainBucket
extract labeled volume from BrainBucket
## S4 method for signature 'BrainBucket,index,missing,ANY' x[i]
## S4 method for signature 'BrainBucket,index,missing,ANY' x[i]
x |
the object |
i |
first index |
ROIVolume
subset an ROIVolume
## S4 method for signature 'ROIVolume,numeric,missing,ANY' x[i, j, drop] ## S4 method for signature 'ROIVolume,logical,missing,ANY' x[i, j, drop]
## S4 method for signature 'ROIVolume,numeric,missing,ANY' x[i, j, drop] ## S4 method for signature 'ROIVolume,logical,missing,ANY' x[i, j, drop]
x |
the object |
i |
first index |
j |
second index |
drop |
drop dimension |
extractor
## S4 method for signature 'SparseBrainVector,missing,missing,ANY' x[i, j, k, m, ..., drop = TRUE]
## S4 method for signature 'SparseBrainVector,missing,missing,ANY' x[i, j, k, m, ..., drop = TRUE]
x |
the object |
i |
first index |
j |
second index |
k |
third index |
m |
the fourth index |
... |
additional args |
drop |
dimension |
extractor
## S4 method for signature 'SparseBrainVector,missing,numeric,ANY' x[i, j, k, m, ..., drop = TRUE]
## S4 method for signature 'SparseBrainVector,missing,numeric,ANY' x[i, j, k, m, ..., drop = TRUE]
x |
the object |
i |
first index |
j |
second index |
k |
third index |
m |
the fourth index |
... |
additional args |
drop |
dimension |
extractor
## S4 method for signature 'SparseBrainVector,numeric,missing,ANY' x[i, j, k, m, ..., drop = TRUE]
## S4 method for signature 'SparseBrainVector,numeric,missing,ANY' x[i, j, k, m, ..., drop = TRUE]
x |
the object |
i |
first index |
j |
second index |
k |
third index |
m |
the fourth index |
... |
additional args |
drop |
dimension |
extractor
## S4 method for signature 'SparseBrainVector,numeric,numeric,ANY' x[i, j, k, m, ..., drop = TRUE]
## S4 method for signature 'SparseBrainVector,numeric,numeric,ANY' x[i, j, k, m, ..., drop = TRUE]
x |
the object |
i |
first index |
j |
second index |
k |
third index |
m |
the fourth index |
... |
additional args |
drop |
dimension |
extractor
## S4 method for signature 'SparseBrainVolume,matrix,missing,ANY' x[i, j, k, ..., drop = TRUE]
## S4 method for signature 'SparseBrainVolume,matrix,missing,ANY' x[i, j, k, ..., drop = TRUE]
x |
the object |
i |
first index |
j |
second index |
k |
third index |
... |
additional args |
drop |
dimension |
extractor
## S4 method for signature 'SparseBrainVolume,missing,missing,ANY' x[i, j, k, ..., drop = TRUE]
## S4 method for signature 'SparseBrainVolume,missing,missing,ANY' x[i, j, k, ..., drop = TRUE]
x |
the object |
i |
first index |
j |
second index |
k |
third index |
... |
additional args |
drop |
dimension |
extractor
## S4 method for signature 'SparseBrainVolume,missing,numeric,ANY' x[i, j, k, ..., drop = TRUE]
## S4 method for signature 'SparseBrainVolume,missing,numeric,ANY' x[i, j, k, ..., drop = TRUE]
x |
the object |
i |
first index |
j |
second index |
k |
third index |
... |
additional args |
drop |
dimension |
extractor
## S4 method for signature 'SparseBrainVolume,numeric,missing,missing' x[i, j, k, ..., drop]
## S4 method for signature 'SparseBrainVolume,numeric,missing,missing' x[i, j, k, ..., drop]
x |
the object |
i |
first index |
j |
second index |
k |
third index |
... |
additional args |
drop |
drop dimension |
extractor
## S4 method for signature 'SparseBrainVolume,numeric,numeric,ANY' x[i, j, k, ..., drop = TRUE]
## S4 method for signature 'SparseBrainVolume,numeric,numeric,ANY' x[i, j, k, ..., drop = TRUE]
x |
the object |
i |
first index |
j |
second index |
k |
third index |
... |
additional args |
drop |
dimension |
BrainBucket
extract labeled volume from BrainBucket
## S4 method for signature 'BrainBucket,index,missing' x[[i]]
## S4 method for signature 'BrainBucket,index,missing' x[[i]]
x |
the object |
i |
the first index |
extractor
extractor
## S4 method for signature 'SparseBrainVector,numeric,ANY' x[[i]] ## S4 method for signature 'BrainVector,numeric,ANY' x[[i]]
## S4 method for signature 'SparseBrainVector,numeric,ANY' x[[i]] ## S4 method for signature 'BrainVector,numeric,ANY' x[[i]]
i |
the volume index |
i |
the volume index |
Generic function to add a dimension to an object
add dimension to BrainSpace
addDim(x, n) ## S4 method for signature 'BrainSpace,numeric' addDim(x, n)
addDim(x, n) ## S4 method for signature 'BrainSpace,numeric' addDim(x, n)
x |
a dimensioned object |
n |
the size of the dimension to add |
x = BrainSpace(c(10,10,10), c(1,1,1)) x1 <- addDim(x, 10) ndim(x1) == 4 dim(x1)[4] == 10
x = BrainSpace(c(10,10,10), c(1,1,1)) x1 <- addDim(x, 10) ndim(x1) == 4 dim(x1)[4] == 10
Constructor for AFNIMetaInfo
class
AFNIMetaInfo(descriptor, afni_header)
AFNIMetaInfo(descriptor, afni_header)
descriptor |
an instance of class |
afni_header |
a |
an instance of class AFNIMetaInfo
conversion from DenseBrainVolume to array
conversion from SparseBrainVolume
to array
conversion from SparseBrainVolume to numeric
conversion from BrainVolume to LogicalBrainVolume
conversion from DenseBrainVolume to LogicalBrainVolume
conversion from ClusteredBrainVolume to LogicalBrainVolume
conversion from BrainVolume to array
BrainData
instance to arrayconvert BrainData
instance to array
## S4 method for signature 'BrainData' as.array(x)
## S4 method for signature 'BrainData' as.array(x)
x |
the object |
convert SparseBrainVector to list of DenseBrainVolume
## S4 method for signature 'SparseBrainVector' as.list(x) ## S4 method for signature 'BrainVector' as.list(x)
## S4 method for signature 'SparseBrainVector' as.list(x) ## S4 method for signature 'BrainVector' as.list(x)
x |
the object |
Convert BrainVolume to linkS4class{LogicalBrainVolume}
## S4 method for signature 'BrainVolume' as.logical(x)
## S4 method for signature 'BrainVolume' as.logical(x)
x |
the object |
the image values will be converted to using R base function as.logical
and wrapped in LogicalBrainVolume
an instance of linkS4class{LogicalBrainVolume}
Convert to a LogicalBrainVolume
as.mask(x, indices) ## S4 method for signature 'BrainVolume,missing' as.mask(x) ## S4 method for signature 'BrainVolume,numeric' as.mask(x, indices)
as.mask(x, indices) ## S4 method for signature 'BrainVolume,missing' as.mask(x) ## S4 method for signature 'BrainVolume,numeric' as.mask(x, indices)
x |
the object to binarize |
indices |
the indices to set to TRUE |
BrainData
instance to matrixconvert BrainData
instance to matrix
## S4 method for signature 'BrainData' as.matrix(x)
## S4 method for signature 'BrainData' as.matrix(x)
x |
the object |
ROIVector
to a matrixconvert SparseBrainVector to matrix
## S4 method for signature 'ROIVector' as.matrix(x) ## S4 method for signature 'ROIVector' as.matrix(x) ## S4 method for signature 'SparseBrainVector' as.matrix(x) ## S4 method for signature 'DenseBrainVector' as.matrix(x)
## S4 method for signature 'ROIVector' as.matrix(x) ## S4 method for signature 'ROIVector' as.matrix(x) ## S4 method for signature 'SparseBrainVector' as.matrix(x) ## S4 method for signature 'DenseBrainVector' as.matrix(x)
x |
the object |
x |
the object |
x |
the object |
Convert SparseBrainVolume to numeric
## S4 method for signature 'SparseBrainVolume' as.numeric(x)
## S4 method for signature 'SparseBrainVolume' as.numeric(x)
x |
the object to convert |
Convert to from dense to sparse representation
as.sparse(x, mask, ...) ## S4 method for signature 'DenseBrainVector,LogicalBrainVolume' as.sparse(x, mask) ## S4 method for signature 'DenseBrainVector,numeric' as.sparse(x, mask) ## S4 method for signature 'DenseBrainVolume,LogicalBrainVolume' as.sparse(x, mask) ## S4 method for signature 'DenseBrainVolume,numeric' as.sparse(x, mask)
as.sparse(x, mask, ...) ## S4 method for signature 'DenseBrainVector,LogicalBrainVolume' as.sparse(x, mask) ## S4 method for signature 'DenseBrainVector,numeric' as.sparse(x, mask) ## S4 method for signature 'DenseBrainVolume,LogicalBrainVolume' as.sparse(x, mask) ## S4 method for signature 'DenseBrainVolume,numeric' as.sparse(x, mask)
x |
the object to make sparse, e.g. |
mask |
the elements to retain |
... |
additional arguments |
mask
can be an integer vector of 1D indices or a mask volume of class LogicalBrainVolume
bvol <- BrainVolume(array(runif(24*24*24), c(24,24,24)), BrainSpace(c(24,24,24), c(1,1,1))) indmask <- sort(sample(1:(24*24*24), 100)) svol <- as.sparse(bvol, indmask) mask <- LogicalBrainVolume(runif(length(indmask)), space=space(bvol), indices=indmask) sum(mask) == 100
bvol <- BrainVolume(array(runif(24*24*24), c(24,24,24)), BrainSpace(c(24,24,24), c(1,1,1))) indmask <- sort(sample(1:(24*24*24), 100)) svol <- as.sparse(bvol, indmask) mask <- LogicalBrainVolume(runif(length(indmask)), space=space(bvol), indices=indmask) sum(mask) == 100
BrainData
instance to vectorconvert BrainData
instance to vector
## S4 method for signature 'BrainData' as.vector(x)
## S4 method for signature 'BrainData' as.vector(x)
x |
the object |
Generic getter function to extract image axes
axes(x) ## S4 method for signature 'BrainSpace' axes(x) ## S4 method for signature 'BrainData' axes(x)
axes(x) ## S4 method for signature 'BrainSpace' axes(x) ## S4 method for signature 'BrainData' axes(x)
x |
an object with a set of axes |
Virtual base class representing an ordered set of named axes.
ndim
the number of axes (or dimensions)
Convert 1-dimensional real axis coordinates along a single axis dimension to a 1D index along the same axis.
Convert 1-dimensional index to a coordinate value along the same axis.
axisToIndex(x, real, dimNum) indexToAxis(x, index, dimNum) ## S4 method for signature 'BrainSpace,numeric,numeric' axisToIndex(x, real, dimNum) ## S4 method for signature 'BrainSpace,numeric,numeric' indexToAxis(x, index, dimNum)
axisToIndex(x, real, dimNum) indexToAxis(x, index, dimNum) ## S4 method for signature 'BrainSpace,numeric,numeric' axisToIndex(x, real, dimNum) ## S4 method for signature 'BrainSpace,numeric,numeric' indexToAxis(x, index, dimNum)
x |
the object |
real |
the axis coordinates |
dimNum |
the dimension number of the axis (e.g. 1, 2, 3) |
index |
the axis index |
x |
the object |
dimNum |
the dimension number of the axis (e.g. 1, 2, 3) |
a vector of axis indices
a vector of axis indices
This is a base class to represent a data source
metaInfo
meta information for the data source
a class that stores a represents a 4-dimensional array as a set of basis functions (dictionary) and corresponding set of coefficients.
mask
the mask defining the sparse domain
basis
the matrix of bases, were each column is a basis vector.
coeffs
the sparseMatrix
of coefficients
map
instance of class IndexLookupVolume
is used to map between spatial and index/row coordinates
Constructor for BinaryReader
class
BinaryReader(input, byteOffset, dataType, bytesPerElement, endian = .Platform$endian)
BinaryReader(input, byteOffset, dataType, bytesPerElement, endian = .Platform$endian)
input |
file name to read from or else a |
byteOffset |
the number of bytes to skip at the start of input |
dataType |
R data type of binary elements |
bytesPerElement |
number of bytes in each data element (e.g. 4 or 8 for floating point numbers) |
endian |
endianness of binary input connection |
This class supports reading of bulk binary data from a connection
input
the binary input connection
byteOffset
the number of bytes to skip at the start of input
dataType
the dataType of the binary Elements
bytesPerElement
number of bytes in each data element (e.g. 4 or 8 for floating point numbers)
endian
endianness of binary input connection
This class supports writing of bulk binary data to a connection
Constructor for BinaryWriter
class
BinaryWriter(output, byteOffset, dataType, bytesPerElement, endian = .Platform$endian)
BinaryWriter(output, byteOffset, dataType, bytesPerElement, endian = .Platform$endian)
output |
file name to write to or else a |
byteOffset |
the number of bytes to skip at the start of output |
dataType |
R data type of binary elements |
bytesPerElement |
number of bytes in each data element (e.g. 4 or 8 for floating point numbers) |
endian |
endianness of binary output connection |
output
the binary output connection
byteOffset
the number of bytes to skip at the start of input
dataType
the dataType of the binary Elements
bytesPerElement
number of bytes in each data element (e.g. 4 or 8 for floating point numbers)
endian
endianness of binary output connection
searchlight centers are sampled without replacement, but the same surround voxel can belong to multiple searchlight samples.
BootstrapSearchlight(mask, radius = 8, iter = 100)
BootstrapSearchlight(mask, radius = 8, iter = 100)
mask |
an image volume containing valid central voxels for roving searchlight |
radius |
in mm of spherical searchlight (can be a vector which is randomly sampled) |
iter |
the total number of searchlights to sample (default is 100). |
Generic function to extract the spatial bounds (origin + dim * spacing) of an image param x the object
bounds
bounds(x) ## S4 method for signature 'BrainSpace' bounds(x) ## S4 method for signature 'BrainData' bounds(x)
bounds(x) ## S4 method for signature 'BrainSpace' bounds(x) ## S4 method for signature 'BrainData' bounds(x)
x |
the object with |
a matrix
where each row contains the min (column 1) and max (column 2) bounds of the image dimension from 1 to ndim(image)
.
bspace <- BrainSpace(c(10,10,10), c(2,2,2)) b <- bounds(bspace) nrow(b) == ndim(bspace) ncol(b) == 2
bspace <- BrainSpace(c(10,10,10), c(2,2,2)) b <- bounds(bspace) nrow(b) == ndim(bspace) ncol(b) == 2
a four-dimensional image that conists of a sequence of labeled image volumes backed by a list
Constructor function for BrainBucket
class
BrainBucket(volumeList)
BrainBucket(volumeList)
volumeList |
a named list of |
an instance of class BrainBucket
source
the data source for the bucket volumes
labels
the names of the sub-volumes contained in the bucket
data
a list of BrainVolume
instances with names corresponding to volume labels
vol1 <- BrainVolume(rnorm(24*24*24), BrainSpace(c(24,24,24), c(1,1,1))) vol2 <- BrainVolume(rnorm(24*24*24), BrainSpace(c(24,24,24), c(1,1,1))) vol3 <- BrainVolume(rnorm(24*24*24), BrainSpace(c(24,24,24), c(1,1,1))) vlist <- list(vol1,vol2,vol3) names(vlist) <- paste0("V", 1:3) bucket <- BrainBucket(vlist) all.equal(dim(bucket[[1]]), dim(vol1))
vol1 <- BrainVolume(rnorm(24*24*24), BrainSpace(c(24,24,24), c(1,1,1))) vol2 <- BrainVolume(rnorm(24*24*24), BrainSpace(c(24,24,24), c(1,1,1))) vol3 <- BrainVolume(rnorm(24*24*24), BrainSpace(c(24,24,24), c(1,1,1))) vlist <- list(vol1,vol2,vol3) names(vlist) <- paste0("V", 1:3) bucket <- BrainBucket(vlist) all.equal(dim(bucket[[1]]), dim(vol1))
A class that is used to produce a BrainBucket
instance
Constructor function for BrainBucketSource
class
BrainBucketSource(fileName, pattern = NULL, indices = NULL)
BrainBucketSource(fileName, pattern = NULL, indices = NULL)
fileName |
the name of the bucket file |
pattern |
optional regular expression used to filter the sub-volumes using associated labels |
indices |
optional set of sub-volume indices to load |
sourceList
a list of sources for the bucket sub-volumes
cache
a cache used to store data in memory
Base class for brain image data
source
an instance of class BaseSource
to store the source of the data
space
an instance of class BrainSpace
to represent the geometry of the data space
This class represents a neuroimaging file format
fileFormat
the name of the file format (e.g. NIfTI)
headerEncoding
the file encoding of the header file (e.g. 'raw' for binary, 'gzip' for gz compressed')
headerExtension
the file extension for the header file (e.g. 'nii' for NIfTI single files)
dataEncoding
the file encoding for the data file
dataExtension
the file extension for the data file (e.g. 'nii' for NIfTI single files)
BrainFileSource
Base class for representing a data source for images. The purpose of this class is to provide a layer in between low level IO and image loading functionality.
metaInfo
meta information for the data source
BrainMetaInfo
This class contains meta information from an image
This class contains meta information for an image
BrainMetaInfo(Dim, spacing, origin = rep(0, length(spacing)), dataType = "FLOAT", label = "", spatialAxes = OrientationList3D$AXIAL_LPI, additionalAxes = NullAxis)
BrainMetaInfo(Dim, spacing, origin = rep(0, length(spacing)), dataType = "FLOAT", label = "", spatialAxes = OrientationList3D$AXIAL_LPI, additionalAxes = NullAxis)
Dim |
image dimensions |
spacing |
voxel dimensions |
origin |
coordinate origin |
dataType |
the type of the data (e.g. "FLOAT") |
label |
name(s) of images |
spatialAxes |
image axes for spatial dimensions (x,y,z) |
additionalAxes |
axes for dimensions > 3 (e.g. time, color band, direction) |
an instance of class BrainMetaInfo
dataType
the data type code, e.g. FLOAT
Dim
image dimensions
spatialAxes
image axes for spatial dimensions (x,y,z)
additionalAxes
axes for dimensions > 3 (e.g. time, color band, direction)
spacing
voxel dimensions
origin
coordinate origin
label
name(s) of images
BrainSlice constructor
BrainSlice(data, space, indices = NULL)
BrainSlice(data, space, indices = NULL)
data |
data vector or matrix |
space |
an instance of class BrainSpace |
indices |
linear indices corresponding used if |
bspace <- BrainSpace(c(64,64), spacing=c(1,1)) dat <- array(rnorm(64*64), c(64,64)) bslice <- BrainSlice(dat,bspace) print(bslice)
bspace <- BrainSpace(c(64,64), spacing=c(1,1)) dat <- array(rnorm(64*64), c(64,64)) bslice <- BrainSlice(dat,bspace) print(bslice)
Base class for representing a data source for images. The purpose of this class is to provide a layer in between low level IO and image loading functionality.
metaInfo
meta information for the data source
BrainSpace
classConstructor function for BrainSpace
class
BrainSpace(Dim, spacing = NULL, origin = NULL, axes = NULL, trans = NULL)
BrainSpace(Dim, spacing = NULL, origin = NULL, axes = NULL, trans = NULL)
Dim |
a vector describing the dimensions of the spatial grid |
spacing |
the real-valued voxel dimensions (usually in millimeters) |
origin |
the coordinate origin of the image space |
axes |
the image axes ordering (default is based on the NIFTI standard, Left-Posterior-Inferior) |
trans |
a matrix representing the coordinate transformation associated with the image space (default is based on the NIFTI standard, Left-Posterior-Inferior) |
an instance of class BrainSpace
one should rarely need to create a new BrainSpace
instance, as it will almost always be created automatically using information stored in an image header.
Also, If one already has an existing image object, its BrainSpace
instance can be easily extracted with the space
method.
bspace <- BrainSpace(c(64,64,64), origin=c(0,0,0), spacing=c(2,2,2)) print(bspace) origin(bspace) axes(bspace) trans(bspace)
bspace <- BrainSpace(c(64,64,64), origin=c(0,0,0), spacing=c(2,2,2)) print(bspace) origin(bspace) axes(bspace) trans(bspace)
This class represents the geometry of a brain image
Dim
the grid dimensions of the image
origin
the coordinates of the spatial origin
spacing
the dimensions (in mm) of the grid units (voxels)
axes
the set of named spatial axes in the untransformed native grid space.
trans
an affine transformation matrix that moves from grid -> real world coordinates
inverseTrans
an inverse matrix that moves from real world -> grid coordinates
Four-dimensional brain image
constructor function for virtual class BrainVector
BrainVector(data, space = NULL, mask = NULL, source = NULL, label = "")
BrainVector(data, space = NULL, mask = NULL, source = NULL, label = "")
data |
the image data which can be a |
space |
a |
mask |
an optional |
source |
an optional |
label |
a label of type |
a concrete instance of BrainVector
class.
If mask
is provided then SparseBrainVector
, otherwise DenseBrainVector
Construct a BrainVectorSource
object
BrainVectorSource(fileName, indices = NULL, mask = NULL)
BrainVectorSource(fileName, indices = NULL, mask = NULL)
fileName |
name of the 4-dimensional image file |
indices |
the subset of integer volume indices to load – if |
mask |
image volume indicating the subset of voxels that will be loaded. If provided, function returns |
If a mask
is supplied then it should be a LogicalBrainVolume
or BrainVolume
instance. If the latter, then the mask will be defined by nonzero elements of the volume.
a instance deriving from BrainVectorSource
A class that is used to produce a BrainVectorSource
instance
indices
the index vector of the volumes to be loaded
Construct a BrainVolume
instance, using default (dense) implementation
BrainVolume(data, space, source = NULL, label = "", indices = NULL)
BrainVolume(data, space, source = NULL, label = "", indices = NULL)
data |
a three-dimensional |
space |
an instance of class |
source |
an instance of class |
label |
a |
indices |
an 1D vector that gives the linear indices of the associated |
a DenseBrainVolume
instance
bspace <- BrainSpace(c(64,64,64), spacing=c(1,1,1)) dat <- array(rnorm(64*64*64), c(64,64,64)) bvol <- BrainVolume(dat,bspace, label="test") print(bvol)
bspace <- BrainSpace(c(64,64,64), spacing=c(1,1,1)) dat <- array(rnorm(64*64*64), c(64,64,64)) bvol <- BrainVolume(dat,bspace, label="test") print(bvol)
BrainVolume Base class for image representing 3D volumetric data.
BrainVolume
instanceBrainVolumeSource
A class is used to produce a BrainVolume
instance
Constructor for BrainVolumeSource
BrainVolumeSource(input, index = 1)
BrainVolumeSource(input, index = 1)
input |
the input file name |
index |
the image subvolume index |
index
the index of the volume to be read – must be of length 1.
close
## S4 method for signature 'BinaryReader' close(con) ## S4 method for signature 'BinaryWriter' close(con)
## S4 method for signature 'BinaryReader' close(con) ## S4 method for signature 'BinaryWriter' close(con)
con |
the object to close |
Three-dimensional brain image that is divided into N disjoint partitions
Construct a ClusteredBrainVolume
instance
ClusteredBrainVolume(mask, clusters, labelMap = NULL, source = NULL, label = "")
ClusteredBrainVolume(mask, clusters, labelMap = NULL, source = NULL, label = "")
mask |
an instance of class |
clusters |
a vector of clusters ids with length equal to number of nonzero voxels in mask |
labelMap |
an optional |
source |
an optional instance of class |
label |
an optional |
ClusteredBrainVolume
instance
bspace <- BrainSpace(c(16,16,16), spacing=c(1,1,1)) grid <- indexToGrid(bspace, 1:(16*16*16)) kres <- kmeans(grid, centers=10) mask <- BrainVolume(rep(1, 16^3),bspace) clusvol <- ClusteredBrainVolume(mask, kres$cluster)
bspace <- BrainSpace(c(16,16,16), spacing=c(1,1,1)) grid <- indexToGrid(bspace, 1:(16*16*16)) kres <- kmeans(grid, centers=10) mask <- BrainVolume(rep(1, 16^3),bspace) clusvol <- ClusteredBrainVolume(mask, kres$cluster)
Create a clustered Searchlight iterator
ClusteredSearchlight(mask, csize)
ClusteredSearchlight(mask, csize)
mask |
an image volume containing valid central voxels for roving searchlight |
csize |
the number of clusters |
an iter
class
Constructor for ColumnReader
class
ColumnReader(nrow, ncol, reader)
ColumnReader(nrow, ncol, reader)
nrow |
the number of rows |
ncol |
the number of columns |
reader |
a function that takes a set of column indices and returns a |
This class supports reading of data froma matrix-like stroage format
nrow
the number of rows
ncol
the number of columns
reader
a function that takes a set of column indices and returns a matrix
Concatenate two objects
concat(x, y, ...) ## S4 method for signature 'SparseBrainVector,missing' concat(x, y, ...) ## S4 method for signature 'SparseBrainVector,SparseBrainVector' concat(x, y, ...) ## S4 method for signature 'BrainVector,BrainVolume' concat(x, y, ...) ## S4 method for signature 'BrainVolume,BrainVector' concat(x, y, ...) ## S4 method for signature 'BrainVector,BrainVector' concat(x, y, ...) ## S4 method for signature 'DenseBrainVolume,missing' concat(x, y, ...) ## S4 method for signature 'DenseBrainVolume,DenseBrainVolume' concat(x, y, ...)
concat(x, y, ...) ## S4 method for signature 'SparseBrainVector,missing' concat(x, y, ...) ## S4 method for signature 'SparseBrainVector,SparseBrainVector' concat(x, y, ...) ## S4 method for signature 'BrainVector,BrainVolume' concat(x, y, ...) ## S4 method for signature 'BrainVolume,BrainVector' concat(x, y, ...) ## S4 method for signature 'BrainVector,BrainVector' concat(x, y, ...) ## S4 method for signature 'DenseBrainVolume,missing' concat(x, y, ...) ## S4 method for signature 'DenseBrainVolume,DenseBrainVolume' concat(x, y, ...)
x |
the first object, typically |
y |
the second object, typically |
... |
additional objects |
The x
and y
images must have compatible dimensions. a BrainVolume
can be concatenated to BrainVector
, and vice versa. See examples.
dimensions of x and y must be equal
bv1 <- BrainVolume(rep(1,1000), BrainSpace(c(10,10,10), c(1,1,1))) bv2 <- BrainVolume(rep(2,1000), BrainSpace(c(10,10,10), c(1,1,1))) bv3 <- concat(bv1,bv2) inherits(bv3, "BrainVector") bv4 <- concat(bv3, bv1) dim(bv4)[4] == 3 bv5 <- concat(bv1, bv3) dim(bv4)[4] == 3 bv6 <- concat(bv4,bv5) dim(bv6)[4] == 6
bv1 <- BrainVolume(rep(1,1000), BrainSpace(c(10,10,10), c(1,1,1))) bv2 <- BrainVolume(rep(2,1000), BrainSpace(c(10,10,10), c(1,1,1))) bv3 <- concat(bv1,bv2) inherits(bv3, "BrainVector") bv4 <- concat(bv3, bv1) dim(bv4)[4] == 3 bv5 <- concat(bv1, bv3) dim(bv4)[4] == 3 bv6 <- concat(bv4,bv5) dim(bv6)[4] == 6
Find connected components
find connected components in BrainVolume
connComp(x, ...) ## S4 method for signature 'BrainVolume' connComp(x, threshold = 0, clusterTable = TRUE, localMaxima = TRUE, localMaximaDistance = 15)
connComp(x, ...) ## S4 method for signature 'BrainVolume' connComp(x, threshold = 0, clusterTable = TRUE, localMaxima = TRUE, localMaximaDistance = 15)
x |
the image object |
... |
additonal arguments |
threshold |
threshold defining lower intensity bound for image mask |
clusterTable |
return clusterTable |
localMaxima |
return table of local maxima |
localMaximaDistance |
the distance used to define minum distance between local maxima |
Extract connected components from a 3D mask
connComp3D(mask, connect = c("6-connect", "18-connect", "26-connect"))
connComp3D(mask, connect = c("6-connect", "18-connect", "26-connect"))
mask |
a 3D binary array |
connect |
the connectiivty constraint: "6-connect", "18-connect", or "26-connect" |
a two-element list of the connected components (cluster index
and cluster size
)
The first element index
is a 3D array containing the cluster index of the connected component for each voxel.
The second element size
is a 3D array consisting of the size of the connected component inhabited by each voxel.
dat <- array(as.logical(rnorm(10*10*10)>.5), c(10, 10, 10)) res1 <- connComp3D(dat, connect="6-connect") res2 <- connComp3D(dat, connect="18-connect") res3 <- connComp3D(dat, connect="26-connect")
dat <- array(as.logical(rnorm(10*10*10)>.5), c(10, 10, 10)) res1 <- connComp3D(dat, connect="6-connect") res2 <- connComp3D(dat, connect="18-connect") res3 <- connComp3D(dat, connect="26-connect")
Extract coordinates
coords
coords(x, ...) ## S4 method for signature 'ROIVolume' coords(x, real = FALSE) ## S4 method for signature 'SparseBrainVector' coords(x, i) ## S4 method for signature 'IndexLookupVolume' coords(x, i)
coords(x, ...) ## S4 method for signature 'ROIVolume' coords(x, real = FALSE) ## S4 method for signature 'SparseBrainVector' coords(x, i) ## S4 method for signature 'IndexLookupVolume' coords(x, i)
x |
the object to extract coordinates from |
... |
additional arguments |
real |
if |
i |
the index in to the lookup volume |
Generic function to convert N-dimensional real world coordinates to grid coordinates
coordToGrid(x, coords) ## S4 method for signature 'BrainSpace,matrix' coordToGrid(x, coords) ## S4 method for signature 'BrainSpace,numeric' coordToGrid(x, coords) ## S4 method for signature 'BrainVolume,matrix' coordToGrid(x, coords)
coordToGrid(x, coords) ## S4 method for signature 'BrainSpace,matrix' coordToGrid(x, coords) ## S4 method for signature 'BrainSpace,numeric' coordToGrid(x, coords) ## S4 method for signature 'BrainVolume,matrix' coordToGrid(x, coords)
x |
the object |
coords |
a matrix of real world coordinates |
a matrix of grid coordinates
Generic function to convert N-dimensional real world coordinates to 1D indices
coordToIndex(x, coords) ## S4 method for signature 'BrainSpace,matrix' coordToIndex(x, coords) ## S4 method for signature 'BrainSpace,numeric' coordToIndex(x, coords) ## S4 method for signature 'BrainVolume,matrix' coordToIndex(x, coords)
coordToIndex(x, coords) ## S4 method for signature 'BrainSpace,matrix' coordToIndex(x, coords) ## S4 method for signature 'BrainSpace,numeric' coordToIndex(x, coords) ## S4 method for signature 'BrainVolume,matrix' coordToIndex(x, coords)
x |
the object |
coords |
a matrix of real world coordinates |
a vector of indices
BrainFileDescriptor
instance.Generic function to get the name of the data file, given a file name and a BrainFileDescriptor
instance.
dataFile(x, fileName) ## S4 method for signature 'BrainFileDescriptor,character' dataFile(x, fileName)
dataFile(x, fileName) ## S4 method for signature 'BrainFileDescriptor,character' dataFile(x, fileName)
x |
descriptor instance |
fileName |
file name to be stripped of its extension |
the correct header name
BrainFileDescriptor
instance.
Will test for match to data file onlyGeneric function to test whether a file name conforms to the given a BrainFileDescriptor
instance.
Will test for match to data file only
dataFileMatches(x, fileName) ## S4 method for signature 'BrainFileDescriptor,character' dataFileMatches(x, fileName)
dataFileMatches(x, fileName) ## S4 method for signature 'BrainFileDescriptor,character' dataFileMatches(x, fileName)
x |
object for which the file name is to matched to |
fileName |
file name to be matched |
TRUE for match, FALSE otherwise
Generic function to create data reader
dataReader(x, offset) ## S4 method for signature 'NIfTIMetaInfo' dataReader(x, offset = 0) ## S4 method for signature 'AFNIMetaInfo' dataReader(x, offset = 0)
dataReader(x, offset) ## S4 method for signature 'NIfTIMetaInfo' dataReader(x, offset = 0) ## S4 method for signature 'AFNIMetaInfo' dataReader(x, offset = 0)
x |
an object specifying the infromation required to produce the reader |
offset |
the byte offset (number of bytes to skip before reading) |
Four-dimensional brain image, backed by an array
constructor function for class DenseBrainVector
DenseBrainVector(data, space, source = NULL, label = "")
DenseBrainVector(data, space, source = NULL, label = "")
data |
a 4-dimensional |
space |
a |
source |
an optional |
label |
a label of type |
DenseBrainVector
instance
Three-dimensional brain image, backed by an array
Construct a DenseBrainVolume
instance
DenseBrainVolume(data, space, source = NULL, label = "", indices = NULL)
DenseBrainVolume(data, space, source = NULL, label = "", indices = NULL)
data |
a three-dimensional |
space |
an instance of class |
source |
an instance of class |
label |
a |
indices |
an optional 1-d index vector |
DenseBrainVolume
instance
BrainData
objectdim of BrainData
object
## S4 method for signature 'BrainData' dim(x)
## S4 method for signature 'BrainData' dim(x)
x |
the object |
dim
## S4 method for signature 'BrainSpace' dim(x)
## S4 method for signature 'BrainSpace' dim(x)
x |
the object |
FileMetaInfo
dim of FileMetaInfo
## S4 method for signature 'FileMetaInfo' dim(x)
## S4 method for signature 'FileMetaInfo' dim(x)
x |
the object |
Generic function to drop a dimension from an object
dropDim(x, dimnum) ## S4 method for signature 'AxisSet2D,numeric' dropDim(x, dimnum) ## S4 method for signature 'AxisSet2D,missing' dropDim(x, dimnum) ## S4 method for signature 'AxisSet3D,numeric' dropDim(x, dimnum) ## S4 method for signature 'AxisSet3D,missing' dropDim(x, dimnum) ## S4 method for signature 'BrainSpace,numeric' dropDim(x, dimnum) ## S4 method for signature 'BrainSpace,missing' dropDim(x)
dropDim(x, dimnum) ## S4 method for signature 'AxisSet2D,numeric' dropDim(x, dimnum) ## S4 method for signature 'AxisSet2D,missing' dropDim(x, dimnum) ## S4 method for signature 'AxisSet3D,numeric' dropDim(x, dimnum) ## S4 method for signature 'AxisSet3D,missing' dropDim(x, dimnum) ## S4 method for signature 'BrainSpace,numeric' dropDim(x, dimnum) ## S4 method for signature 'BrainSpace,missing' dropDim(x)
x |
a dimensioned object |
dimnum |
the index of the dimension to drop |
x = BrainSpace(c(10,10,10), c(1,1,1)) x1 <- dropDim(x) ndim(x1) == 2 dim(x1)[2] == 10
x = BrainSpace(c(10,10,10), c(1,1,1)) x1 <- dropDim(x) ndim(x1) == 2 dim(x1)[2] == 10
Generic functions to apply a function to each series of a 4D image That is, if the 4th dimension is 'time' each series is a 1D time series.
eachSeries(x, FUN, withIndex, ...) ## S4 method for signature 'SparseBrainVector,'function',logical' eachSeries(x, FUN, withIndex = FALSE, ...) ## S4 method for signature 'DenseBrainVector,'function',missing' eachSeries(x, FUN, withIndex = FALSE, ...) ## S4 method for signature 'BrainVector,'function',missing' eachSeries(x, FUN, withIndex = FALSE, ...)
eachSeries(x, FUN, withIndex, ...) ## S4 method for signature 'SparseBrainVector,'function',logical' eachSeries(x, FUN, withIndex = FALSE, ...) ## S4 method for signature 'DenseBrainVector,'function',missing' eachSeries(x, FUN, withIndex = FALSE, ...) ## S4 method for signature 'BrainVector,'function',missing' eachSeries(x, FUN, withIndex = FALSE, ...)
x |
a four dimensional image |
FUN |
a |
withIndex |
whether the index of the series is supplied as the second argument to the function |
... |
additional arguments |
when x
is a SparseBrainVector
eachSeries
only iterates over nonzero series.
bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1))) res <- eachSeries(bvec, mean) length(res) == 24*24*24
bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1))) res <- eachSeries(bvec, mean) length(res) == 24*24*24
Generic functions to apply a function to each (2D) slice of an image
eachSlice(x, FUN, withIndex, ...) ## S4 method for signature 'BrainVolume,'function',missing' eachSlice(x, FUN) ## S4 method for signature 'BrainVolume,'function',logical' eachSlice(x, FUN, withIndex)
eachSlice(x, FUN, withIndex, ...) ## S4 method for signature 'BrainVolume,'function',missing' eachSlice(x, FUN) ## S4 method for signature 'BrainVolume,'function',logical' eachSlice(x, FUN, withIndex)
x |
the object |
FUN |
a |
withIndex |
whether the index of the slice is supplied as the second argument to the function |
... |
additional arguments |
Generic function to apply a function to each volume of a four-dimensional image
eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'SparseBrainVector,'function',logical,missing' eachVolume(x, FUN, withIndex = FALSE, mask, ...) ## S4 method for signature 'SparseBrainVector,'function',missing,missing' eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature ## 'SparseBrainVector,‘function',missing,LogicalBrainVolume’ eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'BrainVector,'function',missing,missing' eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'BrainVector,'function',missing,BrainVolume' eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'BrainVector,'function',missing,missing' eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'BrainBucket,'function',missing,missing' eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'BrainBucket,'function',logical,ANY' eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'BrainVector,'function',logical,ANY' eachVolume(x, FUN, withIndex, mask, ...)
eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'SparseBrainVector,'function',logical,missing' eachVolume(x, FUN, withIndex = FALSE, mask, ...) ## S4 method for signature 'SparseBrainVector,'function',missing,missing' eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature ## 'SparseBrainVector,‘function',missing,LogicalBrainVolume’ eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'BrainVector,'function',missing,missing' eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'BrainVector,'function',missing,BrainVolume' eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'BrainVector,'function',missing,missing' eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'BrainBucket,'function',missing,missing' eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'BrainBucket,'function',logical,ANY' eachVolume(x, FUN, withIndex, mask, ...) ## S4 method for signature 'BrainVector,'function',logical,ANY' eachVolume(x, FUN, withIndex, mask, ...)
x |
four-dimensional image, e.g. of class |
FUN |
a |
withIndex |
whether the index of the volume supplied as the second argument to the function |
mask |
an image mask indicating subset of volume elements to apply function over |
... |
additional arguments |
a list
of results of apply FUN
to each volume.
bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1))) res <- eachVolume(bvec, mean) res <- eachVolume(bvec, function(x,i) median(x), withIndex=TRUE)
bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1))) res <- eachVolume(bvec, mean) res <- eachVolume(bvec, function(x,i) median(x), withIndex=TRUE)
BrainFileDescriptor
instance.
Will test for match to either header file or data fileGeneric function to test whether a file name conforms to the given BrainFileDescriptor
instance.
Will test for match to either header file or data file
fileMatches(x, fileName) ## S4 method for signature 'BrainFileDescriptor,character' fileMatches(x, fileName)
fileMatches(x, fileName) ## S4 method for signature 'BrainFileDescriptor,character' fileMatches(x, fileName)
x |
object for which the file name is to matched to |
fileName |
file name to be matched |
TRUE for match, FALSE otherwise
This class contains meta information from an image data file
This class contains meta information for a NIfTI image file
This class contains meta information for a AFNI image file
headerFile
name of the file containing meta information
dataFile
name of the file containing data
fileDescriptor
descriptor of image file format
endian
byte order of data ('little' or 'big')
dataOffset
the number of bytes preceding the start of image data in data file
bytesPerElement
number of bytes per element
intercept
constant value added to image – multiple values allowed (must equal numer of sub-images)
slope
image multiplier – multiple values allowed (must equal numer of sub-images)
header
a list of format specific attributes
nifti_header
a list
of attributes specific to the NIfTI file format
afni_header
a list of attributes specific to the AFNI file format
afni_header
a list
of attributes specific to the AFNI file format
Generic function to map values from one set to another using a user-supplied lookup table
fill(x, lookup) ## S4 method for signature 'BrainVolume,list' fill(x, lookup) ## S4 method for signature 'BrainVolume,matrix' fill(x, lookup)
fill(x, lookup) ## S4 method for signature 'BrainVolume,list' fill(x, lookup) ## S4 method for signature 'BrainVolume,matrix' fill(x, lookup)
x |
the object to map values from |
lookup |
the lookup table. The first column is the "key" the second column is the "value". |
a new object where the original values have been filled in with the values in the lookup table
x <- BrainSpace(c(10,10,10), c(1,1,1)) vol <- BrainVolume(sample(1:10, 10*10*10, replace=TRUE), x) ## lookup table is list lookup <- lapply(1:10, function(i) i*10) ovol <- fill(vol, lookup) ## lookup table is matrix. First column is key, second column is value names(lookup) <- 1:length(lookup) lookup.mat <- cbind(as.numeric(names(lookup)), unlist(lookup)) ovol2 <- fill(vol, lookup.mat) all.equal(as.vector(ovol2), as.vector(ovol))
x <- BrainSpace(c(10,10,10), c(1,1,1)) vol <- BrainVolume(sample(1:10, 10*10*10, replace=TRUE), x) ## lookup table is list lookup <- lapply(1:10, function(i) i*10) ovol <- fill(vol, lookup) ## lookup table is matrix. First column is key, second column is value names(lookup) <- 1:length(lookup) lookup.mat <- cbind(as.numeric(names(lookup)), unlist(lookup)) ovol2 <- fill(vol, lookup.mat) all.equal(as.vector(ovol2), as.vector(ovol))
Generic function to convert N-dimensional grid coordinate coordinates to real world coordinates
gridToCoord(x, coords) ## S4 method for signature 'BrainSpace,matrix' gridToCoord(x, coords) ## S4 method for signature 'BrainSpace,numeric' gridToCoord(x, coords) ## S4 method for signature 'BrainVolume,matrix' gridToCoord(x, coords)
gridToCoord(x, coords) ## S4 method for signature 'BrainSpace,matrix' gridToCoord(x, coords) ## S4 method for signature 'BrainSpace,numeric' gridToCoord(x, coords) ## S4 method for signature 'BrainVolume,matrix' gridToCoord(x, coords)
x |
the object |
coords |
a matrix of grid coordinates |
a matrix of real coordinates
Generic function to convert voxel coordinates in the reference space (LPI) to native array space.
gridToGrid(x, vox) ## S4 method for signature 'BrainSpace,matrix' gridToGrid(x, vox) ## S4 method for signature 'matrix,matrix' gridToGrid(x, vox)
gridToGrid(x, vox) ## S4 method for signature 'BrainSpace,matrix' gridToGrid(x, vox) ## S4 method for signature 'matrix,matrix' gridToGrid(x, vox)
x |
the object |
coords |
a matrix of LPI voxel coordinates |
a matrix of native voxel coordinates
Generic function to convert N-dimensional grid coordinate to 1D indices
gridToIndex(x, coords) ## S4 method for signature 'BrainSlice,matrix' gridToIndex(x, coords) ## S4 method for signature 'BrainSpace,matrix' gridToIndex(x, coords) ## S4 method for signature 'BrainSpace,numeric' gridToIndex(x, coords) ## S4 method for signature 'BrainVolume,matrix' gridToIndex(x, coords) ## S4 method for signature 'BrainVolume,numeric' gridToIndex(x, coords)
gridToIndex(x, coords) ## S4 method for signature 'BrainSlice,matrix' gridToIndex(x, coords) ## S4 method for signature 'BrainSpace,matrix' gridToIndex(x, coords) ## S4 method for signature 'BrainSpace,numeric' gridToIndex(x, coords) ## S4 method for signature 'BrainVolume,matrix' gridToIndex(x, coords) ## S4 method for signature 'BrainVolume,numeric' gridToIndex(x, coords)
x |
the object, typically a |
coords |
a matrix where each row is a coordinate or a vector of length equal to |
a vector of indices
BrainFileDescriptor
instance.Generic function to get the name of the header file, given a file name and a BrainFileDescriptor
instance.
headerFile(x, fileName) ## S4 method for signature 'BrainFileDescriptor,character' headerFile(x, fileName)
headerFile(x, fileName) ## S4 method for signature 'BrainFileDescriptor,character' headerFile(x, fileName)
x |
descriptor instance |
fileName |
file name to be stripped of its extension |
the correct header name
BrainFileDescriptor
instance.
Will test for match to header file onlyGeneric function to test whether a file name conforms to the given BrainFileDescriptor
instance.
Will test for match to header file only
headerFileMatches(x, fileName) ## S4 method for signature 'BrainFileDescriptor,character' headerFileMatches(x, fileName)
headerFileMatches(x, fileName) ## S4 method for signature 'BrainFileDescriptor,character' headerFileMatches(x, fileName)
x |
object for which the file name is to matched to |
fileName |
file name to be matched |
TRUE for match, FALSE otherwise
image
## S4 method for signature 'BrainVolume' image(x, slice = dim(vol)[3]/2, col = gray((0:255)/255, alpha = 1), zero_col = "#000000", axis = 3, ...)
## S4 method for signature 'BrainVolume' image(x, slice = dim(vol)[3]/2, col = gray((0:255)/255, alpha = 1), zero_col = "#000000", axis = 3, ...)
slice |
the voxel index of the slice to display |
col |
a color map |
zero_col |
the color to use when the value is 0 (e.g background color) |
... |
extra arguments to passed to |
Three-dimensional brain image that can be used as a map between 1D grid indices and a table of values
Currently used in the SparseBrainVector
class.
IndexLookupVolume(space, indices)
IndexLookupVolume(space, indices)
space |
a BrainSpace object |
indices |
the set of 1-d indices defining the lookup map |
Generic function to convert 1D indices to N-dimensional real world coordinates
indexToCoord(x, idx) ## S4 method for signature 'BrainSpace,numeric' indexToCoord(x, idx) ## S4 method for signature 'BrainVolume,index' indexToCoord(x, idx)
indexToCoord(x, idx) ## S4 method for signature 'BrainSpace,numeric' indexToCoord(x, idx) ## S4 method for signature 'BrainVolume,index' indexToCoord(x, idx)
x |
the object |
idx |
the 1D indices |
a matrix of real coordinates
bvol <- BrainVolume(array(0, c(10,10,10)), BrainSpace(c(10,10,10), c(1,1,1))) idx <- 1:10 g <- indexToCoord(bvol, idx) idx2 <- coordToIndex(bvol, g) all.equal(idx, idx2)
bvol <- BrainVolume(array(0, c(10,10,10)), BrainSpace(c(10,10,10), c(1,1,1))) idx <- 1:10 g <- indexToCoord(bvol, idx) idx2 <- coordToIndex(bvol, g) all.equal(idx, idx2)
Generic function to convert 1D indices to N-dimensional grid coordinates
indexToGrid(x, idx) ## S4 method for signature 'BrainSlice,index' indexToGrid(x, idx) ## S4 method for signature 'BrainSpace,numeric' indexToGrid(x, idx) ## S4 method for signature 'BrainVector,index' indexToGrid(x, idx) ## S4 method for signature 'BrainVector,integer' indexToGrid(x, idx) ## S4 method for signature 'BrainVolume,index' indexToGrid(x, idx) ## S4 method for signature 'BrainVolume,integer' indexToGrid(x, idx)
indexToGrid(x, idx) ## S4 method for signature 'BrainSlice,index' indexToGrid(x, idx) ## S4 method for signature 'BrainSpace,numeric' indexToGrid(x, idx) ## S4 method for signature 'BrainVector,index' indexToGrid(x, idx) ## S4 method for signature 'BrainVector,integer' indexToGrid(x, idx) ## S4 method for signature 'BrainVolume,index' indexToGrid(x, idx) ## S4 method for signature 'BrainVolume,integer' indexToGrid(x, idx)
x |
the object |
idx |
the 1D |
a matrix of grid coordinates
bvol <- BrainVolume(array(0, c(10,10,10)), BrainSpace(c(10,10,10), c(1,1,1))) idx <- 1:10 g <- indexToGrid(bvol, idx) bvol[g]
bvol <- BrainVolume(array(0, c(10,10,10)), BrainSpace(c(10,10,10), c(1,1,1))) idx <- 1:10 g <- indexToGrid(bvol, idx) bvol[g]
Extract indices
indices
indices(x) ## S4 method for signature 'ROIVolume' indices(x) ## S4 method for signature 'ROIVector' indices(x) ## S4 method for signature 'SparseBrainVector' indices(x) ## S4 method for signature 'IndexLookupVolume' indices(x)
indices(x) ## S4 method for signature 'ROIVolume' indices(x) ## S4 method for signature 'ROIVector' indices(x) ## S4 method for signature 'SparseBrainVector' indices(x) ## S4 method for signature 'IndexLookupVolume' indices(x)
x |
the object to extract indices |
Generic getter to extract inverse image coordinate transformation
inverseTrans(x) ## S4 method for signature 'BrainSpace' inverseTrans(x) ## S4 method for signature 'BrainData' inverseTrans(x)
inverseTrans(x) ## S4 method for signature 'BrainSpace' inverseTrans(x) ## S4 method for signature 'BrainData' inverseTrans(x)
x |
an object |
bspace <- BrainSpace(c(10,10,10), c(2,2,2)) itrans <- inverseTrans(bspace) identical(trans(bspace) %*% inverseTrans(bspace), diag(4))
bspace <- BrainSpace(c(10,10,10), c(2,2,2)) itrans <- inverseTrans(bspace) identical(trans(bspace) %*% inverseTrans(bspace), diag(4))
Create a Kernel object from a function of distance from kernel center
Kernel(kerndim, vdim, FUN = dnorm, ...)
Kernel(kerndim, vdim, FUN = dnorm, ...)
kerndim |
the dimensions in voxels of the kernel |
vdim |
the dimensions of the voxels in real units |
FUN |
the kernel function taking as its first argument representing the distance from the center of the kernel |
... |
additional parameters to the kernel FUN |
A class representing an image kernel
width
the width in voxels of the kernel
weights
the kernel weights
voxels
the relative voxel coordinates of the kernel
coords
the relative real coordinates of the kernel
BrainVector
. This is the numbe rof volumes in the volume vector (e.g. the 4th image dimension)Get length of BrainVector
. This is the numbe rof volumes in the volume vector (e.g. the 4th image dimension)
## S4 method for signature 'ROIVolume' length(x) ## S4 method for signature 'BrainVector' length(x)
## S4 method for signature 'ROIVolume' length(x) ## S4 method for signature 'BrainVector' length(x)
load a BrainBucket object from file
loadBucket(fileName, pattern = NULL, indices = NULL)
loadBucket(fileName, pattern = NULL, indices = NULL)
fileName |
the name of the file to load |
pattern |
optional regular expression used to filter the sub-volumes using associated labels |
indices |
optional set of sub-volume indices to load |
Generic function to load data from a data source
Load data from a BrainBucketSource
loadData
load a BrainVolume
loadData(x, ...) ## S4 method for signature 'BrainBucketSource' loadData(x, key) ## S4 method for signature 'SparseBrainVectorSource' loadData(x, mmap = FALSE) ## S4 method for signature 'BrainVectorSource' loadData(x, mmap = FALSE) ## S4 method for signature 'BrainVolumeSource' loadData(x)
loadData(x, ...) ## S4 method for signature 'BrainBucketSource' loadData(x, key) ## S4 method for signature 'SparseBrainVectorSource' loadData(x, mmap = FALSE) ## S4 method for signature 'BrainVectorSource' loadData(x, mmap = FALSE) ## S4 method for signature 'BrainVolumeSource' loadData(x)
x |
a data source |
... |
additional arguments |
key |
the name or index of the bucket to load |
mmap |
use memory-mapped file |
an instance of class BrainVolume
an instance of class BrainVector
load an image volume from a file
loadVector(fileName, indices = NULL, mask = NULL, mmap = FALSE)
loadVector(fileName, indices = NULL, mask = NULL, mmap = FALSE)
fileName |
the name of the file to load |
indices |
the indices of the sub-volumes to load (e.g. if the file is 4-dimensional) |
mask |
a mask defining the spatial elements to load |
mmap |
memory mapping if possible |
an BrainVector
object
Load an image volume from a file
loadVolume(fileName, index = 1)
loadVolume(fileName, index = 1)
fileName |
the name of the file to load |
index |
the index of the volume (e.g. if the file is 4-dimensional) |
an instance of the class DenseBrainVolume
fname <- system.file("extdata", "global_mask.nii", package="neuroim") x <- loadVolume(fname) print(dim(x)) space(x)
fname <- system.file("extdata", "global_mask.nii", package="neuroim") x <- loadVolume(fname) print(dim(x)) space(x)
load a list of image volumes and return a BrainVector
instance
loadVolumeList(fileNames, mask = NULL)
loadVolumeList(fileNames, mask = NULL)
fileNames |
a list of files to load |
mask |
an optional mask indicating subset of voxels to load |
an instance of class BrainVector
Three-dimensional brain image where all values are either TRUE or FALSE
Construct a LogicalBrainVolume
instance
LogicalBrainVolume(data, space, source = NULL, label = "", indices = NULL)
LogicalBrainVolume(data, space, source = NULL, label = "", indices = NULL)
data |
a three-dimensional |
space |
an instance of class |
source |
an instance of class |
label |
a |
indices |
an optional 1-d index vector |
LogicalBrainVolume
instance
Index Lookup operation
lookup
lookup(x, i, ...) ## S4 method for signature 'SparseBrainVector,numeric' lookup(x, i) ## S4 method for signature 'IndexLookupVolume,numeric' lookup(x, i)
lookup(x, i, ...) ## S4 method for signature 'SparseBrainVector,numeric' lookup(x, i) ## S4 method for signature 'IndexLookupVolume,numeric' lookup(x, i)
x |
the object to query |
i |
the index to lookup |
... |
additional arguments |
Construct a BrainVector
instance, using default (dense) implementation
makeVector(data, refdata, source = NULL, label = "")
makeVector(data, refdata, source = NULL, label = "")
data |
a four-dimensional |
refdata |
an instance of class |
source |
an instance of class |
label |
a |
DenseBrainVector
instance
Construct a BrainVolume
instance, using default (dense) implementation
makeVolume(data = NULL, refvol, source = NULL, label = "", indices = NULL)
makeVolume(data = NULL, refvol, source = NULL, label = "", indices = NULL)
data |
an optional one- or three-dimensional |
refvol |
an instance of class |
source |
an optional instance of class |
label |
an optional |
indices |
an optional 1d vector of indices in to the 3d space |
DenseBrainVolume
instance
bspace <- BrainSpace(c(64,64,64), spacing=c(1,1,1)) dat <- array(rnorm(64*64*64), c(64,64,64)) bvol <- BrainVolume(dat,bspace, label="test") bvol2 <- makeVolume(dat, bvol) all.equal(as.array(bvol),as.array(bvol2)) data <- 1:10 indices = seq(1,1000, length.out=10) bvol3 <- makeVolume(data,bvol,indices=indices) sum(bvol3) == sum(data)
bspace <- BrainSpace(c(64,64,64), spacing=c(1,1,1)) dat <- array(rnorm(64*64*64), c(64,64,64)) bvol <- BrainVolume(dat,bspace, label="test") bvol2 <- makeVolume(dat, bvol) all.equal(as.array(bvol),as.array(bvol2)) data <- 1:10 indices = seq(1,1000, length.out=10) bvol3 <- makeVolume(data,bvol,indices=indices) sum(bvol3) == sum(data)
Generic function to apply a function to an object
apply a kernel function to a BrainVolume
map(x, m, ...) ## S4 method for signature 'BrainVolume,Kernel' map(x, m, mask = NULL)
map(x, m, ...) ## S4 method for signature 'BrainVolume,Kernel' map(x, m, mask = NULL)
x |
the object that is mapped |
m |
the mapping object |
... |
additional arguments |
mask |
restrict application of kernel to masked area |
map an matrix of intensity values to a matrix of color values.
mapToColors(imslice, col = heat.colors(128, alpha = 1), zero_col = "#00000000", alpha = 1, irange = range(imslice), threshold = c(0, 0))
mapToColors(imslice, col = heat.colors(128, alpha = 1), zero_col = "#00000000", alpha = 1, irange = range(imslice), threshold = c(0, 0))
imslice |
vector or matrix of intensity values |
col |
a color map |
zero_col |
the background color. |
alpha |
transparency multiplier |
given two named axes return AxisSet2D singleton
matchAnatomy2D(axis1, axis2)
matchAnatomy2D(axis1, axis2)
axis1 |
the first axis |
axis2 |
the second axis |
given three named axes return AxisSet3D singleton
matchAnatomy3D(axis1, axis2, axis3)
matchAnatomy3D(axis1, axis2, axis3)
axis1 |
the first axis |
axis2 |
the second axis |
axis3 |
the third axis |
vox
argument.matrixToVolumeList
converts a matrix to a list of BrainVolumes with values filled at grid coordinates determined by the vox
argument.
matrixToVolumeList(voxmat, mat, mask, default = NA)
matrixToVolumeList(voxmat, mat, mask, default = NA)
voxmat |
an N by 3 matrix of voxel coordinates |
mat |
an N by M matrix of values where M is the number of volumes to create (e.g. one volume per column in |
mask |
a reference volume defining the geometry of the output volumes. This can either be of type |
default |
the value that will be used for voxels not contained within voxmat (defualt is |
a list
of BrainVolume
instances, one for each column of mat
This is a BrainSpace
object encoding the geometry of the MNI_1MM template.
data(MNI_SPACE_1MM)
data(MNI_SPACE_1MM)
a BrainSpace
instance
This class represents an axis with a name attribute
axis
the name of the axis
direction
of axis (-1,+1)
names
## S4 method for signature 'BrainBucketSource' names(x) ## S4 method for signature 'BrainBucket' names(x)
## S4 method for signature 'BrainBucketSource' names(x) ## S4 method for signature 'BrainBucket' names(x)
x |
the object to get |
Generic function to extract the number of dimensions of an object
ndim(x, ...) ## S4 method for signature 'AxisSet' ndim(x, ...) ## S4 method for signature 'BrainData' ndim(x) ## S4 method for signature 'BrainSpace' ndim(x)
ndim(x, ...) ## S4 method for signature 'AxisSet' ndim(x, ...) ## S4 method for signature 'BrainData' ndim(x) ## S4 method for signature 'BrainSpace' ndim(x)
x |
n-dimensional object |
... |
additional arguments |
x = BrainSpace(c(10,10,10), c(1,1,1)) ndim(x) == 3 x = BrainSpace(c(10,10,10,3), c(1,1,1,1)) ndim(x) == 4
x = BrainSpace(c(10,10,10), c(1,1,1)) ndim(x) == 3 x = BrainSpace(c(10,10,10,3), c(1,1,1,1)) ndim(x) == 4
NIfTIMetaInfo
classConstructor for NIfTIMetaInfo
class
NIfTIMetaInfo(descriptor, nifti_header)
NIfTIMetaInfo(descriptor, nifti_header)
descriptor |
an instance of class |
nifti_header |
a |
an instance of class NIfTIMetaInfo
numClusters
get number of clusters in a ClusteredBrainVolume
numClusters(x) ## S4 method for signature 'ClusteredBrainVolume' numClusters(x)
numClusters(x) ## S4 method for signature 'ClusteredBrainVolume' numClusters(x)
x |
the object to extract number of clusters |
Generic getter to extract image origin
origin(x) ## S4 method for signature 'BrainSpace' origin(x) ## S4 method for signature 'BrainData' origin(x)
origin(x) ## S4 method for signature 'BrainSpace' origin(x) ## S4 method for signature 'BrainData' origin(x)
x |
an object with an origin |
bspace <- BrainSpace(c(10,10,10), c(2,2,2)) origin(bspace)
bspace <- BrainSpace(c(10,10,10), c(2,2,2)) origin(bspace)
overlay two objects
overlay(x, y, ...)
overlay(x, y, ...)
x |
the underlay object |
y |
the overlay object |
... |
additional arguments for class-specific implementations |
patchSet
patchSet(x, dims, mask, ...)
patchSet(x, dims, mask, ...)
x |
the object to extract patches from |
dims |
a vector indicating the dimensions of the patches |
mask |
mask indicating the valid patch area |
Extract permutation matrix
permMat
permMat
permMat
permMat(x, ...) ## S4 method for signature 'AxisSet2D' permMat(x, ...) ## S4 method for signature 'AxisSet3D' permMat(x, ...) ## S4 method for signature 'BrainSpace' permMat(x, ...)
permMat(x, ...) ## S4 method for signature 'AxisSet2D' permMat(x, ...) ## S4 method for signature 'AxisSet3D' permMat(x, ...) ## S4 method for signature 'BrainSpace' permMat(x, ...)
x |
the object |
... |
additional arguments |
Generic function to print an object
print(x, ...)
print(x, ...)
x |
the object to print |
... |
additional arguments |
AxisSet2D
instanceprint a AxisSet2D
instance
## S4 method for signature 'AxisSet2D' print(x, ...)
## S4 method for signature 'AxisSet2D' print(x, ...)
x |
the object |
... |
extra args |
AxisSet3D
instanceprint a AxisSet3D
instance
## S4 method for signature 'AxisSet3D' print(x, ...)
## S4 method for signature 'AxisSet3D' print(x, ...)
x |
the object |
... |
extra args |
NamedAxis
print a NamedAxis
## S4 method for signature 'NamedAxis' print(x, ...)
## S4 method for signature 'NamedAxis' print(x, ...)
x |
the object |
... |
extra arguments |
Create an spherical random searchlight iterator
RandomSearchlight(mask, radius)
RandomSearchlight(mask, radius)
mask |
an volumetric image mask of type |
radius |
width in mm of spherical searchlight |
readAFNIHeader
readAFNIHeader(fileName)
readAFNIHeader(fileName)
fileName |
the name of the AFNI header file (ending in .HEAD) |
ColumnReader
)Generic function to read a set of column vector from an input source (e.g. ColumnReader
)
readColumns(x, columnIndices) ## S4 method for signature 'ColumnReader,numeric' readColumns(x, columnIndices)
readColumns(x, columnIndices) ## S4 method for signature 'ColumnReader,numeric' readColumns(x, columnIndices)
x |
the input channel |
columnIndices |
the column indices |
a matrix
consisting of the requested column vectors
Generic function to read a sequence of elements from an input source
readElements
readElements(x, numElements) ## S4 method for signature 'BinaryReader,numeric' readElements(x, numElements)
readElements(x, numElements) ## S4 method for signature 'BinaryReader,numeric' readElements(x, numElements)
x |
the input channel |
numElements |
the number of elements to read |
the elements as a vector
read header information of an image file
readHeader(fileName)
readHeader(fileName)
fileName |
the name of the file to read |
an instance of class FileMetaInfo
BrainFileDescriptor
instance.Generic function to read image meta info given a file and a BrainFileDescriptor
instance.
readMetaInfo(x, fileName) ## S4 method for signature 'NIfTIFileDescriptor' readMetaInfo(x, fileName) ## S4 method for signature 'AFNIFileDescriptor' readMetaInfo(x, fileName)
readMetaInfo(x, fileName) ## S4 method for signature 'NIfTIFileDescriptor' readMetaInfo(x, fileName) ## S4 method for signature 'AFNIFileDescriptor' readMetaInfo(x, fileName)
x |
descriptor instance |
fileName |
file name contianing meta information |
Create A Cuboid Region of Interest
RegionCube(bvol, centroid, surround, fill = NULL, nonzero = FALSE)
RegionCube(bvol, centroid, surround, fill = NULL, nonzero = FALSE)
bvol |
an |
centroid |
the center of the cube in voxel coordinates |
surround |
the number of voxels on either side of the central voxel. A |
fill |
optional value(s) to assign to data slot. |
nonzero |
keep only nonzero elements from |
an instance of class ROIVolume
sp1 <- BrainSpace(c(10,10,10), c(1,1,1)) cube <- RegionCube(sp1, c(5,5,5), 3) vox <- coords(cube) cube2 <- RegionCube(sp1, c(5,5,5), 3, fill=5)
sp1 <- BrainSpace(c(10,10,10), c(1,1,1)) cube <- RegionCube(sp1, c(5,5,5), 3) vox <- coords(cube) cube2 <- RegionCube(sp1, c(5,5,5), 3, fill=5)
Creates a Spherical ROI based on a Centroid.
RegionSphere(bvol, centroid, radius, fill = NULL, nonzero = FALSE)
RegionSphere(bvol, centroid, radius, fill = NULL, nonzero = FALSE)
bvol |
an |
centroid |
the center of the sphere in voxel space |
radius |
the radius in real units (e.g. millimeters) of the spherical ROI |
fill |
optional value(s) to store as data |
nonzero |
if |
an instance of class ROIVolume
sp1 <- BrainSpace(c(10,10,10), c(1,2,3)) cube <- RegionSphere(sp1, c(5,5,5), 3.5) vox <- coords(cube) cds <- coords(cube, real=TRUE) ## fill in ROI with value of 6 cube1 <- RegionSphere(sp1, c(5,5,5), 3.5, fill=6) all(cube1@data == 6)
sp1 <- BrainSpace(c(10,10,10), c(1,2,3)) cube <- RegionSphere(sp1, c(5,5,5), 3.5) vox <- coords(cube) cds <- coords(cube, real=TRUE) ## fill in ROI with value of 6 cube1 <- RegionSphere(sp1, c(5,5,5), 3.5, fill=6) all(cube1@data == 6)
Create a square region of interest where the z-dimension is fixed at one voxel coordinate.
RegionSquare(bvol, centroid, surround, fill = NULL, nonzero = FALSE, fixdim = 3)
RegionSquare(bvol, centroid, surround, fill = NULL, nonzero = FALSE, fixdim = 3)
bvol |
an |
centroid |
the center of the cube in voxel coordinates. |
surround |
the number of voxels on either side of the central voxel. |
fill |
optional value(s) to assign to data slot. |
nonzero |
keep only nonzero elements from |
fixdim |
the fixed dimension is the third, or z, dimension. |
an instance of class ROIVolume
.
sp1 <- BrainSpace(c(10,10,10), c(1,1,1)) square <- RegionSquare(sp1, c(5,5,5), 1) vox <- coords(square) ## a 3 X 3 X 1 grid nrow(vox) == 9
sp1 <- BrainSpace(c(10,10,10), c(1,1,1)) square <- RegionSquare(sp1, c(5,5,5), 1) vox <- coords(square) ## a 3 X 3 X 1 grid nrow(vox) == 9
Render an image to create a drawable image.
render(x, width, height, colmap, ...) ## S4 method for signature 'BrainSlice,numeric,numeric,character' render(x, width, height, colmap, zero_col = "#00000000", alpha = 1, units = "points", irange = range(x), threshold = c(0, 0))
render(x, width, height, colmap, ...) ## S4 method for signature 'BrainSlice,numeric,numeric,character' render(x, width, height, colmap, zero_col = "#00000000", alpha = 1, units = "points", irange = range(x), threshold = c(0, 0))
x |
the object, e.g. an instance of type |
width |
width of the rendered image |
height |
height of the rendered image |
colmap |
the colors used to map from values to RGBA colors. |
... |
additional arguments |
zero_col |
color used when background intensity is 0. |
alpha |
transparency multiplier |
units |
grid unit type, e.g. "points", "mm", "inches", "npc" |
Render a slice at z coordinate
renderSlice(x, zpos, width, height, colmap, ...)
renderSlice(x, zpos, width, height, colmap, ...)
x |
the object, e.g. an instance of type |
zpos |
the z coordinate to slice through. |
width |
width of the rendered image |
height |
height of the rendered image |
colmap |
the colors used to map from values to RGBA colors. |
... |
additional arguments |
Generic function to remap the grid-to-world coordinates mapping of an image.
reorient(x, orient) ## S4 method for signature 'BrainSpace,character' reorient(x, orient)
reorient(x, orient) ## S4 method for signature 'BrainSpace,character' reorient(x, orient)
x |
the object |
orient |
the orientation code indcating the "remapped" axes. |
a reoriented space
ROIVector
Create an instance of class ROIVector
ROIVector(vspace, coords, data = rep(nrow(coords), 1))
ROIVector(vspace, coords, data = rep(nrow(coords), 1))
vspace |
an instance of class |
coords |
matrix of voxel coordinates |
data |
the |
an instance of class ROIVector
A class that represents a vector-valued volumetric region of interest
data
the matrix
data stored in ROI
coords
the voxel coordinates of the ROI
ROIVolume
Create an instance of class ROIVolume
ROIVolume(vspace, coords, data = rep(nrow(coords), 1))
ROIVolume(vspace, coords, data = rep(nrow(coords), 1))
coords |
matrix of voxel coordinates |
data |
the data values, numeric vector |
space |
an instance of class |
an instance of class ROIVolume
A class that represents a volumetric region of interest
data
the numeric
data stored in ROI
coords
the voxel coordinates of the ROI
Generic functions to scale (center and/or normalize by standard deviation) each series of a 4D image That is, if the 4th dimension is 'time' each series is a 1D time series.
scaleSeries(x, center, scale) ## S4 method for signature 'BrainVector,logical,logical' scaleSeries(x, center, scale) ## S4 method for signature 'BrainVector,missing,logical' scaleSeries(x, center, scale) ## S4 method for signature 'BrainVector,missing,missing' scaleSeries(x, center, scale) ## S4 method for signature 'BrainVector,logical,missing' scaleSeries(x, center, scale)
scaleSeries(x, center, scale) ## S4 method for signature 'BrainVector,logical,logical' scaleSeries(x, center, scale) ## S4 method for signature 'BrainVector,missing,logical' scaleSeries(x, center, scale) ## S4 method for signature 'BrainVector,missing,missing' scaleSeries(x, center, scale) ## S4 method for signature 'BrainVector,logical,missing' scaleSeries(x, center, scale)
x |
a four dimensional image |
center |
a |
scale |
a |
bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1))) res <- scaleSeries(bvec, TRUE, TRUE)
bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1))) res <- scaleSeries(bvec, TRUE, TRUE)
Create an exhaustive searchlight iterator
Searchlight(mask, radius, eager = FALSE)
Searchlight(mask, radius, eager = FALSE)
mask |
an image volume containing valid central voxels for roving searchlight |
radius |
in mm of spherical searchlight |
an iter
class
Extract one or more series from object and return as ROI object
Extract one or more series from object
series_roi(x, i, ...) series(x, i, ...) ## S4 method for signature 'BasisBrainVector,matrix' series(x, i) ## S4 method for signature 'BasisBrainVector,numeric' series(x, i, j, k) ## S4 method for signature 'SparseBrainVector,matrix' series(x, i) ## S4 method for signature 'SparseBrainVector,numeric' series(x, i, j, k) ## S4 method for signature 'BrainVector,matrix' series(x, i) ## S4 method for signature 'BrainVector,matrix' series_roi(x, i) ## S4 method for signature 'BrainVector,ROIVolume' series(x, i) ## S4 method for signature 'BrainVector,ROIVolume' series_roi(x, i) ## S4 method for signature 'BrainVector,LogicalBrainVolume' series(x, i) ## S4 method for signature 'BrainVector,LogicalBrainVolume' series_roi(x, i) ## S4 method for signature 'BrainVector,numeric' series(x, i, j, k) ## S4 method for signature 'BrainVector,numeric' series_roi(x, i, j, k)
series_roi(x, i, ...) series(x, i, ...) ## S4 method for signature 'BasisBrainVector,matrix' series(x, i) ## S4 method for signature 'BasisBrainVector,numeric' series(x, i, j, k) ## S4 method for signature 'SparseBrainVector,matrix' series(x, i) ## S4 method for signature 'SparseBrainVector,numeric' series(x, i, j, k) ## S4 method for signature 'BrainVector,matrix' series(x, i) ## S4 method for signature 'BrainVector,matrix' series_roi(x, i) ## S4 method for signature 'BrainVector,ROIVolume' series(x, i) ## S4 method for signature 'BrainVector,ROIVolume' series_roi(x, i) ## S4 method for signature 'BrainVector,LogicalBrainVolume' series(x, i) ## S4 method for signature 'BrainVector,LogicalBrainVolume' series_roi(x, i) ## S4 method for signature 'BrainVector,numeric' series(x, i, j, k) ## S4 method for signature 'BrainVector,numeric' series_roi(x, i, j, k)
x |
the object |
i |
the series indices |
... |
additional arguments |
j |
index for 2nd dimension |
k |
index for 3rd dimension |
x |
the object |
i |
the series indices |
... |
additional arguments |
j |
index for 2nd dimension |
k |
index for 3rd dimension |
Construct a series iterator
seriesIter(x) ## S4 method for signature 'SparseBrainVector' seriesIter(x) ## S4 method for signature 'BrainVector' seriesIter(x)
seriesIter(x) ## S4 method for signature 'SparseBrainVector' seriesIter(x) ## S4 method for signature 'BrainVector' seriesIter(x)
x |
the object to be iterated over. This is typically an instance of class |
an iter
object from the iterators
package.
SparseBrainVector
: get a seriesIter for a SparseBrainVector
instance
BrainVector
: get a series iterator for a BrainVector
instance
## create a BrainVector with 10X10X10X10, where the last dimension is ## by convention the fourth dimension. bvec <- BrainVector(array(rnorm(10*10*10*10), rep(10,4)), BrainSpace(rep(10,4), c(1,1,1))) iter <- seriesIter(bvec) ## compute mean of each series library(foreach) library(iterators) foreach(i=iter, .combine=c) %do% { mean(i) } iter <- seriesIter(bvec) ## combine all series into a matrix foreach(i=iter, .combine=rbind) %do% { i } ## scale all series, add as columns in matrix. foreach(i=seriesIter(bvec), .combine=cbind) %do% { scale(i) }
## create a BrainVector with 10X10X10X10, where the last dimension is ## by convention the fourth dimension. bvec <- BrainVector(array(rnorm(10*10*10*10), rep(10,4)), BrainSpace(rep(10,4), c(1,1,1))) iter <- seriesIter(bvec) ## compute mean of each series library(foreach) library(iterators) foreach(i=iter, .combine=c) %do% { mean(i) } iter <- seriesIter(bvec) ## combine all series into a matrix foreach(i=iter, .combine=rbind) %do% { i } ## scale all series, add as columns in matrix. foreach(i=seriesIter(bvec), .combine=cbind) %do% { scale(i) }
AxisSet1D
show an AxisSet1D
## S4 method for signature 'AxisSet1D' show(object)
## S4 method for signature 'AxisSet1D' show(object)
object |
the object |
AxisSet2D
show an AxisSet2D
## S4 method for signature 'AxisSet2D' show(object)
## S4 method for signature 'AxisSet2D' show(object)
object |
the object |
AxisSet3D
show an AxisSet3D
## S4 method for signature 'AxisSet3D' show(object)
## S4 method for signature 'AxisSet3D' show(object)
object |
the object |
AxisSet4D
show an AxisSet4D
## S4 method for signature 'AxisSet4D' show(object)
## S4 method for signature 'AxisSet4D' show(object)
object |
the object |
BaseMetaInfo
show a BaseMetaInfo
## S4 method for signature 'BaseMetaInfo' show(object)
## S4 method for signature 'BaseMetaInfo' show(object)
object |
the object |
BrainSpace
show a BrainSpace
## S4 method for signature 'BrainSpace' show(object)
## S4 method for signature 'BrainSpace' show(object)
object |
the object |
BrainVector
show a BrainVector
## S4 method for signature 'BrainVector' show(object)
## S4 method for signature 'BrainVector' show(object)
object |
the object |
BrainVectorSource
show a BrainVectorSource
## S4 method for signature 'BrainVectorSource' show(object)
## S4 method for signature 'BrainVectorSource' show(object)
object |
the object |
BrainVolume
show a BrainVolume
## S4 method for signature 'BrainVolume' show(object)
## S4 method for signature 'BrainVolume' show(object)
object |
the object |
FileMetaInfo
show a FileMetaInfo
## S4 method for signature 'FileMetaInfo' show(object)
## S4 method for signature 'FileMetaInfo' show(object)
object |
the object |
NamedAxis
show an NamedAxis
## S4 method for signature 'NamedAxis' show(object)
## S4 method for signature 'NamedAxis' show(object)
object |
the object |
NullMetaInfo
show a NullMetaInfo
## S4 method for signature 'NullMetaInfo' show(object)
## S4 method for signature 'NullMetaInfo' show(object)
object |
the object |
ROIVolume
show an ROIVolume
## S4 method for signature 'ROIVolume' show(object)
## S4 method for signature 'ROIVolume' show(object)
object |
the object |
SparseBrainVector
show a SparseBrainVector
## S4 method for signature 'SparseBrainVector' show(object)
## S4 method for signature 'SparseBrainVector' show(object)
object |
the object |
Extract a 2D slice from an image volume
slice(x, zlevel, along, orientation, ...) ## S4 method for signature 'BrainVolume,numeric,numeric,missing' slice(x, zlevel, along, orientation) ## S4 method for signature 'BrainVolume,numeric,BrainSpace,AxisSet3D' slice(x, zlevel, along, orientation)
slice(x, zlevel, along, orientation, ...) ## S4 method for signature 'BrainVolume,numeric,numeric,missing' slice(x, zlevel, along, orientation) ## S4 method for signature 'BrainVolume,numeric,BrainSpace,AxisSet3D' slice(x, zlevel, along, orientation)
x |
the object |
zlevel |
coordinate (in voxel units) along the sliced axis |
along |
the axis along which to slice |
orientation |
the target orientation of the 2D slice |
... |
additional arguments |
extract a 2D slice from a BrainVolume
instance.
sliceData(vol, slice, axis = 3)
sliceData(vol, slice, axis = 3)
vol |
an |
slice |
the integer index of the slice to cut. |
axis |
the axis number (1, 2, 3) defining fixed axis of the 2D slice. |
Generic function to extract geometric properties of an image.
space(x, ...) ## S4 method for signature 'BrainData' space(x) ## S4 method for signature 'BrainSpace' space(x) ## S4 method for signature 'IndexLookupVolume' space(x)
space(x, ...) ## S4 method for signature 'BrainData' space(x) ## S4 method for signature 'BrainSpace' space(x) ## S4 method for signature 'IndexLookupVolume' space(x)
x |
the object to query, e.g. an instance of |
... |
additional arguments |
an object representing the geometric space of the image of type BrainSpace
x = BrainSpace(c(10,10,10), c(1,1,1)) vol <- BrainVolume(rnorm(10*10*10), x) identical(x,space(vol))
x = BrainSpace(c(10,10,10), c(1,1,1)) vol <- BrainVolume(rnorm(10*10*10), x) identical(x,space(vol))
Generic function to extract the voxel dimensions of an image
spacing
spacing(x) ## S4 method for signature 'BrainData' spacing(x) ## S4 method for signature 'BrainSpace' spacing(x)
spacing(x) ## S4 method for signature 'BrainData' spacing(x) ## S4 method for signature 'BrainSpace' spacing(x)
x |
the object |
a numeric vector
bspace <- BrainSpace(c(10,10,10), c(2,2,2)) all.equal(spacing(bspace), c(2,2,2))
bspace <- BrainSpace(c(10,10,10), c(2,2,2)) all.equal(spacing(bspace), c(2,2,2))
a sparse four-dimensional brain image, backed by a matrix
, where each column represents
a vector spanning the fourth dimension (e.g. time)
constructs a SparseBrainVector object
SparseBrainVector(data, space, mask, source = NULL, label = "")
SparseBrainVector(data, space, mask, source = NULL, label = "")
data |
an array which can be a |
space |
a BrainSpace instance |
mask |
a 3D |
source |
the data source – an instance of class |
label |
associated sub-image labels |
mask
the mask defining the sparse domain
data
the matrix of series, where rows span across voxel space and columns span the fourth dimensions
map
instance of class IndexLookupVolume
is used to map between spatial and index/row coordinates
bspace <- BrainSpace(c(10,10,10,100), c(1,1,1)) mask <- array(rnorm(10*10*10) > .5, c(10,10,10)) mat <- matrix(rnorm(sum(mask)), 100, sum(mask)) svec <- SparseBrainVector(mat, bspace,mask) length(indices(svec)) == sum(mask)
bspace <- BrainSpace(c(10,10,10,100), c(1,1,1)) mask <- array(rnorm(10*10*10) > .5, c(10,10,10)) mat <- matrix(rnorm(sum(mask)), 100, sum(mask)) svec <- SparseBrainVector(mat, bspace,mask) length(indices(svec)) == sum(mask)
A class that is used to produce a SparseBrainVector
instance
constructs a SparseBrainVectorSource object
SparseBrainVectorSource(metaInfo, indices, mask)
SparseBrainVectorSource(metaInfo, indices, mask)
metaInfo |
an object of class |
indices |
a vector of 1D indices |
mask |
a 3D |
mask
the subset of voxels that will be stored in memory
Three-dimensional brain image, backed by a sparseVector
for Matrix
package
Construct a SparseBrainVolume
instance
SparseBrainVolume(data, space, indices = NULL, source = NULL, label = "")
SparseBrainVolume(data, space, indices = NULL, source = NULL, label = "")
data |
a numeric vector |
space |
an instance of class |
indices |
a index vector indicating the 1-d coordinates of the data values |
source |
an instance of class |
label |
a |
Image data is backed by Matrix::sparseVector
.
SparseBrainVolume
instance
data
a sparseVector
instance
data <- 1:10 indices <- seq(1,1000, length.out=10) bspace <- BrainSpace(c(64,64,64), spacing=c(1,1,1)) sparsevol <- SparseBrainVolume(data,bspace,indices=indices) densevol <- BrainVolume(data,bspace,indices=indices) sum(sparsevol) == sum(densevol)
data <- 1:10 indices <- seq(1,1000, length.out=10) bspace <- BrainSpace(c(64,64,64), spacing=c(1,1,1)) sparsevol <- SparseBrainVolume(data,bspace,indices=indices) densevol <- BrainVolume(data,bspace,indices=indices) sum(sparsevol) == sum(densevol)
Generic function to fill disjoint sets of values with the output of a function
splitFill(x, fac, FUN) ## S4 method for signature 'BrainVolume,factor,'function'' splitFill(x, fac, FUN)
splitFill(x, fac, FUN) ## S4 method for signature 'BrainVolume,factor,'function'' splitFill(x, fac, FUN)
x |
the object to split |
fac |
the |
FUN |
the function to summarize the the sets |
FUN
can either return a scalar for each input vector or a vector equal to the length of the input vector.
If it returns a scalar then every voxel in the set will be filled with that value in the output vector.
a new object where the original values have been replaced by the function output
## summarize with mean -- FUN returns a scalar x = BrainSpace(c(10,10,10), c(1,1,1)) vol <- BrainVolume(rnorm(10*10*10), x) fac <- factor(rep(1:10, length.out=1000)) ovol.mean <- splitFill(vol, fac, mean) identical(dim(ovol.mean), dim(vol)) length(unique(as.vector(ovol.mean))) == 10 ## transform by reversing vector -- FUN returns a vector. ovol2 <- splitFill(vol, fac, rev)
## summarize with mean -- FUN returns a scalar x = BrainSpace(c(10,10,10), c(1,1,1)) vol <- BrainVolume(rnorm(10*10*10), x) fac <- factor(rep(1:10, length.out=1000)) ovol.mean <- splitFill(vol, fac, mean) identical(dim(ovol.mean), dim(vol)) length(unique(as.vector(ovol.mean))) == 10 ## transform by reversing vector -- FUN returns a vector. ovol2 <- splitFill(vol, fac, rev)
function
Generic function to summarize subsets of an object by first splitting by row and then "reducing" by a summary function
splitReduce(x, fac, FUN) ## S4 method for signature 'matrix,integer,'function'' splitReduce(x, fac, FUN) ## S4 method for signature 'matrix,integer,missing' splitReduce(x, fac) ## S4 method for signature 'matrix,factor,missing' splitReduce(x, fac) ## S4 method for signature 'matrix,factor,'function'' splitReduce(x, fac, FUN) ## S4 method for signature 'BrainVector,factor,'function'' splitReduce(x, fac, FUN) ## S4 method for signature 'BrainVector,factor,missing' splitReduce(x, fac, FUN)
splitReduce(x, fac, FUN) ## S4 method for signature 'matrix,integer,'function'' splitReduce(x, fac, FUN) ## S4 method for signature 'matrix,integer,missing' splitReduce(x, fac) ## S4 method for signature 'matrix,factor,missing' splitReduce(x, fac) ## S4 method for signature 'matrix,factor,'function'' splitReduce(x, fac, FUN) ## S4 method for signature 'BrainVector,factor,'function'' splitReduce(x, fac, FUN) ## S4 method for signature 'BrainVector,factor,missing' splitReduce(x, fac, FUN)
x |
a numeric matrix(like) object |
fac |
the factor to define subsets of the object |
FUN |
the function to apply to each subset. if |
if FUN
is supplied it must take a vector and return a single scalar value. If it returns more than one value, an error will occur.
if x
is a BrainVector
instance then voxels (dims 1:3) are treated as columns and time-series (dim 4) as rows.
The summary function then is applied to groups of voxels. However, if the goal is to apply a function to groups of time-points,
then this can be achieved as follows:
splitReduce(t(as.matrix(bvec)), fac)
a new matrix
where the original values have been "reduced" by the supplied function.
mat = matrix(rnorm(100*100), 100, 100) fac = sample(1:3, nrow(mat), replace=TRUE) ## compute column means of each sub-matrix ms <- splitReduce(mat, fac) all.equal(row.names(ms), levels(fac)) ## compute column medians of each sub-matrix ms <- splitReduce(mat, fac, median) ## compute time-series means grouped over voxels. ## Here, \code{length(fac)} must equal the number of voxels: \code{prod(dim(bvec)[1:3]} bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1))) fac <- factor(sample(1:3, prod(dim(bvec)[1:3]), replace=TRUE)) ms <- splitReduce(bvec, fac) ms2 <- splitReduce(bvec, fac, mean) all.equal(row.names(ms), levels(fac)) all.equal(ms,ms2)
mat = matrix(rnorm(100*100), 100, 100) fac = sample(1:3, nrow(mat), replace=TRUE) ## compute column means of each sub-matrix ms <- splitReduce(mat, fac) all.equal(row.names(ms), levels(fac)) ## compute column medians of each sub-matrix ms <- splitReduce(mat, fac, median) ## compute time-series means grouped over voxels. ## Here, \code{length(fac)} must equal the number of voxels: \code{prod(dim(bvec)[1:3]} bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1))) fac <- factor(sample(1:3, prod(dim(bvec)[1:3]), replace=TRUE)) ms <- splitReduce(bvec, fac) ms2 <- splitReduce(bvec, fac, mean) all.equal(row.names(ms), levels(fac)) all.equal(ms,ms2)
Generic function to center/scale row-subsets of a matrix or matrix-like object
splitScale(x, f, center, scale) ## S4 method for signature 'matrix,factor,logical,logical' splitScale(x, f, center = TRUE, scale = TRUE) ## S4 method for signature 'matrix,factor,missing,missing' splitScale(x, f) ## S4 method for signature 'DenseBrainVector,factor,missing,missing' splitScale(x, f) ## S4 method for signature 'DenseBrainVector,factor,logical,missing' splitScale(x, f, center) ## S4 method for signature 'DenseBrainVector,factor,logical,logical' splitScale(x, f, center, scale)
splitScale(x, f, center, scale) ## S4 method for signature 'matrix,factor,logical,logical' splitScale(x, f, center = TRUE, scale = TRUE) ## S4 method for signature 'matrix,factor,missing,missing' splitScale(x, f) ## S4 method for signature 'DenseBrainVector,factor,missing,missing' splitScale(x, f) ## S4 method for signature 'DenseBrainVector,factor,logical,missing' splitScale(x, f, center) ## S4 method for signature 'DenseBrainVector,factor,logical,logical' splitScale(x, f, center, scale)
x |
a numeric matrix or matrix-like object |
f |
the splitting object, typically a |
center |
should values within each submatrix be centered? (mean removed from each column of submatrix) |
scale |
should values be scaled? (divide vector by standard deviation from each column of submatrix) |
a new matrix or matrix-like object where the original rows have been grouped by f
and then centered and/or scaled for each grouping
M <- matrix(rnorm(1000), 10, 100) fac <- factor(rep(1:2, each=5)) Ms <- splitScale(M, fac) ## correctly centered all(abs(apply(Ms[fac == 1,], 2, mean)) < .000001) all(abs(apply(Ms[fac == 2,], 2, mean)) < .000001) # correctly scaled all.equal(apply(Ms[fac == 1,], 2, sd), rep(1, ncol(Ms))) all.equal(apply(Ms[fac == 2,], 2, sd), rep(1, ncol(Ms)))
M <- matrix(rnorm(1000), 10, 100) fac <- factor(rep(1:2, each=5)) Ms <- splitScale(M, fac) ## correctly centered all(abs(apply(Ms[fac == 1,], 2, mean)) < .000001) all(abs(apply(Ms[fac == 2,], 2, mean)) < .000001) # correctly scaled all.equal(apply(Ms[fac == 1,], 2, sd), rep(1, ncol(Ms))) all.equal(apply(Ms[fac == 2,], 2, sd), rep(1, ncol(Ms)))
BrainFileDescriptor
instance.Generic function to strip extension from file name, given a BrainFileDescriptor
instance.
stripExtension(x, fileName) ## S4 method for signature 'BrainFileDescriptor,character' stripExtension(x, fileName)
stripExtension(x, fileName) ## S4 method for signature 'BrainFileDescriptor,character' stripExtension(x, fileName)
x |
descriptor instance |
fileName |
file name to be stripped of its extension |
fileName without extension
BrainVector
object.Generic function to extract a sub-vector from a BrainVector
object.
subVector(x, i, ...) ## S4 method for signature 'SparseBrainVector,numeric' subVector(x, i) ## S4 method for signature 'DenseBrainVector,numeric' subVector(x, i)
subVector(x, i, ...) ## S4 method for signature 'SparseBrainVector,numeric' subVector(x, i) ## S4 method for signature 'DenseBrainVector,numeric' subVector(x, i)
x |
four-dimensional image |
i |
the indices of the volume(s) to extract |
... |
additional arguments |
a BrainVector
object that is a sub-sequence of the supplied object.
bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1))) vec <- subVector(bvec,1:2) all.equal(2, dim(vec)[4]) vec <- subVector(bvec, c(1,3,5,7)) all.equal(4, dim(vec)[4]) mask <- LogicalBrainVolume(rep(TRUE, 24*24*24), BrainSpace(c(24,24,24), c(1,1,1))) svec <- SparseBrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1)), mask) vec <- subVector(svec, c(1,3,5)) all.equal(3, dim(vec)[4])
bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1))) vec <- subVector(bvec,1:2) all.equal(2, dim(vec)[4]) vec <- subVector(bvec, c(1,3,5,7)) all.equal(4, dim(vec)[4]) mask <- LogicalBrainVolume(rep(TRUE, 24*24*24), BrainSpace(c(24,24,24), c(1,1,1))) svec <- SparseBrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1)), mask) vec <- subVector(svec, c(1,3,5)) all.equal(3, dim(vec)[4])
Generic function to extract a one or more individual volumes from a four-dimensional image
takeVolume(x, i, ...) ## S4 method for signature 'SparseBrainVector,numeric' takeVolume(x, i, merge = FALSE) ## S4 method for signature 'BrainVector,numeric' takeVolume(x, i, merge = FALSE)
takeVolume(x, i, ...) ## S4 method for signature 'SparseBrainVector,numeric' takeVolume(x, i, merge = FALSE) ## S4 method for signature 'BrainVector,numeric' takeVolume(x, i, merge = FALSE)
x |
four-dimensional image |
i |
the indices of the volume(s) to extract |
... |
additional arguments |
merge |
concatenate extracted volumes |
a list of BrainVolume
elements
bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1))) vol <- takeVolume(bvec,1) all.equal(dim(vol), c(24,24,24)) vol <- takeVolume(bvec,1:3) length(vol) == 3 class(vol) == "list"
bvec <- BrainVector(array(rnorm(24*24*24*24), c(24,24,24,24)), BrainSpace(c(24,24,24,24), c(1,1,1))) vol <- takeVolume(bvec,1) all.equal(dim(vol), c(24,24,24)) vol <- takeVolume(bvec,1:3) length(vol) == 3 class(vol) == "list"
Generic getter to extract image coordinate transformation
trans(x) ## S4 method for signature 'BrainMetaInfo' trans(x) ## S4 method for signature 'NIfTIMetaInfo' trans(x) ## S4 method for signature 'BrainSpace' trans(x) ## S4 method for signature 'BrainData' trans(x)
trans(x) ## S4 method for signature 'BrainMetaInfo' trans(x) ## S4 method for signature 'NIfTIMetaInfo' trans(x) ## S4 method for signature 'BrainSpace' trans(x) ## S4 method for signature 'BrainData' trans(x)
x |
an object with a transformation |
This function returns a transformation that can be used to go from "grid coordinates" to "real world coordinates" in millimeters.
This function returns a transformation that can be used to go from "grid coordinates" to "real world coordinates" in millimeters.
see BrainSpace
bspace <- BrainSpace(c(10,10,10), c(2,2,2)) trans(bspace) all.equal(dim(trans(bspace)), c(4,4))
bspace <- BrainSpace(c(10,10,10), c(2,2,2)) trans(bspace) all.equal(dim(trans(bspace)), c(4,4))
Generic function to extract data values of object
values(x, ...) ## S4 method for signature 'ROIVolume' values(x, ...) ## S4 method for signature 'ROIVector' values(x, ...)
values(x, ...) ## S4 method for signature 'ROIVolume' values(x, ...) ## S4 method for signature 'ROIVector' values(x, ...)
x |
the object to get values from |
... |
additional arguments |
extract voxel coordinates
voxels(x, ...) ## S4 method for signature 'Kernel' voxels(x, centerVoxel = NULL)
voxels(x, ...) ## S4 method for signature 'Kernel' voxels(x, centerVoxel = NULL)
x |
the object to extract voxels from |
... |
additional arguments to function |
centerVoxel |
the absolute location of the center of the voxel, default is (0,0,0) |
Generic function to write a sequence of elements from an input source
writeElements
writeElements(x, els) ## S4 method for signature 'BinaryWriter,numeric' writeElements(x, els)
writeElements(x, els) ## S4 method for signature 'BinaryWriter,numeric' writeElements(x, els)
x |
the output channel |
els |
the elements to write |
Generic function to write a 4D image vector to disk
writeVector(x, fileName, format, dataType) ## S4 method for signature 'BrainVector,character,missing,missing' writeVector(x, fileName) ## S4 method for signature 'BrainVector,character,character,missing' writeVector(x, fileName, format) ## S4 method for signature 'BrainVector,character,missing,character' writeVector(x, fileName, dataType)
writeVector(x, fileName, format, dataType) ## S4 method for signature 'BrainVector,character,missing,missing' writeVector(x, fileName) ## S4 method for signature 'BrainVector,character,character,missing' writeVector(x, fileName, format) ## S4 method for signature 'BrainVector,character,missing,character' writeVector(x, fileName, dataType)
x |
an image object, typically a |
fileName |
output file name. |
format |
file format string. Since "NIFTI" is the only currently supported format, this parameter can be safely ignored and omitted. |
dataType |
the numeric data type. If specified should be a |
bvec <- BrainVector(array(0, c(10,10,10,10)), BrainSpace(c(10,10,10,10), c(1,1,1))) ## Not run: writeVector(bvol, "out.nii") writeVector(bvol, "out.nii.gz") writeVector(bvec, "out.nii") writeVector(bvec, "out.nii.gz") ## End(Not run)
bvec <- BrainVector(array(0, c(10,10,10,10)), BrainSpace(c(10,10,10,10), c(1,1,1))) ## Not run: writeVector(bvol, "out.nii") writeVector(bvol, "out.nii.gz") writeVector(bvec, "out.nii") writeVector(bvec, "out.nii.gz") ## End(Not run)
Generic function to write a 3D image volume to disk
writeVolume(x, fileName, format, dataType) ## S4 method for signature 'BrainVolume,character,missing,missing' writeVolume(x, fileName) ## S4 method for signature 'ClusteredBrainVolume,character,missing,missing' writeVolume(x, fileName) ## S4 method for signature 'BrainVolume,character,character,missing' writeVolume(x, fileName, format) ## S4 method for signature 'BrainVolume,character,missing,character' writeVolume(x, fileName, dataType)
writeVolume(x, fileName, format, dataType) ## S4 method for signature 'BrainVolume,character,missing,missing' writeVolume(x, fileName) ## S4 method for signature 'ClusteredBrainVolume,character,missing,missing' writeVolume(x, fileName) ## S4 method for signature 'BrainVolume,character,character,missing' writeVolume(x, fileName, format) ## S4 method for signature 'BrainVolume,character,missing,character' writeVolume(x, fileName, dataType)
x |
an image object, typically a |
fileName |
output file name |
format |
file format string. Since "NIFTI" is the only currently supported format, this parameter can be safely ignored and omitted. |
dataType |
output data type, If specified should be a |
The output format will be inferred from file extension.
The output format will be inferred from file extension.
writeVolume(x, "out.nii")
outputs a NIFTI file.
writeVolume(x, "out.nii.gz")
outputs a gzipped NIFTI file.
No other file output formats are currently supported.
bvol <- BrainVolume(array(0, c(10,10,10)), BrainSpace(c(10,10,10), c(1,1,1))) ## Not run: writeVolume(bvol, "out.nii") writeVolume(bvol, "out.nii.gz") ## End(Not run)
bvol <- BrainVolume(array(0, c(10,10,10)), BrainSpace(c(10,10,10), c(1,1,1))) ## Not run: writeVolume(bvol, "out.nii") writeVolume(bvol, "out.nii.gz") ## End(Not run)