Initialize NeuroAnalyzer
using NeuroAnalyzerusing NeuroAnalyzerFunctional Near-Infrared Spectroscopy (fNIRS) is a non-invasive, optical neuroimaging technique that measures brain activity by detecting changes in blood oxygenation and flow. It is based on the principles of near-infrared spectroscopy (NIRS) and provides real-time, portable, and wearable imaging of brain function. fNIRS is increasingly used in cognitive neuroscience, clinical research, and brain-computer interfaces (BCIs) due to its low cost, safety, and ease of use.
fNIRS is a functional neuroimaging modality that uses near-infrared light (650–900 nm) to measure changes in oxygenated hemoglobin (HbO) and deoxygenated hemoglobin (HbR) in the brain. - It is based on the neurovascular coupling principle, where neural activity leads to localized changes in blood flow and oxygenation.
Key Features
| Feature | Description |
|---|---|
| Signal Source | Changes in HbO and HbR due to neural activity. |
| Temporal Resolution | 0.1–10 Hz (limited by the hemodynamic response). |
| Spatial Resolution | 1–3 cm (dependent on optode spacing). |
| Invasiveness | Non-invasive (no ionizing radiation or contrast agents). |
| Portability | Wearable and portable systems available for real-world use. |
| Cost | Lower cost compared to fMRI or MEG. |
Near-Infrared Light and Tissue
The absorption of light in tissue is described by the Beer-Lambert law:
\[ A = \log \left( \frac{I_0}{I} \right) = \epsilon \cdot c \cdot d + G \]
where:
\(A\) is the absorbance,
\(I_0\) is the incident light intensity,
\(I\) is the transmitted light intensity,
\(\epsilon\) is the molar extinction coefficient (depends on wavelength),
\(c\) is the concentration of HbO or HbR,
\(d\) is the distance between source and detector,
\(G\) is the scattering losses (empirically determined).
For fNIRS, the change in absorbance (\(\Delta A\)) is related to the change in concentration of HbO and HbR:
\[ \Delta A(\lambda) = (\epsilon_{HbO}(\lambda) \cdot \Delta [HbO] + \epsilon_{HbR}(\lambda) \cdot \Delta [HbR]) \cdot d \]
where:
\(\epsilon_{HbO}(\lambda)\) and \(\epsilon_{HbR}\) are extinction coefficients at wavelength \(\lambda\),
\(\Delta [HbO]\) and \(\Delta [HbR]\) are the changes in HbO and HbR concentrations.
Light Sources
Detectors
Optodes
Preprocessing
Hemodynamic Response Function (HRF)
Hemoglobin Concentration Changes
\[ \begin{bmatrix} \Delta [HbO] \\ \Delta [HbR] \end{bmatrix} = \frac{1}{d \cdot \Delta \epsilon} \begin{bmatrix} \Delta A(\lambda_1) \\ \Delta A(\lambda_2) \end{bmatrix} \]
where \(\Delta \epsilon\) is the difference in extinction coefficients between HbO and HbR.
Statistical Analysis
| Application | Description |
|---|---|
| Cognitive Neuroscience | Studying attention, memory, language, and decision-making. |
| Clinical Research | Assessing neurodevelopmental disorders (e.g., autism, ADHD), stroke rehabilitation, and depression. |
| Brain-Computer Interfaces (BCIs) | Using fNIRS for real-time neural decoding (e.g., motor imagery, mental arithmetic). |
| Neurofeedback | Training individuals to regulate their brain activity for therapeutic purposes. |
| Pediatric Neuroimaging | Safe and portable imaging for infants and children. |
| Sleep Research | Monitoring brain activity during sleep without disrupting sleep. |
| Sports Science | Assessing brain function during physical exercise. |
| Advantage | Description |
|---|---|
| Non-Invasive | No ionizing radiation, no contrast agents, and safe for repeated use. |
| Portable and Wearable | Systems are lightweight and portable, enabling real-world use. |
| High Temporal Resolution | Captures hemodynamic changes at 0.1–10 Hz. |
| Low Cost | Lower cost compared to fMRI, PET, or MEG. |
| Safe for All Ages | Can be used in infants, children, and clinical populations. |
| Multi-Modal Integration | Can be combined with EEG, fMRI, and behavioral measures for comprehensive analysis. |
| Limitation | Description |
|---|---|
| Limited Spatial Resolution | 1–3 cm resolution, limited to superficial cortex. |
| Depth Resolution | Shallow penetration (primarily measures superficial cortex). |
| Hemodynamic Lag | Delayed and smoothed response compared to neural activity. |
| Motion Artifacts | Sensitive to head movements and environmental light. |
| Interpretation Challenges | Requires expertise to distinguish neural activity from artifacts or systemic changes. |
| Cost of High-End Systems | Time-domain (TD) and frequency-domain (FD) systems are expensive. |
| Modality | Temporal Resolution | Spatial Resolution | Invasiveness | Cost | Applications |
|---|---|---|---|---|---|
| fNIRS | 0.1–10 Hz | 1–3 cm | Non-invasive | Low | Cognitive neuroscience, clinical research. |
| EEG | Milliseconds | 5–10 mm | Non-invasive | Low | Clinical EEG, BCIs. |
| fMRI | Seconds | 1–3 mm | Non-invasive | High | Structural-functional mapping. |
| MEG | Milliseconds | 2–5 mm | Non-invasive | High | Epilepsy, cognitive neuroscience. |
| PET | Minutes | 4–6 mm | Invasive | High | Metabolic imaging. |
Loading NIRS data:
n = import_nirs("files/fnirs.nirs")
header(n) Data type: NIRS
File format: NIRS
Source file: files/fnirs.nirs
File size [MB]: 0.72
Memory size [MB]: 0.9
Subject:
Recording:
Recording notes:
Recording date:
Recording time:
Sampling rate (Hz): 25
Signal length [samples]: 9015
Signal length [seconds]: 360.6
Number of channels: 12
Epochs ID:
Number of epochs: 1
Epoch length [samples]: 9015
Epoch length [seconds]: 360.6
Wavelength [nm]: [690.0, 830.0]
Markers: no
Channel locations: yes
Number of NIRS channels: 12
Loading SNIRF data:
n = import_snirf("files/fnirs.snirf")
header(n) Data type: NIRS
File format: SNIRF
Source file: files/fnirs.snirf
File size [MB]: 1.91
Memory size [MB]: 0.29
Subject: default:
Recording:
Recording notes:
Recording date: 2022-03-03
Recording time: 12:03:48
Sampling rate (Hz): 50
Signal length [samples]: 500
Signal length [seconds]: 10.0
Number of channels: 72
Epochs ID:
Number of epochs: 1
Epoch length [samples]: 500
Epoch length [seconds]: 10.0
Wavelength [nm]: [760.0, 850.0]
Markers: yes
Channel locations: yes
Number of NIRS channels: 72
Viewing optode locations:
plot_locs(n,
ch = "all",
src_labels = false,
det_labels = false,
opt_labels = false,
head = false)Tip: Red (or black in monochrome mode) optodes represent sources, green (white) optodes are detectors.
Getting wavelengths:
n.header.recording[:wavelengths]2-element Vector{Float64}:
760.0
850.0
Getting channel of 760 or 850 nm wavelength:
ch760 = get_channel(n, ch = get_channel(n, wl = 760))
ch850 = get_channel(n, ch = get_channel(n, wl = 850))Getting data associated with these channels:
d760 = n.data[ch760, :, :]
d850 = n.data[ch850, :, :]Converting RAW intensity to OD (optical density):
n = import_nirs("files/fnirs.nirs")
intensity2od!(n)
header(n) Data type: NIRS
File format: NIRS
Source file: files/fnirs.nirs
File size [MB]: 0.72
Memory size [MB]: 1.17
Subject:
Recording:
Recording notes:
Recording date:
Recording time:
Sampling rate (Hz): 25
Signal length [samples]: 9015
Signal length [seconds]: 360.6
Number of channels: 16
Epochs ID:
Number of epochs: 1
Epoch length [samples]: 9015
Epoch length [seconds]: 360.6
Wavelength [nm]: [690.0, 830.0]
Markers: no
Channel locations: yes
Number of NIRS channels: 16
Tip: OD channels will be added to the object as nirs_od channel type. OD channels will be placed after RAW (intensity channels) and before other channels.
Converting OD (optical density) to hemoglobin concentration:
od2conc!(n)
header(n) Data type: NIRS
File format: NIRS
Source file: files/fnirs.nirs
File size [MB]: 0.72
Memory size [MB]: 1.59
Subject:
Recording:
Recording notes:
Recording date:
Recording time:
Sampling rate (Hz): 25
Signal length [samples]: 9015
Signal length [seconds]: 360.6
Number of channels: 22
Epochs ID:
Number of epochs: 1
Epoch length [samples]: 9015
Epoch length [seconds]: 360.6
Wavelength [nm]: [690.0, 830.0]
Markers: no
Channel locations: yes
Number of NIRS channels: 22
Tip: For each channel three channels will be added: nirs_hbo (oxygenated hemoglobin), nirs_hbr (deoxgenated hemoglobin) and nirs_hbt (total hemoglobin). The sequence of added channels is: ch1 HbO, ch1 HbR, ch1 HbT, ch2 HbO, ch2 HbR, ch2 HbT etc.
Tip: It is recommended to run a band-pass filter prior to calculating Hb concentration:
n = import_nirs("files/fnirs.nirs")
intensity2od!(n)
NeuroAnalyzer.filter!(n,
ch = "all",
fprototype = :fir,
ftype = :bp,
cutoff = (0.5, 10),
bw = 0.1,
order = 91)
od2conc!(n)HbO, HbR, HbT of channel 1:
labels(n)[17:22]6-element Vector{String}:
"S1_D1 HbO"
"S1_D1 HbR"
"S1_D1 HbT"
"S1_D2 HbO"
"S1_D2 HbR"
"S1_D2 HbT"
n.header.recording[:channel_type][17:22]6-element Vector{String}:
"nirs_hbo"
"nirs_hbr"
"nirs_hbt"
"nirs_hbo"
"nirs_hbr"
"nirs_hbt"
Chanel 1 data:
ch1_od = n.data[17:22, :, :]Plotting channels:
NeuroAnalyzer.plot(n,
ch = "all",
gui = false)Plotting Hb concentrations:
NeuroAnalyzer.plot(n,
ch = ["S1_D1 HbO", "S1_D2 HbO"],
type = :butterfly,
seg = (0, 30),
title = "HbO",
ylabel = "HbO [μM/mm]",
gui = false)NeuroAnalyzer.plot(n,
ch = ["S1_D1 HbR", "S1_D2 HbR"],
type = :butterfly,
seg = (0, 30),
title = "HbR",
ylabel = "HbR [μM/mm]",
xlabel = "",
gui = false)NeuroAnalyzer.plot(n,
ch = ["S1_D1 HbT", "S1_D2 HbT"],
type = :butterfly,
seg = (0, 30),
title = "HbT",
ylabel = "HbT [μM/mm]",
gui = false)