# Classification of Hyperspectral In Vivo Brain Tissue Based on Linear Unmixing
## 4 Classification Methodology Based on Linear Unmixing
### Method A  
The first methodology consisted of three main stages after the segmentation of the rubber ring markers, which are illustrated in the block diagram of Figure 2. In the initial stage, the characteristic end-members of the four studied classes (NT, TT, HT, and BG) were estimated by the EBEAE algorithm [26]. This estimation process used as training information all the manually labeled pixels in the ground-truth datasets for the remaining five HS images (inter-patient approach). Thus, each labeled pixel in the EBEAE formulation was a vector gathering the 128 spectral bands (i.e., \(L=128\)). In each ground-truth dataset of the HS image, the number of labeled pixels was different, i.e., for each class, the number of measurements in the EBEAE procedure was variable.  
For each class, the number of representative end-members was related to the variability of the spectral signatures in the dataset [27; 30], and this parameter was selected by the procedure in [41]. The representative number of end-members was two for NT (\(N_{NT}=2\)), two for TT (\(N_{TT}=2\)), one for HT (\(N_{HT}=1\)), and three for BG (\(N_{BG}=3\)) for all HS images. Since for the HT class, only one end-member was needed, this was equivalent to using the average of the HT labeled ground-truth pixels. With respect to the hyperparameters of EBEAE, they were manually selected to improve the classification outcome, but following the guidelines in [26]. Thus, since the goal was to reduce the estimation error, the entropy weight was chosen always as zero (\(\mu=0\)). Meanwhile, the similarity weight \(\rho\) should be small if there is large variability in the dataset. For this purpose, this hyperparameter was set as 0.3 for NT (\(\rho_{NT}=0.3\)), 0.2 for TT (\(\rho_{TT}=0.2\)), and 0.01 for BG (\(\rho_{BG}=0.01\)). Consequently, after this estimation step, we had the sets of characteristic end-members \(\{\mathcal{P}_{NT},\mathcal{P}_{TT},\mathcal{P}_{HT},\mathcal{P}_{BG}\}\) for the NT, TT, HT, and BG classes, respectively. In this way, we had low-dimensional sets for each class, i.e., \(\text{card}(\mathcal{P}_{NT})=2\), \(\text{card}(\mathcal{P}_{TT})=2\), \(\text{card}(\mathcal{P}_{HT})=1\), and \(\text{card}(\mathcal{P}_{BG})=3\).  
Figure 2: Block diagram of the stages corresponding to Method A. HSI: Hyperspectral Imaging.  
As a second step, for the \(k\)-th pixel \(\mathbf{y}_{k}\) in each HS image, the distance to each end-member set was computed by the concept of the distance from a point to a set [42], as:  
\[d(\mathbf{y}_{k},\mathcal{P}_{i})=\inf_{\mathbf{p}\in\mathcal{P}_{i}}d(\mathbf{y }_{k},\mathbf{p})\quad i\in\{NT,TT,HT,BG\},\;k\in\{1,\ldots,K\} \tag{11}\]  
where \(d(\cdot,\cdot)\) represents a distance or metric. In this study, five distances were evaluated:  
\[d_{1}(\mathbf{x},\mathbf{y}) =\sum_{l=1}^{L}|(\mathbf{x})_{l}-(\mathbf{y})_{l}|\] Manhattan metric (12) \[d_{2}(\mathbf{x},\mathbf{y}) =\sqrt{(\mathbf{x}-\mathbf{y})^{\top}(\mathbf{x}-\mathbf{y})} \text{Euclidean metric} \tag{13}\] \[d_{\mathcal{C}}(\mathbf{x},\mathbf{y}) =\frac{\mathbf{x}^{\top}\mathbf{y}}{\|\mathbf{x}\|\|\mathbf{y}\|} \text{Correlation metric}\] (14) \[d_{M}(\mathbf{x},\mathbf{y}) =\sqrt{(\mathbf{x}-\mathbf{y})^{\top}\mathbf{Q}(\mathbf{x}- \mathbf{y})} \text{Mahalanobis metric}\] (15) \[d_{SAM}(\mathbf{x},\mathbf{y}) =\cos^{-1}\left(\frac{\mathbf{x}^{\top}\mathbf{y}}{\|\mathbf{x}\| \|\mathbf{y}\|}\right) \text{SAM metric} \tag{16}\]  
where \(\mathbf{Q}\in\mathbb{R}^{L\times L}\) represents the covariance matrix of the dataset. In the last stage, the \(k\)-th pixel \(\mathbf{y}_{k}\) was classified according to the minimum distance among the four classes:  
\[c(\mathbf{y}_{k})=\arg\min_{i\in\{NT,TT,HT,BG\}}d(\mathbf{y}_{k},\mathcal{P}_{ i}). \tag{17}\]