Respiration signal restoration method based on PatchTST model
By employing refined data preprocessing and feature mapping in the PatchTST model, the problems of data adaptation and model optimization in the reconstruction of high-resolution physiological waveforms from low-resolution sensor data are solved, achieving efficient and accurate reconstruction of respiratory physiological signals, which is suitable for medical scenarios with limited resources.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-05
- Publication Date
- 2026-03-24
AI Technical Summary
Existing technologies suffer from problems such as insufficient data preprocessing, difficulty in model adaptation, poor training optimization, and inadequate performance evaluation in the process of reconstructing low-resolution sensor data into high-resolution physiological waveforms. These problems result in low reconstruction accuracy and efficiency, failing to meet the needs of real-time clinical monitoring.
The PatchTST model is adopted, and through refined data preprocessing (such as timestamp parsing, missing data imputation, outlier handling), block segmentation and embedding, positional encoding, Transformer encoder block processing and output head projection, combined with standardized training and validation, the model performance evaluation is optimized, a unified dataset is formed and the computational complexity is reduced.
It achieves high-quality reconstruction of respiratory physiological signals, reduces computational resource requirements, improves reconstruction accuracy and generalization ability, is suitable for medical scenarios with limited resources, simplifies the implementation of the technology, and provides reliable clinical data support.
Smart Images

Figure CN121725964A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of respiratory monitoring technology, specifically referring to a respiratory signal restoration method based on the PatchTST model. Background Technology
[0002] Physiological waveform signals (such as airway pressure (Paw), volume (Vol), and flow rate) are core data for respiratory function monitoring, playing an irreplaceable role in medical scenarios such as intensive care, respiratory disease diagnosis, and evaluation of the effectiveness of ventilator-assisted therapy. High-resolution respiratory physiological waveforms can accurately reflect key physiological states of patients, such as respiratory rhythm, airway resistance, and changes in lung volume, serving as an important basis for clinical decision-making.
[0003] In practical applications, limitations such as sensor hardware cost, device portability, and interference from the acquisition environment often limit the acquisition of low-resolution sensor data in medical settings. This type of data cannot directly reflect the detailed features of respiratory physiological waveforms, making it difficult to meet the needs of precise clinical monitoring. Therefore, reconstructing high-resolution respiratory physiological waveforms from low-resolution sensor data has become a key research direction in the field of respiratory monitoring technology.
[0004] In existing technologies, models used for time-series signal reconstruction mostly employ the traditional Transformer architecture. When processing long physiological signals with 3000 or more time steps, these models suffer from high computational costs and excessive memory consumption, failing to efficiently meet the computational demands of real-time clinical monitoring. Furthermore, the original low-resolution input data and high-resolution target waveforms are stored in separate files, leading to issues such as timestamp mismatches, missing data, and outlier interference. Existing preprocessing methods fail to achieve efficient time alignment and refined data cleaning, resulting in poor-quality training datasets that negatively impact reconstruction accuracy. Moreover, overfitting is prone to occur during model training, and performance evaluation often relies on single numerical metrics, lacking a comprehensive evaluation method that combines quantitative and qualitative assessments, making it difficult to fully verify the model's practical application effectiveness.
[0005] Therefore, existing technologies cannot effectively solve problems such as data preprocessing, model adaptation, training optimization, and performance evaluation in the process of reconstructing high-resolution physiological waveforms from low-resolution sensor data. There is an urgent need for a method that can effectively improve the efficiency and accuracy of respiratory physiological signal reconstruction. Summary of the Invention
[0006] The purpose of this invention is to overcome the problems of data preprocessing, model adaptation, training optimization and performance evaluation in the process of reconstructing low-resolution sensor data into high-resolution physiological waveforms, which are not well solved by the existing technology. The invention provides a respiratory signal restoration method based on the Patch TST model that can effectively improve the efficiency and accuracy of respiratory physiological signal reconstruction.
[0007] To achieve the above objectives, the present invention employs the following technical solution: a respiratory signal restoration method based on the PatchTST model, comprising the following steps:
[0008] S1. Read low-resolution sensor input data and high-resolution respiratory physiological waveform target data, perform data cleaning, formatting and time alignment to form a unified dataset;
[0009] S2. Divide the aligned time series data into fixed-length window samples, divide the training set and validation set, and construct a PyTorch data loader after standardizing the data.
[0010] S3. Feature mapping from input signal to target waveform is achieved through block segmentation and embedding, position encoding, Transformer encoder block processing and output head projection.
[0011] S4. Perform model training, initialize the training environment, execute the training and validation loop, save the model checkpoint with the optimal validation loss, and visualize the training process.
[0012] S5. Load the optimal model to infer the test data, reverse convert the prediction results to the original physical units, calculate the performance indicators, and complete the qualitative evaluation through visualization.
[0013] Furthermore, the step S1 of "performing data cleaning, formatting, and time alignment to form a unified dataset" specifically includes the following steps:
[0014] S11. Load the low-resolution input features stored in a TXT file, and perform timestamp parsing, missing data imputation, and outlier handling on the data. Among them, missing data imputation adopts a two-step method of linear interpolation combined with zero-value filling, and outlier handling adopts the interquartile range (IQR) method to prune data points that exceed the range of Q1-1.5IQR to Q3+1.5IQR to the boundary value.
[0015] S12. Load the high-resolution target waveform stored in a CSV file, perform data integrity checks, data flattening, high-resolution timestamp generation, and data cropping, discard the first and last minute of data in the record, and then merge them into the target DataFrame.
[0016] S13. Use the pandas.merge_asof function with a tolerance of 1 second to perform nearest neighbor merging, so as to achieve time alignment between the input features and the target waveform, and discard unmatched rows.
[0017] The “window sample” mentioned in step S2 uses a window with a length of 3000 data points. Non-overlapping windows are generated by sliding with a step size equal to the window length. Each window contains an input matrix of shape (3000, 4) and a target matrix of shape (3000, 3). The dataset is divided into a training set and a validation set in an 80 / 20 ratio. After fitting the training data with StandardScaler, Z-score standardization is performed on the training set and the validation set respectively. The input data and the target data use independent standardizers.
[0018] The "blocking and embedding" in step S3 specifically includes: first dividing the input sequence of shape (3000,4) into 100 non-overlapping patches of length 30, then flattening each patch into a 120-dimensional vector, and then projecting it onto a 128-dimensional feature space through a linear embedding layer.
[0019] The "position encoding" mentioned in step S3 is to generate a position vector using a mathematical formula and add it to the embedded patch token.
[0020] The number of "Transformer encoder block processing" mentioned in step S3 is 8 layers, and each layer contains a multi-head self-attention mechanism and a feedforward neural network.
[0021] The “output head projection” mentioned in step S3 is to project the 128-dimensional vector to 90 dimensions through a linear layer, and then shape the output patch sequence into a complete sequence of (3000,3).
[0022] The "model training" described in step S4 uses mean squared error as the loss function and AdamW as the optimizer, with 600 training iterations. Each epoch includes a training phase and a validation phase. The training phase performs forward propagation, loss calculation, backpropagation, gradient pruning, and weight update, while the validation phase only performs forward propagation and calculates the loss. After each epoch, if the current validation loss is the best in history, the checkpoint containing the model weights, configuration, and normalizer is saved to best_model.pth. After training is completed, a graph showing the change between training loss and validation loss is generated.
[0023] Step S5, which involves "inversely converting the prediction results to the original physical units, calculating the performance metrics, and visualizing the training process," specifically includes the following steps:
[0024] S51. Use the inverse_transform method of scaler_Y to inversely transform the standardized predicted values and the true values back to the original physical units;
[0025] S52. Calculate the mean absolute error and root mean square error as quantitative performance indicators.
[0026] S53. Randomly select 4 test samples, generate a superimposed comparison diagram of the predicted waveform and the actual waveform, and complete the qualitative evaluation.
[0027] Compared with the prior art, the beneficial effects of the present invention are:
[0028] (1) This invention effectively solves the problem of adapting low-resolution input data to high-resolution target waveforms through a refined raw data preprocessing process: it uses a two-step method of "linear interpolation + zero-value filling" to process missing data and the IQR method to prune outliers, which can remove data noise interference and ensure the integrity and accuracy of input features; it uses the "pandas.merge_asof" function to achieve time alignment within a 1-second tolerance and discards unmatched data, which solves the problem of timestamp mismatch caused by recording the two types of data separately; at the same time, it discards unstable data at the beginning and end of the target waveform and generates high-resolution timestamps, further optimizing the quality of target data. The resulting unified dataset provides a high-quality foundation for subsequent waveform reconstruction, enabling the reconstructed airway pressure (Paw), volume (Vol), and flow (Flow) signals to more realistically reflect the patient's respiratory physiological state, providing reliable data support for clinical intensive care and respiratory disease diagnosis.
[0029] (2) The PatchTST model of this invention significantly optimizes the efficiency of traditional Transformer in processing long sequences through the core design of "patch segmentation and embedding": the input sequence of 3000 time steps is divided into 100 non-overlapping patches of length 30, reducing the sequence length from 3000 to 100. Combined with the linear embedding layer projected to the high-dimensional feature space, it effectively avoids the quadratic computational increase problem caused by the computational complexity of self-attention in traditional Transformer. This design enables the model to retain the ability to capture temporal dependencies when processing long-term respiratory signals, while significantly reducing the consumption of computing resources and training / inference time. It can adapt to the computing power requirements for real-time reconstruction of respiratory signals in clinical scenarios and is easy to deploy on conventional medical equipment (such as ordinary GPUs or high-performance CPUs).
[0030] (3) This invention ensures model performance through multi-stage optimization. In the data preparation stage, the training set and validation set are divided into an 80 / 20 ratio, and the method of "fitting the training set with a normalizer and processing the input / target data with dual independent normalizers" is adopted to avoid leakage of validation set information. During the training process, a training-validation loop of 600 epochs is set, and only the model checkpoint with the optimal validation loss is saved to effectively avoid the risk of overfitting. In the performance evaluation stage, the prediction results are inversely converted into the original physical units through "scaler_Y.inverse_transform", and the quantitative indicators of MAE and RMSE are calculated and compared with the generated waveform superimposed to achieve comprehensive verification of accuracy. These designs enable the model to maintain low error on unseen test data, and it can be stably applied to respiratory signal reconstruction in different patients and different acquisition environments. Its generalization ability and accuracy meet the diverse clinical monitoring needs.
[0031] (4) This invention uses low-resolution sensor data (f1_a, f1_b, f2_a, f2_b) as input, without relying on high-cost, high-resolution dedicated physiological signal acquisition equipment, which greatly reduces the requirements for medical hardware and is suitable for deployment in resource-limited scenarios such as primary hospitals and mobile monitoring. At the same time, the model training and inference process is highly standardized (such as fixed window length, unified data loader construction method, and automated checkpoint saving), and the prediction results are presented intuitively through visual comparison charts, with physical units consistent with routine clinical indicators, which facilitates understanding and use by medical staff, reduces the operational threshold for technology implementation, and helps the widespread popularization of accurate respiratory physiological signal monitoring technology. Attached Figure Description
[0032] Figure 1 This is a schematic diagram of the overall process of the present invention. Detailed Implementation
[0033] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0034] Example
[0035] like Figure 1 As shown in the figure, the respiratory signal reconstruction method based on the PatchTST model described in this embodiment includes five steps, S1 to S5. S1: Read low-resolution sensor input data and high-resolution respiratory physiological waveform target data, perform data cleaning, formatting, and time alignment to form a unified dataset. This step is data preprocessing, and its purpose is to construct the unified dataset.
[0036] Specifically, it includes the following steps:
[0037] S11. Load the low-resolution input features stored in a TXT file, and perform timestamp parsing, missing data imputation, and outlier handling on the data. Among them, missing data imputation adopts a two-step method of linear interpolation combined with 0-value filling, and outlier handling adopts the interquartile range method to cut data points that exceed the range of Q1~1.5IQR to Q3+1.5IQR to the boundary value.
[0038] The low-resolution input features include four feature dimensions: f1_a, f1_b, f2_a, and f2_b. f1_a, f1_b, f2_a, and f2_b are the four core input features acquired by the low-resolution sensor, all of which are time-series signals directly related to respiratory physiological activities. Specifically, f1_a and f1_b are acquired from dual-channel signals of a chest and abdominal motion sensor (such as a piezoelectric thin-film sensor or strain gauge sensor), while f2_a and f2_b are acquired from dual-channel signals of a simple airway pressure / airflow sensor (such as a low-cost piezoresistive sensor or thermal flow sensor). These four low-resolution features capture key time-series information about the respiratory process from two dimensions: respiratory motion morphology and basic airway mechanics. The chest and abdominal motion signals (f1_a and f1_b) reflect macroscopic features such as respiratory depth, respiratory rate, and respiratory rhythm; the basic airway pressure / airflow signals (f2_a and f2_b) reflect basic mechanical features such as the pressure difference between inhalation and exhalation and the presence or absence of airflow.
[0039] The above four features work together to form a low-resolution input, providing sufficient respiratory physiological information to support the PatchTST model, enabling it to reconstruct high-resolution airway pressure (Paw), volume (Vol), and flow waveforms through feature mapping.
[0040] The missing data filling adopts a two-step method of linear interpolation combined with zero-value filling. Specifically, it adopts a two-step method of "linear interpolation + zero-value filling". First, linear interpolation is performed on the region with a continuous missing length of ≤5 data points (based on the linear fitting of the effective data points before and after the missing region). Then, zero-value filling is performed on the region with a continuous missing length of >5 data points (to avoid interpolation distortion caused by excessively long missing regions).
[0041] The outlier handling employs the interquartile range (IQR) method. This involves calculating the first quartile (Q1), third quartile (Q3), and IQR = Q3 - Q1 for each feature dimension. Data points exceeding the range [Q1 - 1.5IQR, Q3 + 1.5IQR] are pruned to their corresponding boundary values to remove extreme noise interference. The IQR method is a robust outlier detection and handling method based on data distribution characteristics, used to accurately prune extreme outliers in low-resolution respiratory sensor data, avoiding noise interference with model training. Specifically, it refers to the difference between the third quartile (Q3) and the first quartile (Q1) in the dataset, reflecting the dispersion of the middle 50% of the data. The formula is: IQR = Q3 - Q1. Where, the first quartile (Q1) is the value at the 25th percentile after sorting the data from smallest to largest; the third quartile (Q3) is the value at the 75th percentile after sorting the data from smallest to largest.
[0042] S12. Load the high-resolution target waveform stored in a CSV file, perform data integrity checks, data flattening, high-resolution timestamp generation, and data cropping, discard the first and last minute of data in the record, and then merge them into the target DataFrame.
[0043] This step involves high-resolution target waveform processing, which loads a high-resolution target waveform stored in a CSV file. This high-resolution target waveform includes three physiological dimensions: airway pressure (Paw), volume (Vol), and flow rate (Flow).
[0044] The data integrity check refers to traversing each column of the CSV file and discarding records with column-level missing data (data missing rate of a certain column >10%); data flattening refers to flattening the data rows stored in the CSV file by respiratory cycle into a continuous time series; high-resolution timestamp generation refers to generating continuous timestamps (interval time 0.01 seconds) that correspond one-to-one with the data points based on the sampling frequency (100Hz) of the target waveform; data pruning refers to discarding the first and last 1 minutes of unstable data in each record (due to sensor instability at the beginning of acquisition, or possible equipment power failure / patient movement interference at the end of recording), and merging the processed data into a unified target DataFrame.
[0045] S13. Use the pandas.merge_asof function with a tolerance of 1 second to perform nearest neighbor merging, so as to achieve time alignment between the input features and the target waveform, and discard unmatched rows.
[0046] This step involves time alignment and data merging. The pandas.merge_asof function is a key-based ordered merging function. This step uses the timestamp of the low-resolution input features as a reference, sets a tolerance threshold of 1 second, and performs nearest neighbor merging to achieve time alignment between the input features and the target waveform. After merging, unmatched rows (data outside the tolerance) are discarded, and finally a unified dataset containing the input features and the target waveform is formed.
[0047] After completing step S1, proceed to step S2: divide the aligned time series data into fixed-length window samples, divide the training set and validation set, standardize the data, and then build a PyTorch data loader.
[0048] This step involves building a model training data loader. Window sample generation refers to using a window of 3000 data points, sliding it with a step size equal to the window length to generate non-overlapping windows. Each window contains an input matrix of shape (3000, 4) and a target matrix of shape (3000, 3). The 3000 data points correspond to a 30-second respiratory signal, containing 3-5 complete respiratory cycles. The input matrix of shape (3000, 4) is a matrix composed of 3000 time steps × 4 input features. Similarly, the target matrix of shape (3000, 3) is a matrix composed of 3000 time steps × 3 physiological waveform dimensions.
[0049] The division of the training and validation sets refers to randomly dividing the generated window samples into two groups at an 80 / 20 ratio, thus forming the training and validation sets. That is, the training set accounts for 80% of the total window samples, and the validation set accounts for 20%. At the same time, it is necessary to ensure that there is no data overlap between the training and validation sets.
[0050] The process of standardizing the data and then building a PyTorch data loader involves using StandardScaler to fit the training data, followed by Z-score standardization on both the training and validation sets, with independent standardizers used for the input and target data. Based on the PyTorch framework, a custom Dataset class is built to read the standardized training and validation data. A batch data loader is then constructed using torch.utils.data.DataLoader, with a batch size of 32, supporting parallel data reading during training. torch.utils.data.DataLoader is the core data loading utility class provided by the PyTorch deep learning framework, enabling batch, efficient, and parallel reading of training / validation data.
[0051] Step S3: Through block segmentation and embedding, position encoding, Transformer encoder block processing and output head projection, feature mapping from input signal to target waveform is achieved.
[0052] The “blocking and embedding” step specifically includes: first, dividing the input sequence of shape (3000,4) into 100 non-overlapping patches of length 30, then flattening each patch into a 120-dimensional vector, and projecting it onto a 128-dimensional feature space through a linear embedding layer.
[0053] The aforementioned "position encoding" involves generating a position vector using a mathematical formula and adding it to the embedded patch token. The mathematical formula is: PE(pos,2i)=sin(pos / 10000) 2i / d_model ), PE(pos,2i+1)=cos(pos / 10000 2i / d _model The position pos is the position of the patch in the sequence (0-99), i is the dimension index (0-63), and d_model=128 is the embedding dimension; the generated position vector is added element-wise to the embedded patch sequence to obtain a feature sequence containing position information.
[0054] The "Transformer encoder block processing" consists of 8 layers, each containing a multi-head self-attention mechanism and a feedforward neural network. In this embodiment, the Transformer encoder block processing is the core feature extraction step in the PatchTST model to achieve the mapping of low-resolution input features to high-resolution respiratory waveform features, and it is a key step connecting the "position-encoded patch sequence" and the "output head projection". The Transformer EncoderBlock is the basic unit of the Transformer architecture, a modular feature processing structure containing a multi-head self-attention mechanism, a feedforward neural network, residual connections, and layer normalization. In this embodiment, by stacking 8 layers of this encoder block, deep feature extraction is performed on the embedded patch sequence (100×128 dimensions) containing position information, capturing the temporal dependencies and physiological feature associations between respiratory signal patches, and outputting a high-level feature sequence that can characterize the high-resolution waveform.
[0055] The so-called "output head projection" involves projecting a 128-dimensional vector to 90 dimensions through a linear layer, and then shaping the output patch sequence into a complete sequence of (3000, 3).
[0056] S4. Perform model training, initialize the training environment, execute the training and validation loop, save the model checkpoint with the optimal validation loss, and visualize the training process.
[0057] This step involves training optimization and model saving. In this embodiment, "model training" uses mean squared error as the loss function and AdamW as the optimizer, with 600 training iterations. Each epoch includes a training phase and a validation phase. The training phase performs forward propagation, loss calculation, backpropagation, gradient pruning, and weight updates, while the validation phase only performs forward propagation and calculates the loss. After each epoch, if the current validation loss is the best historically, the checkpoint containing the model weights, configuration, and normalizer is saved to best_model.pth. After training is completed, a graph showing the change between training loss and validation loss is generated.
[0058] S5. Load the optimal model to infer the test data, reverse convert the prediction results to the original physical units, calculate the performance indicators, and complete the qualitative evaluation through visualization.
[0059] This step involves model inference and performance evaluation. Specifically, "after inversely converting the prediction results to the original physical units, calculating performance metrics, and visualizing the training process" includes the following steps:
[0060] S51. Use the inverse_transform method of scaler_Y to inversely transform the standardized predicted values and the true values back to the original physical units.
[0061] This step involves inversely converting the standardized target waveform data predicted by the model back to the original physical units of respiratory physiological waveforms, which is a prerequisite for quantitative / qualitative assessment. The scaler_Y is a StandardScaler normalizer built for high-resolution target waveforms (Paw, Vol, Flow) (fitted only based on the training set target data); inverse_transform is the inverse transformation method provided by the StandardScaler class, whose core function is to undo the Z-score normalization operation, restoring the dimensionless standardized values to clinically meaningful original physical units (such as airway pressure Paw: cmH2O, volume Vol: mL, flow rate Flow: L / min), allowing the model prediction results to be directly compared and evaluated with the actual physiological waveforms.
[0062] S52. Calculate the Mean Absolute Error (MAE) and Root Mean Square Error (RMSE) as quantitative performance indicators. The MAE and RMSE are core quantitative performance indicators for evaluating the accuracy of respiratory physiological waveform reconstruction, used to quantify the numerical deviation between the high-resolution waveform predicted by the model and the actual waveform. The MAE reflects the average absolute deviation between the predicted and actual values; a smaller value indicates a smaller overall deviation in the reconstructed waveform. The RMSE is calculated by taking the square root of the mean of the squared errors between the predicted and actual values; it is more sensitive to extremely large errors (such as reconstruction deviations caused by sudden changes in airway pressure); a smaller value indicates better stability of the reconstructed waveform.
[0063] S53. Randomly select 4 test samples, generate a superimposed comparison diagram of the predicted waveform and the actual waveform, and complete the qualitative evaluation.
[0064] This step generates a superimposed comparison image of the predicted waveform and the actual waveform, completing the qualitative assessment. It is a core visual qualitative assessment method for the model reconstruction effect and a supplement to quantitative indicators (MAE / RMSE). This operation uses data visualization to superimpose and display the high-resolution respiratory physiological waveform predicted by the model (inversely converted to the original physical units) with the actual waveform, evaluating the reconstruction effect from the dimension of "visual fit." Unlike the "numerical quantification" of MAE / RMSE, this method focuses on core clinical characteristics such as waveform trend consistency, peak / trough matching degree, and respiratory cycle synchronicity, directly adapting to the interpretation habits of medical staff for respiratory waveforms.
[0065] As described above, the present invention can be well implemented.
Claims
1. A respiratory signal reconstruction method based on the PatchTST model, characterized in that, Includes the following steps: S1. Read low-resolution sensor input data and high-resolution respiratory physiological waveform target data, perform data cleaning, formatting and time alignment to form a unified dataset; S2. Divide the aligned time series data into fixed-length window samples, divide the training set and validation set, and construct a PyTorch data loader after standardizing the data. S3. Feature mapping from input signal to target waveform is achieved through block segmentation and embedding, position encoding, Transformer encoder block processing and output head projection. S4. Perform model training, initialize the training environment, execute the training and validation loop, save the model checkpoint with the optimal validation loss, and visualize the training process. S5. Load the optimal model to infer the test data, reverse convert the prediction results to the original physical units, calculate the performance indicators, and complete the qualitative evaluation through visualization.
2. The respiratory signal reconstruction method based on the PatchTST model according to claim 1, characterized in that, Step S1, which involves "cleaning, formatting, and time-aligning the data to form a unified dataset," specifically includes the following steps: S11. Load the low-resolution input features stored in a TXT file, and perform timestamp parsing, missing data imputation, and outlier handling on the data. Among them, missing data imputation adopts a two-step method of linear interpolation combined with 0-value filling, and outlier handling adopts the interquartile range method to prune data points that exceed the range of Q1-1.5IQR to Q3+1.5IQR to the boundary value. S12. Load the high-resolution target waveform stored in a CSV file, perform data integrity checks, data flattening, high-resolution timestamp generation, and data cropping, discard the first and last minute of data in the record, and then merge them into the target DataFrame. S13. Use the pandas.merge_asof function with a tolerance of 1 second to perform nearest neighbor merging, so as to achieve time alignment between the input features and the target waveform, and discard unmatched rows.
3. The respiratory signal reconstruction method based on the PatchTST model according to claim 1, characterized in that, The "window sample" mentioned in step S2 uses a window with a length of 3000 data points. Non-overlapping windows are generated by sliding with a step size equal to the window length. Each window contains an input matrix of shape (3000, 4) and a target matrix of shape (3000, 3). The dataset is divided into a training set and a validation set in an 80 / 20 ratio. After fitting the training data with StandardScaler, Z-score standardization is performed on the training set and the validation set respectively. The input data and the target data use independent standardizers.
4. The respiratory signal reconstruction method based on the PatchTST model according to claim 1, characterized in that, The "blocking and embedding" in step S3 specifically includes: first dividing the input sequence of shape (3000,4) into 100 non-overlapping patches of length 30, then flattening each patch into a 120-dimensional vector, and then projecting it onto a 128-dimensional feature space through a linear embedding layer.
5. The respiratory signal reconstruction method based on the PatchTST model according to claim 4, characterized in that, The "position encoding" mentioned in step S3 is to generate a position vector using a mathematical formula and add it to the embedded patch token.
6. The respiratory signal reconstruction method based on the PatchTST model according to claim 5, characterized in that, The "Transformer encoder block processing" mentioned in step S3 consists of 8 layers, each containing a multi-head self-attention mechanism and a feedforward neural network.
7. The respiratory signal reconstruction method based on the PatchTST model according to claim 6, characterized in that, The "output head projection" mentioned in step S3 involves projecting a 128-dimensional vector to 90 dimensions through a linear layer, and then shaping the output patch sequence into a complete sequence of (3000,3).
8. The respiratory signal reconstruction method based on the PatchTST model according to claim 7, characterized in that, The "model training" described in step S4 uses mean squared error as the loss function and AdamW as the optimizer. The training iterations are 600 epochs. Each epoch includes a training phase and a validation phase. The training phase performs forward propagation, loss calculation, back propagation, gradient pruning, and weight update. The validation phase only performs forward propagation and calculates the loss. After each epoch, if the current validation loss is the best in history, the checkpoint containing the model weights, configuration, and normalizer is saved to best_model.pth. After training is completed, a graph showing the changes in training loss and validation loss is generated.
9. A respiratory signal reconstruction method based on the PatchTST model according to claim 8, characterized in that, Step S5, which involves "inversely converting the prediction results to the original physical units, calculating the performance metrics, and visualizing the training process," specifically includes the following steps: S51. Use the inverse_transform method of scaler_Y to inversely transform the standardized predicted values and the true values back to the original physical units; S52. Calculate the mean absolute error and root mean square error as quantitative performance indicators. S53. Randomly select 4 test samples, generate a superimposed comparison diagram of the predicted waveform and the actual waveform, and complete the qualitative evaluation.
Citation Information
Cited By
Non-contact respiratory mechanics reverse reconstruction system based on 4D holographic field perception
CN121997843A