---
title: "Batch mode"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Batch mode}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```


First of all, please read the vignette on working with single images at https://rorynolan.github.io/nandb/articles/single-images.html to see how N&B calculations work on an individual image basis and to understand the nature and importance of thresholding and detrending. It's not necessary to understand every line, but it provides important context.


## Batch processing

Batch processing applies the same routine to all of the images in a directory. If you have a directory with some images on which you want to perform N&B calculations and some that you don't, put the ones you want to calculate on in their own directory and act on that directory. Then put the resulting images wherever you like. 

First decide whether or not your images need to be thresholded or not. Again, if some need to be thresholded and some don't, put these in separate directories and process them separately. Always remember to check that the thresholding worked satisfactorily when it has been employed.

To calculate brightness on a directory `path/to/some/dir` with e.g. _Huang_ thresholding and detrending, run

```{r detrend-dir-thresh, eval=FALSE} 
brightness_folder("path/to/some/dir", def = "e", thresh = "Huang", detrend = TRUE)
```

This will make a new directory called `brightness` within `path/to/some/dir` which will contain the processed TIFF images. They will be named in such a way as to make clear how they were processed (with which thresholding and detrending parameters).

`brightness_timeseries()` also has its equivalent batch mode `brightness_timeseries_folder()`, so all bases are covered.
