**3. Data analysis**

#### **3.1 Pre-processing**

This section explores and explains the signal processing which includes signal pre-processing, optode selection criteria, statistical feature computation, and the signal classification method to generate a control command for the control of a 3-DOF prosthetic arm designed for transhumeral amputees.

Functional near-infrared spectroscopy is the raw light intensity values recorded during a change in oxygenation and de-oxygenation of the blood in the human brain. With the help of dual-tip optodes, this concentration is recorded with two different wavelengths i.e. 760 and 850 nm. In the nirsLAB environment, the data is further processed. nirsLAB is the signal processing software that comes with the machine. nirsLAB is fully aware of the specifications and conditions applied during signal acquisition, hence the best choice for signal processing. The unwanted data is truncated along with unusual spikes or discontinuities that occurred during acquisition. It is then filtered to compute the hemodynamic states. These hemodynamic states are now utilized to extract the features.

As soon as the light intensities are acquired, they are fed to nirsLAB where first the time of stimulus is defined which in our case is 10 seconds as per the designed experimental paradigm. The data is further marked according to the conditions i.e. motion and rest.

**Figure 5** represents the raw fNIRS data of both wavelengths i.e. 760 and 850 nm. It is evident that the amplitude for both data sets is different as the concentration of hemodynamic response is varying from healthy to the amputated subject. This is because of the absence of an arm. As the brain generates these signals, the unwanted responses die due to the absence of neuron carrier in the brain. The connection of arm and brain is cut because there is nothing present at the receiving end. Further, the discontinuities are removed along with the spikes if there exists any. The data is then fed for filtration. nirsLAB provides the commonly practiced filters for fNIRS data. Band-pass filter was implemented to smooth the acquired light intensities. The filtered and raw data at both the wavelengths are illustrated below in **Figure 6**.

**57**

calculated as Eqs. (1) and (2):

**Figure 5.**

*subject.*

*Control of a Prosthetic Arm Using fNIRS, a Neural-Machine Interface*

nirsLAB makes use of firls and filtfilt MATLAB® commands to filter the data. firls returns the parameters of a linear-phase filter, while filtfilt applies the filter parameters into the data. The latter is set to work as finite impulse response (FIR). The roll-off defines the width of the transition frequency band, i.e. how steep the transition between frequencies which are cut and frequencies which are passed for each of the upper and lower limits of frequency. The width of the transition band is

*The first chunk of fNIRS data according to the defined experimental paradigm is illustrated. The initial and final rest is truncated. (a) fNIRS signals of healthy subjects and (b) fNIRS signals acquired from amputee* 

<sup>−</sup> Upper limit 1 = +

<sup>−</sup> Lower limit 1 = − <sup>2</sup>

This noise-free and minimum artifact data are then used to find the hemody-

This light intensity raw data is then used to compute the hemodynamic response of the brain. The hemodynamic changes computed offline in nirsLAB are based on the modified Beer-Lambert law for scattering media, as mentioned above. While in nirsLAB the operator can modify all input parameters of the Beer-Lambert law

namic states by using the modified Beer-Lambert Law [10, 39–41].

2

*Roll off* (1)

*Roll off* (2)

*DOI: http://dx.doi.org/10.5772/intechopen.93565*

*Control of a Prosthetic Arm Using fNIRS, a Neural-Machine Interface DOI: http://dx.doi.org/10.5772/intechopen.93565*

#### **Figure 5.**

*Data Acquisition - Recent Advances and Applications in Biomedical Engineering*

additionally divided into two parts. In the first part, all the tasks were recorded sequentially, i.e. the sequence of the tasks was pre-defined. In the second stage, the subjects were demanded to perform similar motions but with random intentions. All these six tasks were logged by fNIRS. Each task comprised of 10-second trials separated by a 20-second rest session. Particulars about the experimental model are

The acquired data was then processed and is briefly illustrated in the coming

This section explores and explains the signal processing which includes signal pre-processing, optode selection criteria, statistical feature computation, and the signal classification method to generate a control command for the control of a

Functional near-infrared spectroscopy is the raw light intensity values recorded

As soon as the light intensities are acquired, they are fed to nirsLAB where first the time of stimulus is defined which in our case is 10 seconds as per the designed experimental paradigm. The data is further marked according to the conditions i.e.

**Figure 5** represents the raw fNIRS data of both wavelengths i.e. 760 and 850 nm.

It is evident that the amplitude for both data sets is different as the concentration of hemodynamic response is varying from healthy to the amputated subject. This is because of the absence of an arm. As the brain generates these signals, the unwanted responses die due to the absence of neuron carrier in the brain. The connection of arm and brain is cut because there is nothing present at the receiving end. Further, the discontinuities are removed along with the spikes if there exists any. The data is then fed for filtration. nirsLAB provides the commonly practiced filters for fNIRS data. Band-pass filter was implemented to smooth the acquired light intensities. The filtered and raw data at both the wavelengths are illustrated

during a change in oxygenation and de-oxygenation of the blood in the human brain. With the help of dual-tip optodes, this concentration is recorded with two different wavelengths i.e. 760 and 850 nm. In the nirsLAB environment, the data is further processed. nirsLAB is the signal processing software that comes with the machine. nirsLAB is fully aware of the specifications and conditions applied during signal acquisition, hence the best choice for signal processing. The unwanted data is truncated along with unusual spikes or discontinuities that occurred during acquisition. It is then filtered to compute the hemodynamic states. These hemodynamic

3-DOF prosthetic arm designed for transhumeral amputees.

states are now utilized to extract the features.

given below in **Figure 4**.

*Experimental model for signal acquisition.*

**3. Data analysis**

**3.1 Pre-processing**

motion and rest.

below in **Figure 6**.

section.

**Figure 4.**

**56**

*The first chunk of fNIRS data according to the defined experimental paradigm is illustrated. The initial and final rest is truncated. (a) fNIRS signals of healthy subjects and (b) fNIRS signals acquired from amputee subject.*

nirsLAB makes use of firls and filtfilt MATLAB® commands to filter the data. firls returns the parameters of a linear-phase filter, while filtfilt applies the filter parameters into the data. The latter is set to work as finite impulse response (FIR). The roll-off defines the width of the transition frequency band, i.e. how steep the transition between frequencies which are cut and frequencies which are passed for each of the upper and lower limits of frequency. The width of the transition band is calculated as Eqs. (1) and (2):

$$\text{Upper limit} = \mathbf{1} + \frac{Roll - off}{\mathbf{2}} \tag{1}$$

$$\text{Lower limit} = \texttt{z} - \frac{Roll - off}{\texttt{z}} \tag{2}$$

This noise-free and minimum artifact data are then used to find the hemodynamic states by using the modified Beer-Lambert Law [10, 39–41].

This light intensity raw data is then used to compute the hemodynamic response of the brain. The hemodynamic changes computed offline in nirsLAB are based on the modified Beer-Lambert law for scattering media, as mentioned above. While in nirsLAB the operator can modify all input parameters of the Beer-Lambert law

#### **Figure 6.**

*(a) The filtered data for both wavelengths after filtering can be seen in this illustration. Band-pass filter has range of 0.01–0.2 Hz. The roll-off was set to 15 as a default value. (b) The same signal is smoothed and as it is a large time-series, (c) a chunk of signal for a closer look is illustrated which is for the first 5 seconds of the activity during the task.*

(absorption coefficients and inter-optode distance), in NIRStar®, these are fixed, as they are calculated real-time. More precisely, the values for real-time ΔHbO and ΔHb computation are as follows:

Absorption coefficients are 3.843707 and 1.4865865 for 760 nm, deoxy and oxy, respectively, and for 850 nm, 1.798643 and 2.526391 deoxy and oxy, respectively.

The default inter-optode distance is set to 3.0 cm and the absorption coefficient unit is millimole per liter per centimeter (1/cm)/(mmol/L).

**59**

*Control of a Prosthetic Arm Using fNIRS, a Neural-Machine Interface*

∆A . c. d.DPF g (λ) = ∆ ε(λ) (λ) + (λ) (3)

where the variables can be defined as A: light reduction, or ∆A(λ): changes in light reduction at a given wavelength (λ); ε(λ): loss of the chromophore at a certain wavelength (λ); ∆c: changes observed in the chromophore absorption; d: distance between source and detector; DPF(λ): differential path length factor (DPF) for a certain wavelength (λ); g(λ): the scattering of the light wave at a certain wavelength (λ), where g is annulled since it is presumed to be insignificant when only light attenuation (as in continuous-wave NIRS) is considered [20, 36, 42–47].

The differential path length factor (DPF) is a dimensionless modification factor that takes care of the increase in the optical path length that is produced by the scattering of light in organic tissue. The product of DPF and source-detector separation evaluates the "true" path length that the light has traveled inside the biological tissue cell [37, 38, 48, 49]. For NIRx technologies, this value is set constant for

The mathematical representation of statistical features extracted during the

= <sup>=</sup> ∑ N i i 1 <sup>1</sup> <sup>X</sup> N

( <sup>+</sup> )

i i1

where *N* denotes the length of the data points within a segment and *X*i repre-

Signal peak (SP) is defined by the change in signals amplitude among two adjacent segments which surpass a predefined threshold to reduce noise. It is given

> = = − ∑ N

i 1

where *N* represents the samples while *X*i and *X*i+1 represent the successive peaks in the signal. These features are extracted and fed to the classifier to predict

The statistical features extracted from the data sample are then fed to the classifier. Classifying methods are employed to predict the motion intention. To comprehensively evaluate the performance of features, the two widely used classifiers in pattern recognition were implemented, namely, linear discriminant analysis (LDA) and artificial neural network (ANN). A generic yet comprehensive process is illustrated in **Figure 7**.

*SM* (4)

*SP* fX X (5)

*DOI: http://dx.doi.org/10.5772/intechopen.93565*

Mathematically, it is defined as Eq. (3)

wavelengths 7.25/6.38 for 760/850 nm respectively.

Signal mean (SM) was computed as Eq. (4)

**3.2 Feature extraction**

study is given as follows.

sents the signal values.

by Eq. (5)

the motion.

**4. Classification process**

*Control of a Prosthetic Arm Using fNIRS, a Neural-Machine Interface DOI: http://dx.doi.org/10.5772/intechopen.93565*

Mathematically, it is defined as Eq. (3)

*Data Acquisition - Recent Advances and Applications in Biomedical Engineering*

(absorption coefficients and inter-optode distance), in NIRStar®, these are fixed, as they are calculated real-time. More precisely, the values for real-time ΔHbO and

*(a) The filtered data for both wavelengths after filtering can be seen in this illustration. Band-pass filter has range of 0.01–0.2 Hz. The roll-off was set to 15 as a default value. (b) The same signal is smoothed and as it is a large time-series, (c) a chunk of signal for a closer look is illustrated which is for the first 5 seconds of the* 

unit is millimole per liter per centimeter (1/cm)/(mmol/L).

Absorption coefficients are 3.843707 and 1.4865865 for 760 nm, deoxy and oxy, respectively, and for 850 nm, 1.798643 and 2.526391 deoxy and oxy, respectively. The default inter-optode distance is set to 3.0 cm and the absorption coefficient

**58**

**Figure 6.**

*activity during the task.*

ΔHb computation are as follows:

$$
\Delta \mathbf{A}(\lambda) = \mathbf{e}(\lambda).\Delta \mathbf{c}.\mathbf{d}.\mathbf{DPF}(\lambda) + \mathbf{g}(\lambda)\tag{3}
$$

where the variables can be defined as A: light reduction, or ∆A(λ): changes in light reduction at a given wavelength (λ); ε(λ): loss of the chromophore at a certain wavelength (λ); ∆c: changes observed in the chromophore absorption; d: distance between source and detector; DPF(λ): differential path length factor (DPF) for a certain wavelength (λ); g(λ): the scattering of the light wave at a certain wavelength (λ), where g is annulled since it is presumed to be insignificant when only light attenuation (as in continuous-wave NIRS) is considered [20, 36, 42–47].

The differential path length factor (DPF) is a dimensionless modification factor that takes care of the increase in the optical path length that is produced by the scattering of light in organic tissue. The product of DPF and source-detector separation evaluates the "true" path length that the light has traveled inside the biological tissue cell [37, 38, 48, 49]. For NIRx technologies, this value is set constant for wavelengths 7.25/6.38 for 760/850 nm respectively.

#### **3.2 Feature extraction**

The mathematical representation of statistical features extracted during the study is given as follows.

Signal mean (SM) was computed as Eq. (4)

$$\text{LSM} = \frac{\mathbf{1}}{\mathbf{N}} \sum\_{i=1}^{N} \mathbf{X}\_i \tag{4}$$

where *N* denotes the length of the data points within a segment and *X*i represents the signal values.

Signal peak (SP) is defined by the change in signals amplitude among two adjacent segments which surpass a predefined threshold to reduce noise. It is given by Eq. (5)

$$SP = \sum\_{i=1}^{N} \mathbf{f}\left( \left| \mathbf{X}\_{i} - \mathbf{X}\_{i \ast \mathbf{1}} \right| \right) \tag{5}$$

where *N* represents the samples while *X*i and *X*i+1 represent the successive peaks in the signal. These features are extracted and fed to the classifier to predict the motion.

#### **4. Classification process**

The statistical features extracted from the data sample are then fed to the classifier. Classifying methods are employed to predict the motion intention. To comprehensively evaluate the performance of features, the two widely used classifiers in pattern recognition were implemented, namely, linear discriminant analysis (LDA) and artificial neural network (ANN). A generic yet comprehensive process is illustrated in **Figure 7**.

**Figure 7.** *A generic classification process.*

#### **4.1 Linear discriminant analysis**

Fisher's discriminant analysis or linear discriminant analysis is a method used to dimensionally contract samples of two or more classes to separate them, linearly. This classification method projects all the samples on an imaginary line which is useful for data classification. To cater for the word linear, it suggests that the classifier will dimension the given samples to represent the class information. It characterizes the resulting combinations to reduce the number of arbitrary samples by tracing a set of values in a distinct form. It anticipates the sample information so that each class is isolated without any problem. It decreases intraclass variance and increases the interclass mean. By doing this, unlike data samples become segmented from each other and their set point shrinks together so that they cannot be mixed with other classes.

LDA is commonly used for pattern classification in offline and online systems. This technique projects all the data points on a line in such a way that each data sample that corresponds to a class is separated effectively. It decreases the intra-class variance and increases the inter-class mean. By doing this, different classes become separated from each other, and their data points get closer together so that they cannot be mixed with other classes. LDA works by maximizing the Fisher's criterion given in Eq. (6)

$$\mathbf{J}(\mathbf{v}) = \frac{\mathbf{v}^{\mathrm{t}} \mathbf{S}\_{\mathrm{B}} \mathbf{v}}{\mathbf{v}^{\mathrm{t}} \mathbf{S}\_{\mathrm{w}} \mathbf{v}} \tag{6}$$

Between classes scatter matrix S\_B is defined as in Eq. (7)

$$\mathbf{S}\_{\rm B} = \sum\_{\mathbf{x}\_i}^{\varepsilon} \mathbf{n}\_i \left(\boldsymbol{\mu}\_i - \boldsymbol{\mu}\right) \left(\boldsymbol{\mu}\_i - \boldsymbol{\mu}\right)^t \tag{7}$$

where ni represents several samples that belong to class i, the class scatter matrix Sw is defined as in Eq. (8)

$$\mathbf{S}\_{\mathbf{w}} = \sum\_{\mathbf{x}\_{\mathrm{i}}}^{\mathrm{e}} \mathbf{S}\_{\mathrm{i}} = \sum\_{\mathbf{x}\_{\mathrm{i}}}^{\mathrm{e}} \sum\_{\mathbf{x}\_{\mathrm{k}} \in \mathrm{Class}(\mathrm{i})} \left( \mathbf{x}\_{\mathrm{k}} - \boldsymbol{\mu}\_{\mathrm{i}} \right) \left( \mathbf{x}\_{\mathrm{k}} - \boldsymbol{\mu}\_{\mathrm{i}} \right)^{\mathrm{t}} \tag{8}$$

**61**

*Control of a Prosthetic Arm Using fNIRS, a Neural-Machine Interface*

A generalized eigenvector problem can be represented as Eq. (9)

written represented as in Eq. (10) provided that Sw is nonsingular.

output based on the input that have non-linear characteristic.

S v= S v B w λ

The optimal v is the eigenvector corresponding to the largest eigenvalue can be

The classifier results were validated using the cross-validation scheme. The number of folds/layers was set to 10. It means that the entire data was mixed randomly into 10 groups, out of which nine took part to train the classifier while one remains untouched for testing purposes. This process was repeated 10 times until all

As an initial measure, the attributes of the dataset which need to be classified or dimensionally contracted will lead to the choice of applying this method as a classifier or a dimensionality reduction algorithm to play out any desired task. The primary thought of Fisher's analysis is fundamentally to isolate sample classes linearly moving them to an alternate feature-space. In this way, if the considered data set is linearly distinguishable, just using the algorithm as a classifier will yield better results. In any case, if the dataset is not truly distinct the classifier will attempt to sort out this dataset in another space. Yet despite every measure, the classes sample data may overlap due to the non-linear characteristic present in the sampled dataset. For this situation, there emerges a need to utilize another grouping model to manage nonlinearities governing the dataset. Hence, a neural network that comprise of hidden layers is also implemented. As for the neural network, raw data is used as input rather than featured data. This will give a broader idea of how to predict any

ANN utilizes multiple neuron layers to map data from one distribution to another for better and optimized classification. A technique called backpropagation helps ANN to learn the relationship between input and output class label. The neural network toolbox provided by MATLAB® was utilized to train the classifier. First, network topology and an activation function were defined and then weights were randomized. The model uses all training data to approximate the error of the predicted output as compared to the actual output. Then it uses the error to adjust the weights so that it could be minimized for the next training data and this process was repeated until the error was minimized. For this network we employed Relu as the activation function; the weights were initialized using the Xavier distribution, the network utilized the Adam optimizer function for gradient descent. We used 60% of data for training, and 20% for testing and validation each. A confusion matrix was generated afterward, which had a class number corresponding to each arm motion. The number of hidden layers was specified i.e. 10, and system training was initiated. Ten neurons were present in each of the intermediate hidden layer. The number of neurons in output or last layer was set to be 6, which is equal to the

After classifying the information, their real-time testing was performed to ensure the behavior of both classifying techniques. But bear in mind that both of

(9)

( ) <sup>1</sup> Sµµ W i *v* <sup>−</sup> = − (10)

*DOI: http://dx.doi.org/10.5772/intechopen.93565*

groups were tested against each other.

**4.2 Artificial neural network (ANN)**

number of elements in the target vector.

*Control of a Prosthetic Arm Using fNIRS, a Neural-Machine Interface DOI: http://dx.doi.org/10.5772/intechopen.93565*

*Data Acquisition - Recent Advances and Applications in Biomedical Engineering*

Fisher's discriminant analysis or linear discriminant analysis is a method used to dimensionally contract samples of two or more classes to separate them, linearly. This classification method projects all the samples on an imaginary line which is useful for data classification. To cater for the word linear, it suggests that the classifier will dimension the given samples to represent the class information. It characterizes the resulting combinations to reduce the number of arbitrary samples by tracing a set of values in a distinct form. It anticipates the sample information so that each class is isolated without any problem. It decreases intraclass variance and increases the interclass mean. By doing this, unlike data samples become segmented from each other and their set point shrinks together so that they cannot be mixed with other classes. LDA is commonly used for pattern classification in offline and online systems. This technique projects all the data points on a line in such a way that each data sample that corresponds to a class is separated effectively. It decreases the intra-class variance and increases the inter-class mean. By doing this, different classes become separated from each other, and their data points get closer together so that they cannot be mixed with other classes. LDA works by maximizing the Fisher's criterion given in Eq. (6)

( ) =

Between classes scatter matrix S\_B is defined as in Eq. (7)

i

x

i ik

x x x Class i

B ii i

t B t w vS v

( )( )

<sup>c</sup> <sup>t</sup>

where ni represents several samples that belong to class i, the class scatter matrix

( )

S S x µx µ ∈

c c <sup>t</sup> w i kiki

J v vS v (6)

S nµ µµ µ = −− ∑ (7)

( )( )

== − − ∑ ∑∑ (8)

**4.1 Linear discriminant analysis**

*A generic classification process.*

**Figure 7.**

**60**

Sw is defined as in Eq. (8)

A generalized eigenvector problem can be represented as Eq. (9)

$$\mathbf{S}\_{\rm B}\mathbf{v} = \mathcal{Z}\mathbf{S}\_{\rm w}\mathbf{v} \tag{9}$$

The optimal v is the eigenvector corresponding to the largest eigenvalue can be written represented as in Eq. (10) provided that Sw is nonsingular.

$$\boldsymbol{\nu} = \mathbf{S}\_{\mathrm{w}}^{-1} \left( \boldsymbol{\mu}\_{i} - \boldsymbol{\mu} \right) \tag{10}$$

The classifier results were validated using the cross-validation scheme. The number of folds/layers was set to 10. It means that the entire data was mixed randomly into 10 groups, out of which nine took part to train the classifier while one remains untouched for testing purposes. This process was repeated 10 times until all groups were tested against each other.

As an initial measure, the attributes of the dataset which need to be classified or dimensionally contracted will lead to the choice of applying this method as a classifier or a dimensionality reduction algorithm to play out any desired task. The primary thought of Fisher's analysis is fundamentally to isolate sample classes linearly moving them to an alternate feature-space. In this way, if the considered data set is linearly distinguishable, just using the algorithm as a classifier will yield better results. In any case, if the dataset is not truly distinct the classifier will attempt to sort out this dataset in another space. Yet despite every measure, the classes sample data may overlap due to the non-linear characteristic present in the sampled dataset. For this situation, there emerges a need to utilize another grouping model to manage nonlinearities governing the dataset. Hence, a neural network that comprise of hidden layers is also implemented. As for the neural network, raw data is used as input rather than featured data. This will give a broader idea of how to predict any output based on the input that have non-linear characteristic.

#### **4.2 Artificial neural network (ANN)**

ANN utilizes multiple neuron layers to map data from one distribution to another for better and optimized classification. A technique called backpropagation helps ANN to learn the relationship between input and output class label. The neural network toolbox provided by MATLAB® was utilized to train the classifier. First, network topology and an activation function were defined and then weights were randomized. The model uses all training data to approximate the error of the predicted output as compared to the actual output. Then it uses the error to adjust the weights so that it could be minimized for the next training data and this process was repeated until the error was minimized. For this network we employed Relu as the activation function; the weights were initialized using the Xavier distribution, the network utilized the Adam optimizer function for gradient descent. We used 60% of data for training, and 20% for testing and validation each. A confusion matrix was generated afterward, which had a class number corresponding to each arm motion. The number of hidden layers was specified i.e. 10, and system training was initiated. Ten neurons were present in each of the intermediate hidden layer. The number of neurons in output or last layer was set to be 6, which is equal to the number of elements in the target vector.

After classifying the information, their real-time testing was performed to ensure the behavior of both classifying techniques. But bear in mind that both of these classifiers have different parameters and methodologies. They are not compared with each other here but they are implemented to grasp a comprehensive idea of how these different brain hemodynamic intentions can be evaluated. LDA and ANN were both applied separately and the outcomes are discussed in next section.
