getVal: Get Value from ComputeFeatures.xxx Function

View source: R/getVal.R

getValR Documentation

Get Value from ComputeFeatures.xxx Function

Description

Extract a value through one of the computeFeatures family of functions using an object mask and reference image or a list of each.

Usage

getVal(mask, ref = NULL, val = "b.mean", FUN = NULL, simplify = TRUE, ...)

Arguments

mask

An object mask or list of objects masks with connected pixels having the same integer value.

ref

A fluorescent Image object or list of Image objects corresponding to the objects in mask or NULL if a reference image is not required. If ref is a character string, it is assumed to be the value for val and will be used in place of the default.

val

A character string identifying the parameter to return from the computeFeatures function assigned to FUN. The default value of "b.mean" returns the mean intensity with the computeFeatures.basic function.

FUN

A computeFeatures function to be applied over mask and ref. The default of NULL uses the character string in val to select the appropriate function. If this function is specified, the value in the argument val must be an exact match to one of the values returned by the specified function.

simplify

If TRUE (default), the result will be collapsed into a vector. Otherwise, a vector for each member of the list mask and ref will be returned.

...

additional parameters are passed to FUN.

Details

Objects identified in mask will be projected onto ref and quantified with the function specified in FUN. The single value specified by val will be returned as a list if simplify == FALSE or as a single vector if simplify == TRUE.

Common usages include getting the mean intensity from an object mask and reference image or getting the area of objects from an object mask as shown below. The code has been accelerated by a factor of 8 for getting the area by using the tabulate function rather than the computeFeatures.shape function.

# To extract the mean intensity:
  mfi <- getVal(mask, ref) # uses default parameter "b.mean"

# To extract object area, collapsed to a single vector:
  area <- getVal(mask, val = "area") # no need 'ref'

# A complex example of Haralick difference entropy at
# at a Haralick scale of 4 pixels
  den <- getVal(mask, ref, val = "h.den.s4",
    FUN = computeFeatures.haralick, haralick.scales = 4)

The character string in val is used as a grep pattern to search among the parameters returned by the computeFeatures functions. Consequently, a partial match such as "ecc" is sufficient for a parameter such as "m.eccentricity". However, because "mean" occurs in "b.mean" and "s.radius.mean", a partial match to "mean" does not identify a unique parameter. The unique parameter is used to assign the value to FUN. This value can be explicitly assigned as one of computeFeatures.basic, computeFeatures.shape, computeFeatures.moment and computeFeatures.haralick.

See the EBImage help page for appropriate values for FUN and val but note that "basic quantiles" parameters are mislabeled with an extra '0'. For example, the 5th percentile and 95th percentile values are named "b.q005" and "b.q095", respectively.

Value

A vector if simplify is TRUE or a list of values obtained from FUN.


ornelles/virustiter documentation built on March 29, 2024, 8:30 p.m.