Design of a Wearable fNIRS Neuroimaging Device with an Internet-of-Things Architecture

The brain is one of the most important and complex organs in the human body. It is responsible for the essential functions of the body. Brain activity monitoring is important in order the diagnosis of neurological disorders and for improving our understanding of the nervous system. To understand the structure and functionality of the brain, it must be monitored in natural or nonclinical settings such as during daily activities including finger tapping and thinking, as well as in outdoor activities like walking, jogging and cycling. This monitoring should assist in the detection of these natural circumstances. There are several techniques to monitor the brain’s structure and function including functional magnetic resonance imaging (fMRI), electroencephalography (EEG), magnetoencephalography (MEG), positron emission tomography (PET), and single positron emission tomography (SPECT). Functional near-infrared spectroscopy (fNIRS) is a non-invasive brain monitoring method which emits NIR light into the brain tissue and detects the transmitted or reflected light from the brain. fNIRS has many advantages over its counterparts in terms of its relatively high temporal/spatial resolution, mobility, portability and safety. It has a higher temporal resolution than fMRI and a greater spatial resolution than EEG. The preparation for fNIRS measurement is also easier than for EEG, as conductive gel is not generally required. This also means patients do not need to wash their hair after fNIRS measurements. Moreover, it is safer compared to LASER technology due to the usage of NIR light. Despite advances in fNIRS technologies, there remain challenges. Its physical set up, including both space requirements and the presence of long cables, contributes to the difficulty in using fNIRS systems for non-clinical environments. Preparation time and price are also concerns. For its use in non-clinical experiments, a portable fNIRS system must be wearable or easily carried by the subject. The cables must also be short and durable. This master thesis research was aimed at addressing the hardware limitations of fNIRS by developing a wearable, small form factor fNIRS system. I have developed an fNIRS system based on the Intel Edison, a high-end embedded system designed for internet of things applications. The Edison on the fNIRS system drives the lighting and data collection process. The system is comprised of two components: a headband containing fNIRS sensors and a control unit which controls the data collection and transmission. The control unit includes an LED driver circuit to turn LEDs on and off, an analog to digital converter to digitize the analog value from the photodetectors and a microprocessor to control data collection and transmission. The control unit is connected to a computer via serial communication. The computer acts as a computing unit, storing the collected data and making the necessary evaluations and calculations. The thesis research involved developing three versions to achieve the goal of creating a robust, wearable, wireless system. We also optimized the intensity of emitted light, the sampling rate and communication between control unit and computing unit. To develop a control unit, I first tested all the components on a breadboard. Then I combined the system on a single 6cm x 7.7cm PCB, effectively miniaturizing the system. Then I connected the sensor with the computing unit and tested the system on a human to measure hemodynamic activity. Simultaneously data was collected from subjects’ fingertips and arms for validation. In conclusion, the system successfully detected the subjects’ pulses and hemodynamic changes. Since the system is small enough to carry in a pocket or put in the back of the head cap, its next version will be a portable and wearable device with the potential to be used in ambulatory experiments.

The

INTRODUCTION
The brain is one of the most complex organs in the human body. It controls essential functions such as thinking, feeling, storing memory, and coordination the body movements, actions and reactions. It is therefore of the utmost importance to keep the brain stable and healthy. However, brain disorders and brain injuries affect more people each year. For example 5.5 million Americans have Alzheimer's Dementia (AD) and this number is expected to grow rapidly through 2050 due to the fact that the population of Americans whose age range is 65 and older will increase from 48 million to 88 million [1]. Parkinson's disease (PD) is another common neurodegenerative disorder, currently affects about 60,000 Americans, more than 10 million people are diagnosed with it worldwide [2]. Almost 6,000 Americans have Amyotrophic Lateral Sclerosis (ALS) every year as well [3]. At least 2.5 million Americans experience traumatic brain injury (TBI) each year, with an unknown number of TBIs sustained by people who do not seek treatment. The Brain Injury Association of America notes that over 12 million Americans have acquired brain injuries [4].
Furthermore, according to the World Health Organization (WHO), neurological diseases constitute 12% of total deaths worldwide. Figure 1 shows the distribution of neurological diseases on number of deaths [5]. Both Figure 1 and the discussion above help to make clear that neurological disorders and brain injuries have a major impact. Prevention, diagnosis, and treatment are of great importance. Therefore, continued or periodic brain monitoring should be done especially after diagnosis of a brain injury or mental disorder. This will provide additional insights to neurologists treating patients with these conditions.

Brain Monitoring Techniques
Neuroimaging or brain imaging could be defined as using imaging techniques to discover the states of neural systems in physiological and physical situations [6].
Neuroimaging could be divided into two categories: -Structural neuroimaging is used for discovering the structure of the brain and neural system. It is also used to understand tumors and injuries which affect these structures.
-Functional neuroimaging is used to understand metabolic and connectivity changes in neural systems. It is used for brain-computer interfaces, when researching neurological and cognitive disorders, and to study some lesions as in Alzheimer's. Table 1 compares neuroimaging systems based on their imaging type, measurement type, working principle, advantages, and disadvantages.

Structural Imaging
Differential absorption of X-rays is used. X-ray absorbed by bone and hard tissues very well, little absorbed by soft tissues and very little absorbed by air and water. Therefore, CT scans pose the structure of brain but not in so much detail [7].
It poses gross features of brain, so it is good to diagnose fractures.
It does not supply very detailed brain image

Magnetic Resonance Imaging (MRI)
MRI machine is a large magnet whose magnetic field realigns the hydrogen atoms in patient's body. While these atoms come back their original statues, they produce radio frequency signal. The image of brain structure is created by detecting these signals.
Noninvasive, little health risk, provides stable imaging Noisy and closed place is not comfortable for patients

Electrical activity
Monitoring the magnetic fields which are naturally generated by neuronal activity [8].
Direct measurement of brain function, high temporal resolution, due to the fact that magnetic fields are generated naturally, it is safe Low spatial resolution (compared to EEG), immobile, needs specialized shielding to eliminate the magnetic interference, non-invasive

Electroencephalography (EEG)
Electrodes are placed on the scalp and the electrical activity generated by neurons is measured from electrodes.
Mobile, high temporal resolution, non-invasive Low spatial resolution, electrical conductivity-sometimes it is not certain which region of brain is active

Positron Emission Tomography (PET)
Hemodynamic and metabolic changes Focusing on the level of the sugar glucose in the brain. Due to the fact that the active neurons use glucose as fuel, it checks glucose level to determine the location of neural firing happens. To monitor glucose level, it uses radioactive isotopes, shortlived radioactive material. When the isotopes are emitted, it creates visible spots which detector can detect [9] It has the ability to recognize non-cancerous and cancerous tumors thus; it prevents patients from unnecessary surgeries, it can diagnose the neurological disorders like Alzheimer in early stage [10] Low temporal resolution, immobile, does not allow continuous measurements because they use radioactive isotopes, only shows the generalized area, do not specify the location

Single Positron Emission Tomography (SPECT)
Works with the same procedure with PET. The main difference between SPECT and PET is that SPECT uses gamma rays instead of positrons [11] Functional Magnetic Resonance Imaging (fMRI) Working with the same procedure with MRI, the main difference is fMRI focuses the hemodynamic changes in the brain. It measures the signal changes while the patient is performing mental tasks [9].
It is safer than CT and PET scan, has high resolution, for psychological evaluation, more objective Low temporal resolution, immobile, physically constraining, susceptible to motion artifacts, exposes participants to loud noises, expensive, only look at the blood flow, do not localize the activity

Functional Near Infrared Spectroscopy (fNIRS)
Focusing the changes in the oxygen level in the blood. It measures the changes by emitting light to the brain tissue and detecting the reflected or transmitted data from the brain. If a region of the brain is active, there is more oxygenation in this area.
Since it uses light, it is safer than laser. It has relatively high temporal and spatial resolution. It can be portable. Inexpensive Requires long cables between sensor and control unit. Table-top device so it is hard to make experiments in mobile environments. Shallow depth of penetration Due to the fact that functional neuroimaging focuses on hemodynamic or metabolic changes in the brain, it is possible to diagnose abnormalities prior to the onset of structural changes. Precautions can then be taken in order to prevent or mitigate permanent damage due to neurological disorders or brain injuries. Therefore, this research is focused on functional neuroimaging. Although fMRI has a strong advantage due to its comparative safety and its high spatial resolution, it is limited by immobility, high cost and requirement for stillness. EEG, another functional neuroimaging technique, has the advantage of high temporal resolution and mobility. However; its low spatial resolution and the uncertainty of electrical conductivity remains a major disadvantage. As a solution of these drawbacks, functional near-infrared spectroscopy (fNIRS) is becoming more popular to monitor brain function [12].

Functional Near Infrared Spectroscopy
fNIRS is a non-invasive functional neuroimaging technique used for monitoring brain's hemodynamic activity [13] [14].
The fNIRS system works by emitting light into the brain tissue and detecting the reflected light. fNIRS systems use NIR light ranging from approximately 700nm to 900nm in wavelength for two main reasons: -NIR light passes through the scalp, the skull, and lipids with minimal absorption.
-Oxygenated Hemoglobin (HbO2) and Deoxygenated Hemoglobin (Hb) are strong absorbers of NIR light. [15] Figure 2 shows the absorption spectra of Hb, HbO2 and water [16].  [16] According to the absorption spectra, Hb absorption peaks near a 700 nm wavelength, and HbO2 near a 950 nm wavelength. To detect both HbO2 and Hb, two different wavelengths close to these values must be emitted. For this reason, LEDs of at least two different wavelengths are used as sources in fNIRS systems.
Photodetectors are used to detect the reflected light. In order to fully cover the head for monitoring, a cap similar to EEG was used with the sources and detectors (also referred to as optodes) placed on it. As a note, optodes may also be placed on a headband to monitor the forehead alone.

Problem
The fNIRS system has some advantages compared to other systems such as fMRI and EEG:  Its temporal resolution (100 Hz or more) is greater than fMRI (10 Hz) [17],  It does not require conductive gel like EEG,  Since it uses NIR lights, it is safer than laser [18].
However, it still has several disadvantages:  fNIRS systems require placing NIR sources and detectors on the scalp.
Precise optode placement is critical to obtain high-quality fNIRS data.
 Each sensor and detector is connected to the system with long cables.  Hemodynamic response signals are acquired slowly, over the course of seconds.

Thesis Research on fNIRS Hardware Development
As a possible solution, we offer an Edison-based wireless and wearable fNIRS system. Our main goal is to develop a portable fNIRS system in order to make measurements in daily life. Brain activity can then be monitored while performing daily activities such as walking, jogging, driving etc. To do so, we miniaturized the fNIRS system by creating a small, inexpensive and more functional system using smaller component chips and reducing the number of wires. The comparison between the commercial fNIRS device and our implemented system is demonstrated in Figure 3.

The Organization of Thesis
This thesis contains 4 further sections: -The second section reviews the literature on fNIRS and other brain monitoring techniques.
-The third section evaluates the research and explains the methods to implement the research. I created three different fNIRS systems to achieve the goal of wearability and portability. Each system was explained in detail in this section.
-In the fourth section, the results of experiments made for verifying our system were shown. Fingertip pulse and hemodynamic changes during arterial occlusion were measured for this purpose.
-In the fifth section, the results were discussed. The problems faced during the development, implementation and experiments are explained. Concluding with suggestions for new solutions.

REVIEW OF LITERATURE
This section will review the many types of research that have been conducted on both the experimental and hardware aspect of fNIRS.
First is the invention of in vivo fNIRS by Frans Jöbsis in 1977. He found that realtime non-invasive detection of hemoglobin (Hb) oxygenation was possible due to the relatively high degree of brain tissue transparency [19]. In 1984, David Delpy from University College London in the UK started NIRS measurements and represented the first quantitative measurement of hemodynamic parameters in sick newborn infants [20]. Then, in 1989, the first commercial system was released by Hamamatsu Photonics K.K. Companies continued developing NIRS prototypes and in 1994, the first 10channel NIRS system was developed by Hitachi. The first simultaneous NIRS measurements with PET and fMRI were taken in 1995 and 1996, respectively. About a decade later, in 2009 Hitachi released a battery-operated, wearable, wireless 22 channel system to monitor the hemodynamic changes in an adult's prefrontal cortex. Figure 4 demonstrates the historical evolution of fNIRS system [15].

Studies regarding Experimental Aspect of fNIRS
Most publications compare brain-monitoring systems such as EEG, MRI, fMRI, fNIRS, presenting fNIRS systems as a better solution.
In 2007, Coyle et al. offered the fNIRS system as a better option for BCI system.
They made measurements using a "Mindswitch" which worked by moving their hand/arm and by imagining moving their hand/arm. They claim the EEG-BCI system showed a good result for doing movements but the fNIRS-BCI system showed a better result for motor imaginary [21].
Also in 2007, Irani et al. did experimentally compared fNIRS and fMRI for neurological conditions like traumatic brain injuries, epilepsy, Alzheimer's disease, Parkinson's disease and psychiatric disorders like schizophrenia, mood disorders, and anxiety disorders. They also validated the use of fNIRS for these disorders. They showed fNIRS could be successfully deployed in clinical research and practice for these disorders. In addition, they reviewed the findings from studies on these disorders. [14]. focused on experiments for infants [22].
In 2011, Cui et al. compared NIRS and fMRI across multiple cognitive tasks in both temporal and spatial domains [23]. These tasks were composed of four experiments: left finger tapping, go/no-go, judgement of line orientation, N-back working memory task using visuospatial stimuli. Their experiments showed that NIRS signals have weaker SNR; however, it is correlated with fMRI signals. A correlation between BOLD response and a photon path developing an ellipse between the NIRS emitter was found in the spatial domain. Thus, it was proven that although NIRS could be a good alternative for fMRI, the spatial resolution and weaker SNR require careful examination. For NIRS data acquisition, they used ETG-4000 (Hitachi Medical, Japan) Optical Topography system. For fMRI measurement, they used 3T Signa Discovery 750 (GE Medical Systems).
All studies indicate fNIRS systems have advantages over MEG, EEG, PET, SPECT, fMRI, as well as limitations.

Studies regarding Hardware Aspect of fNIRS
In addition to research on the clinical and experimental application of Fnirs systems, there is work on the evolution of these systems.
In 2005, Bozkurt et al. developed a portable NIR system for monitoring newborns [24]. They indicated that newborns in neonatal intensive care units (NICU) are at a critical risk of brain injury and thus require continuous brain monitoring. They also stated that this monitoring system should be wireless in order to prevent interference to newborn babies and monitored the temporal region corresponding to the auditory cortex and the forehead for the control measurement. They also monitored electrical activity in response to sound with EEG. They claimed that there was an increase in both oxygenated and deoxygenated hemoglobin in the temporal region. Increase in blood volume indicates blood rushing to the local tissue. Also, the increase in deoxygenated hemoglobin was bigger than for oxygenated hemoglobin, showing local activity.
In 2006, Yurtsever et al. developed a wireless NIRS system [25]. They claimed that for receiving a robust signal, the probe should be comfortable, stable and provides good prevention from ambient light. To meet these requirements, they developed a flexible sensor pad. The flexibility of the pad allowed, the sensors to provide a good sensortissue coupling. They used four LEDs and ten photodetectors as optodes. Yurtsever et al. used a pocket PC with data acquisition card as a control unit. They provided a wireless communication between pocket PC and computer with the pocket PC as a client and the computer as a server. They used a cognitive optical brain imaging (COBI) studio software platform. For system evaluation, they used a tissue simulating phantom, and they stated that they received human-like results.
In 2007, Atsumori et al. offered a multi-channel, portable optical topography system [26]. According to their study, their system differs from previous optical topography systems is that they used vertical cavity surface emitting lasers (VCSELs) instead of optical fibers. By using this configuration, they eliminated the limitation on subjects' ranges of movement. They also claimed that they developed the first portable system to monitor the activity of the whole frontal cortex region.  [27]. In this study, they aimed to use their previous wearable optical topography (WOT) system with OT measurements while walking. They used the same configuration (eight light sources, eight detectors and processing unit) with their previous WOT system. Rather than asking the subject to carry the processing unit as in prior studies, they placed the unit on the subject's wrist. They also asked subjects to perform an attention-demanding (AD) task instead of word fluency task. Like the previous study, communication between the processing unit and the computer could be performed either wirelessly or via flash disk. They aimed to monitor the activation in the dorsolateral prefrontal cortex (DLPFC) and the rostral prefrontal area in humans.
They claimed that although they needed to investigate more subjects to generalize the data, their study showed that the WOT system was robust enough during walking to obtain task-related changes.
In 2013, Piper et al. developed a wearable fNIRS system for brain imaging in freely moving subjects [28]. Eight dual-wavelength LEDs were used as light sensors instead of optical fiber bundles, and eight silicon photodiodes were used as detectors. Each LED and detector was placed in a plastic housing and then mounted on a head cap. They to monitor the primary motor areas of both hemispheres. To analyze the data, they used MATLAB. They reported that they had not seen any significant difference between pedalling and non-pedalling activities. Figure 5 The wearable miniaturized NIRS system developed by Piper et al. [28] In In 2015, Pinti et al. developed a fiberless, wearable fNIRS system for monitoring brain activity during cognitive tasks [30]. They designed a flexible probe unit consisting of six surface emitting laser diodes and six silicon photodiodes. They covered both the dorsolateral and rostral prefrontal cortex. Then they placed the fNIRS probes according to standard positions. They ran fNIRS system wirelessly with fNIRS acquisition software on a laptop. After they verified the signal quality, they turned the system off and ran stand-alone mode staring the data on the fNIRS system. After that, they arranged the cameras and started experiments. Three cameras recorded real-world tasks throughout. After the experiments were complete, they performed the data analysis with custom MATLAB scripts. They claimed that the results showed a hemodynamic trend typically related to functional activation.  [30] In 2016, Agro et al. developed a portable fNIRS system [31]. They aimed to cover the entire skull area, so they used sixty-four LEDs as light source and one hundred twenty-eight silicon photomultiplier (SiPM) optical diodes as detectors. They used SiPM diodes because the SiPMs shows an ideal SNR without any cooling system. They  Figure 7 shows the overall block diagram of the fNIRS system developed for this research. However, the microcontroller's output voltage was insufficient to drive the LEDs strongly enough and brain signal quality was poor. For this reason, we switched to another microcontroller which can supply more powerful output. Also, an LED driver circuit was designed to trigger the LEDs. Although this system was more powerful, it was too big to be portable. We decided to miniaturize the system by using only the necessary chips and components. Figure 8 shows the evaluation of the study.

Version 1: Flexible Headband and Blend Micro
In our first experiment, a semi-flexible patch was designed to carry the LEDs, the detectors, and microprocessor. The patch was placed on the forehead with a headband. Figure 9 shows the block diagram of the system [33]. Micro was used to trigger the LEDs, and the analog inputs were used to collect the analog data coming from photodetectors. Figure 10 shows the algorithm used for triggering the LEDs. As can be seen from the algorithm, each LED turns on for 20ms and turns off for 5ms. The total timing is therefore 200ms, which corresponds with a 5Hz frequency. To collect accurate data, we considered the signal coming from nearby detectors. The active detectors are shown in red color. For example, when S1 (LED pair 1) was triggered, Detector 1 and Detector 2 were the most active. In this design, the distance between sources and detectors was 3 cm. This montage included 4 pairs of LED and 4 photodetectors. Each wavelength provided 10-channel data, providing 20 total measurements per frame. Figure 11 shows the signals collected from a LED and photodetector pair in a dark environment. Figure 11 Signals from LED and photodetector

Version 2: Sandwich Model
By considering the limitations of our previous design, we reviewed the possible embedded boards, wireless communication techniques and possible components. Table   2 shows the comparison of possible embedded boards. Since Blend Micro has limited sampling rate and frequency bandwidth, we needed to replace it with more powerful and faster embedded board. We decided to use the Intel® Edison Compute Module because of its speed and RAM capacity. Table 3 shows the comparison of wireless communication techniques.  Figure 12.

fNIRS Sensor: Flexible Headband
We designed another flexible headband by using sponge/foam material, and 3D printed flexible circuit. We chose sponge/foam material for flexibility and to match the curve of the forehead. We designed the circuit of optodes in Eagle and used a milling machine (OtherMill PRO ) to print it on the flexible sheet. Then, we manually soldered the LEDs and detectors. In this way, we ensured flexibility for both the headband and the optodes circuit. Figure 13 demonstrates the design of headband and flex circuit.

Figure 13 Flex Circuit for Optodes
As we discussed before, the patient comfort is vital to collecting reliable and accurate data. For this reason, the headband worn during experimentation should be soft and light. To ensure comfort, we placed the flexible circuit into a foam headband. The foam headband also kept the flexible circuit tight, establishing and maintaining good contact between the optodes and the skin. It is also important to emit an intense enough light into the brain to collect a strong reflected signal. Figure 14 shows the foam headband and its design.

Figure 14 (a) Foam headband for flexible circuit (b) Headband with flex circuit
Our hardware included 4 LEDs and 4 detectors. To make the system more robust and look nicer, we decided to use multi-wavelength LEDs instead of LED pairs. Each LED can emit three wavelengths: 770nm, 810nm, and 850nm. We used the 770nm and 850nm wavelengths. The maximum current level in the LEDs is 200mA.

Control Unit 1: LED Driver Circuit
To emit enough light to brain tissues, we need to send enough power to trigger the LEDs. To do so, we built a LED driver circuit.
We used programmable current source (LT3092 -Linear Technology [37]) to supply enough current to the LEDs. The LT3092 provides up to 200mA output current, so it is powerful enough to trigger the LEDs at the required intensity. It requires two resistors to supply this current, a fixed resistor and a potentiometer to adjust the amount of current. We used a 1Ω fixed resistor and a 20kΩ potentiometer to achieve 200mA current.
Since we used multi-wavelength LEDs, we needed eight current sources for 4 LEDs. This increased the number of wires between the Intel Edison and LED drivers.
Each of the drivers also had to be programmed individually which increased the complexity of the programming code. To reduce the number of wires and simplify the program we used a demultiplexer (DEMUX) (CD74HC4067 -Texas Instruments [38]) The common output of the fixed resistor and potentiometer was connected to the DEMUX output pin. DEMUX input/source pins were connected to the Intel Edison Digital I/O pins. When the Intel Edison sends the triggering signal, the DEMUX is configured according to its truth table and switches the outputs. The current sources received the signal from the DEMUX and triggered the LEDs according to their current value. Figure 15 shows the design configuration.

Figure 15 Design configuration for LED Driver Circuit
The truth table and working procedure of DEMUX are explained in detail in Appendix E.
The schematic configuration of LED Driver Circuit is provided in Appendix F.

Control Unit 2: Analog-to-Digital Converter
The ADC chip embedded on Blend Micro that we used in the previous study had insufficient resolution. It was 16 channel 10 bits ADC chip and it can drive up to 16MHz. Real-time fNIRS measurements require higher sampling rates. Therefore, we decided to use an external ADC chip.
We need high speed and high data rate so we decided to use an ADS1258 Analog-  Figure 16 illustrates the ADC Evaluation Board.

Figure 16 ADS1258 Evaluation Board
The photodetectors send the detected signal from the brain to the ADC. The ADC chip converts this analog signal to digital signal and sends it to the Intel® Edison via Serial Peripheral Interface (SPI) connection.

Figure 17 Intel Edison Arduino Board
Since it supports 32 mA at 5V, we decided Intel® Edison Arduino Board is a suitable choice for collecting a strong signal.
We programmed Edison's microcontroller to trigger the LEDs at defined time, to receive digitized photodetector data from the ADC, to store the values, and send the values to the computing unit wirelessly or via serial. To make the system small and wearable, we sandwiched these three circuits. Figure 18 shows the sandwiched system.

Figure 18 Sandwiched System
The whole system was put in a 3D printed box. Figure 19 shows the boxed system.

Figure 19 The boxed wearable fNIRS system
There are two ways to power the system. 1) Connect the middle micro USB port to the computer. This power is enough to upload the sketches to Edison and make basic commands.
2) Connect a 9V adapter or battery with a battery holder to power jack of Edison.
This power is enough to perform fNIRS commands.

Computing Unit: Software
A control algorithm was written in the Arduino IDE.  [42].) graphical user interface (GUI). In this GUI, we were able to visualize the raw data from channels and the level of oxyhemoglobin and deoxyhemoglobin as well. The code to collect raw data from the fNIRS sensor is provided in Appendix C.

Version 3: Wearable fNIRS (W-fNIRS)
Although the sandwiched system is compact and wireless, it is still too big for participants to carry. Therefore, we decided to miniaturize the system by not using the daughter boards. The difference between Version 2 and Version 3 is demonstrated in Figure 20.

Figure 20 The difference between Version 2 and Version 3
This third version of the system was again composed of three main parts. These parts are an fNIRS sensor headband, an LED driver circuit, an analog to digital converter, and the Intel Edison as the control unit and software on the computer as computing unit. Figure 21 shows the block diagram of the circuit.

Figure 21 Block diagram of system
These parts of the system are explained below.

fNIRS Sensor: Headband and Optodes Design
In this part of the study, we used both the flexible headband and a head cap which carries the optodes. The head cap allows us to place the optodes on different regions of the head, rather than being limited to the forehead. The detectors were also changed.
Due to the fact need for better sensitivity and response, we used 940 nm photodiodes version. To make the optodes tight, we developed 3D printed holders for each LED and detector. Figure 22 shows the sensor placement on head cap with the holders and the LED with its holder.

Control Unit 1: LED Driver Circuit
We used the same LED driver design configuration as the second version of our systems. However, since the PCB which holds the component shrank, the LED Driver Circuit also shrank. While the dimensions of Version 2 were 10.4 cm x 3.8 cm, Version 3 measured 3.6 cm x 3.7 cm. We significantly reduced the circuit which helped us to develop a smaller portable unit. The programming algorithm to drive and trigger the LEDs through DEMUX and current sources remained the same because we used the exact same configuration. The difference between two circuits can be seen on Figure   23. Figure 23 The difference of LED Drive Circuits in Version 2 and Version 3

Control Unit 2: Analog to Digital Converter
The analog to digital converter mentioned in Version 2 uses the evaluation board to connect with the LED driver circuit and the Intel Edison. This evaluation board includes all the necessary supporting components for reliable measurements. It is very useful module, but its size remains a limitation for use in our desired system. Using only the ADC chip is also not convenient because it requires a dedicated time to learn about the necessary connections to implement the same sensitivity with the evaluation board.
Therefore, we decided to use ADS1115 Analog to Digital Converter to minimize the system. The features of ADS1115 are: -16 bits -Programmable data rate: 8 SPS to 860 SPS -Internal Oscillator -Four single-ended or two differential inputs ADS1115 communicates with Intel® Edison via I 2 C. Since I 2 C communication requires only two wires, we reduced the number of wires [44]. Figure 24 shows the board of ADS1115 designed by Adafruit.

Control Unit 3: Intel® Edison Compute Module and Breakout Board
A microcontroller in the control unit is used to control the entire system. We used For this reason, chose to use the Mini Breakout Board. Figure 25 shows the relative sizes of the Arduino and breakout boards.  Breakout Board with LED driver circuit and ADS1115 are described in Appendix G.
We combined the three boards (LED Driver Board, Analog-to-Digital Converter and Edison Breakout Board). Figure 26 shows the sandwiched system. The schematic and layouts are given in Appendices H.

Because the Intel Mini Breakout Board is connected to the Intel Edison Compute
Module, it is programmable with the Arduino IDE. The only difference between programming the Intel Mini Breakout Board and the Intel Arduino Board is their header pin numbers. A detailed pin number comparison table is provided in Appendix I. The flow chart of the code for collecting raw data is provided in Figure 27. Linux-based systems for embedded hardware systems [45]. Therefore, to reach the shell of the Intel Edison Compute Module, we used Linux commands. Inside the shell, several programming languages such as C, C++, Python, Node.js and Java can program Edison.
A Linux library, MRAA [46], was used programming with these languages. We chose Python because it is open and easy to use.

Battery Experiments
Portable systems should work with rechargeable batteries, allowing use when walking, jogging, or cycling. It should not have to be plugged into a wall outlet during use.
To validate the battery life, we did the battery experiments with different montages and sampling rates. In the first montage, all four LEDs and all four detectors were used, blinking in sequence as previously described. In the second montage, only one LEDphotodetector pair was used. Both wavelengths were still used in the montage. For overall sampling rates were tested in the single pair montage:22 Hz, 15 Hz, 10 Hz and 5 Hz. Figure 29 shows the results.

System Testing
We verified the functionality of the data collection system before designing the PCB. To do experiments, the ADS1115 analog to digital converter and the DEMUX CD74HC4067 were put together on the breadboard. The TXB0108 and TXS0104 were added for voltage level translation. The Intel Edison Mini Breakout Board was then connected to the breadboard and components via jumper wires. Figure 30 shows the testing design.

Figure 30 Testing the system on the breadboard
We verified that the Intel Edison was sending the signal to the DEMUX to set the switches. The DEMUX was setting the channels according to source configuration and sending the signal to blink the LEDs. The data on the serial monitor verified that the photodetectors detected the light coming from the LEDs and sent them to ADS1115 analog to digital converter. It also verified that the ADC digitized the signals and sent them to the Intel Edison Breakout Board via I 2 C communication. We then measured the voltage level of the photodetector output, ADC output and Intel Edison input pins and verified that it showed the same value with the serial monitor. Figure 31 shows the blinking headband and photodetector data.

2.a Algorithmic Configurability
We programmed the system for different configurations.

4.1.2.a.i Number of Channels
In this study, we used 4 multi-wavelength LEDs which have 2 wavelengths, so we had 8 output channels in total. Each LED output channel was connected to a channel of the DEMUX. Thus, we were able to control all wavelengths with code digitally. The number of LEDs was determined in the code with the "pinCount" variable and put in a for loop function. Figure 32 shows the screenshot of the specific part of the code. (Full code can be found in Appendix C) We also used 4 photodetectors. Therefore, for each wavelength, there were 4 photodetector values, for a 32 data channels. We separated the detector values by labelling them with letters "A... D". Therefore, by editing these numbers, we can change the configuration. Figure 33 shows the display of different detectors.

.a.ii Sampling Rate
The sampling rate depends on the LEDs on and off times. These sampling rate can therefore be controlled by configuring the on and off time variables in the code. In the code, we defined "i" and "j" variables as on time and off times, respectively. Then we put them in "delay" function to tell the system to wait during these times. The unit of delay function in the Arduino IDE is milliseconds. In this study, we used a 20ms on time and 5ms off time, per LED and per wavelength. Therefore, the total timing is 200ms, and the overall frequency is 5 Hz. Figure 34 shows the screenshot of that piece of the code.

Experiments on Wireless Communication
The wireless communication between computer and Intel Edison Compute Module was established via Putty using the board's IP address. The command line on Putty and SSH connection is shown in Figure 35.  Figure 36.

Figure 36 Output of Python Code
The Intel Edison Compute Module also could communicate with computer via TCP/IP communication. I was able to display the output and store it in a text file successfully. Figure 37 shows the command prompt, Putty windows and text file together.

Figure 37 Command Prompt, Putty and Text File
To graph the data, a Matlab custom script was used. The data coming from fNIRS control unit was received by Matlab via TCP/IP communication. Then Matlab drew the graph. Figure 38 demonstrates the data and graph.

Feasibility Study on Human Subjects
Pulse rate and arterial occlusion experiments were done to validate our system's feasibility on human subjects.

Pulse Rate Experiments on Finger
In this experiment, the fNIRS sensor pad was placed on the finger to detect oxygenation and pulse rate. The system was able to detect pulse signal successfully. The signal is demonstrated in Figure 39. To calculate heart rate, the time difference between two pulses was obtained. There was 0.7 second between two pulses. The equation to calculate heart rate is given below.
According to equation 4, heart rate was calculated as 84.5 BPM. The resting heart rate for a healthy person is between 60 and 100 BPM, so the value is in the appropriate range [47].
For IoT fNIRS, the experiment was performed wirelessly. The Intel Edison triggered the LEDs, collected the data from the ADC, displayed them on the screen and stored them into a .csv file. Then the .csv file was copied to computer via WinSCP.
Then, the copied .csv file was read by Matlab and graphed. Figure

.2.2 Experiments for Arterial Occlusion
In medicine, occlusion means that the blockage or closing of a blood vessel or hollow organ [48]. For arm, when the artery is blocked, the blood flow going through the fingers is getting slower depends on the amount of pressure. Therefore, while the amount of oxyhemoglobin decreases, the amount of deoxyhemoglobin increases during the occlusion. When the artery is released, the blood flow rushes, the amount of oxyhemoglobin increases, and the amount of deoxyhemoglobin decreases. It is possible to catch the changes in oxy and deoxyhemoglobin with fNIRS system.
In this experiment, the fNIRS sensor was placed on the subject's arm, below the elbow. Also, a blood pressure monitor was placed above the elbow on the muscle to occlude the artery during the experiment. To capture the oxygenation changes during occlusion, a 9-minutes experiment protocol was applied. We experimented while the subject was sitting in a relaxed position. The trial was started with 3 min rest block.
After 3 minutes, occlusion was applied for another 3 min. During the occlusion, subject stayed still. This was followed by 3 min rest block. Therefore, one trial lasted for 9 minutes.

Figure 41 Experiment setup and experimental protocol for arterial occlusion
For IoT fNIRS, this experiment was also performed wirelessly. The Intel Edison triggered the LEDs, collected the data from the ADC, displayed them on the screen and stored them into a .csv file. Then the .csv file was copied to computer via WinSCP.
Then, the copied .csv file was read by Matlab and graphed. Figure 42 shows the csv file and Matlab figure with raw data. The system was able to detect the decrease of oxygenation during the occlusion and increase of oxygenation when the artery was released successfully. This result is in agreement with previous arterial occlusion experiments [49]. The hemodynamic changes from different subjects are illustrated in Figure 43.  To validate the implemented system, experiments on system level and data verification were performed. On the system level, we tested the battery life and algorithmic configurability. According to the test results, it was proven that the system could work up to 4 hours on battery. Also, the system was found to perform with different configurations. We were able to adjust the number of channels and sampling rate. For data verification, we performed finger pulse rate and arterial occlusion tests.
The system was able to detect the pulses from the finger successfully. As the result of arterial occlusion test, the system detected a sudden decrease of oxygen level due to arterial occlusion and sudden increase of oxygen level due to the release of the artery.
In conclusion, the system answers the portable fNIRS system requirements which was mentioned in Chapter 3.

Research Insights
The original purpose of this study was to create a small, wireless, wearable fNIRS measurement system and validate it. However, it was seen that in order to make accurate and reliable measurements, we need powerful microcontrollers.
The major drawback that we faced during this study is the output voltage of Intel Edison Breakout Board. The output voltage value is 1.8V, and most of the components require 3.3V or 5V to operate. For this reason, we had to use voltage level translators, which made our circuit bigger. Also, it requires extra configuration and programming.
We tried to use transistors as level shifters first, but the direction of the current level was not appropriate for our system. Figure 44 shows the working principle of a PNP transistor.

Figure 44 Working principle of a PNP transistor
As can be seen from the figure, the current should flow from emitter to base and out from the base in order to work the transistor [50]. However, in our system, the current should flow into the base from Edison. It is the working principle of an NPN transistor, but in NPN transistor, emitter must be connected to ground in order to supply current flow [51]. Figure 45 shows the working principle of an NPN transistor.   Figure 46 shows the footprint and actual size of TXS0104 chip.  should be considered seriously.

Future Work
The achievements of current work and suggestions for future work are mentioned in Table 4 and Figure 47. Hardware * A smaller-size-of PCB was designed to shrink all necessary components to control fNIRS system. It increased the portability. * The microprocessor which controls the fNIRS system was improved through the evaluation of three systems. So we were able to calculate accurate and reliable data * An extremely small PCB which can be placed into the head cap will be designed. Thus, we will reduce the length of cables between the control unit and fNIRS sensor. * Better holder design and circuit design for fNIRS sensor, LEDs and detectors, will be created.

Software
* An embedded software was developed for fNIRS firmware so we could configure most features by ourselves. Gave us freedom to configure the measurements * A Graphical User Interface (GUI) will be developed in Matlab or Python to display and track real-time data. Also, it will be configurable from the GUI. * To support portability, real-time wireless communication between fNIRS system and computer/smartphone will be established Design * A portable fNIRS system was designed, so the ease of use in the natural environment was increased. * The fNIRS system will be wireless and thus more portable. Also, it will be more configurable by the end-users.  DEMUX CD74HC4067 works as a digitally controlled analog switch. It switches between sixteen input pins based on the configuration of four sources and enable pin.
Enable pin determines whether the connection between signal pin and channels is open or not. If enable pin is high, it blocks the connection. If enable pin is low, it allows the connection.
The signal pin (COM pin on the board) connects to channels according to source pins configuration based on the truth table [53]. The truth table and working principle are provided.
In our system, the signal pin connects to ground. The LEDs are connected to VCC.
The current flows from VCC to LED, then connected channel of DEMUX. Since the channel connects to signal pin, the current flows to ground through the signal pin and completes the circuit.