Photonics Research, Volume. 13, Issue 8, 2202(2025)

Deep learning assisted real-time and portable refractometer using a π-phase-shifted tilted fiber Bragg grating sensor

Ziqi Liu1, Chang Liu1, Tuan Guo2,3, Zhaohui Li1,3, and Zhengyong Liu1,3、*
Author Affiliations
  • 1School of Electronics and Information Technology, Guangdong Provincial Key Laboratory of Optoelectronic Information Processing Chips and Systems, Sun Yat-sen University, Guangzhou 510006, China
  • 2Guangdong Key Laboratory of Optical Fiber Sensing and Communications, Institute of Photonics Technology, Jinan University, Guangzhou 511443, China
  • 3Southern Marine Science and Engineering Guangdong Laboratory (Zhuhai), Zhuhai 519082, China
  • show less

    In this work, we demonstrate a π-phase-shifted tilted fiber Bragg grating (π-PSTFBG)-based sensor for measuring the refractive index (RI) of NaCl solutions, achieving a real-time and online measurement system by employing a densely connected convolutional neural network (D-CNN) model to demodulate the full spectrum. The proposed π-PSTFBG sensor is prepared by using the advanced fiber grating inscription system based on a two-beam interferometry method, which could introduce deeper features of dip-splitting for all the lossy dips in the spectrum, giving the possibility of fully measuring the change of RI. This enhanced feature gives relatively higher prediction accuracy (R2 of 99.67%) using the well-trained D-CNN model compared with the results achieved by pure TFBG or that with a gold coating. As a further demonstration from a practical view, a prototype integrated with the proposed D-CNN algorithm is developed to conduct RI measurement of NaCl solutions in real time using a π-PSTFBG-based RI sensor. The results show that the proposed real-time demodulation system is capable of measuring RI with an average error of 1.6×10-4 RIU in a short response time of <1 s. The demonstrated spectral demodulation approach powered by deep learning shows great potential in real-time analysis for chemical solutions and point-of-care medical testing based on RI changes, especially for the portable requirements.

    1. INTRODUCTION

    As one of the important merits to evaluate the environmental ecosystem, precise and real-time measurement of the metallic ions in aqueous condition provides an effective means to monitor the pollutions aggravated owing to the acceleration of industrialization and urbanization. These resultant pollutants consist of various wastes and sewage with heavy metal ions (HMIs), eventually recycling into aqueous ecosystems and marine resources [14], which becomes a serious threat to the health of aquatic animals and plants and human beings [57]. At present, typical HMI detection methods include atomic absorption spectrometry [8], inductively coupled plasma mass spectrometry [9], chemiluminescence [10], electrochemical analysis [11], and photoluminescence (PL) [12]. Although these methods are relatively mature, a complex and costly system is typically required, and offline monitoring is difficult. Therefore, it is imperative to develop an HMI detection method with high sensitivity, low cost, and miniaturization, holding great significance in environmental protection and other fields.

    In recent years, optical methods for HMI detection have also been vigorously developed due to the advantages of high sensitivity, anti-electromagnetic interference, and low cost [13]. Among them, optical-fiber-based RI sensors have become a very promising refractive index (RI) measurement device due to the intrinsic RI sensitivity characteristics [14,15]. The RI of the solution is usually related to its concentration and temperature, and its variation relationship can be obtained by establishing the model function [16]. Therefore, the change of RI on the surface of the sensor structure caused by the change of solution concentration can be easily captured by the sensor [17], so as to achieve accurate detection of solution concentration. A variety of optical fiber sensors using different structures have been proposed, such as etching the fiber structure [18,19] and a long-period fiber grating (LPFG) [20,21]. However, the etched fiber itself is not sensitive to changes in ion concentration and is strongly dependent on high-sensitivity coating materials. LPFG is sensitive to changes in surrounding RI (SRI) due to the coupling between the forward fiber core mode and cladding mode. However, due to the angle between the grating plane relative to the optical axis, a tilted fiber Bragg grating (TFBG) has more abundant resonance of cladding modes than LPFG, making TFBG behave sensitively to the changes of SRI. For instance, in 2013, Liu et al. [22] verified that the transmission spectrum of TFBG showed high sensitivity and stability to RI changes. To further improve the sensitivity and ion selectivity of TFBG to weak surface RI changes, researchers have proposed a variety of new coating materials for sensitization in recent years. In 2023, Zhu et al. [23] further improved the sensitivity of TFBG to SRI changes by coating with a thin gold film and wrapping a layer of lead-sensitive thrombin aptamers on the surface to stimulate a surface plasmon resonance (SPR) effect; low concentration (0.1 parts per billion) of Pb2+ can be measurable. Another SPR-TFBG sensor proposed by Ren et al. to detect the cadmium ion (Cd2+) achieved a wide range of detection ranging from 0.01 to 1000 nmol/L through glutathione materials [24].

    Recent investigations of highly sensitive TFBG to SRI make it widely employed in various scenarios, mainly focusing on optimizing the device structure and new coating materials to improve the RI sensitivity and ion selectivity of TFBG sensors. Although high performance has been achieved, there are still remaining difficulties, such as real-time spectral demodulation and miniaturization of the sensing system, which are important to move the TFBG-based sensors to portable applications. At present, various demodulation methods for TFBG spectra have been proposed. For example, as early in 2010, Lu et al. [25] established the relationship between the cut-off resonance wavelength and SRI to achieve polarization-insensitive SRI measurement. In the same year, Alberto et al. [26] proposed an envelope area detection method for RI based on the envelope resonance mode with an RI resolution of 5.7×104 RIU. In 2017, Cieszczyk et al. [27] proposed a new demodulation method based on the contour length of the TFBG transmission spectrum, which demonstrates a good sensitivity in an RI range of 1.38–1.43. In 2023, Huang et al. [28] also established a linear relationship between the derivative of the envelope curve and the change of RI, which improved the sensitivity for hundreds of nm/RIU. However, these methods require a high-resolution optical spectrometer or interrogator to collect spectra, so as to facilitate high-precision tracking of wavelength drift or envelope variation. In recent years, some researchers have demonstrated advanced signal processing technology to realize low-resolution TFBG spectral demodulation schemes. For example, in 2018, Bekmurzayeva et al. [29] proposed a spectral demodulation scheme based on a short-time Karhunen-Loeve transform algorithm. By converting the TFBG spectrum into the set of multiple eigenvalues, the mapping relationship between the eigenvalue with the most information and TFBG spectrum is constructed. In 2023, Lobry et al. [30] used the cubic spline interpolation method to achieve the spectral reconstruction using a low-resolution TFBG spectrum, and conducted the curve fitting for envelope tracking. However, these methods sacrifice the wholeness of spectral analysis in an attempt to map the TFBG spectra with only a few feature points, which may introduce arbitrary errors during spectral processing. Most importantly, although some miniaturized setups were demonstrated, the system still requires external PCs to complete data processing, indicating that the related demodulation algorithms are not desirable for realizing standalone and real-time sensing systems. There are few investigations on the implementation of low-cost and real-time offline demodulation systems for TFBG sensors based on edge devices.

    In an attempt to establish the relationship between TFBG spectral changes and particular measurands, in recent years, various machine learning (ML) algorithms have been proposed to demodulate the RI change of TFBG-based sensors by mapping spectral changes with sensing parameters. In 2022, Chubchev et al. [31] first employed this approach using the spectral data of an SPR-TFBG-based RI sensor together with principal component analysis and polynomial regression dimensionality reduction to measure small RI changes with an optimal resolution of 9×106  RIU. In the same year, we also demonstrated a TFBG RI demodulation algorithm based on a residual convolutional neural network (CNN), achieving a mean square error (MSE) of 2.818×107  RIU, and verified that this method is also suitable for low-resolution spectral data, but the number of parameters in the network is 331,361. The problem of developing more lightweight algorithms needs to be further addressed [32]. Moreover, most data acquisition relies on large equipment like an optical spectrum or vector analyzer. In recent years, some studies have adopted the spectral demodulation method based on array waveguide grating (AWG) and ML algorithms to realize the rapid demodulation of optical fiber sensors, which has realized the miniaturization of the system to a certain extent. These approaches show promising demodulation performance for interference sensors [33,34] and fiber Bragg grating (FBG)-based sensors [3537] that have dominant peaks, which however is still a challenge for complex spectra like TFBG-based sensors due to the limited spectral resolution. Thus, a proper approach is desirable to realize the interrogation of the full spectrum in real time for a portable and miniaturized sensing device.

    In this paper, we propose a real-time and portable RI monitoring system based on a densely connected convolutional neural network (D-CNN). To introduce sufficient spectral features correlated to RI changes, a π-phase-shifted TFBG (π-PSTFBG) sensor is demonstrated for RI measurement in sodium chloride (NaCl) aqueous solution. Full spectrum data collected by π-PSTFBG under different RIs are directly used as datasets without complex pretreatment. As a result of experimental verification for the π-PSTFBG sensor, the well-trained D-CNN model shows a good detection capability and has a high RI prediction accuracy of 99.67% and a mean absolute error of 5.99×104  RIU. Moreover, the same structure of the D-CNN model is employed to analyze the spectrum of TFBG and SPR-TFBG sensors, achieving accuracies of 99.17% and 99.26%, respectively, which are relatively lower compared to a π-PSTFBG sensor that possesses phase-shift characteristics. Ultimately, we demonstrated a prototype of an offline miniaturized real-time demodulation system based on the D-CNN network, and showed its capability of RI measurement in less than 1 s, making a large advancement for RI real-time monitoring in practical applications.

    2. DEVICE PRINCIPLE AND FABRICATION

    Currently, it is an ordinary way to employ the TFBG technique to conduct the monitoring of SRI. TFBG is a Bragg grating device that has a grating plane with a relative angle of θ to the fiber axis. As illustrated in Fig. 1(a) where the structure of a typical TFBG is demonstrated, the transmission spectrum of the grating is highly dependent on the tilted angle θ as well as the grating pitch Λg. Basically, the Bragg grating structure induces coupling between two propagating modes in the fiber core, whereas the tilted grating couples the core mode to various cladding modes, resulting in different lossy dips in the transmission spectrum, as plotted in Fig. 1(b). Because the effective RI of higher-order cladding modes is close to SRI, causing leaky resonances, this characteristic allows TFBG to be widely used in the detection of SRI by tracking the wavelength shifts of cut-off modes.

    (a) Structure of the TFBG and (b) transmission spectrum and local amplification of TFBG with a tilted angle of 16°; (c) structure of the π-PSTFBG and (d) transmission spectrum and local amplification of PSTFBG with a tilted angle of 16°; (e) schematic illustration of the fiber grating inscription setup based on two-beam interferometry; (f) introduction of π-phase shift during grating inscription based on two-beam interferometry method.

    Figure 1.(a) Structure of the TFBG and (b) transmission spectrum and local amplification of TFBG with a tilted angle of 16°; (c) structure of the π-PSTFBG and (d) transmission spectrum and local amplification of PSTFBG with a tilted angle of 16°; (e) schematic illustration of the fiber grating inscription setup based on two-beam interferometry; (f) introduction of π-phase shift during grating inscription based on two-beam interferometry method.

    As a further improvement, the π-PSTFBG introduces a certain phase shift (i.e., π) spatially to the grating plane, as illustrated in Fig. 1(c), where a small discontinuous region appears in the center of the grating. As such, the π-PSTFBG is actually the center of the grating that generates the offset of Δz0 along the axis of the grating. A certain phase ϕi=2πΛΔz0 is shifted, where Λ(=Λg/cosθ) is the grating period as measured along the axis of the fiber [38]. According to the coupling occurring in a short-period grating, the coupling detuning coefficients between core to counterpropagating cladding modes can be expressed as [39]δlm01clco12(β01co+βlmcl2πΛgcosθ),where β01co and βlmcl are the propagation constants of the core and a particular cladding mode, which equal 2πnco/λ and 2πncli/λ, respectively. nco and ncli represent the effective RI of the core mode and the ith order cladding mode. When the phase-matching condition is satisfied at a particular wavelength, the coupling detuning coefficient is zero, i.e., δlm01clco=0, and we can obtain the resonant wavelength formulated as λr=(nco+ncli)Λgcosθ.

    The phase shift is then rewritten as ϕi=2π(nco+ncli)λrΔz0.

    Therefore, at each resonant wavelength of cladding mode, the coupling with a phase shift occurs for every cladding mode, resulting in a lossy dip presenting a sharp peak. Figure 1(d) shows an experimentally measured transmission spectrum of π-PSTFBG; in comparison with Fig. 1(b), the introduction of π-phase shift changes the spectral characteristics of the TFBG in a way by splitting each transmission dip into two. This makes the spectral features of π-PSTFBG more abundant and provides further possibilities for the analysis of its spectral data.

    In a realization of the π-PSTFBG in experiment, an advanced fiber grating inscription system was set up based on a two-beam interferometry method, as schematically illustrated in Fig. 1(e). Prior to the fabrication of the π-PSTFBG, a certain angle θ is introduced between the fiber and the x-axis on the x-o-y plane to achieve a tilted angle of the grating plane, as shown in Fig. 1(f). In the fabrication process, at the moment when the scanning mirror moves along the x-axis to the midpoint of the grating, the scanning mirror is suddenly shifted by Λ/2 from the present position, causing a corresponding shift to the interference stripes as shown in Fig. 1(f).

    Figure 2 shows various transmission spectra of π-PSTFBG with different tilted angles, i.e., 6°, 8°, 10°, 16°. The main spectral characteristics of π-PSTFBG are similar to that of TFBG, except that a further envelope inside the spectrum is clearly present, as demonstrated by the blue curve in Fig. 2(d). The tilted angle determines the cut-off cladding mode to be coupled. The Bragg wavelength shows a red shift as the tilted angle increases, broadening the envelope of the coupling resonance to a shorter wavelength. In this study, π-PSTFBG of 16° was chosen to conduct the RI real-time measurement as well as the full spectrum demodulation based on D-CNN because the effective exponent of the dominant cladding resonances covers a wider RI range, thus showing better spectral changes in shape for model training.

    Experimentally measured transmission spectrum of π-PSTFBG with tilted angles of (a) 6°, (b) 8°, (c) 10°, and (d) 16°.

    Figure 2.Experimentally measured transmission spectrum of π-PSTFBG with tilted angles of (a) 6°, (b) 8°, (c) 10°, and (d) 16°.

    3. DATA ACQUISITION OF RI MEASUREMENT

    In the experiment to further verify the RI response of π-PSTFBG, we used 16° π-PSTFBG and 16°-TFBG without the acrylate coating to measure an aqueous solution of NaCl with different RIs. During the measurement, the actual RI of each NaCl solution was calibrated by a refractometer (RI-Chek pocket digital refractometry, Reichert 13940000). In an attempt to better compare the intrinsic sensing characteristics of the two devices, the gratings were not subjected to any sensitization treatment. As shown in Fig. 3(a), an external super luminescent diode (SLD, VSLS-1550-B-16) is used to achieve broadband light in the experiment, and an optical spectrum analyzer (OSA) is employed to collect the transmission spectra of TFBG and π-PSTFBG with a resolution of 0.05 nm.

    (a) Schematic setup to acquire transmission spectral data of 16° π-PSTFBG under the conditions of various SRIs, while a conventional 16°-TFBG is employed as control group for comparison; transmission spectra collected under different RIs of (b) TFBG and (c) π-PSTFBG.

    Figure 3.(a) Schematic setup to acquire transmission spectral data of 16° π-PSTFBG under the conditions of various SRIs, while a conventional 16°-TFBG is employed as control group for comparison; transmission spectra collected under different RIs of (b) TFBG and (c) π-PSTFBG.

    Regarding the collection of spectrum data during RI measurement, the TFBG sensor and π-PSTFBG sensor were immersed in NaCl solutions with RIs ranging from 1.3327 to 1.3795. In this range, there were 31 groups of solutions with various RIs, and 10 spectral samples were collected for each group, acquiring 310 spectral samples in total for TFBG and π-PSTFBG individually. To eliminate the influence of the output power of the light source on the data, the acquired transmission spectra were subtracted by the original light source.

    Figures 3(b) and 3(c) plot the measured transmission spectra, respectively, for TFBG and π-PSTFBG at the selected SRIs. As observed from the results, with the increase of SRI, the transmission spectra of both TFBG and π-PSTFBG are obviously changed with a feature of red shift of cut-off mode wavelength. Regarding the π-PSTFBG, there is one sharp peak existing in each lossy dip, as demonstrated in Fig. 2, so the red shifts of the three cut-off mode wavelength points (i.e., left trough, phase-shift point, right trough) can be traced simultaneously under different RIs, with a sensitivity of 532.8 nm/RIU, 532.9 nm/RIU, and 533.1 nm/RIU, respectively. At the same time, it is also observed that the phase-shift point envelope curve of π-PSTFBG changes significantly with increasing RI, which can also be used as an important parameter to analyze the correspondence between spectrum and RI, as shown in Fig. 3(c). However, the accuracy of the physical model fitting methods for distinguishing small changes of RI highly depends on spectral resolution as well as the precise detection of the cut-off wavelength dip [40], which usually causes large uncertainty due to its small contrast. Additionally, such wavelength tracking or envelope fitting demodulation methods are usually post-processing, which seriously hinders the performance of real-time demodulation. The post-processing demodulation is not conducive to the proposed π-PSTFBG sensor in practical applications of chemical, biological analysis.

    4. DEMODULATION ALGORITHM AND RESULTS

    A. Establishment of D-CNN Model

    To realize truly real-time monitoring of the SRI change for chemical solution analysis, we propose a novel approach based on deep learning to demodulate the full spectrum of a π-PSTFBG sensor without complex pre-processing. Figure 4 shows a schematical illustration of the proposed algorithm structure, which is established to extract RI parameters directly from the transmission spectra of π-PSTFBG based on a densely connected convolutional neural network (D-CNN). To achieve the real-time, high-speed, and low-cost demodulation, a conventional CNN model is utilized to compare with the proposed D-CNN model. The specific configurations of the two models are shown in Fig. 4(a). As for the CNN model, it consists of convolution layers, max-pooling layers, average pooling layer, batch normalization layer, and linear layer, with a batch size of 64.

    (a) Schematic diagram of the proposed demodulation algorithm based on deep learning for analyzing the full spectrum of the π-PSTFBG sensor; two-dimensional distribution of the intermediate features via t-SNE visualization for (b) the input data and (c) the output data after the DenseBlock_2 layer.

    Figure 4.(a) Schematic diagram of the proposed demodulation algorithm based on deep learning for analyzing the full spectrum of the π-PSTFBG sensor; two-dimensional distribution of the intermediate features via t-SNE visualization for (b) the input data and (c) the output data after the DenseBlock_2 layer.

    In addition to the CNN model, an improved structure of D-CNN is proposed as well to handle the dense characteristics of π-PSTFBG with more complex feature changes. The critical difference of D-CNN is to replace the convolution block of the CNN model with a densely connected block [41], as shown in the detailed illustration of DenseBlock in Fig. 4(a), where x1=concat([x0,f1(x0)]), x2=concat([x1,f2(x1)]), and x0 and x2 are the input and output of DenseBlock. Specifically, DenseBlock directly concatenates the features extracted from each layer with the output features of all preceding layers in the channel dimension. This direct feature integration preserves the inherent characteristics of the features from previous layers, which in turn avoids the disappearance of the gradient and prevents the loss of crucial spectral sensing features. For a more intuitive illustration, as shown in Figs. 4(b) and 4(c), t-distributed stochastic neighbor embedding (t-SNE) visualization was adopted to show the feature comparison between input data of the network and the output data after the DenseBlock_2 layer. As the network learning goes deeper, the feature of the data under different RIs becomes gradually distinguishable and presents an approximate linear distribution, indicating that the learning process of the D-CNN is effective and global.

    In the output block, a linear layer is utilized in the CNN and D-CNN models to facilitate the mapping of the extracted feature vectors to the predicted RI values. During network training, both configurations adopt MAE as the loss function to improve the stability of model training and R2 as the evaluation function, which are expressed by MAE=1ni=1n|y^lyi|,R2=1i(yiy^l)2i(yiy¯)2,where n represents the total number of spectral samples, y^l stands for the value predicted by the model, and yi is the truth value for the ith spectrum. Training and validation were performed in Python 3.8 environment on a server equipped with a 12th generation Intel core i5-12500 CPU at 2.40 GHz, GeForce RTXs 2050.

    A comparative configuration of the CNN and D-CNN models reveals that the latter exhibits a significant reduction in the number of parameters, despite maintaining comparable performance. This is mainly attributed to the customized modifications based on the full spectrum of the TFBG-based sensor by introducing the dense convolution blocks and the adjusted kernel size of the input layer. As presented in Table 1, a layer-wise comparison of the two networks’ weight parameters shows that the CNN model comprises 76,769 parameters, whereas the D-CNN model has 31,185 parameters. A substantial reduction of 45,584 parameters has been achieved, which is of great significance for resource saving, system integration, and other aspects. The dense connections of D-CNN yield a notable parameter reduction while preserving the model’s excellent performance, which is further substantiated by training and testing both models on the same dataset, reducing the burden of realizing real-time and low-cost spectral demodulation.

    Configured Parameters in Each Layer of CNN and D-CNN Models

    CNND-CNN
    Layer NameParametersLayer NameParameters
    InputInput
    Conv1D96Conv1D128
    Batch normalization32Batch normalization64
    MaxPool1D0MaxPool1D0
    Conv1D3616Conv1D5152
    MaxPool1D0MaxPool1D0
    Conv1D14,400DenseBlock11380
    MaxPool1D0DenseBlock21780
    Conv1D20,544Conv1D2628
    MaxPool1D0AvgPool1D0
    Conv1D20,544DenseBlock31460
    MaxPool1D0AvgPool1D0
    Conv1D12,352Flatten0
    AvgPool1D0Linear18,593
    Flatten0
    Linear5185

    B. Demodulation Results and Performance Verification

    To further validate the good performance of the D-CNN model, 310 full spectra of π-PSTFBG acquired by OSA in NaCl solutions with varying RIs were used to train both CNN and D-CNN models separately, enabling a direct comparison of their performance. The dataset was partitioned into a training set, a validation set, and a test set, according to a ratio of 6:2:2. The input data dimensionality for the model was (None, 1, 8001). During the training process, the CNN and D-CNN are trained separately using the same dataset. This training process can be regarded as a calibration procedure, analogous to traditional wavelength or intensity tracking methods used to measure RI changes. The results of the test dataset, as illustrated in Fig. 5, demonstrate that the CNN model achieves an accuracy of R2 of 98.36% with an MAE of 1.02×103  RIU. Furthermore, the prediction time of the CNN for the test dataset of 62 spectral samples is only 0.1586 s, indicating a processing time of approximately 2.56 ms per spectrum. At the same time, the test accuracy R2 of the D-CNN model is 99.67%, with the MAE of 5.99×104 RIU. Notably, the prediction time of the D-CNN is only 0.1525 s for the same spectral samples, giving a processing time of 2.46  ms for a single spectrum.

    Prediction results of π-PSTFBG RI sensor based on the well-trained models of (a) convolutional neural network (CNN) and (b) densely connected CNN (D-CNN) in comparison with labeled truth values.

    Figure 5.Prediction results of π-PSTFBG RI sensor based on the well-trained models of (a) convolutional neural network (CNN) and (b) densely connected CNN (D-CNN) in comparison with labeled truth values.

    According to the predicted results, the D-CNN model exhibits superior performance, which indicates that a dense block architecture is particularly suited for training complex spectral data of a π-PSTFBG sensor with a reduced number of parameters, while also exhibiting a slightly faster test time compared to the CNN model. It is particularly suitable for the integration of small and lightweight hardware systems to achieve the full spectrum interrogation in real time. This efficiency in processing large spectral datasets of π-PSTFBG makes the D-CNN model a promising approach for developing a cost-effective and high-precision real-time sensing system.

    In addition to the presented deep learning approach, various classic machine learning (ML) models have been explored for establishing mapping relationships between spectral inputs and target parameters, including decision tree regression (DTR), random forest regression (RFR), gradient boosting regression (GBR), and linear regression (LR). At the same time, in order to more effectively illustrate the necessity of using a relatively complex D-CNN model, we add a very simple multilayer perceptron (MLP) model for comparison. To comprehensively validate the efficacy of the proposed D-CNN algorithm, we conducted systematic comparisons by training these baseline models on the π-PSTFBG dataset and evaluated the results using the coefficient of determination (R2), MSE, as well as MAE, with detailed comparative results presented in Table 2. It demonstrates that while conventional ML-based spectrum demodulation approaches and the MLP model with simple structure can achieve basic functionality, the proposed D-CNN architecture exhibits superior performance across all evaluation metrics. Moreover, due to the large dimension of the full spectral data, resulting in a large number of hidden layers required, the number of parameters of the MLP model reached a staggering 43,958,337, which is more than that of the D-CNN model (31,185) and particularly unfavorable for realizing the independent demodulation device with limited storage and computation resources. In comparison, the demonstrated D-CNN model adopts feature reuse through the introduction of DenseBlock, greatly reducing the number of parameters and improving the utilization efficiency of spectral features, which is crucial to realize an edge-computing-based sensing system.

    Spectral Demodulation Results of π-PSTFBG Based on Machine Learning Algorithm

    ML AlgorithmR2MSEMAE
    DTR84.77%2.261×1052.24×103
    RFR98.84%1.633×1068.94×104
    GBR98.21%2.522×1061.08×103
    LR99.13%1.253×1065.29×104
    MLP99.14%1.442×1066.64×104
    CNN98.36%2.742×1061.02×103
    D-CNN99.67%5.083×1075.99×104

    To rigorously assess model robustness and generalization capabilities, we added Gaussian white noise to the test dataset to simulate the noise disturbance in practical application scenarios. Figure 6 presents the prediction performance of several models under noise-free, low-noise (SNR=31  dB), and high-noise (SNR=25  dB) scenarios. The results reveal that while all models experience performance degradation with increasing noise levels, as evidenced by progressively elevated MAE values, the proposed D-CNN approach consistently maintains superior prediction accuracy. It is a unique advantage brought by the multi-scale feature extraction characteristics of deep learning and is of great significance for RI real-time detection in practical applications. In addition, enhancing robustness of traditional ML models requires precise peaks selection, which is a time-consuming process incompatible with real-time performance [42]. Therefore, the direct demodulation of full spectrum based on the proposed D-CNN approach proves optimal for real-time RI monitoring for π-PSTFBG-based sensors.

    Histogram of the mean absolute error of prediction results based on machine learning model in three noise scenarios.

    Figure 6.Histogram of the mean absolute error of prediction results based on machine learning model in three noise scenarios.

    C. Spectral Demodulation of TFBG and SPR-TFBG Sensors

    To verify the advantages brought by the unique characteristics and feature enrichment of π-PSTFBG, we prepared a TFBG with similar parameters for comparison. To ensure a fair evaluation, the identical D-CNN model structure and dataset size were adopted. Consequently, as shown in Fig. 3(b), 310 sets of TFBG spectral samples were acquired by OSA for training and testing. The test results are shown in Fig. 7(a); the test accuracy R2 of the D-CNN model is 99.17%, with an MAE of 8.796×104  RIU, indicating good universality and feasibility. On the other hand, the test accuracy achieved by π-PSTFBG surpassed that of TFBG, thus preliminarily validating that the spectral characteristics of the proposed π-PSTFBG sensor are indeed more suitable for spectral demodulation methods based on deep learning.

    Predicted RI results by the well-trained D-CNN model with respect to the labeled truth values: (a) TFBG, (b) SPR-TFBG. (c) Measured transmission spectra at different RIs using SPR-TFBG.

    Figure 7.Predicted RI results by the well-trained D-CNN model with respect to the labeled truth values: (a) TFBG, (b) SPR-TFBG. (c) Measured transmission spectra at different RIs using SPR-TFBG.

    To enhance the intrinsic spectral characteristics of TFBG, it is intuitive to coat gold film on the fiber surface to excite SPR, which leads to a sharp resonance as one sensing feature on the spectrum. In comparison, another TFBG was produced using the same parameters and processes, and then was uniformly coated with a 50 nm thick layer of gold film on the outer surface by magnetron sputtering. Figure 7(c) plots the measured transmission spectrum of SPR-TFBG, showing a noticeable SPR effect. Like the pure TFBG and π-PSTFBG cases, a total of 310 spectral samples were recorded for fair evaluation at different RIs. As a result of the D-CNN model that has the same configuration structure, when tested on an unknown dataset after model convergence, as the result depicted in Fig. 7(b), the model exhibited the test accuracy of 99.26% and an MAE of 8.15×104  RIU, achieving a good but slightly lower test accuracy.

    Table 3 displays the comparative prediction results of TFBG-, SPR-TFBG-, and π-PSTFBG-based RI sensors using the well-trained D-CNN model. Although the same D-CNN structure was employed for these three kinds of sensors, the optimal models with specific parameters were trained separately for each sensor. The prediction results shown in Figs. 5(b), 7(a), and 7(b) reveal that although all three types of sensors show good prediction accuracy, π-PSTFBG clearly maintains an advantage from the comparison.

    Comparison of the Test Results Using the Same Well-Trained D-CNN Model for TFBG-, SPR-TFBG-, and π-PSTFBG-Based Sensors

    SensorR2MSEMAE
    TFBG99.17%1.2902×1068.796×104
    SPR-TFBG99.26%1.1340×1068.15×104
    π-PSTFBG99.67%5.0829×1075.99×104

    π-PSTFBG could achieve superior performance of measuring RIs for both low-concentration and high-concentration NaCl solutions, which is mainly attributed to its inherent phase-shift peaks for all the lossy dips in the full spectrum. These findings indicate that π-PSTFBG possesses enhanced data features with distinct spectral characteristics at various RIs. In addition, we employed a common CNN model without special design to re-evaluate TFBG-, SPR-TFBG-, and π-PSTFBG-based sensors. The achieved accuracies for the three sensors are 97.78%, 98.08%, and 98.36%, respectively, further validating that the intrinsic phase-shift characteristics of π-PSTFBG enhance feature discriminability during model optimization. Consequently, it is more suitable for full spectrum demodulation algorithms based on deep learning, enabling rapid and high-precision demodulation of complex spectra.

    5. REALIZATION AND MEASUREMENT OF REAL-TIME DEMODULATION SYSTEM

    On the basis of the verified feasibility of the proposed full spectrum demodulation approach, it is desirable to investigate its potential of real-time and offline measurement, which is essential for wide application of rapid and portable analysis of RI-based HMI. Utilizing the D-CNN full spectrum demodulation model, a miniature offline demodulation prototype is designed and developed to demonstrate its real-time measurement.

    Figure 8(a) shows the schematic layout of the real-time demodulation system, including a power control unit, a light source module including a super luminescent diode (SLD, Denselight DLCS5169A) and its driver, as well as a data processing module consisting of a spectrometer unit (Ibsen I-MON 512), microprocessor (Raspberry Pi 5, 8 GB), and an LCD screen (LCD1602A). The integrated SLD operates within the wavelength range of 1510–1590 nm, with its temperature and a current controlled by the driver. Particularly for the spectrometer unit, as shown in Fig. 8(b), there is a blazed grating and mirror inside to diffract the broadband light into distinct wavelength components. A photodiode array with 512 pixels is employed to detect the intensity of different wavelengths, forming a full spectrum composed of 512 points and a low resolution of 0.166  nm. In terms of the data processing module, a fast communication connection is established between the spectrometer unit and the microprocessor to get the raw data of the spectrum, which are then directly processed by the trained D-CNN model integrated in the microprocessor, realizing real-time prediction of the spectral data. Due to the light weight of the model, there is no need to integrate other hardware storage units to share the storage pressure of the microprocessor. As a result, the predicted RI value is displayed on the LCD screen in real time. Figure 8(c) shows a prototype of the real-time demodulation system for a π-PSTFBG-based RI sensor. Its size is about 17  cm×12  cm×6  cm and the estimated total cost is 5200$, including the light source and spectrum detector as well as on-board microprocessor. The system power consumption is only 12  W, which is much smaller than that of common spectral demodulators such as OSA or interrogator working with an external PC.

    The compositions of (a) the real-time demodulation system and (b) the spectrometer unit; (c) the prototype of the real-time demodulation system for π-PSTFBG-based RI sensor.

    Figure 8.The compositions of (a) the real-time demodulation system and (b) the spectrometer unit; (c) the prototype of the real-time demodulation system for π-PSTFBG-based RI sensor.

    Although the effectiveness and practicability of the D-CNN model as well as the ability of spectral self-feature enhancement in π-PSTFBG spectra were demonstrated in preceding sections, the spectral data was acquired by large-size OSA, which is not desirable for portable and low-cost sensing systems. To verify the performance of the prototype, we use the system to simultaneously collect transmission spectra of π-PSTFBG for validating the efficiency of the proposed D-CNN model under low-cost hardware conditions. Figure 9(a) displays the measured transmission spectra of π-PSTFBG changing with various RIs of NaCl solution. Similarly, to train the model as a calibration process, the acquired 775 spectral samples by the system were also divided according to the ratio of 6:2:2, altering the input of the network to (None, 1, 512), significantly reducing the data size compared to the data collected by OSA. As shown in Fig. 9(b), the test accuracy of the model is 99.67%, and MAE is 5.44×104  RIU. The well-trained D-CNN model is integrated into the microprocessor of the demodulation system to achieve accurate real-time analysis of the spectrum, which is a kind of delayed reasoning process after the demodulation model gets well trained. Although the impact of normal environmental disturbances on the system is relatively small, the limitations of post-training delay reasoning in real-time demodulation systems make the systems highly vulnerable to problems such as spectral deformation, requiring the sensor to be packaged stably in an attempt to reduce external interferences such as mechanical bending on the fiber during actual measurement.

    (a) Measured transmission spectra of π-PSTFBG collected by a low-resolution spectrometer at different RIs; (b) predicted RI results by well-trained D-CNN model based on the original spectral data of π-PSTFBG obtained via low-resolution interrogator.

    Figure 9.(a) Measured transmission spectra of π-PSTFBG collected by a low-resolution spectrometer at different RIs; (b) predicted RI results by well-trained D-CNN model based on the original spectral data of π-PSTFBG obtained via low-resolution interrogator.

    To assess the feasibility and stability of the proposed real-time demodulation system, a 7-day continuous measurement was conducted using the proposed π-PSTFBG in NaCl solutions with varying RIs. As depicted in Figs. 10(a)–10(g), four groups of NaCl solutions with fixed RIs of 1.3480, 1.3562, 1.3647, and 1.3730 were tested. The duration of each test in 1 day was about 1500 s, during which the number of collected spectra was 3500, meaning that the system took only 0.43  s to process one full spectrum. As illustrated in Fig. 10(a), during the measurement, the RI of the solution was first increased from low to high values, and then decreased. At each time when changing the NaCl solution in the testing container, the container was rinsed with pure water, leading to observable fluctuations between two different RI stages, which is reasonable as the spectrum changes with residual solution in the ambient aqueous environment. To further investigate the influence of pure water flushing, a cycling test was carried out on the NaCl solution with RI of 1.3730 without prior washing of the test container, as shown in stages ①–④ in Fig. 10(a). The cycling test results revealed that the predicted results for the remaining three sets of solutions closely aligned with the actual values except the first group measured after water cleaning. Such cycling tests were repeated on other days, yielding similar results shown in Figs. 10(b)–10(g), thereby demonstrating that the well-trained D-CNN model integrated in the system can also have considerable demodulation performance for the unseen spectral data collected in different time periods, indicating good stability and repeatability of the π-PSTFBG sensor and the real-time demodulation based on full spectral analysis.

    (a)–(g) 7-day continuous measurement using the developed prototype of real-time demodulation assisted by D-CNN model for the NaCl solutions with RIs of 1.3480, 1.3562, 1.3647, and 1.3730. (h) Predicted RIs in a longer duration individually for each solution of 1.3462, 1.3579, 1.3679, and 1.3717. (i) Average predicted RIs with respect to the labeled truth values. (j) Predicted value change curve of real-time demodulation system when a NaCl solution with high RI drops into a NaCl solution with low RI.

    Figure 10.(a)–(g) 7-day continuous measurement using the developed prototype of real-time demodulation assisted by D-CNN model for the NaCl solutions with RIs of 1.3480, 1.3562, 1.3647, and 1.3730. (h) Predicted RIs in a longer duration individually for each solution of 1.3462, 1.3579, 1.3679, and 1.3717. (i) Average predicted RIs with respect to the labeled truth values. (j) Predicted value change curve of real-time demodulation system when a NaCl solution with high RI drops into a NaCl solution with low RI.

    In an attempt to further evaluate the measurement accuracy, repeated tests were carried out using another four groups of NaCl solutions, which have RIs of 1.3462, 1.3579, 1.3679, and 1.3717. During the test in a duration of 15  min, about 2140 RI values, corresponding to different salinities, were predicted in real time according to the spectra for each set of RI solutions. As a result, the predicted results plotted in Fig. 10(h) remain stable responses, giving an average error of 1.6×104  RIU and R2 of 99.9% if compared with the actual values. Figure 10(i) shows the predicted RI relative to the true values, achieving a fitting error of 2.5×109 RIU. The achieved result is much better than the RI detection accuracy of most studies with the detection limits lower than 104  RIU [43,44], such as the machine-learning-based RI detection algorithm proposed by Fasseaux et al. [44] in 2024, which gave a detection limit of 3×105 RIU but a prediction accuracy of only 95% within a 0.01 RIU range.

    Moreover, to further demonstrate the real-time capability of the approach in a view of actual measurement by the prototype, continuous RI measurement was kept in a solution with low RI of 1.3460, and then the RI of the NaCl solution was rapidly changed by adding a drop of NaCl solution with high RI of 1.3798. A video of the real-time RI measurement of the NaCl solution was captured (see Visualization 1), demonstrating a real-time visualization of the measurement process. As shown in Fig. 10(j), at the moment of dropping the higher-RI NaCl solution, the measured RI increases instantaneously, with a response time of less than 1 s. A sharp rise in RI was observed for each drop, which is reasonable due to the instantaneous reaction caused by the grating surface of π-PSTFBG but the NaCl solution is not evenly mixed yet. Then, as the higher-RI solution got diffused along time, the predicted value gradually returned to stable. After several drops of higher-RI solution, the original RI was increased up to 1.370. These promising results pave the way to apply real-time demodulation of the proposed TFBG-based RI sensors without sophisticated processing of the spectrum, further verifying the good stability and capability of fast measurement by a compact and offline demodulation system for HMI detection. It is worth noting that the RI of the NaCl solution is related to temperature [45]. From a practical perspective of RI detection at different temperatures, the spectrum could be offset as a whole by subtracting a certain wavelength shift of the core mode to achieve temperature compensation. It can be rapidly achieved by detecting the wavelength offset of the core mode through the automatic peak-detection algorithm based on the Gaussian fitting model. Then, the compensated spectrum is employed as an input dataset of the D-CNN model to obtain the RI value of the solution after temperature change and realize real-time RI detection with temperature compensated for online. This is mainly attributed to the fact that the influence of temperature on the π-PSTFBG sensor is only reflected in the overall spectral offset and the RI variation changes the shape of the spectrum.

    6. CONCLUSION

    In summary, a new spectral demodulation system of refractive index (RI) parameters based on D-CNN has been proposed and validated using a π-PSTFBG sensor, which enhances the spectral features. The efficacy of the lightweight D-CNN algorithm was evaluated by two sets of spectral data, one with high resolution and the other with low resolution. Experimental results demonstrate that, following adequate training, the D-CNN model could achieve high-speed and high-precision RI demodulation based on full spectral data. The determination coefficient R2 during demodulation exceeded 99.67% for both sets of spectral data, which is higher than the demodulation accuracy of standard TFBG and SPR-TFBG devices, which is 99.17% and 99.26%, respectively. This discrepancy can be attributed to the π-PSTFBG structure that introduces deeper features in the spectrum, thereby enhancing data quality for deep learning algorithms. A prototype integrated with the well-trained D-CNN algorithm with a low-resolution spectrometer was developed, demonstrating capabilities for both offline and real-time measurements. Continuous cycling tests conducted over 7 days confirmed the system’s stability and repeatability, achieving an average error of 1.6×104 RIU. The findings demonstrate that the real-time interrogation approach for TFBG-based RI sensors holds significant potential for applications in rapid demodulation of complex spectra, advancing the development of chemical analysis, HMI detection, as well as point-of-care medical monitoring in a portable manner.

    [29] A. Bekmurzayeva, M. Shaimerdenova, Y. Abukhanov. Detection of tilted fiber Bragg grating fiber-optic sensors with short-term KLT: towards low-cost biosensors. IEEE Sensors, 1-4(2018).

    [41] G. Huang, Z. Liu, L. van der Maaten. Densely connected convolutional networks. 30th IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2261-2269(2017).

    Tools

    Get Citation

    Copy Citation Text

    Ziqi Liu, Chang Liu, Tuan Guo, Zhaohui Li, Zhengyong Liu, "Deep learning assisted real-time and portable refractometer using a π-phase-shifted tilted fiber Bragg grating sensor," Photonics Res. 13, 2202 (2025)

    Download Citation

    EndNote(RIS)BibTexPlain Text
    Save article for my favorites
    Paper Information

    Category: Optical Devices

    Received: Mar. 4, 2025

    Accepted: May. 9, 2025

    Published Online: Jul. 25, 2025

    The Author Email: Zhengyong Liu (liuzhengy@mail.sysu.edu.cn)

    DOI:10.1364/PRJ.561101

    CSTR:32188.14.PRJ.561101

    Topics