Use Nolan's algorithm to find the ideal swaps parameter for Robin Hood detrending.

best_swaps(img, quick = FALSE)

Arguments

img

A 4-dimensional array in the style of an ijtiff_img (indexed by img[y, x, channel, frame]) or a 3-dimensional array which is a single channel of an ijtiff_img (indexed by img[y, x, frame]).

quick

If FALSE (the default), the swap finding routine is run several times to get a consensus for the best parameter. If TRUE, the swap finding routine is run only once.

Value

A natural number. The ideal swaps parameter for boxcar detrending. If there are multiple channels, the function returns a vector, one swaps parameter for each channel.

Examples

if (FALSE) { # \dontrun{
## These examples are not run on CRAN because they take too long.
## You can still try them for yourself.
img <- ijtiff::read_tif(system.file("extdata", "bleached.tif",
  package = "detrendr"
))
best_swaps(img)
} # }