# The NIRS Brain AnalyzIR Toolbox
## 2 Architecture of Toolbox
### Data Classes
#### 2.1.3 _nirs_core_ChannelStats  
Both first- and higher-level channel-based statistical analysis are encapsulated in the general _ChannelStats_ class object. The _ChannelStats_ class is created as the result of either the first-level general linear model (GLM) modules or the second (or higher) level group-level models and contains the estimates of \"brain activity\" for the various task conditions as well as their uncertainty covariance models. Statistical estimates within the class are computed by Student's \(t\)-statistic estimates. False-discovery rates are controlled by a Benjamini-Hochberg [27] correction applied to all data contained within the class. Thus, if the class contains multiple fNIRS source-detector pairs, oxy-/deoxy-hemoglobin, and multiple conditions, the correction will be very conservative over all of these estimates. This can be relaxed by separating the task conditions via calls to the \"\(t\)-test\" function or by removing the data types to separate oxy- and deoxy-hemoglobin. This class can hold any data type (raw, optical density, hemoglobin, or derived measures such as oxygen saturation or metabolism estimates). The \"\(t\)-test\" function can be evoked from the _ChannelStats_ class to create composite statistics and is returned in a similar _ChannelStats_ object. The \(t\)-test is computed by the expression  
\[t=c\cdot\beta/\sqrt{c\cdot Cov_{\beta}\cdot c^{T}} \tag{1}\]  
where \(c\) is the contrast vector, \(\beta\) is the activity strength, and \(T\) is the transpose operator. For example, if there were five total task conditions, then the test of condition #1 > condition #2 would be given by \(c=[1\)-\(1000]^{T}\). In the toolbox, the contrast can be specified directly as a vector or by human-readable strings; e.g., _MyStats.ttest([1-1000])_ or _MyStats.ttest(\"task1-task2\")_ where \"task1/2\" are the names of two event types in the data. The _ChannelStats_ object also retains information about the linear model that was used to create it, which allows a hemodynamic response curve to be returned using the function call of form <_MyStats>_._HRF_ which returns the estimated time course of the hemodynamic response as a _nirs_core_Data_ variable. Block averaging, deconvolution, nonlinear, and canonical forms of the first level regression model are all handled. In addition, the statistics contained within the _ChannelStats_ class may also be recalled using the command \"table\" (e.g., _MyStats.table_), which returns a table of the regression coefficients, \(t\)-statistics, \(p\)-values, Benjamini-Hochberg FDR-corrected \(p\)-values (termed \(q\)-values), and an estimate of the type-II power for that entry of data. This table can be saved to an Excel or SPSS format or copied to the virtual clipboard. The type-II power calculation is estimated by computing the minimum detectable change (MDC) [28] and given by the expression  
\[MDC=\big{(}T_{\alpha}(n+m-2)+T_{2\beta}(n+m-2)\big{)}\cdot\sqrt{\frac{MSE}{n} +\ \frac{MSE}{m}} \tag{2}\]  
where \(T_{\alpha}(n+m-2)\) and \(T_{2\beta}(n+m-2)\) are the Student's \(t\)-value for the type-I error (\(\alpha\)) and statistical power (1-\(\beta\)) control with \(n+m-2\) degrees-of-freedom. The MDC defines the value of the change in the fNIRS signal needed to reach a specific power to reject the null hypothesis at a given alpha. Given an experimentally measured value, we can use the inverse of this equation to solve for the power (1-\(\beta\)). For example, given a measured Student's \(t\)-value of \(T\) (998,1) = 3.0 for the fNIRS signal change (=\(MDC/\sqrt{\frac{MSE}{n}\ +\ \frac{MSE}{m}}\)) with \(n=m=500\), then \(T_{\alpha}\) (998,1) = 1.64 at \(\alpha=0.05\). Solving for the power, (1-\(\beta\)) = 0.82 or the measurement is 82% powered to detect a \(p<0.05\) change for the one-sided test. For both first- and higher-level models, the power for an fNIRS measurement is returned within the _ChannelStats_ object using this equation.