SImageSet
. These are provided for convenience by analogy to the 'apply' family of functions, but allowing greater control over how the functions are applied over an imaging dataset.
"pixelApply"(.object, .fun, ..., .pixel, .feature, .feature.groups, .pixel.dependencies, .simplify = TRUE, .use.names = TRUE, .verbose = FALSE)
"featureApply"(.object, .fun, ..., .feature, .pixel, .pixel.groups, .feature.dependencies, .simplify = TRUE, .use.names = TRUE, .verbose = FALSE)
SImageSet
..fun
.integer
vector of numeric indices, a character
vector of pixel names, or a logical
vector indicating which pixels to use.factor
or a vector that can be coerced into a factor, that indicates groups of pixels over which the function should be applied. Groups pixels are treated as cells in a ragged array, by analogy to the tapply
function.factor
features, in the same manner as for pixels..object
(pixels, features, and grouping variables, as appropriate) be used for the names of the result?.simplify = FALSE
, a list. Otherwise, a matrix, or a higher-dimensional array if grouping is specified.
.pixel
and .feature
can be used to apply the function over only a subset of pixels or features (or both), allowing faster computation when calculation on only a subset of data is needed. For pixelApply
, the function is applied to the feature vector belonging to each pixel. The use of .feature.groups
allows codetapply-like functionality on the feature vectors, applied separately to each pixel.
For featureApply
, the function is applied to the vector of intensity values (i.e., the flattened image) corresponding to each feature. The use of .feature.groups
allows codetapply-like functionality on the flattened image intensity vectors, applied separately to each feature.
The fData
from .object
is installed into the environment of .fun
for pixelApply
, and the pData
from .object
is installed into the environment of .fun
for featureApply
. This allows access to the symbols from fData
or pData
during the execution of .fun
. If .fun
already has an environment, it is retained as the parent of the installed environment.
Additionally, the following objects are made available by installing them into the .fun
environment:
.Object
: The passed .object
. (Note the case.)
.Index
: The index of the current iteration.
It is expected that these methods will be expanded in the future for different types of imaging datasets (e.g., data read directly from disk).
MSImageSet
data <- matrix(1:256, nrow=4)
coord <- expand.grid(x=1:4, y=1:4, z=1:4)
sset <- SImageSet(data=data, coord=coord)
fData(sset)$flag <- rep(c(TRUE, FALSE), 2)
pixelApply(sset, max, .feature.groups=flag)
pData(sset)$flag <- rep(c(TRUE, FALSE), 32)
featureApply(sset, max, .pixel.groups=flag)
Run the code above in your browser using DataLab