Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Number and Brightness Image Analysis
Version:2.1.1
Maintainer:Rory Nolan <rorynoolan@gmail.com>
Description:Calculation of molecular number and brightness from fluorescence microscopy image series. The software was published in a 2016 paper <doi:10.1093/bioinformatics/btx434>. The seminal paper for the technique is Digman et al. 2008 <doi:10.1529/biophysj.107.114645>. A review of the technique was published in 2017 <doi:10.1016/j.ymeth.2017.12.001>.
License:BSD_3_clause + file LICENSE
URL:https://rorynolan.github.io/nandb/,https://github.com/rorynolan/nandb
BugReports:https://github.com/rorynolan/nandb/issues
Depends:R (≥ 3.1)
Imports:assertthat, autothresholdr (≥ 1.3.11), BBmisc, checkmate (≥1.9.3), detrendr (≥ 0.6.12), dplyr, filesstrings (≥ 3.2),ggplot2, glue (≥ 1.3), ijtiff (≥ 2.2), magrittr (≥ 1.5),purrr, Rcpp (≥ 1.0.1), reshape2, rlang (≥ 0.3.3), stringr (≥1.4), utils, viridis, withr (≥ 2.1.0)
Suggests:abind, covr, gridExtra, knitr, magick, matrixStats (≥ 0.50),pacman, rmarkdown, spelling, testthat (≥ 2.1), tidyr
LinkingTo:Rcpp (≥ 1.0.1)
VignetteBuilder:knitr
Config/testthat/edition:3
Config/testthat/parallel:true
Encoding:UTF-8
Language:en-US
RoxygenNote:7.1.1
NeedsCompilation:yes
Packaged:2025-05-06 16:12:45 UTC; rnolan
Author:Rory NolanORCID iD [aut, cre, cph], Luis AlvarezORCID iD [ctb, cph], Sergi Padilla-ParraORCID iD [ctb, ths, cph]
Repository:CRAN
Date/Publication:2025-05-06 22:30:02 UTC

nandb: Number and brightness in R.

Description

Thenandb package gives functions for calculation of molecular number andbrightness from images, as detailed in Digman et al. 2008. It comes with animplementation of the novel 'automatic detrending' technique.

References

Digman MA, Dalal R, Horwitz AF, Gratton E. Mapping the Number ofMolecules and Brightness in the Laser Scanning Microscope. BiophysicalJournal. 2008;94(6):2320-2332.doi:10.1529/biophysj.107.114645.


Calculate brightness from image series.

Description

Given a time stack of images,brightness() performs a calculation of thebrightness for each pixel.

Usage

brightness(  img,  def,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  s = 1,  offset = 0,  readout_noise = 0,  parallel = FALSE)

Arguments

img

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

def

A character. Which definition of brightness do you want to use,"B" or"epsilon"?

thresh

The threshold or thresholding method (seeautothresholdr::mean_stack_thresh()) to use on the image prior todetrending and brightness calculations.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Ifthere are many channels, this may be specified as a vector, one element foreach channel.

quick

IfFALSE (the default), the swap finding routine is runseveral times to get a consensus for the best parameter. IfTRUE, theswap finding routine is run only once.

filt

Do you want to smooth (filt = 'mean') or median (filt = 'median') filter the number image usingsmooth_filter() ormedian_filter() respectively? If selected, these are invoked here with afilter radius of 1 (with corners included, so each median is the median of9 elements) and with the optionna_count = TRUE. If you want tosmooth/median filter the number image in a different way, first calculatethe numbers without filtering (filt = NULL) using this function and thenperform your desired filtering routine on the result. If there are manychannels, this may be specified as a vector, one element for each channel.

s

A positive number. TheS-factor of microscope acquisition.

offset

Microscope acquisition parameters. See referenceDalal et al.

readout_noise

Microscope acquisition parameters. See referenceDalal et al.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

Value

A matrix, the brightness image.

References

Digman MA, Dalal R, Horwitz AF, Gratton E. Mapping the Number ofMolecules and Brightness in the Laser Scanning Microscope. BiophysicalJournal. 2008;94(6):2320-2332.doi:10.1529/biophysj.107.114645.

Dalal, RB, Digman, MA, Horwitz, AF, Vetri, V, Gratton, E (2008).Determination of particle number and brightness using a laser scanningconfocal microscope operating in the analog mode. Microsc. Res. Tech., 71,1:69-81.doi:10.1002/jemt.20526.

Examples

img <- ijtiff::read_tif(system.file("extdata", "50.tif", package = "nandb"))ijtiff::display(img[, , 1, 1])b <- brightness(img, "e", thresh = "Huang")b <- brightness(img, "B", thresh = "tri")

Brightness calculations for every image in a folder.

Description

Performbrightness() calculations on all tif images in a folder and save theresulting brightness images to disk.

Usage

brightness_folder(  folder_path = ".",  def,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  s = 1,  offset = 0,  readout_noise = 0,  parallel = FALSE)

Arguments

folder_path

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

def

A character. Which definition of brightness do you want to use,"B" or"epsilon"?

thresh

The threshold or thresholding method (seeautothresholdr::mean_stack_thresh()) to use on the image prior todetrending and brightness calculations.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Ifthere are many channels, this may be specified as a vector, one element foreach channel.

quick

IfFALSE (the default), the swap finding routine is runseveral times to get a consensus for the best parameter. IfTRUE, theswap finding routine is run only once.

filt

Do you want to smooth (filt = 'mean') or median (filt = 'median') filter the number image usingsmooth_filter() ormedian_filter() respectively? If selected, these are invoked here with afilter radius of 1 (with corners included, so each median is the median of9 elements) and with the optionna_count = TRUE. If you want tosmooth/median filter the number image in a different way, first calculatethe numbers without filtering (filt = NULL) using this function and thenperform your desired filtering routine on the result. If there are manychannels, this may be specified as a vector, one element for each channel.

s

A positive number. TheS-factor of microscope acquisition.

offset

Microscope acquisition parameters. See referenceDalal et al.

readout_noise

Microscope acquisition parameters. See referenceDalal et al.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

See Also

number()

Examples

## Not run: setwd(tempdir())img <- ijtiff::read_tif(system.file("extdata", "50.tif", package = "nandb"))ijtiff::write_tif(img, "img1.tif")ijtiff::write_tif(img, "img2.tif")brightness_folder(def = "B", thresh = "Huang")## End(Not run)

Create a brightness time-series.

Description

Given a stack of imagesimg, use the firstframes_per_set of them tocreate one brightness image, the nextframes_per_set of them to create thenext brightness image and so on to get a time-series of brightness images.

Usage

brightness_timeseries(  img,  def,  frames_per_set,  overlap = FALSE,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  s = 1,  offset = 0,  readout_noise = 0,  parallel = FALSE)

Arguments

img

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

def

A character. Which definition of brightness do you want to use,"B" or"epsilon"?

frames_per_set

The number of frames with which to calculate thesuccessive brightnesses.

overlap

A boolean. IfTRUE, the windows used to calculate number areoverlapped, ifFALSE, they are not. For example, for a 20-frame imageseries with 5 frames per set, if the windows are not overlapped, then theframe sets used are 1-5, 6-10, 11-15 and 16-20; whereas if they areoverlapped, the frame sets are 1-5, 2-6, 3-7, 4-8 and so on up to 16-20.

thresh

The threshold or thresholding method (seeautothresholdr::mean_stack_thresh()) to use on the image prior todetrending and brightness calculations.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Ifthere are many channels, this may be specified as a vector, one element foreach channel.

quick

IfFALSE (the default), the swap finding routine is runseveral times to get a consensus for the best parameter. IfTRUE, theswap finding routine is run only once.

filt

Do you want to smooth (filt = 'mean') or median (filt = 'median') filter the number image usingsmooth_filter() ormedian_filter() respectively? If selected, these are invoked here with afilter radius of 1 (with corners included, so each median is the median of9 elements) and with the optionna_count = TRUE. If you want tosmooth/median filter the number image in a different way, first calculatethe numbers without filtering (filt = NULL) using this function and thenperform your desired filtering routine on the result. If there are manychannels, this may be specified as a vector, one element for each channel.

s

A positive number. TheS-factor of microscope acquisition.

offset

Microscope acquisition parameters. See referenceDalal et al.

readout_noise

Microscope acquisition parameters. See referenceDalal et al.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

Details

This may discard some images, for example if 175 frames are in the input andframes_per_set = 50, then the last 25 are discarded. If detrending isselected, it is performed on the whole image stack before the sectioning isdone for calculation of numbers.

Value

An object of classbrightness_ts_img.

See Also

brightness().

Examples

img <- ijtiff::read_tif(system.file("extdata", "50.tif", package = "nandb"))bts <- brightness_timeseries(img, "e", frames_per_set = 20, thresh = "Huang")

Brightness time-series calculations for every image in a folder.

Description

Performbrightness_timeseries() calculations on all tif images in a folderand save the resulting number images to disk.

Usage

brightness_timeseries_folder(  folder_path = ".",  def,  frames_per_set,  overlap = FALSE,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  s = 1,  offset = 0,  readout_noise = 0,  parallel = FALSE)

Arguments

folder_path

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

def

A character. Which definition of brightness do you want to use,"B" or"epsilon"?

frames_per_set

The number of frames with which to calculate thesuccessive brightnesses.

overlap

A boolean. IfTRUE, the windows used to calculate number areoverlapped, ifFALSE, they are not. For example, for a 20-frame imageseries with 5 frames per set, if the windows are not overlapped, then theframe sets used are 1-5, 6-10, 11-15 and 16-20; whereas if they areoverlapped, the frame sets are 1-5, 2-6, 3-7, 4-8 and so on up to 16-20.

thresh

The threshold or thresholding method (seeautothresholdr::mean_stack_thresh()) to use on the image prior todetrending and brightness calculations.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Ifthere are many channels, this may be specified as a vector, one element foreach channel.

quick

IfFALSE (the default), the swap finding routine is runseveral times to get a consensus for the best parameter. IfTRUE, theswap finding routine is run only once.

filt

Do you want to smooth (filt = 'mean') or median (filt = 'median') filter the number image usingsmooth_filter() ormedian_filter() respectively? If selected, these are invoked here with afilter radius of 1 (with corners included, so each median is the median of9 elements) and with the optionna_count = TRUE. If you want tosmooth/median filter the number image in a different way, first calculatethe numbers without filtering (filt = NULL) using this function and thenperform your desired filtering routine on the result. If there are manychannels, this may be specified as a vector, one element for each channel.

s

A positive number. TheS-factor of microscope acquisition.

offset

Microscope acquisition parameters. See referenceDalal et al.

readout_noise

Microscope acquisition parameters. See referenceDalal et al.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

See Also

brightness_timeseries()

Examples

## Not run: setwd(tempdir())img <- ijtiff::read_tif(system.file("extdata", "50.tif", package = "nandb"))ijtiff::write_tif(img, "img1.tif")ijtiff::write_tif(img, "img2.tif")brightness_timeseries_folder(def = "e", thresh = "tri", frames_per_set = 20)## End(Not run)

Cross-correlated number and brightness image classes.

Description

Thecc_number_img andcc_brightness_img classes are designed to holdobjects which are images calculated from thecross-correlated number andbrightness technique.

Usage

cc_number_img(img, thresh, swaps, filt)cc_brightness_img(img, thresh, swaps, filt)

Arguments

img

The calculated cross-correlated number or brightness image.

thresh

A positive integer, possibly an object of classautothresholdr::th. If the different channels of the image had differentthresholds, this argument may be specified as a vector or list (of positiveintegers, possibly objects of classautothresholdr::th), one element foreach channel.

swaps

A non-negative integer with an attributeauto. If thedifferent channels of the image had differentswaps, this argument may bespecified as a list (of non-negative integers with attributesauto), oneelement for each channel. For undetrended images, setswaps = NA.

filt

A string, the filtering method used. Must be either"mean" or"median", orNA for no filtering. If the different channels of theimage had different filters, this may be specified as a character vector,one element for each channel.

Details

An object of classcc_number_img orcc_brightness_img is a 4-dimensionalarray of real numbers in the mould of anijtiff_img(indexed asimg[y, x, channel, frame]) with 3 attributes:

thresh

A positive integer, possibly an object of classautothresholdr::th detailing which threshold and thresholding method wasused in preprocessing (in the multi-channel case, one threshold per channelis given).

swaps

A non-negative integer indicating the number ofswaps used for Robin Hood detrending, with an attributeauto which is alogical indicating whether or not the parameter was chosen automatically (inthe multi-channel case, oneswaps per channel is given).

filt

Wasmean or median filtering used in postprocessing?

Value

An object of classcc_number_img orcc_brightness_img.


Cross-correlated number and brightness time series image classes.

Description

Thecc_number_ts_img andcc_brightness_ts_img classes are designed tohold objects which are images calculated from thecross-correlated numberand brightness technique.

Usage

cc_number_ts_img(img, frames_per_set, overlapped, thresh, swaps, filt)cc_brightness_ts_img(img, frames_per_set, overlapped, thresh, swaps, filt)

Arguments

img

The calculated cross-correlated number or brightness time seriesimage series.

frames_per_set

The number of frames used in the calculation of eachpoint in the cross-correlated number or brightness time series.

overlapped

A boolean.TRUE indicates that the windows used tocalculate consecutive brightnesses over time were overlapped,FALSEindicates that they were not.

thresh

A positive integer, possibly an object of classautothresholdr::th. If the different channels of the image had differentthresholds, this argument may be specified as a vector or list (of positiveintegers, possibly objects of classautothresholdr::th), one element foreach channel.

swaps

A non-negative integer with an attributeauto. If thedifferent channels of the image had differentswaps, this argument may bespecified as a list (of non-negative integers with attributesauto), oneelement for each channel. For undetrended images, setswaps = NA.

filt

A string, the filtering method used. Must be either"mean" or"median", orNA for no filtering. If the different channels of theimage had different filters, this may be specified as a character vector,one element for each channel.

Details

An object of classcc_number_ts_img orcc_brightness_ts_img is a4-dimensional array of real numbers in the mould of anijtiff_img with 3 attributes:

thresh

A positive integer, possibly an object of classautothresholdr::th detailing which threshold and thresholding method wasused in preprocessing (in the multi-channel case, one threshold per channelis given).

swaps

A non-negative integer indicating the parameterused for Robin Hood detrending with an attributeauto which is a logicalindicating whether or not the parameter was chosen automatically (in themulti-channel case, oneswaps per channel is given).

frames_per_set

A positive integer detailing how many frames wereused in the calculation of each point in the number or brightness timeseries.

overlapped

A boolean.TRUE indicates that the windowsused to calculate consecutive brightnesses over time were overlapped,FALSEindicates that they were not.

Value

An object of classcc_number_ts_img orcc_brightness_ts_img.

See Also

cc_number_timeseries(),cc_brightness_timeseries().


Cross-correlated brightness.

Description

Given a time stack of images and two channels, calculate thecross-correlated brightness of those two channels for each pixel.

Usage

cc_brightness(  img,  ch1 = 1,  ch2 = 2,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  parallel = FALSE)

Arguments

img

A 4-dimensional array of images indexed byimg[y, x, channel, frame] (an object of classijtiff::ijtiff_img). The image to perform thecalculation on. To perform this on a file that has not yet been read in,set this argument to the path to that file (a string).

ch1

A natural number. The index of the first channel to use.

ch2

A natural number. The index of the second channel to use.

thresh

Do you want to apply an intensity threshold prior tocalculating cross-correlated brightness (viaautothresholdr::mean_stack_thresh())? If so, set your thresholding methodhere. If this is a single value, that same threshold will be applied toboth channels. If this is a length-2 vector or list, then these twothresholds will be applied to channels 1 and 2 respectively. A value ofNA for either channel gives no thresholding for that channel.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Todetrend one channel and not the other, specify this as a length 2 vector.

quick

FALSE repeats the detrending procedure (which has some inherentrandomness) a few times to hone in on the best detrend.TRUE is quicker,performing the routine only once.FALSE is better.

filt

Do you want to smooth (filt = 'smooth') or median (filt = 'median') filter the cross-correlated brightness image usingsmooth_filter() ormedian_filter() respectively? If selected, these areinvoked here with a filter radius of 1 and with the optionna_count = TRUE. A value ofNA for either channel gives no thresholding for thatchannel. If you want to smooth/median filter the cross-correlatedbrightness image in a different way, first calculate the cross-correlatedbrightnesses without filtering (filt = NULL) using this function and thenperform your desired filtering routine on the result.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

Value

A numeric matrix, the cross-correlated brightness image.

Examples

img <- ijtiff::read_tif(system.file("extdata", "two_ch.tif",  package = "nandb"))ijtiff::display(detrendr::mean_pillars(img[, , 1, ]))ijtiff::display(detrendr::mean_pillars(img[, , 2, ]))b <- brightness(img, def = "e", thresh = "Huang", filt = "median")ijtiff::display(b[, , 1, 1])ijtiff::display(b[, , 2, 1])cc_b <- cc_brightness(img, thresh = "Huang")ijtiff::display(cc_b[, , 1, 1])

Cross-correlated brightness calculations for every image in a folder.

Description

Performcc_brightness() calculations on all TIFF images in a folder andsave the resulting images to disk.

Usage

cc_brightness_folder(  folder_path = ".",  ch1 = 1,  ch2 = 2,  thresh = NULL,  detrend = detrend,  quick = quick,  filt = NULL,  parallel = FALSE)

Arguments

folder_path

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

ch1

A natural number. The index of the first channel to use.

ch2

A natural number. The index of the second channel to use.

thresh

Do you want to apply an intensity threshold prior tocalculating cross-correlated brightness (viaautothresholdr::mean_stack_thresh())? If so, set your thresholding methodhere. If this is a single value, that same threshold will be applied toboth channels. If this is a length-2 vector or list, then these twothresholds will be applied to channels 1 and 2 respectively. A value ofNA for either channel gives no thresholding for that channel.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Todetrend one channel and not the other, specify this as a length 2 vector.

quick

FALSE repeats the detrending procedure (which has some inherentrandomness) a few times to hone in on the best detrend.TRUE is quicker,performing the routine only once.FALSE is better.

filt

Do you want to smooth (filt = 'smooth') or median (filt = 'median') filter the cross-correlated brightness image usingsmooth_filter() ormedian_filter() respectively? If selected, these areinvoked here with a filter radius of 1 and with the optionna_count = TRUE. A value ofNA for either channel gives no thresholding for thatchannel. If you want to smooth/median filter the cross-correlatedbrightness image in a different way, first calculate the cross-correlatedbrightnesses without filtering (filt = NULL) using this function and thenperform your desired filtering routine on the result.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

Examples

## Not run: setwd(tempdir())ijtiff::write_tif(img, "a.tif")ijtiff::write_tif(img, "ab.tif")cc_brightness_folder()list.files()## End(Not run)

Create a cross-correlated brightness time-series.

Description

Given a stack of imagesimg, use the firstframes_per_set of them tocreate one cross-correlated brightness image, the nextframes_per_set ofthem to create the next and so on to get a time-series of cross-correlatedbrightness images.

Usage

cc_brightness_timeseries(  img,  frames_per_set,  overlap = FALSE,  ch1 = 1,  ch2 = 2,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  parallel = FALSE)

Arguments

img

A 4-dimensional array of images indexed byimg[y, x, channel, frame] (an object of classijtiff::ijtiff_img). The image to perform thecalculation on. To perform this on a file that has not yet been read in,set this argument to the path to that file (a string).

frames_per_set

The number of frames with which to calculate thesuccessive cross-correlated brightnesses.

This may discard some images, for example if 175 frames are in the input andframes_per_set = 50, then the last 25 are discarded. If bleaching or/andthresholding are selected, they are performed on the whole image stack beforethe sectioning is done for calculation of cross-correlated brightnesses.

overlap

A boolean. IfTRUE, the windows used to calculate brightnessare overlapped, ifFALSE, they are not. For example, for a 20-frame imageseries with 5 frames per set, if the windows are not overlapped, then theframe sets used are 1-5, 6-10, 11-15 and 16-20; whereas if they areoverlapped, the frame sets are 1-5, 2-6, 3-7, 4-8 and so on up to 16-20.

ch1

A natural number. The index of the first channel to use.

ch2

A natural number. The index of the second channel to use.

thresh

Do you want to apply an intensity threshold prior tocalculating cross-correlated brightness (viaautothresholdr::mean_stack_thresh())? If so, set your thresholding methodhere. If this is a single value, that same threshold will be applied toboth channels. If this is a length-2 vector or list, then these twothresholds will be applied to channels 1 and 2 respectively. A value ofNA for either channel gives no thresholding for that channel.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Todetrend one channel and not the other, specify this as a length 2 vector.

quick

FALSE repeats the detrending procedure (which has some inherentrandomness) a few times to hone in on the best detrend.TRUE is quicker,performing the routine only once.FALSE is better.

filt

Do you want to smooth (filt = 'smooth') or median (filt = 'median') filter the cross-correlated brightness image usingsmooth_filter() ormedian_filter() respectively? If selected, these areinvoked here with a filter radius of 1 and with the optionna_count = TRUE. A value ofNA for either channel gives no thresholding for thatchannel. If you want to smooth/median filter the cross-correlatedbrightness image in a different way, first calculate the cross-correlatedbrightnesses without filtering (filt = NULL) using this function and thenperform your desired filtering routine on the result.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

Value

An array where theith slice is theith cross-correlatedbrightness image.

See Also

brightness().

Examples

img <- ijtiff::read_tif(system.file("extdata", "two_ch.tif",  package = "nandb"))cc_bts <- cc_brightness_timeseries(img, 10,  thresh = "Huang",  filt = "median", parallel = 2)ijtiff::display(cc_bts[, , 1, 1])

Cross-correlated brightness time-series calculations for every image in afolder.

Description

Performcc_brightness_timeseries() calculations on all tif images in afolder and save the resulting images to disk.

Usage

cc_brightness_timeseries_folder(  folder_path = ".",  frames_per_set,  overlap = FALSE,  ch1 = 1,  ch2 = 2,  thresh = NULL,  detrend = detrend,  quick = quick,  filt = NULL,  parallel = FALSE)

Arguments

folder_path

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

frames_per_set

The number of frames with which to calculate thesuccessive cross-correlated brightnesses.

This may discard some images, for example if 175 frames are in the input andframes_per_set = 50, then the last 25 are discarded. If bleaching or/andthresholding are selected, they are performed on the whole image stack beforethe sectioning is done for calculation of cross-correlated brightnesses.

overlap

A boolean. IfTRUE, the windows used to calculate brightnessare overlapped, ifFALSE, they are not. For example, for a 20-frame imageseries with 5 frames per set, if the windows are not overlapped, then theframe sets used are 1-5, 6-10, 11-15 and 16-20; whereas if they areoverlapped, the frame sets are 1-5, 2-6, 3-7, 4-8 and so on up to 16-20.

ch1

A natural number. The index of the first channel to use.

ch2

A natural number. The index of the second channel to use.

thresh

Do you want to apply an intensity threshold prior tocalculating cross-correlated brightness (viaautothresholdr::mean_stack_thresh())? If so, set your thresholding methodhere. If this is a single value, that same threshold will be applied toboth channels. If this is a length-2 vector or list, then these twothresholds will be applied to channels 1 and 2 respectively. A value ofNA for either channel gives no thresholding for that channel.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Todetrend one channel and not the other, specify this as a length 2 vector.

quick

FALSE repeats the detrending procedure (which has some inherentrandomness) a few times to hone in on the best detrend.TRUE is quicker,performing the routine only once.FALSE is better.

filt

Do you want to smooth (filt = 'smooth') or median (filt = 'median') filter the cross-correlated brightness image usingsmooth_filter() ormedian_filter() respectively? If selected, these areinvoked here with a filter radius of 1 and with the optionna_count = TRUE. A value ofNA for either channel gives no thresholding for thatchannel. If you want to smooth/median filter the cross-correlatedbrightness image in a different way, first calculate the cross-correlatedbrightnesses without filtering (filt = NULL) using this function and thenperform your desired filtering routine on the result.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

See Also

cc_brightness_timeseries()

Examples

## Not run: setwd(tempdir())ijtiff::write_tif(img, "a.tif")ijtiff::write_tif(img, "ab.tif")cc_brightness_timeseries_folder(frames_per_set = 25)list.files()## End(Not run)

Cross-correlated number.

Description

Given a time stack of images and two channels, calculate thecross-correlated number of those two channels for each pixel.

Usage

cc_number(  img,  ch1 = 1,  ch2 = 2,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  parallel = FALSE)

Arguments

img

A 4-dimensional array of images indexed byimg[y, x, channel, frame] (an object of classijtiff::ijtiff_img). The image to perform thecalculation on. To perform this on a file that has not yet been read in,set this argument to the path to that file (a string).

ch1

A natural number. The index of the first channel to use.

ch2

A natural number. The index of the second channel to use.

thresh

Do you want to apply an intensity threshold prior tocalculating cross-correlated number (viaautothresholdr::mean_stack_thresh())? If so, set your thresholding methodhere. If this is a single value, that same threshold will be applied toboth channels. If this is a length-2 vector or list, then these twothresholds will be applied to channels 1 and 2 respectively. A value ofNA for either channel gives no thresholding for that channel.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Todetrend one channel and not the other, specify this as a length 2 vector.

quick

FALSE repeats the detrending procedure (which has some inherentrandomness) a few times to hone in on the best detrend.TRUE is quicker,performing the routine only once.FALSE is better.

filt

Do you want to smooth (filt = 'smooth') or median (filt = 'median') filter the cross-correlated number image usingsmooth_filter()ormedian_filter() respectively? If selected, these are invoked here witha filter radius of 1 and with the optionna_count = TRUE. A value ofNAfor either channel gives no thresholding for that channel. If you want tosmooth/median filter the cross-correlated number image in a different way,first calculate the cross-correlated numbers without filtering (filt = NULL) using this function and then perform your desired filtering routineon the result.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

Value

A numeric matrix, the cross-correlated number image.

Examples

img <- ijtiff::read_tif(system.file("extdata", "two_ch.tif",  package = "nandb"))ijtiff::display(detrendr::mean_pillars(img[, , 1, ]))ijtiff::display(detrendr::mean_pillars(img[, , 2, ]))n <- number(img, def = "n", thresh = "Huang", filt = "median")ijtiff::display(n[, , 1, 1])ijtiff::display(n[, , 2, 1])cc_n <- cc_number(img, thresh = "Huang")ijtiff::display(cc_n[, , 1, 1])

Cross-correlated number calculations for every image in a folder.

Description

Performcc_number() calculations on all TIFF images in a folder andsave the resulting images to disk.

Usage

cc_number_folder(  folder_path = ".",  ch1 = 1,  ch2 = 2,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  parallel = FALSE)

Arguments

folder_path

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

ch1

A natural number. The index of the first channel to use.

ch2

A natural number. The index of the second channel to use.

thresh

Do you want to apply an intensity threshold prior tocalculating cross-correlated number (viaautothresholdr::mean_stack_thresh())? If so, set your thresholding methodhere. If this is a single value, that same threshold will be applied toboth channels. If this is a length-2 vector or list, then these twothresholds will be applied to channels 1 and 2 respectively. A value ofNA for either channel gives no thresholding for that channel.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Todetrend one channel and not the other, specify this as a length 2 vector.

quick

FALSE repeats the detrending procedure (which has some inherentrandomness) a few times to hone in on the best detrend.TRUE is quicker,performing the routine only once.FALSE is better.

filt

Do you want to smooth (filt = 'smooth') or median (filt = 'median') filter the cross-correlated number image usingsmooth_filter()ormedian_filter() respectively? If selected, these are invoked here witha filter radius of 1 and with the optionna_count = TRUE. A value ofNAfor either channel gives no thresholding for that channel. If you want tosmooth/median filter the cross-correlated number image in a different way,first calculate the cross-correlated numbers without filtering (filt = NULL) using this function and then perform your desired filtering routineon the result.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

Examples

## Not run: setwd(tempdir())ijtiff::write_tif(img, "a.tif")ijtiff::write_tif(img, "ab.tif")cc_number_folder()list.files()## End(Not run)

Create a cross-correlated number time-series.

Description

Given a stack of imagesimg, use the firstframes_per_set of them tocreate one cross-correlated number image, the nextframes_per_set ofthem to create the next and so on to get a time-series of cross-correlatednumber images.

Usage

cc_number_timeseries(  img,  frames_per_set,  overlap = FALSE,  ch1 = 1,  ch2 = 2,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  parallel = FALSE)

Arguments

img

A 4-dimensional array of images indexed byimg[y, x, channel, frame] (an object of classijtiff::ijtiff_img). The image to perform thecalculation on. To perform this on a file that has not yet been read in,set this argument to the path to that file (a string).

frames_per_set

The number of frames with which to calculate thesuccessive cross-correlated numbers.

This may discard some images, for example if 175 frames are in the input andframes_per_set = 50, then the last 25 are discarded. If bleaching or/andthresholding are selected, they are performed on the whole image stack beforethe sectioning is done for calculation of cross-correlated numbers.

overlap

A boolean. IfTRUE, the windows used to calculate brightnessare overlapped, ifFALSE, they are not. For example, for a 20-frame imageseries with 5 frames per set, if the windows are not overlapped, then theframe sets used are 1-5, 6-10, 11-15 and 16-20; whereas if they areoverlapped, the frame sets are 1-5, 2-6, 3-7, 4-8 and so on up to 16-20.

ch1

A natural number. The index of the first channel to use.

ch2

A natural number. The index of the second channel to use.

thresh

Do you want to apply an intensity threshold prior tocalculating cross-correlated number (viaautothresholdr::mean_stack_thresh())? If so, set your thresholding methodhere. If this is a single value, that same threshold will be applied toboth channels. If this is a length-2 vector or list, then these twothresholds will be applied to channels 1 and 2 respectively. A value ofNA for either channel gives no thresholding for that channel.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Todetrend one channel and not the other, specify this as a length 2 vector.

quick

FALSE repeats the detrending procedure (which has some inherentrandomness) a few times to hone in on the best detrend.TRUE is quicker,performing the routine only once.FALSE is better.

filt

Do you want to smooth (filt = 'smooth') or median (filt = 'median') filter the cross-correlated number image usingsmooth_filter()ormedian_filter() respectively? If selected, these are invoked here witha filter radius of 1 and with the optionna_count = TRUE. A value ofNAfor either channel gives no thresholding for that channel. If you want tosmooth/median filter the cross-correlated number image in a different way,first calculate the cross-correlated numbers without filtering (filt = NULL) using this function and then perform your desired filtering routineon the result.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

Value

An array where theith slice is theith cross-correlatednumber image.

See Also

number().

Examples

img <- ijtiff::read_tif(system.file("extdata", "two_ch.tif",  package = "nandb"))cc_nts <- cc_number_timeseries(img, 10,  thresh = "Huang",  filt = "median", parallel = 2)ijtiff::display(cc_nts[, , 1, 1])

Cross-correlated number time-series calculations for every image in afolder.

Description

Performcc_number_timeseries() calculations on all tif images in afolder and save the resulting images to disk.

Usage

cc_number_timeseries_folder(  folder_path = ".",  frames_per_set,  overlap = FALSE,  ch1 = 1,  ch2 = 2,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  parallel = FALSE)

Arguments

folder_path

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

frames_per_set

The number of frames with which to calculate thesuccessive cross-correlated numbers.

This may discard some images, for example if 175 frames are in the input andframes_per_set = 50, then the last 25 are discarded. If bleaching or/andthresholding are selected, they are performed on the whole image stack beforethe sectioning is done for calculation of cross-correlated numbers.

overlap

A boolean. IfTRUE, the windows used to calculate brightnessare overlapped, ifFALSE, they are not. For example, for a 20-frame imageseries with 5 frames per set, if the windows are not overlapped, then theframe sets used are 1-5, 6-10, 11-15 and 16-20; whereas if they areoverlapped, the frame sets are 1-5, 2-6, 3-7, 4-8 and so on up to 16-20.

ch1

A natural number. The index of the first channel to use.

ch2

A natural number. The index of the second channel to use.

thresh

Do you want to apply an intensity threshold prior tocalculating cross-correlated number (viaautothresholdr::mean_stack_thresh())? If so, set your thresholding methodhere. If this is a single value, that same threshold will be applied toboth channels. If this is a length-2 vector or list, then these twothresholds will be applied to channels 1 and 2 respectively. A value ofNA for either channel gives no thresholding for that channel.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Todetrend one channel and not the other, specify this as a length 2 vector.

quick

FALSE repeats the detrending procedure (which has some inherentrandomness) a few times to hone in on the best detrend.TRUE is quicker,performing the routine only once.FALSE is better.

filt

Do you want to smooth (filt = 'smooth') or median (filt = 'median') filter the cross-correlated number image usingsmooth_filter()ormedian_filter() respectively? If selected, these are invoked here witha filter radius of 1 and with the optionna_count = TRUE. A value ofNAfor either channel gives no thresholding for that channel. If you want tosmooth/median filter the cross-correlated number image in a different way,first calculate the cross-correlated numbers without filtering (filt = NULL) using this function and then perform your desired filtering routineon the result.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

See Also

cc_number_timeseries()

Examples

## Not run: setwd(tempdir())ijtiff::write_tif(img, "a.tif")ijtiff::write_tif(img, "ab.tif")cc_number_timeseries_folder(frames_per_set = 25)list.files()## End(Not run)

Calculate thecross-variance of two vectors.

Description

The cross-variance function is defined in the reference.

Usage

cross_var(x, y)

Arguments

x

A numeric vector.

y

A numeric vector with the same length asx.

Value

A number

References

Digman, MA, Wiseman, PW, Choi, C, Horwitz, AR, Gratton, E (2009).Stoichiometry of molecular complexes at adhesions in living cells. Proc.Natl. Acad. Sci. U.S.A., 106, 7:2170-5.

Examples

cross_var(0:3, 2:5)

Calculate thecross-variance of corresponding pillars of 3d arrays.

Description

The cross-variance function is defined in the reference.

Usage

cross_var_pillars(x, y)

Arguments

x

A 3-dimensional array.

y

A 3-dimensional array with the same dimensions asx.

Details

Pillar⁠i, j⁠ of the 3-dimensional arrayarr isarr[i, j, ].

Value

A matrix.

Examples

x <- array(1:27, dim = rep(3, 3))y <- array(0:26, dim = rep(3, 3))cross_var_pillars(x, y)

Make a raster plot of a matrix.

Description

Given a matrixmat, make a raster plot of the matrix whereby in theplot, the pixel atx =i,y =j has colour based onthe value ofmat[i, j] and thex axis points right and they axis points down (see 'Details').

Usage

matrix_raster_plot(  mat,  scale_name = "scale",  limits = NULL,  ranges = NULL,  range_names = NULL,  colours = NULL,  na_colour = "black",  clip = FALSE,  clip_low = FALSE,  clip_high = FALSE,  log_trans = FALSE,  breaks = NULL,  include_breaks = NULL)

Arguments

mat

The matrix you wish to plot.

scale_name

A string. The title of the color scale on the right of theplot.

limits

This gives the user the option to set all values outside acertain range to their nearest value within that range (ifclip = TRUE) or toNA (ifclip = FALSE. For example, to set allvalues outside the range [1.5, 2.6) toNA, use⁠limits = c(1.5, 2.6), clip = FALSE⁠. The colour range will cover all values within thesespecified limits.

ranges

A numeric vector. If you want specific ranges of values to havethe same color, specify these ranges via an increasing numeric vector. Forexample, if you want the ranges 0.5-1.2 and 1.2-3, useranges = c(0.5, 1.2, 3). Ifranges is specified as a number (a numericvector of length 1)n, this is equivalent to setting ranges to ben equal-length intervals within the range of the matrix, i.e. it isequivalent to setting 'ranges = seq(min(mat), max(mat), length.out = n

  • 1)⁠. At most one of ⁠rangesandlimits⁠should be set. If ranges is set, the behaviour for values which are not in any of the ranges are set by the⁠clip⁠arguments as in the⁠limits' argument.

range_names

A character vector. If your colour scale is discrete, hereyou can set the names which will label each range in the legend.

colours

If you have setranges, here you may specify whichcolors you wish to colour each range. It must have the same length as thenumber of intervals you have specified inranges. If you have notspecifiedranges, here you may specify the colours (to be passed toggplot2::scale_fill_gradientn()) to create the continuouscolour band. It is specified as a character vector, with the colorsspecified either as the values incolors() or as in the valueof thergb() function. Note that this allows the use ofgrDevices::rainbow() and friends. The default usesviridis::viridis().

na_colour

Which colour should theNA pixels be? Default isblack.

clip

If eitherlimits orranges are set (one shouldnever set both), there may be values that fall outside the specifiedlimits/ranges. Ifclip = TRUE, values outside these limits/rangesare set to their nearest values within them, but ifclip = FALSE,these values are set to NA. Note that settingclip = TRUE isequivalent to setting bothclip_low andclip_high toTRUE.

clip_low

Setting this toTRUE (and leavingclip = FALSE,clip_high = FALSE) will set all values falling below the specifiedlimits/ranges to their nearest value within them, but all values fallingabove those limits/ranges will be set toNA.

clip_high

Setting this toTRUE (and leavingclip = FALSE,clip_low = FALSE) will set all values falling above thespecified limits/ranges to their nearest value within them, but all valuesfalling below those limits/ranges will be set toNA.

log_trans

Do you want to log-transform the colour scaling?

breaks

Where do you want tick marks to appear on the legend colourscale?

include_breaks

If you don't want to specify all the breaks, but youwant some specific ones to be included on the legend colour scale, specifythose specific ones here.

Value

In the graphics console, a raster plot (viaggplot2::geom_raster()) will appear with the matrix valuesrepresented as pixel colours, with a named scale bar.

Examples

img <- ijtiff::read_tif(system.file("extdata", "50.tif", package = "nandb"))ijtiff::display(img[, , 1, 1])matrix_raster_plot(img[, , 1, 1])b <- brightness(img, def = "B", detrend = FALSE, thresh = "Huang")matrix_raster_plot(b, scale_name = "brightness")matrix_raster_plot(b, scale_name = "brightness", log_trans = TRUE)matrix_raster_plot(b,  scale_name = "brightness", log_trans = TRUE,  include_breaks = 1.35)matrix_raster_plot(b,  scale_name = "brightness", log_trans = TRUE,  breaks = 1:3)matrix_raster_plot(b,  scale_name = "brightness",  ranges = seq(0.5, 3, length.out = 6),  range_names = paste0(1:5, "mer"))matrix_raster_plot(b,  scale_name = "brightness",  ranges = seq(0.5, 3, length.out = 6),  range_names = paste0(1:5, "mer"), log_trans = TRUE)matrix_raster_plot(b,  scale_name = "brightness",  include_breaks = 1.25, range_names = NULL,  log_trans = FALSE)matrix_raster_plot(b,  scale_name = "brightness",  include_breaks = 1.25, log_trans = TRUE)matrix_raster_plot(b,  scale_name = "brightness",  limits = c(1, 1.25), clip = TRUE)matrix_raster_plot(b,  scale_name = "brightness",  include_breaks = 1.25)

Smooth and median filters with options for handling NAs.

Description

These are alternatives toEBImage::filter2() andEBImage::medianFilter() forsmooth and median filtering respectively. These functions have many optionsfor dealing withNA values whichEBImage's functions lack.

Usage

median_filter(mat, size = 1L, na_rm = FALSE, na_count = FALSE)smooth_filter(mat, size = 1L, na_rm = FALSE, na_count = FALSE)

Arguments

mat

A matrix (representing an image).

size

An integer; the median filter radius.

na_rm

ShouldNAs be ignored?

na_count

If this is TRUE, in each median calculation, if the majorityof arguments areNAs,NA is returned but if theNAs arein the minority, they are ignored as inmedian(x, na.rm = TRUE).

Details

The behavior at image boundaries is such as the source image has been paddedwith pixels whose values equal the nearest border pixel value.

Value

A matrix (the median filtered image).

Examples

m <- matrix(1:9, nrow = 3)m[2:3, 2:3] <- NAprint(m)median_filter(m)median_filter(m, na_rm = TRUE)median_filter(m, na_count = TRUE)smooth_filter(m)smooth_filter(m, na_rm = TRUE)smooth_filter(m, na_count = TRUE)

Number and brightness image classes.

Description

Thenumber_img andbrightness_img classes are designed to hold objectswhich are images calculated from thenumber and brightness technique.

Usage

number_img(img, def, thresh, swaps, filt)brightness_img(img, def, thresh, swaps, filt)

Arguments

img

The calculated number or brightness image.

def

The number or brightness definition used.

thresh

A positive integer, possibly an object of classautothresholdr::th. If the different channels of the image had differentthresholds, this argument may be specified as a vector or list (of positiveintegers, possibly objects of classautothresholdr::th), one element foreach channel.

swaps

A non-negative integer with an attributeauto. If thedifferent channels of the image had differentswaps, this argument may bespecified as a list (of non-negative integers with attributesauto), oneelement for each channel. For undetrended images, setswaps = NA.

filt

A string, the filtering method used. Must be either"mean" or"median", orNA for no filtering. If the different channels of theimage had different filters, this may be specified as a character vector,one element for each channel.

Details

An object of classnumber_img orbrightness_img is a 4-dimensional arrayof real numbers in the mould of anijtiff_img (indexedasimg[y, x, channel, frame]) with 4 attributes:

def

Arewe using the"N" or"n" definition of number, or the"B" or"epsilon"definition of brightness?

thresh

A positive integer, possibly anobject of classautothresholdr::th detailing which threshold andthresholding method was used in preprocessing (in the multi-channel case, onethreshold per channel is given).

swaps

A non-negative integerindicating the number of swaps Robin Hood detrending, with an attributeauto which is a logical indicating whether or not the parameter was chosenautomatically (in the multi-channel case, one threshold per channel isgiven).

filt

Was mean or median filtering used in postprocessing?

Value

An object of classnumber_img orbrightness_img.


Number and brightness time series image classes.

Description

Thenumber_ts_img andbrightness_ts_img classes are designed to holdobjects which are images calculated from thenumber and brightnesstechnique.

Usage

number_ts_img(img, def, frames_per_set, overlapped, thresh, swaps, filt)brightness_ts_img(img, def, frames_per_set, overlapped, thresh, swaps, filt)

Arguments

img

The calculated number or brightness time series image series.

def

The number or brightness definition used.

frames_per_set

The number of frames used in the calculation of eachpoint in the number or brightness time series.

overlapped

A boolean.TRUE indicates that the windows used tocalculate consecutive brightnesses over time were overlapped,FALSEindicates that they were not.

thresh

A positive integer, possibly an object of classautothresholdr::th. If the different channels of the image had differentthresholds, this argument may be specified as a vector or list (of positiveintegers, possibly objects of classautothresholdr::th), one element foreach channel.

swaps

A non-negative integer with an attributeauto. If thedifferent channels of the image had differentswaps, this argument may bespecified as a list (of non-negative integers with attributesauto), oneelement for each channel. For undetrended images, setswaps = NA.

filt

A string, the filtering method used. Must be either"mean" or"median", orNA for no filtering. If the different channels of theimage had different filters, this may be specified as a character vector,one element for each channel.

Details

An object of classnumber_ts_img orbrightness_ts_img is a 3- or4-dimensional array of real numbers with 4 attributes:

def

Are we using the"N" or"n" definition of number,or the"B" or"epsilon" definition of brightness?

thresh

Apositive integer, possibly an object of classautothresholdr::th detailingwhich threshold and thresholding method was used in preprocessing (in themulti-channel case, one threshold per channel is given).

swaps

Anon-negative integer indicating the number of swaps used for Robin Hooddetrending, with an attributeauto which is a logical indicating whether ornot the parameter was chosen automatically (in the multi-channel case, oneswaps per channel is given).

frames_per_set

A positive integerdetailing how many frames were used in the calculation of each point in thenumber or brightness time series.

overlapped

A boolean.TRUEindicates that the windows used to calculate consecutive brightnesses overtime were overlapped,FALSE indicates that they were not.

Value

An object of classnumber_ts_img orbrightness_ts_img.

See Also

number_timeseries(),brightness_timeseries().


Calculate number from image series.

Description

Given a time stack of images,number() performs a calculation of the numberfor each pixel.

Usage

number(  img,  def,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  s = 1,  offset = 0,  readout_noise = 0,  gamma = 1,  parallel = FALSE)

Arguments

img

A 4-dimensional array of images indexed byimg[y, x, channel, frame] (an object of classijtiff::ijtiff_img). The image to perform thecalculation on. To perform this on a file that has not yet been read in,set this argument to the path to that file (a string).

def

A character. Which definition of number do you want to use,"n"or"N"?

thresh

The threshold or thresholding method (seeautothresholdr::mean_stack_thresh()) to use on the image prior todetrending and number calculations. If there are many channels, this may bespecified as a vector or list, one element for each channel.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Ifthere are many channels, this may be specified as a vector, one element foreach channel.

quick

FALSE repeats the detrending procedure (which has some inherentrandomness) a few times to hone in on the best detrend.TRUE is quicker,performing the routine only once.FALSE is better.

filt

Do you want to smooth (filt = 'mean') or median (filt = 'median') filter the number image usingsmooth_filter() ormedian_filter() respectively? If selected, these are invoked here with afilter radius of 1 (with corners included, so each median is the median of9 elements) and with the optionna_count = TRUE. If you want tosmooth/median filter the number image in a different way, first calculatethe numbers without filtering (filt = NULL) using this function and thenperform your desired filtering routine on the result. If there are manychannels, this may be specified as a vector, one element for each channel.

s

A positive number. TheS-factor of microscope acquisition.

offset,readout_noise

Microscope acquisition parameters. See referenceDalal et al.

gamma

Factor for correction of numbern due to the illuminationprofile. The default (gamma = 1) has no effect. Changing gamma will havethe effect of dividing the result bygamma, so the result withgamma = 0.5 is two times the result withgamma = 1. For a Gaussian illuminationprofile, usegamma = 0.3536; for a Gaussian-Lorentzian illuminationprofile, usegamma = 0.0760.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

Value

A matrix, the number image.

References

Digman MA, Dalal R, Horwitz AF, Gratton E. Mapping the Number ofMolecules and Brightness in the Laser Scanning Microscope. BiophysicalJournal. 2008;94(6):2320-2332.doi:10.1529/biophysj.107.114645.

Dalal, RB, Digman, MA, Horwitz, AF, Vetri, V, Gratton, E (2008).Determination of particle number and brightness using a laser scanningconfocal microscope operating in the analog mode. Microsc. Res. Tech., 71,1:69-81.doi:10.1002/jemt.20526.

Hur K-H, Macdonald PJ, Berk S, Angert CI, Chen Y, Mueller JD (2014)Quantitative Measurement of Brightness from Living Cells in the Presence ofPhotodepletion. PLoS ONE 9(5): e97440.doi:10.1371/journal.pone.0097440.

Examples

img <- ijtiff::read_tif(system.file("extdata", "50.tif", package = "nandb"))ijtiff::display(img[, , 1, 1])num <- number(img, "N", thresh = "Huang")num <- number(img, "n", thresh = "tri")

Number calculations for every image in a folder.

Description

Performnumber() calculations on all tif images in a folder and save theresulting number images to disk.

Usage

number_folder(  folder_path = ".",  def,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  s = 1,  offset = 0,  readout_noise = 0,  gamma = 1,  parallel = FALSE)

Arguments

folder_path

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

def

A character. Which definition of number do you want to use,"n"or"N"?

thresh

The threshold or thresholding method (seeautothresholdr::mean_stack_thresh()) to use on the image prior todetrending and number calculations. If there are many channels, this may bespecified as a vector or list, one element for each channel.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Ifthere are many channels, this may be specified as a vector, one element foreach channel.

quick

FALSE repeats the detrending procedure (which has some inherentrandomness) a few times to hone in on the best detrend.TRUE is quicker,performing the routine only once.FALSE is better.

filt

Do you want to smooth (filt = 'mean') or median (filt = 'median') filter the number image usingsmooth_filter() ormedian_filter() respectively? If selected, these are invoked here with afilter radius of 1 (with corners included, so each median is the median of9 elements) and with the optionna_count = TRUE. If you want tosmooth/median filter the number image in a different way, first calculatethe numbers without filtering (filt = NULL) using this function and thenperform your desired filtering routine on the result. If there are manychannels, this may be specified as a vector, one element for each channel.

s

A positive number. TheS-factor of microscope acquisition.

offset

Microscope acquisition parameters. See referenceDalal et al.

readout_noise

Microscope acquisition parameters. See referenceDalal et al.

gamma

Factor for correction of numbern due to the illuminationprofile. The default (gamma = 1) has no effect. Changing gamma will havethe effect of dividing the result bygamma, so the result withgamma = 0.5 is two times the result withgamma = 1. For a Gaussian illuminationprofile, usegamma = 0.3536; for a Gaussian-Lorentzian illuminationprofile, usegamma = 0.0760.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

Note

Extreme number values (of magnitude greater than 3.40282e+38) will bewritten to the TIFF file asNA, since TIFF files cannot handle such hugenumbers.

See Also

number()

Examples

## Not run: setwd(tempdir())img <- ijtiff::read_tif(system.file("extdata", "50.tif", package = "nandb"))ijtiff::write_tif(img, "img2.tif")number_folder(def = "n", thresh = "Huang", parallel = 2)## End(Not run)

Create a number time-series.

Description

Given a stack of imagesimg, use the firstframes_per_set of them tocreate one number image, the nextframes_per_set of them to create the nextnumber image and so on to get a time-series of number images.

Usage

number_timeseries(  img,  def,  frames_per_set,  overlap = FALSE,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  s = 1,  offset = 0,  readout_noise = 0,  gamma = 1,  parallel = FALSE)

Arguments

img

A 4-dimensional array of images indexed byimg[y, x, channel, frame] (an object of classijtiff::ijtiff_img). The image to perform thecalculation on. To perform this on a file that has not yet been read in,set this argument to the path to that file (a string).

def

A character. Which definition of number do you want to use,"n"or"N"?

frames_per_set

The number of frames with which to calculate thesuccessive numbers.

overlap

A boolean. IfTRUE, the windows used to calculate brightnessare overlapped, ifFALSE, they are not. For example, for a 20-frame imageseries with 5 frames per set, if the windows are not overlapped, then theframe sets used are 1-5, 6-10, 11-15 and 16-20; whereas if they areoverlapped, the frame sets are 1-5, 2-6, 3-7, 4-8 and so on up to 16-20.

thresh

The threshold or thresholding method (seeautothresholdr::mean_stack_thresh()) to use on the image prior todetrending and number calculations. If there are many channels, this may bespecified as a vector or list, one element for each channel.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Ifthere are many channels, this may be specified as a vector, one element foreach channel.

quick

FALSE repeats the detrending procedure (which has some inherentrandomness) a few times to hone in on the best detrend.TRUE is quicker,performing the routine only once.FALSE is better.

filt

Do you want to smooth (filt = 'mean') or median (filt = 'median') filter the number image usingsmooth_filter() ormedian_filter() respectively? If selected, these are invoked here with afilter radius of 1 (with corners included, so each median is the median of9 elements) and with the optionna_count = TRUE. If you want tosmooth/median filter the number image in a different way, first calculatethe numbers without filtering (filt = NULL) using this function and thenperform your desired filtering routine on the result. If there are manychannels, this may be specified as a vector, one element for each channel.

s

A positive number. TheS-factor of microscope acquisition.

offset

Microscope acquisition parameters. See referenceDalal et al.

readout_noise

Microscope acquisition parameters. See referenceDalal et al.

gamma

Factor for correction of numbern due to the illuminationprofile. The default (gamma = 1) has no effect. Changing gamma will havethe effect of dividing the result bygamma, so the result withgamma = 0.5 is two times the result withgamma = 1. For a Gaussian illuminationprofile, usegamma = 0.3536; for a Gaussian-Lorentzian illuminationprofile, usegamma = 0.0760.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

Details

This may discard some images, for example if 175 frames are in the input andframes_per_set = 50, then the last 25 are discarded. If detrending isselected, it is performed on the whole image stack before the sectioning isdone for calculation of numbers.

Value

An object of classnumber_ts_img.

See Also

number().

Examples

img <- ijtiff::read_tif(system.file("extdata", "50.tif", package = "nandb"))nts <- number_timeseries(img, "n", frames_per_set = 20, thresh = "Huang")

Number time-series calculations for every image in a folder.

Description

Performnumber_timeseries() calculations on all tif images in a folder andsave the resulting number images to disk.

Usage

number_timeseries_folder(  folder_path = ".",  def,  frames_per_set,  overlap = FALSE,  thresh = NULL,  detrend = FALSE,  quick = FALSE,  filt = NULL,  s = 1,  offset = 0,  readout_noise = 0,  gamma = 1,  parallel = FALSE)

Arguments

folder_path

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

def

A character. Which definition of number do you want to use,"n"or"N"?

frames_per_set

The number of frames with which to calculate thesuccessive numbers.

overlap

A boolean. IfTRUE, the windows used to calculate brightnessare overlapped, ifFALSE, they are not. For example, for a 20-frame imageseries with 5 frames per set, if the windows are not overlapped, then theframe sets used are 1-5, 6-10, 11-15 and 16-20; whereas if they areoverlapped, the frame sets are 1-5, 2-6, 3-7, 4-8 and so on up to 16-20.

thresh

The threshold or thresholding method (seeautothresholdr::mean_stack_thresh()) to use on the image prior todetrending and number calculations. If there are many channels, this may bespecified as a vector or list, one element for each channel.

detrend

Detrend your data withdetrendr::img_detrend_rh(). This isthe best known detrending method for brightness analysis. For morefine-grained control over your detrending, use thedetrendr package. Ifthere are many channels, this may be specified as a vector, one element foreach channel.

quick

FALSE repeats the detrending procedure (which has some inherentrandomness) a few times to hone in on the best detrend.TRUE is quicker,performing the routine only once.FALSE is better.

filt

Do you want to smooth (filt = 'mean') or median (filt = 'median') filter the number image usingsmooth_filter() ormedian_filter() respectively? If selected, these are invoked here with afilter radius of 1 (with corners included, so each median is the median of9 elements) and with the optionna_count = TRUE. If you want tosmooth/median filter the number image in a different way, first calculatethe numbers without filtering (filt = NULL) using this function and thenperform your desired filtering routine on the result. If there are manychannels, this may be specified as a vector, one element for each channel.

s

A positive number. TheS-factor of microscope acquisition.

offset

Microscope acquisition parameters. See referenceDalal et al.

readout_noise

Microscope acquisition parameters. See referenceDalal et al.

gamma

Factor for correction of numbern due to the illuminationprofile. The default (gamma = 1) has no effect. Changing gamma will havethe effect of dividing the result bygamma, so the result withgamma = 0.5 is two times the result withgamma = 1. For a Gaussian illuminationprofile, usegamma = 0.3536; for a Gaussian-Lorentzian illuminationprofile, usegamma = 0.0760.

parallel

Would you like to use multiple cores to speed up thisfunction? If so, set the number of cores here, or to use all availablecores, useparallel = TRUE.

Note

Extreme number values (of magnitude greater than 3.40282e+38) will bewritten to the TIFF file asNA, since TIFF files cannot handle such hugenumbers.

See Also

number_timeseries()

Examples

## Not run: setwd(tempdir())img <- ijtiff::read_tif(system.file("extdata", "50.tif", package = "nandb"))ijtiff::write_tif(img, "img1.tif")ijtiff::write_tif(img, "img2.tif")number_timeseries_folder(def = "n", thresh = "Huang", frames_per_set = 20)## End(Not run)

[8]ページ先頭

©2009-2025 Movatter.jp