# The NIRS Brain AnalyzIR Toolbox
## 6 Toolbox Utilities
### Region of Interest Analysis  
The toolbox includes support for region-of-interest analysis. Region-of-interest analysis can be applied to either the time course (_nirs.core.Data_) or statistical model (_nirs.core.ChannelStats_) variables. The region-of-interest code returns an object of the same form as either the time-course or _ChannelStats_ variables and can be used in the processing modules. Similar to computing the Student's \(t\)-value over several task conditions, region-of-interest analysis is done via the equation  
\[\beta_{roi}=c\cdot\beta_{channel} \tag{36a}\] \[Cov_{\beta_{roi}}=c\cdot Cov_{\beta}\cdot c^{T} \tag{36b}\]  
where \(c\) is the contrast vector and \(\beta\) is the channel-space values (either from the ChannelStats model or as channel-by-time matrices for the time-series data). In a simple version, the contrast vector of \(c=[0\ 0.5\ 0.5\ 0\ 0\ \dots\ ]^{\mathrm{T}}\) would average over the 2 nd and 3 rd channel entries.  
Region-of-interests can be defined using tables defined by the list of the sources, detectors, and weights used. This can be specified manually or based on anatomical registration. For three-dimensionally registered probes, the expected relative sensitivity of each fNIRS source-to-detector channel to anatomical parcellation labels can be used to define a weighted region-of-interest based on the optical forward model (**H**). The optical forward model (see Section 4) defines the sensitivity of the measurements in channel space to underlying changes in the brain space. This model is calculated by estimation or simulation of the diffusion of light through the tissue (see [67] for details).  
Figure 6: The fNIRS probe was registered to the Colin27 atlas, which was used in combination with the automatic anatomical labeling toolbox (AAL2) to label the Brodmann area 10. The images above show topology maps (Clarke azimuthal map projection) showing the depth of the nearest cortical point in the region-of-interest to the surface of the head. A yellow indicates a depth of greater than 30 mm, which would be inaccessible to fNIRS.  
For anatomical regions-of-interest, one can use the optical forward model and a brain-space region mask define the contrast vector in channel-space. The contrast vector (\(c\)) is given by  
\[c_{roi}=\textbf{{H}}\cdot\textit{Mask}_{ROI}\] (37a) where \[\textit{Mask}_{ROI}(r)=\left\{\begin{array}{ll}1&\quad if\ r\ \in ROI\\ 0&\quad else\end{array}\right. \tag{37b}\]  
The Student's \(t\)-test for a specific region-of-interest is then given by  
\[T_{ROI}=c\cdot\Gamma/\sqrt{c\times Cov_{T}\times c^{T}} \tag{37c}\]  
and  
\[c\ =\ c_{COND}\cdot c_{ROI} \tag{37d}\]  
where \(c_{ROI}\) and \(c_{COND}\) are the contrast vectors for the region-of-interest (ROI) and for the pooling of conditions. For statistical testing of the region-of-interest, this contrast vector defines the expected response in channel space given the region in brain space. Thus, Equation (37) test the null hypothesis that the signal from the region-of-interest is equal to zero. This does not test if the activity specifically came from only that region. In other words, this does not test if the entire region is active or just a subset. It also does not rule out that the activity could have been from a nearby region, which was also covered by that source-detector pair. This also assumes the optical forward model and probe registration are accurate. Any mismatch in the registration or forward model (e.g., as a result of anatomical differences including brain atrophy) will mean that the contrast vector is testing a slightly non-optimal hypothesis. As discussed in [15], using a sub-optimal contrast vector for the hypothesis is equivalent to using the wrong time-window for computing the effect. In this case, it is akin to a weighted average across the wrong combination of channels. This introduces type-II error (e.g., the false-negative rate will increase and one might miss activity that actually was significant), but does not introduce type I error (false-positive rate).