# The NIRS Brain AnalyzIR Toolbox
## 2 Architecture of Toolbox
### Processing Modules Classes
#### 2.2.3. Calculate CMRO\({}_{2}\)  
In addition to raw signal intensity and oxy-/deoxy-hemoglobin time traces, the _nirs.core.data_ data class is able to store any arbitrary derived time-course data such as total-hemoglobin, tissue oxygen saturation (S\({}_{\text{t}}\)O\({}_{2}\)), relative pulsatile blood flow (pCBF) [39], and estimates of the cerebral metabolic rate of oxygen (CMRO\({}_{2}\)). The CMRO\({}_{2}\) module within the toolbox pipeline supports both a steady-state and dynamic model of metabolism. The CMRO\({}_{2}\) models are given by the two models:  
Steady state Equations [40]:  
\[q(t)=1+\frac{\Delta Hb(t)}{\mathcal{O}EF_{0}\cdot HbT_{0}} \tag{6a}\] \[v(t)=1+\frac{\Delta Hb(t)+\Delta HbO_{2}(t)}{HbT_{0}}\] (6b) \[f(t)=v(t)^{\frac{1}{t}}\] (6c) \[OEF(t)=\frac{q(t)}{v(t)}+\frac{\tau}{f(t)}\cdot\bigg{(}\frac{dq(t)}{dt}-\frac{ q(t)}{v(t)}\cdot\frac{dv(t)}{dt}\bigg{)}\] (6d) \[CMRO_{2}(t)=f(t)\cdot OEF(t) \tag{6e}\]  
Dynamic Equations [41]:  
\[\frac{dI_{flow}(t)}{dt}=a_{0}\cdot U_{flow}(t)-\tau_{s}\cdot I_{flow}(t)-\tau_{ feedback}\cdot(f(t)-1) \tag{7a}\]\[\frac{dI_{\text{CMRO}_{2}}(t)}{dt}=b_{0}\cdot U_{\text{CMRO}_{2}}(t)-\tau_{s} \cdot I_{\text{CMRO}_{2}}(t)-\tau_{feedback}\cdot(\text{CMRO}_{2}(t)-1) \tag{7b}\] \[\frac{df(t)}{dt}=I_{flow}(t)\] (7c) \[\frac{d\text{CMRO}_{2}(t)}{dt}=I_{\text{CMRO}_{2}}(t)\] (7d) \[\frac{dv(t)}{dt}=\frac{1}{\tau}\cdot\left(f(t)-v(t)^{\frac{1}{2}}\right)\] (7e) \[\frac{d\text{OEF}(t)}{dt}=\frac{\left(f(t)\cdot I_{\text{CMRO}_{2}}(t)-\text{ CMRO}_{2}(t)\cdot I_{flow}(t)\right)}{f(t)^{2}}\] (7f) \[\frac{dq(t)}{dt}=\frac{1}{\tau}f(t)\cdot\left(\text{OEF}(t)-\frac{q(t)}{v(t)} \right)+\frac{q(t)}{v(t)}\cdot\frac{dv(t)}{dt} \tag{7g}\]  
In both of these models, \(q(t)\), \(v(t)\), and \(f(t)\) are the normalized deoxy-hemoglobin (\(Hb(t)/Hb_{0}\)) and blood volume/total hemoglobin (\(HbT(t)/HbT_{0}\)), and blood flow signals respectively. \(OEF(t)\) is the oxygen extraction fraction (\(OEF=(S_{a}O_{2}-S_{v}O_{2})\)/\(S_{a}O_{2}\) where \(S_{a}O_{2}\) and \(S_{v}O_{2}\) are the arterial and venous oxygen saturations). Further details of these models can be found in [PERSON] et al. (2016) and [PERSON] et al. (2016). These two model versions are then fit to the fNIRS data using the option of either a nonlinear search method or an extended Kalman filter implementation. The output of these modules is an estimate of the state variables (flow, CMRO\({}_{2}\)) as time-course variables in the toolbox. Using these models, oxygen metabolism, oxygen extraction fraction, and blood flow can be estimated as hidden state variables from fNIRS measurements of the changes in oxy- and deoxy-hemoglobin under the assumptions of the two models. It is important to note that these are not directly measured variables and users are strongly encouraged to background in the [PERSON] et al. (2016) and [PERSON] et al. (2016) in order to understand the limitations of these models. Although some research shows that these simplified models may not estimate oxygen metabolism as accurately when compared to more detailed multiple compartment models ([PERSON] et al., 2016; [PERSON] et al., 2016; [PERSON] et al., 2016), these models may provide some basis to interpret the relationships of oxy- and deoxy-hemoglobin signals.