Breaking Down the Technology: A Beginner’s Guide to Near-Infrared Spectroscopy (NIRS)for non-invasive Glucose Measurement

Blood glucose monitoring is an essential part of diabetes management. It involves measuring the level of glucose in the blood to ensure that it stays within a safe range. Invasive techniques like fingerstick tests, which require pricking the finger to obtain a drop of blood, have historically been used for blood glucose monitoring. While these methods are effective, they can be uncomfortable, time-consuming, and inconvenient. In recent years, non-invasive methods for blood glucose monitoring have gained popularity. One such method is near-infrared spectroscopy (NIRS), which is a type of optical spectroscopy that uses light in the near-infrared region of the electromagnetic spectrum to measure glucose levels in the blood.
In this article, we will explore the basics of NIRS and how it works for glucose measurement. We will also go over NIRS's advantages and disadvantages, its current uses in glucose monitoring, and its potential for future development.
What is Near-Infrared Spectroscopy?
Before diving into how NIRS works for glucose measurement, it is essential to understand the basics of near-infrared spectroscopy. Spectroscopy is a technique used to study the interaction of light with matter. A sample is illuminated with light of a particular wavelength, and the amount of light absorbed or transmitted by the sample is measured. The way light interacts with the sample can reveal details about its structure, properties, and chemical make-up.
Near-infrared spectroscopy is a type of spectroscopy that uses light in the near-infrared region of the electromagnetic spectrum. The near-infrared region is between 700 and 2500 nanometers (nm) and is not visible to the naked eye. Near-infrared light has a lower energy than visible light, which allows it to penetrate deeper into the sample.
Depending on the chemical makeup of the matter, near-infrared light that interacts with it is either absorbed or transmitted. Each chemical compound has a distinct spectrum due to how differently they absorb or transmit light. Near-infrared spectroscopy involves measuring the absorption or transmission of light by the sample and analyzing the resulting spectra to identify the chemical compounds present in the sample.
How Does NIRS Work to Measure Glucose?
In the context of glucose measurement, NIRS involves shining near-infrared light on a sample of blood and measuring the absorption or transmission of light by the blood. Like water, hemoglobin, and lipids, glucose molecules absorb near-infrared light differently from other blood-borne molecules. Blood glucose levels can be measured thanks to glucose's distinctive ability to absorb near-infrared light.
The process of measuring glucose levels using NIRS involves the following steps:
- A near-infrared light source is used to shine near-infrared light onto the sample of blood.
- The near-infrared light interacts with the blood, and some of the light is absorbed by the glucose molecules in the blood.
- The remaining light is transmitted through the blood and collected by a detector.
- The amount of light absorbed and transmitted by the blood is analyzed to determine the glucose concentration in the blood.
Mathematical models and algorithms are needed to analyze how light is absorbed and transmitted by the blood. One commonly used algorithm is partial least squares regression (PLSR), which is a statistical method that correlates the spectral data obtained from the blood with the corresponding glucose concentration values. Based on the spectral information gathered from the blood, the PLSR algorithm develops a model that can be used to forecast glucose levels.
How is this actually done?
The NIRS system typically consists of a light source, a detector, and a spectrometer. The light source emits light of a known intensity and wavelength range into the skin, and the detector measures the amount of light that passes through the skin or is reflected back to the surface. The concentration of glucose in the blood is then calculated by the spectrometer by analyzing the intensity of light at various wavelengths.
One of the challenges of using NIRS for glucose sensing is the interference from other substances in the blood, such as water, hemoglobin, and lipids. These substances can also absorb light in the near-infrared region and affect the accuracy of glucose measurements. To address this challenge, NIRS devices often use a combination of wavelengths and mathematical algorithms to isolate the glucose signal from the background noise.
The combination of wavelengths and mathematical algorithms used to isolate the glucose signal from the background noise in NIRS technology is known as "multivariate analysis." Multivariate analysis involves the use of statistical models to analyze multiple variables simultaneously.
In glucose sensing, multivariate analysis is used to separate the glucose signal from the background noise caused by other substances in the blood. The mathematical algorithm used is typically based on partial least squares regression (PLSR), which is a technique that creates a linear model between the spectral data and the glucose concentration. The PLSR algorithm identifies the correlation between the spectral data and the glucose concentration and uses this relationship to predict the glucose level in real-time.
Between 1000 and 1700 nm, which is the range of the spectrum where glucose has the strongest absorption signal, is the typical range of wavelengths used in NIRS devices. However, water and lipids in the blood also absorb light in this region, making it challenging to distinguish the glucose signal. NIRS devices use a combination of wavelengths and sophisticated algorithms that simultaneously analyze the spectral data at various wavelengths to get around this problem.
The Extended Kalman Filter (EKF), a recursive algorithm that is frequently used in NIRS devices, calculates the glucose concentration using a mathematical model that takes into account a number of different variables, such as the spectral data, the noise level, and the individual's physiological parameters. The EKF algorithm uses two steps to estimate the glucose concentration: a prediction step and an update step that takes into account the measured data.
Going in with PLSR
Partial least squares regression (PLSR) is a statistical technique used to create a linear model between the spectral data and the glucose concentration. Finding the relationship between the two variables' correlations is the aim of PLSR, which then makes use of this connection to predict the glucose level in real time.
The PLSR algorithm works by breaking down the spectral data into several orthogonal factors, called latent variables, that explain the variation in the glucose concentration. The most significant latent variables that are correlated with the level of glucose are then found by the PLSR algorithm, and a linear model that predicts the level of glucose is built using these variables.
The mathematical formula for PLSR is:
X = T*P’ + E
Y = U*Q’ + F
where X is the matrix of the spectral data, Y is the vector of the glucose concentration, T and U are the score vectors for the latent variables, P and Q are the loading vectors for the spectral data and glucose concentration, respectively, E and F are the residual matrices, and ' is the transpose operation.
The PLSR algorithm finds the score and loading vectors that maximize the covariance between the spectral data and the glucose concentration. These vectors are then used to create a linear model that predicts the glucose level in real-time.
The prediction formula for PLSR is:
Y = b0 + b1T1 + b2T2 + … + bnTn
where Y is the predicted glucose level, b0 is the intercept, b1 to bn are the regression coefficients, and T1 to Tn are the scores for the selected latent variables.
An applied example
Let’s say we have a dataset of 50 individuals with diabetes. Both a NIRS device and a conventional fingerstick glucose test have been used to measure each person's blood glucose levels. Our goal is to use the spectral data to predict glucose levels without the need for fingersticks.
First, we divide the dataset into a training set and a testing set. Let’s say we randomly select 40 individuals for the training set and 10 individuals for the testing set.
Next, we use the PLSR algorithm to create a linear model that relates the spectral data to the glucose levels in the training set. The PLSR algorithm creates a linear equation that predicts the glucose levels based on the spectral data by identifying the latent variables that are most correlated with the glucose levels.
For example, the PLSR algorithm may identify two latent variables that explain most of the variation in glucose levels. The linear equation for predicting glucose levels may be:
Glucose Level = 0.5 * Latent Variable 1 + 0.3 * Latent Variable 2 + 50
Now that we have the linear model, we can use the spectral data from the testing set to predict the glucose levels. Each person's spectral data is entered into the linear equation to produce a predicted glucose level.
For example, let’s say we input the spectral data for the first individual in the testing set into the linear equation:
Glucose Level = 0.5 * 1.2 + 0.3 * 0.8 + 50
The predicted glucose level for this individual is:
Glucose Level = 50.6 mg/dL
We determine the prediction accuracy by comparing the predicted glucose levels to the actual glucose levels as determined by fingerstick. This procedure can be repeated for every person in the testing group in order to assess how well the PLSR algorithm predicts glucose levels from spectral data.
Implementing this with a synthetic data set in Python would be something like this:
import numpy as np
from sklearn.preprocessing import StandardScaler
# Generate spectral data with 20 features and 50 samples
X = np.random.rand(50, 20)
# Generate corresponding glucose levels using a linear equation
y = 5*X[:, 0] + 2*X[:, 1] + 1*X[:, 2] + np.random.normal(0, 0.5, 50)
# Standardize the spectral data
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
# Split the data into training and testing sets
X_train = X_scaled[:40, :]
y_train = y[:40]
X_test = X_scaled[40:, :]
y_test = y[40:]
# Create a PLSR object with two latent variables
pls = PLSRegression(n_components=2)
# Train the PLSR model using training data
pls.fit(X_train, y_train)
# Predict target values for test data using PLSR model
y_pred = pls.predict(X_test)
# Print the predicted and actual target values for the first sample in test data
print('Predicted glucose level:', y_pred[0])
print('Actual glucose level:', y_test[0])
In this example, we use a random number generator to create spectral data with 20 features and 50 samples. We then generate the corresponding glucose levels using a linear equation and add some random noise to simulate real-world data. We standardize the spectral data using the StandardScaler
function from scikit-learn, and split the data into training and testing sets. In order to predict target values for test data, we first create a PLSR object with two latent variables, train the PLSR model using training data, and then print the predicted and actual target values for the first sample in the test data. You can modify the parameters and generate your own dataset based on this example.
To print these datasets, you could use:
import matplotlib.pyplot as plt
# Plot the training samples
plt.scatter(X_train[:, 0], y_train, label='Training Samples')
# Plot the testing samples
plt.scatter(X_test[:, 0], y_test, label='Testing Samples')
# Set the axis labels and legend
plt.xlabel('Spectral Data (Feature 1)')
plt.ylabel('Glucose Level')
plt.legend()
plt.show()
with the following result:

What are the benefits of NIRS for glucose monitoring?
NIRS has several advantages over traditional, invasive methods for glucose monitoring. Here are some of the benefits of using NIRS for glucose monitoring:
- Non-invasive: The most significant advantage of NIRS is that it is non-invasive. Unlike traditional methods that require pricking the finger to obtain a drop of blood, NIRS requires only a small sensor placed on the skin, making it less painful and less invasive.
- Convenient: NIRS can be used for continuous glucose monitoring, allowing for real-time monitoring of glucose levels. This convenience means that patients do not have to stop what they are doing to monitor their glucose levels, making it easier to manage their diabetes while maintaining their daily routines.
- Accurate: NIRS has been shown to be highly accurate in measuring glucose levels. Research studies have demonstrated that NIRS can provide glucose measurements that are comparable to traditional methods.
- Cost-effective: NIRS can potentially reduce the cost of diabetes management. Traditional methods of glucose monitoring require frequent testing supplies, such as test strips and lancets, which can add up in cost over time. NIRS requires only a small sensor, which can be reused multiple times, reducing the overall cost of glucose monitoring.
- Low risk of infection: Invasive methods of glucose monitoring carry a risk of infection. NIRS eliminates this risk, making it a safer option for glucose monitoring.
What are the limitations of NIRS for glucose monitoring?
While NIRS has a number of benefits over conventional glucose monitoring techniques, it also has some drawbacks. Here are some of the limitations of using NIRS for glucose monitoring:
- Limited penetration: NIRS has limited penetration depth, which means that it can only measure glucose levels in the superficial layers of skin. This limitation can lead to inaccurate readings if the glucose levels in the deeper layers of skin are different from the surface levels.
- Interference from other molecules: NIRS is susceptible to interference from other molecules present in the blood, such as water, hemoglobin, and lipids. These molecules absorb or transmit near-infrared light, which can interfere with the measurement of glucose levels.
- Calibration required: NIRS requires calibration before use. Calibration involves establishing a relationship between the spectral data obtained from the blood and the corresponding glucose concentration values. Calibration is necessary to ensure accurate glucose measurements.
- Limited data: NIRS is a relatively new technology for glucose monitoring, and there is limited data on its long-term efficacy and safety. Further research is needed to establish the effectiveness of NIRS in managing diabetes.
Potential for Future Advancements
NIRS has the potential for future advancements in glucose monitoring. Here are some of the potential future advancements in NIRS for glucose monitoring:
- Improved accuracy: Researchers are working to improve the accuracy of NIRS for glucose monitoring. One approach is to use multiple wavelengths of light to measure glucose levels, which can reduce interference from other molecules in the blood.
- Wearable technology: NIRS technology can be integrated into wearable devices, such as smartwatches and fitness trackers, allowing for continuous glucose monitoring. This can provide patients with greater convenience and ease in managing their diabetes.
- Personalized medicine: NIRS technology can be used to provide personalized medicine for diabetes management. By monitoring glucose levels continuously, doctors can adjust medication dosages and lifestyle recommendations based on real-time data.
- Improved safety: Researchers are exploring the potential for NIRS to improve the safety of glucose monitoring by detecting hypoglycemia (low blood sugar) before symptoms occur. This can help prevent dangerous hypoglycemic events in patients with diabetes.
For a more detailed description of NIRS, I recommend:
Tang L, Chang SJ, Chen CJ, Liu JT. Non-Invasive Blood Glucose Monitoring Technology: A Review. Sensors (Basel). 2020 Dec 4;20(23):6925. doi: 10.3390/s20236925. PMID: 33291519; PMCID: PMC7731259.