Learn R Programming

nandb (version 0.2.1)

Number: Calculate number from image series.

Description

Given a time stack of images, Number performs a calculation of the number for each pixel. NumberTxtFolder does this calculation for an entire folder, writing the results as text files via WriteImageTxt(). Numbers calculates the numbers for several image series in parallel.

Usage

Number(arr, tau = NA, mst = NULL, filt = NULL, n.ch = 1,
  verbose = FALSE)

NumberTxtFolder(folder.path = ".", tau = NA, mst = NULL, filt = NULL, ext = "tif", mcc = parallel::detectCores(), seed = NULL, verbose = FALSE)

Numbers(arr3d.list, tau = NA, mst = NULL, fail = NA, filt = NULL, n.ch = 1, verbose = FALSE, mcc = parallel::detectCores(), seed = NULL)

Arguments

arr

A 3-dimensional array (the image stack) where the \(n\)th slice is the \(n\)th image in the time series. To perform this on a file that has not yet been read in, set this argument to the path to that file (a string).

tau

If this is specified, bleaching correction is performed with CorrectForBleaching() which uses exponential filtering with time constant tau (where the unit of time is the time between frames). If this is set to 'auto', then the value of tau is calculated automatically via BestTau().

mst

Do you want to apply an intensity threshold prior to calculating number (via autothresholdr::mean_stack_thresh())? If so, set your thresholding method here.

filt

Do you want to smooth (filt = 'smooth') or median (filt = 'median') filter the number image using SmoothFilterB() or MedianFilterB() respectively? If selected, these are invoked here with a filter radius of 1 and with the option na_count = TRUE. If you want to smooth/median filter the number image in a different way, first calculate the numbers without filtering (filt = NULL) using this function and then perform your desired filtering routine on the result.

n.ch

The number of channels in the image (default 1).

verbose

If arr3d is specified as a file name, print a message to tell the user that that file is now being processed (useful for NumberTxtFolder, does not work with multiple cores).

folder.path

The path (relative or absolute) to the folder you wish to process.

ext

The file extension of the images in the folder that you wish to process. You must wish to process all files with this extension; if there are files that you don't want to process, take them out of the folder. The default is for tiff files. Do not use regular expression in this argument.

mcc

The number of cores to use for the parallel processing.

seed

If using parallel processing (mcc > 1), a seed for the random number generation for BestTau. Don't use set.seed, it won't work.

arr3d.list

A list of 3-dimensional arrays. To perform this on files that have not yet been read in, set this argument to the path to these files (a character vector).

fail

If thresholding is done, to which value should pixels not exceeeding the threshold be set?

Value

Number returns a matrix, the number image; Numbers returns a list of these. The result of NumberTxtFolder is the text csv files written to disk (in the same folder as the input images).

Details

Do not try to parallelize the use of Number and friends yourself (e.g. with mclapply()) because it will throw an error (this is because the autothresholdr package does not work in parallel (indeed anything run using the rJava package won't)). Always use Numbers for this purpose (this has a workaround whereby it does the thresholding in series and does the rest in parallel).

Examples

Run this code
# NOT RUN {
library(EBImage)
img <- ReadImageData(system.file('extdata', '50.tif', package = 'nandb'))
display(normalize(img[, , 1]), method = 'raster')
number <- Number(img, tau = NA, mst = "Huang")
setwd(tempdir())
WriteIntImage(img, '50.tif')
WriteIntImage(img, '50again.tif')
NumberTxtFolder(tau = NA, mst = "Huang", mcc = 2)
file.remove(list.files())  # cleanup
img.paths <- rep(system.file('extdata', '50.tif', package = 'nandb'), 2)
numbers <- Numbers(img.paths, mst = 'otsu', mcc = 2)

# }

Run the code above in your browser using DataLab