Learn R Programming

nandb (version 0.2.1)

CorrectForBleaching: Detrend an image series

Description

CorrectForBleaching applies detrending to an image time series using the method described in Nolan et al. 2017. CorrectForBleachingFolder performs this correction on all images in a folder, writing the corrected images to disk.

Usage

CorrectForBleaching(arr, tau, n.ch = 1)

CorrectForBleachingFolder(folder.path = ".", tau = NA, mst = NULL, ext = "tif", na = "error", mcc = parallel::detectCores(), seed = NULL)

Arguments

arr

An array, can be 3- or 4-dimensional. The first two slots give the x- and y-cordinates of pixels respectively. If the array is 3-dimensional, the third slot gives the index of the frame. If it is 4-dimensional, the third slot indexes the channel and the fourth indexes the frame in the stack.. 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

The time constant for the exponential filtering. If this is set to 'auto', then the value of tau is calculated automatically via BestTau().

n.ch

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

folder.path

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

mst

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

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.

na

How do you want to treat NA values? R can only write integer values (and hence not NAs) to tiff pixels. na = 'saturate' sets them to saturated value. na = 'zero' sets them to zero, while na = 'error' will give an error if the image contains NAs. Note that if you threshold, you are almost certain to get NAs.

mcc

The number of cores to use for the parallel processing.

seed

A seed for the random number generation for BestTau. Don't use set.seed, it won't work.

Value

CorrectForBleaching returns the detrended image series.

Details

If you wish to apply thresholding and bleaching correction, aplpluy the thresholding first. CorrectforBleachingFolder takes care of this for you.

References

Stroud, P. D.: A recursive exponential filter for time-sensitive data, Los Alamos national Laboratory, LAUR-99-5573, public.lanl.gov/stroud/ExpFilter/ExpFilter995573.pdf, 1999.

Examples

Run this code
# NOT RUN {
library(magrittr)
img <- ReadImageData(system.file("extdata", "50.tif", package = "nandb"))
autotau <- CorrectForBleaching(img, "auto")
setwd(tempdir())
img <- ReadImageData(system.file('extdata', '50.tif', package = 'nandb'))
WriteIntImage(img, '50.tif')
WriteIntImage(img, '50again.tif')
set.seed(33)
CorrectForBleachingFolder(tau = 1000, mst = "Huang", mcc = 2, na = "s")
list.files()
file.remove(list.files())

# }

Run the code above in your browser using DataLab