normalizeBSLN - Normalize by baseline
Normalizes image time series or image time series split by events using a baseline time period.
Description
This function calculates the relative response change from the median value of the frames from a baseline time period at the beginning of the recording (for image time series) or trial (for image time series split by events). The baseline time period is set by the parameters normalizationMode and baselineMode.
Input
This function accepts a .dat file with axes Y,X,T (image time series) or Y,X,T,E (image time series split by events, e.g. the output of split_data_by_event). Arrays, UMT structs and .umt files are not supported.
The file is streamed in X slabs sized from the available RAM and the output is written slab by slab (Low-RAM mode is always on). Continuous data are not split by this function: to normalize by trial, split the data first with split_data_by_event.
The algorithm
For each trial (or the whole recording, for image time series), the function calculates the response amplitude as the pixel values over time minus the baseline (ΔR). Then this result is divided by the baseline resulting in pixel values expressed as ΔR/R. Here, the baseline corresponds to the median value of the baseline frames, omitting NaN values; a zero baseline is replaced by 1. The baseline period is defined by the parameters normalizationMode and baselineMode.
The input signal S(e,i,t), for each trial/recording e, and pixel i, the relative signal change (ΔR/R(t)) is calculated as:
where Si(t) is the pixel value for a given time t and bslni is the baseline value. The baseline is calculated as the median of the pixel values between the first frame of the trial/recording (t0) and the last frame of the baseline period (tevnt):
Output
The output is the normBSLN.dat file (saved in the save folder) with the same axes and sizes as the input, in single precision. A Y,X,T,E file keeps its E axis: every trial is normalized on its own, ignored event instances included, so the E axis still matches events.mat.
Parameters
In recording mode, which is for Y,X,T data, the baseline is taken from the start of the recording.
In trial mode, which requires Y,X,T,E data, the baseline of every trial is the baseline (pre-event) period stored in events.mat, found in the save folder.
Recording mode does not apply to event-split (Y,X,T,E) data. If it is selected for such data, the function warns and uses trial mode instead (a numeric baselineMode is then ignored).
In recording mode (Y,X,T data), the auto setting uses the first frames encompassing 20% of T, while a number sets the baseline as the first baselineMode seconds.
In trial mode, this parameter must be auto: the baseline is the baseline period of events.mat.
Frame rate (in Hertz) of the data, needed to convert a numeric baselineMode and the trial-mode baseline into frames. When the function runs in a pipeline, the value is taken from the data flowing into the step; otherwise it is read from the .dat header.
Set this parameter to true, to center the normalized data to one (data average ≈ 1). Otherwise, the data will be centered at zero (data average ≈ 0).
Tip
Centering the normalized data to one is useful if other calculations of value changes (Δ) will be performed later on the analysis. In those cases, centering the data at one will avoid any divisions by zero or values too close to zero.