Nondestructive rapid detection method for food deterioration based on electronic nose and pattern recognition
By combining moving average filtering, baseline correction, linear normalization preprocessing, and multidimensional feature extraction with a CNN model and channel attention mechanism, the problems of signal interference and insufficient feature extraction in electronic nose detection methods are solved, enabling accurate and rapid detection of food spoilage.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHENGDU VOCATIONAL COLLEGE OF AGRI SCI & TECH
- Filing Date
- 2026-02-26
- Publication Date
- 2026-05-19
AI Technical Summary
Existing electronic nose-based food spoilage detection methods suffer from problems such as imperfect signal preprocessing, limited feature extraction dimensions, poor adaptability of pattern recognition models, and insufficient detection versatility and specificity, making it difficult to achieve accurate and rapid food spoilage detection.
A preprocessing workflow of moving average filtering, baseline correction, and linear normalization is adopted. Combined with time domain, frequency domain, and trend feature extraction, a multidimensional feature vector is constructed. Then, through a CNN model, channel attention mechanism, and dropout layer pattern recognition method, the accurate classification and identification of food spoilage status is achieved.
It achieves non-destructive and rapid detection, is suitable for different types of food, has a short detection cycle, high signal interference removal rate, improved feature recognition, and improved accuracy of graded identification, making it suitable for on-site application scenarios.
Smart Images

Figure CN121744102B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of non-destructive testing technology for food, and particularly relates to a rapid non-destructive testing method for food spoilage based on electronic nose and pattern recognition. Background Technology
[0002] Food is prone to spoilage during storage, transportation, and sales due to factors such as temperature, humidity, and microbial activity. Spoiled food not only loses its original nutritional value and flavor but may also pose health risks due to the accumulation of volatile harmful substances (such as amines, aldehydes, and acids), resulting in significant waste of food resources and economic losses. Therefore, achieving rapid, accurate, and non-destructive detection of food spoilage is of great practical significance for ensuring food safety, optimizing food supply chain management, and reducing resource waste.
[0003] Currently, food spoilage detection methods are mainly divided into two categories: traditional detection methods and rapid detection methods. Traditional detection methods include sensory evaluation methods, physicochemical analysis methods, and microbiological detection methods. Among them, sensory evaluation methods rely on the sensory judgment of professionals, such as smell and sight. They are simple to operate but highly subjective, have poor repeatability, are easily affected by individual differences and environmental factors, and are difficult to achieve quantitative detection. Physicochemical analysis methods (such as high-performance liquid chromatography and gas chromatography-mass spectrometry) can accurately detect the content of spoilage characteristic components, with high detection accuracy and good stability. However, they are complex to operate, have long detection cycles (usually several hours to several days), expensive instruments and equipment, and rely on professional operators, which cannot meet the needs of rapid on-site detection. Microbiological detection methods determine the degree of spoilage by culturing and counting the number of spoilage microorganisms in food. The detection cycle is long (24-72 hours), making it difficult to adapt to real-time detection scenarios.
[0004] To overcome the shortcomings of traditional methods, rapid detection technologies have emerged. Electronic nose detection technology, due to its advantages of being non-destructive, rapid, and easy to operate, has gained widespread attention in the field of food spoilage detection. The electronic nose responds to volatile odor components released by food through a sensor array, and combines this with pattern recognition algorithms to determine the spoilage status. It requires no destructive treatment of the sample, and the detection cycle can be shortened to several minutes. However, existing electronic nose-based detection methods still have many shortcomings: First, the signal preprocessing process is imperfect, often employing single filtering or normalization methods, which are insufficient to simultaneously eliminate the combined interference from high-frequency noise, baseline drift, and sensor range differences, resulting in low signal purity and affecting the accuracy of subsequent feature extraction. Second, the feature extraction dimension is singular, often focusing only on time-domain features while ignoring frequency-domain features and signal trend features, failing to comprehensively characterize the dynamic changes of volatile components during food spoilage, and resulting in insufficient feature recognition. Third, the pattern recognition model has poor adaptability; traditional CNN models lack specificity in feature weight allocation, are susceptible to redundant feature interference, and suffer from overfitting, leading to low accuracy in identifying mildly spoiled samples, making it difficult to meet the needs of precise grading detection. Fourth, the detection method lacks a balance between universality and specificity, with insufficient adjustments for the differences in spoilage characteristics among different food categories, limiting its applicability.
[0005] Therefore, developing an electronic nose and pattern recognition fusion detection method that can effectively eliminate multi-source interference, comprehensively extract features, accurately classify and identify, and is adaptable to different types of food has become an urgent technical problem to be solved in the field of non-destructive rapid detection of food spoilage. Summary of the Invention
[0006] The purpose of this invention is to provide a non-destructive rapid detection method for food spoilage based on electronic nose and pattern recognition, which can effectively eliminate multi-source interference, comprehensively extract features, accurately classify and identify food spoilage, and is adaptable to the electronic nose and pattern recognition fusion detection of different types of food.
[0007] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0008] A rapid, non-destructive method for detecting food spoilage based on electronic nose and pattern recognition includes the following steps:
[0009] S1: After pre-processing the food to be tested, cut the sample into uniform block structures of a preset size, place them in a sealed testing container, and place them in a constant temperature environment for a preset time to allow the volatile odor components released by the sample to reach a stable concentration in the sealed space.
[0010] S2: Seal the sealed detection container to the sample inlet of the electronic nose detection system, turn on the electronic nose detection system to dynamically adsorb and detect the volatile odor components in the sealed space, and collect the response signals of each sensor in the sensor array in real time to obtain the original odor response signal sequence.
[0011] S3: Remove high-frequency noise from the original odor response signal sequence, eliminate baseline shift caused by initial sensor drift and environmental interference, and normalize the calibrated signal sequence to obtain a preprocessed standardized signal sequence.
[0012] S4: Based on the standardized signal sequence, extract time-domain features, frequency-domain features and trend features. The three types of features are spliced together in a preset order to obtain the odor feature vector of the sample to be tested.
[0013] S5: Input the extracted odor feature vector into the pre-trained pattern recognition model, classify and recognize the feature vector, and output the spoilage state and spoilage level of the food sample to be tested.
[0014] Preferably, the specific process of step S2 is as follows:
[0015] S21: Before detection, the electronic nose sensor array of the electronic nose detection system is activated, and the sealed detection container is sealed and connected to the sample inlet of the electronic nose detection system through a polytetrafluoroethylene sealing gasket.
[0016] S22: Activate the electronic nose detection system and configure the carrier gas flow rate, total detection time, and sensor array response stability judgment threshold according to preset parameters;
[0017] S23: The system collects the electrical response data of each sensor in the array in real time at a set time interval, forming a multi-channel raw response data sequence that changes with the detection time, i.e., the raw odor response signal sequence;
[0018] S24: When the response signal of each sensor in the sensor array does not exceed the set threshold in the fluctuation amplitude of multiple consecutive data points, it is determined that the response has reached a stable state and the data acquisition is stopped.
[0019] Preferably, the specific process of step S3 is as follows:
[0020] S31: Moving average filtering noise reduction: The leading edge, middle segment and trailing edge of the original odor response signal sequence are filtered separately;
[0021] S32: Baseline Correction: Using the initial first 10 seconds of data from the filtered signal sequence as a reference, calculate the average signal value within this time period as the baseline value B; subtract the baseline value B from each data point in the filtered signal sequence to obtain the baseline-calibrated signal sequence;
[0022] S33: Normalization processing: The baseline-calibrated signal sequence Z is mapped to the [0,1] interval using a linear normalization method to obtain a standardized signal sequence.
[0023] Preferably, the specific process of step S4 is as follows:
[0024] S41: Extracting temporal features: Based on the temporal response patterns of standardized signal sequences, five core temporal features are extracted;
[0025] S42: Extracting Frequency Domain Features: The standardized signal sequence is transformed from the time domain to the frequency domain using Fast Fourier Transform to extract the frequency dimension features of the signal and eliminate redundant interference in the time domain signal.
[0026] S43: Extracting Trend Features: Based on data from the stable signal phase, linear fitting is performed using the least squares method to uncover the changing trend after the signal stabilizes.
[0027] S44: Feature Vector Construction: The extracted time-domain features, frequency-domain features, and trend features are concatenated in a preset order of time-frequency-trend to form a single-channel odor feature vector; after extracting feature vectors from the multi-channel standardized signal sequences, they are fused in channel order to form a multi-channel comprehensive odor feature vector.
[0028] Preferably, the time-domain features extracted in step S41 include:
[0029] signal peak s max : Traverse the normalized signal sequence S and extract the maximum value as the signal peak value;
[0030] Peak occurrence time t max Record signal peak value s max Corresponding acquisition time t max ;
[0031] signal rising edge slope k up Using the baseline value B from step S3 as a reference, determine the signal from 0.2. s max Rise to 0.8 s max Time interval [ t a ,t b ], corresponding to the signal value range [ s a ,s b The slope is calculated using a linear regression algorithm.
[0032] Average value during signal stabilization phase Based on the S2 sensor response stability threshold, the signal stability phase is determined as […]. t c [,N], t c Calculate the average signal value during the initial time when the signal first fluctuates for 10 consecutive data points ≤ the response stability judgment threshold.
[0033] Signal integration area A: The area enclosed by the standardized signal sequence and the time axis during the entire detection cycle is calculated using the trapezoidal integration method, reflecting the total content of volatile components.
[0034] Preferably, the frequency domain feature extraction process in step S42 is as follows:
[0035] Signal preprocessing: The standardized signal sequence is padded with zeros to a length closest to the power of N.
[0036] Fast Fourier Transform: Performing an FFT operation on a zero-padded sequence yields a frequency domain signal in complex form;
[0037] Amplitude spectrum calculation: The frequency domain amplitude spectrum is obtained by taking the modulus of the frequency domain signal F;
[0038] Main frequency component extraction: Sort the amplitude spectrum in descending order and extract the frequency components corresponding to the top 5 largest amplitude values. f 1, f 2,..., f 5) and the corresponding amplitudes (A1, A2, ..., A5) constitute the frequency domain characteristic parameter set.
[0039] Preferably, the process of extracting trend features in step S43 is as follows:
[0040] S431: Model Construction: Let the linear fitting equation for the steady-state data be:
[0041] ;
[0042] in, Signal stabilization phase i Fitted values for each data point a To fit the slope of the straight line, b The intercept;
[0043] S432: Solving for fitting parameters: Minimizing the sum of squared fitting errors using the least squares method.
[0044] The slope *a* and intercept *b* are obtained by solving the problem. The formula for calculating the slope *a* is:
[0045] ;
[0046] Among them, molecules This is the covariance-related term in the least squares method, reflecting the index. i Compared with actual signal value s i The degree of linear correlation ensures the accuracy of slope calculation;
[0047] denominator This is a variance-related calculation term in the least squares method, to avoid invalid solutions with zero denominators and ensure the stability of the slope solution;
[0048] S433: Goodness of fit R 2 Calculation: Reflects the degree of fit between the fitted line and the actual data; the formula is:
[0049] .
[0050] Preferably, in step S5, the pattern recognition model uses a convolutional neural network as its basic framework, adds a channel attention mechanism module to optimize feature weight allocation, embeds a dropout layer to suppress overfitting, and the overall structure is designed progressively as input layer - attention mechanism layer - convolutional layer - pooling layer - dropout layer - fully connected layer - output layer:
[0051] The specific process by which pattern recognition models classify and identify feature vectors is as follows:
[0052] S51: The odor feature vector X is reshaped in dimension through the input layer and converted into a two-dimensional feature map format that is adapted to the CNN input;
[0053] S52: The channel attention mechanism is introduced through the attention mechanism module to assign weights to the channel features of the input feature map, strengthen the channel weights that are strongly correlated with the deteriorated feature components, and weaken redundant interference features.
[0054] S53: The two-dimensional convolutional kernel of the convolutional layer is used to extract features from the weighted feature map and capture the local correlation information in the feature vector.
[0055] S54: Max pooling is used in the pooling layer to downsample the convolutional feature map, retaining core features and reducing data dimensionality, thus reducing the computational cost of the model.
[0056] S55: The dropout layer embedded after the pooling layer inhibits model overfitting by randomly deactivating some neurons;
[0057] S56: Flatten the pooled feature map into a one-dimensional feature vector through a fully connected layer;
[0058] S57: The output of the fully connected layer is converted into a probability distribution of four types of results by using the Softmax activation function in the output layer. The four types of results are no degradation, slight degradation, moderate degradation, and severe degradation.
[0059] The beneficial effects of this invention include:
[0060] 1. Achieve non-destructive and rapid detection, adaptable to various on-site application scenarios: The entire process requires no destructive treatment of food samples. Detection is completed simply by collecting the volatile odor components released from the sample. The entire detection cycle, from sample pretreatment to result output, takes no more than 15 minutes, significantly improving detection efficiency compared to traditional physicochemical analysis and microbiological detection methods. Furthermore, the electronic nose detection system is compact, easy to operate, and requires no professional operators. It is suitable for various on-site detection scenarios such as food production workshops, supermarkets, and cold chain transportation, solving the pain point of traditional methods' inability to perform real-time detection.
[0061] 2. A progressive preprocessing workflow of moving average filtering for noise reduction, baseline correction, and linear normalization is adopted. Segmented filtering algorithms are used for the early, middle, and late edge regions of the signal sequence to avoid edge signal distortion and effectively eliminate high-frequency noise interference. The average value of the initial 10 seconds of signal is used as the baseline for correction, eliminating baseline shifts caused by sensor drift, temperature fluctuations, and carrier gas interference. Linear normalization eliminates differences in the measurement ranges of different sensors, uniformly mapping the standardized signal to the [0,1] interval. This multi-step collaborative processing ensures high purity and high consistency of the output signal, providing an accurate data foundation for subsequent feature extraction and pattern recognition. Compared to a single preprocessing method, the signal interference removal rate is improved.
[0062] 3. Multi-dimensional Feature Fusion Extraction Enhances Feature Recognition and Comprehensiveness: Breaking through the limitations of existing single-dimensional feature extraction, a three-dimensional feature extraction system encompassing time domain, frequency domain, and trend domain is constructed. Time domain features capture the dynamic adsorption-stabilization process of volatile components by the sensor; frequency domain features mine signal frequency dimension information through FFT transformation, eliminating temporal redundancy interference; and trend features reflect the continuous release characteristics of volatile components after stabilization. These three types of features, totaling 17 parameters, collaboratively characterize the food spoilage pattern. Simultaneously, feature weight ratios are adjusted for different food categories to strengthen the feature responses corresponding to specific spoilage components, significantly improving the recognition of feature vectors and providing support for the accurate identification of mildly spoiled samples. Compared to single-time domain feature extraction, feature discrimination is significantly improved.
[0063] 4. Accurate hierarchical recognition through pattern recognition model: A model employing CNN + channel attention mechanism + dropout layer is used. The channel attention mechanism adaptively assigns weights to multi-dimensional features, strengthening the channel weights corresponding to the deteriorated feature components and weakening redundant interference features. The dropout layer randomly deactivates some neurons, effectively suppressing model overfitting and improving generalization ability. The model outputs four categories: "undeteriorated - slightly deteriorated - moderately deteriorated - severely deteriorated," achieving accurate hierarchical classification of deterioration degree. After training, the model achieves high classification accuracy for the four deterioration levels. Compared to traditional CNN models, the hierarchical recognition accuracy is improved, solving the problem of insufficient accuracy in recognizing slightly deteriorated samples in existing models. Attached Figure Description
[0064] Figure 1 This is a flowchart illustrating the non-destructive rapid detection method for food spoilage based on electronic nose and pattern recognition according to the present invention.
[0065] Figure 2 This is a schematic diagram of the electronic nose odor signal acquisition process of the present invention.
[0066] Figure 3 This is a schematic diagram of the architecture of the pattern recognition model of the present invention. Detailed Implementation
[0067] The following is in conjunction with the appendix Figures 1-3 The present invention will be further described in detail below:
[0068] Example 1
[0069] See appendix Figure 1 As shown, a non-destructive rapid detection method for food spoilage based on electronic nose and pattern recognition includes the following steps:
[0070] S1: Food sample pretreatment: Select the food sample to be tested, remove impurities and non-edible parts from the sample surface, cut the sample into uniform blocks of a preset size, place them in a sealed test container, and place them in a constant temperature environment for a preset time to allow the volatile odor components released by the sample to reach a stable concentration in the sealed space; the temperature difference between the constant temperature environment and the conventional storage temperature of the food to be tested shall not exceed ±2℃, the equilibration time shall be 15-30min, and the volume ratio of the sealed test container to the sample mass shall be (5-8):1 mL / g.
[0071] S2: Electronic nose odor signal acquisition: The balanced sealed detection container is sealed and connected to the inlet of the electronic nose detection system. The electronic nose detection system is turned on, and the carrier gas flow rate is set to 50-100 mL / min, the detection time is 300-600 s, and the sensor array response stability judgment threshold is ±0.002V. The volatile odor components in the sealed space are dynamically adsorbed and detected by the electronic nose sensor array. The response signals of each sensor in the sensor array are collected in real time to obtain the original odor response signal sequence. The electronic nose sensor array contains at least 8 gas sensors with different sensitive materials, which have specific responses to volatile deterioration characteristic components of aldehydes, ketones, amines, and acids.
[0072] S3: Raw signal preprocessing: The raw odor response signal sequence is preprocessed. First, high-frequency noise in the signal is removed by moving average filtering, with the sliding window size set to 5-10 data points. Then, the baseline correction algorithm is used to eliminate the baseline offset caused by initial sensor drift and environmental interference. The average value of the signal in the first 10 seconds of detection is used as the baseline value to perform baseline calibration on the entire response signal sequence. Finally, the calibrated signal sequence is normalized to map the signal value to the [0,1] interval to obtain the preprocessed standardized signal sequence.
[0073] S4: Odor Feature Parameter Extraction: Based on the standardized signal sequence, three types of feature parameters are extracted to construct a feature vector: First, time-domain feature parameters, including signal peak value, peak occurrence time, signal rise slope, average value of the signal stable phase, and signal integral area; second, frequency-domain feature parameters, by converting the standardized signal sequence to the frequency domain through Fast Fourier Transform, and extracting the first 5 main frequency components and corresponding amplitudes of the frequency domain amplitude spectrum; third, trend feature parameters, by linearly fitting the data of the signal stable phase using the least squares method, and extracting the slope and goodness of fit of the fitted line; the three types of feature parameters are concatenated in a preset order to obtain the odor feature vector of the sample to be tested.
[0074] S5: Pattern Recognition and Spoilage Judgment: The odor feature vector extracted in step S4 is input into a preset pattern recognition model. The model classifies and recognizes the feature vector and outputs the spoilage state and spoilage level of the food sample to be tested. The pattern recognition model is based on a convolutional neural network (CNN) framework. An attention mechanism module is introduced to assign weights to the extracted odor feature parameters, strengthen the feature weights corresponding to the spoilage feature components, and use a dropout layer to suppress model overfitting. The input of the model is the odor feature vector constructed in step S4, and the output is four categories of results: "not spoiled", "slightly spoiled", "moderately spoiled" and "severely spoiled".
[0075] The training process of the pattern recognition model is as follows: Select standard samples of the same category as the food to be detected, collect odor feature vectors of standard samples at different stages of spoilage according to the methods in steps S1-S4, construct a standard feature dataset, divide the standard feature dataset into training set, validation set and test set in a ratio of 7:2:1, input it into the initial CNN model, set the learning rate to 0.001-0.01, the number of iterations to 50-100, and the batch size to 16-32, train the model with the training set and optimize the model parameters with the validation set, and verify the model performance with the test set. When the classification accuracy of the model is not less than 95%, the model training is considered complete and it is used as the preset pattern recognition model.
[0076] In this embodiment, see Figure 2 As shown, the specific process of step S2 is as follows:
[0077] S21: Pre-testing preparation: Before testing, activate the electronic nose sensor array of the electronic nose detection system at a temperature of 150-200℃ for 30-60 minutes to ensure the sensor array is in a stable working state. After temperature equilibration (within ±2℃ of the normal food storage temperature, equilibration time 15-30 minutes), seal the sealed testing container to the sample inlet of the electronic nose detection system using a PTFE gasket to prevent leakage of volatile odor components and ensure the stability of the concentration in the sealed space and the accuracy of the detection.
[0078] S22: Detection parameter setting: Turn on the electronic nose detection system and configure it according to the preset parameters: carrier gas flow rate 50-100mL / min, total detection time 300-600s, sensor array response stability judgment threshold ±0.002V. The electronic nose sensor array contains at least 8 gas sensors with different sensitive materials, which have specific responses to volatile deterioration characteristic components of aldehydes, ketones, amines, and acids, and can specifically capture the signals of key odor components of food spoilage.
[0079] S23: Dynamic Adsorption and Signal Acquisition: The carrier gas carries volatile odor components that have reached a stable concentration within the sealed space and continuously flows through the electronic nose sensor array. The sensor's sensitive material undergoes specific adsorption with different odor components, causing corresponding changes in the sensor's electrical properties (including resistance, capacitance, and voltage). The system acquires the electrical response data of each sensor in the array in real time at set time intervals, forming a multi-channel raw response data sequence that changes with detection time, i.e., the raw odor response signal sequence.
[0080] S24: Signal endpoint determination: When the fluctuation amplitude of the response signal of each sensor in the sensor array does not exceed the set threshold ±0.002V in multiple consecutive data points, the response is determined to have reached a stable state, and data acquisition is stopped. The original odor response signal sequence after acquisition is directly sent to step S3 for moving average filtering, baseline correction, and normalization preprocessing to achieve data linkage between the preceding and following steps.
[0081] Example 2
[0082] Based on Example 1, the specific process of step S3 is as follows:
[0083] S31: Moving average filtering for noise reduction:
[0084] Sequence front edge: 1≤ i ≤[ k The filtering formula for [ / 2] is as follows:
[0085] ;
[0086] in, y i Let i be the signal value of the i-th data point in the filtered signal sequence. i For the data point index of the signal sequence, k The sliding window size, ranging from 5 to 10, is an odd number, adapted to the S2 detection duration and acquisition frequency. k / 2] is for k / 2 rounded down x j The original odor response signal sequence is the first... j The signal values of each data point.
[0087] Middle segment of sequence: [ k / 2]≤ i ≤ N -[ k [ / 2], the filtering formula is as follows:
[0088] .
[0089] Sequence back edge: N−[k / 2]≤i≤N, the filtering formula is as follows:
[0090] .
[0091] S32: Baseline Correction: To eliminate baseline offset caused by initial drift of the electronic nose sensor, ambient temperature fluctuations, and carrier gas interference, the average signal value B within the first 10 seconds of the filtered signal sequence is calculated as the baseline value, using the average signal value during this time period as the baseline. The formula is: .
[0092] Where M is the number of signal data points in the first 10 seconds of the filtered signal sequence, determined by the S2 electronic nose's acquisition frequency. For example, if the acquisition frequency is 1Hz, then M=10; if the acquisition frequency is 2Hz, then M=20, which is linked to the S2 detection parameters. Subtracting the baseline value B from each data point in the filtered signal sequence yields the baseline-calibrated signal sequence Z=[z1,z2,...,z...]. i ,...,z N ], i.e., z i = y i -B. Where z i The first signal sequence Z after baseline calibration i Each data point signal value.
[0093] By subtracting the baseline value point by point, the baseline offset of the entire sequence signal is eliminated, thus preserving the sensor's true response characteristics to volatile components.
[0094] S33: Normalization Processing: To eliminate the influence of differences in the response range of different sensors on subsequent feature extraction, a linear normalization method is used to map the baseline-calibrated signal sequence Z to the [0,1] interval, resulting in a standardized signal sequence S=[s1,s2,...,s...]. i ,...,s N The calculation formula is:
[0095] s i = ( z i −z min ) / ( z max −z min ).
[0096] s i For the standardized signal sequence S=[s1, s 2 ,...,s i ,...,s N The first i Each data point signal value is mapped to the [0,1] interval; z max is the maximum value of the signal sequence Z after single-channel baseline calibration, and is the peak value of all data points in sequence Z; z min is the minimum value of the signal sequence Z after single-channel baseline calibration, and is the valley value of all data points in sequence Z.
[0097] The specific process of step S4 is as follows:
[0098] S41: Extracting temporal features: Based on the time-dimensional response pattern of standardized signal sequences, five core temporal features are extracted to directly reflect the dynamic adsorption-stabilization process of the sensor for volatile deteriorated components.
[0099] S42: Extracting Frequency Domain Features: By using Fast Fourier Transform (FFT) to transform the standardized signal sequence from the time domain to the frequency domain, the frequency dimension features of the signal are extracted, and redundant interference in the time domain signal is eliminated.
[0100] S43: Extracting Trend Features: Based on data from the signal stabilization phase, linear fitting is performed using the least squares method to uncover the trend of change after signal stabilization, reflecting the continuous release characteristics of volatile components.
[0101] S44: Feature Vector Construction: Extract time-domain feature parameters (5), frequency-domain feature parameters (10, 5 frequency components + 5 corresponding amplitudes), and trend feature parameters (2, slope a + goodness-of-fit R). 2 The odor feature vectors are spliced together in a preset order of time domain-frequency domain-trend to form a single-channel odor feature vector with a dimension of 17. The feature vectors of the multi-channel standardized signal sequences are extracted separately and then fused into a multi-channel comprehensive odor feature vector in channel order, which is then directly input into the pattern recognition model in step S5.
[0102] Example 3
[0103] Based on Example 1 or Example 2, the time-domain features extracted in step S41 include:
[0104] signal peak s max : Traverse the normalized signal sequence S, extract the maximum value as the signal peak value, and use the following formula:
[0105] s max = max (s1,s2,...,s i ,...,s N ).
[0106] Peak occurrence time t max Record signal peak value s max Corresponding acquisition time t max The formula is:
[0107] t max =t i | s i=s max ;
[0108] in t i For the first i The acquisition time of each data point is determined by the acquisition frequency of the S2 electronic nose.
[0109] signal rising edge slope k up Using the baseline value B from step S3 as a reference, determine the signal from 0.2. s max Rise to 0.8 s max Time interval [ t a ,t b ], corresponding to the signal value range [ s a ,s b The slope is calculated using a linear regression algorithm, and the formula is:
[0110] ;
[0111] in, n For the effective upward range [ t a , t b The number of data points within the range is determined by the electronic nose acquisition frequency and interval duration in step S2. t b - t a Calculations show that, for example, if the sampling frequency is 1Hz and the interval duration is 5s, then n=5. s t Let be the standardized signal value corresponding to time t. t a At the start of the rising edge, the corresponding normalized signal value reaches 0.2. s max The acquisition time is based on the baseline value B calculated in step S3, eliminating the interference of baseline offset on interval definition. t b At the moment the rising edge terminates, the corresponding normalized signal value reaches 0.8. s max The time of collection, and t a Together they constitute an effective upward range. t a , t bTo avoid interference from initial noise and the stable segment near the peak, ensuring the accuracy of slope calculation, the numerator... This is the covariance correlation term in the linear regression algorithm, reflecting the degree of linear correlation between time t and signal value st. The denominator... This is a variance-related term in the linear regression algorithm, ensuring the effectiveness and stability of the slope solution.
[0112] This formula is based on a linear regression algorithm, and its core purpose is to accurately quantify the rate change and slope during the adsorption of altered components by the sensor. k up The larger the absolute value, the faster the component adsorption rate, corresponding to a more active food spoilage process. Its calculation basis (S3 baseline value B) and input data (S3 normalized signal) are used. s t All of these originate from previous steps, and the interval definition depends on the peak value of the S4 signal. s max The output results are used as one of the core feature parameters in the time domain and incorporated into the S4 feature vector construction process, directly providing highly discriminative dynamic response features for the S5 CNN model.
[0113] Average value during signal stabilization phase Based on the S2 sensor response stability threshold (±0.002V), the signal stability phase is determined to be [ t c [,N], t c The starting point when the signal first experiences a consecutive 10 data point fluctuations ≤ ±0.002V is used to calculate the average signal value during this period, using the following formula:
[0114] ;
[0115] in, The average value of the standardized signal sequence during the stable phase is used to characterize the continuous response level of the electronic nose sensor to the steady-state concentration of volatile deteriorating components after the adsorption of these components in food has reached a stable state. This eliminates fluctuation interference during the dynamic adsorption process and provides a reliable data base for subsequent trend feature fitting. t c The starting time of the signal stabilization phase is defined as the acquisition time corresponding to the first data point in the standardized signal sequence output in step S3 where the fluctuation amplitude of 10 consecutive data points is ≤ ±0.002V (the sensor response stabilization judgment threshold preset in S2). This ensures that the stabilization phase definition standard is consistent with the detection parameters in S2, avoiding logical gaps; denominator N− t c +1: Signal stabilization phase [ t c The total number of valid data points within [N], because the data point index starts from...t c For intervals up to N, which are closed intervals, 1 needs to be added to complete the count and ensure the accuracy of the average calculation; numerator To standardize the signal sequence from the stable start time t c The signal values of all data points up to the end point N of the sequence are summed to fully cover the response data in the stable phase.
[0116] Signal integration area A: The area enclosed by the standardized signal sequence and the time axis throughout the entire detection cycle is calculated using the trapezoidal integration method. It reflects the total content of volatile components. The formula is:
[0117] ;
[0118] Where A is the signal integration area, calculated using the trapezoidal integration method. It primarily characterizes the total content of volatile deteriorated components released from the food during the entire electronic nose detection cycle. It is a cumulative time-domain characteristic parameter reflecting the degree of deterioration; the higher the degree of deterioration, the greater the total release of components, and the more significant the integration area A value. t The time interval between two consecutive data collections from the electronic nose is uniquely determined by the collection frequency preset in step S2, Δ. t= 1 / f , f The sampling frequency of the S2 electronic nose is in Hz.
[0119] The above formula decomposes the region enclosed by the standardized signal sequence and the time axis throughout the entire detection period into N−1 adjacent trapezoids, each trapezoid having Δt as its lower base. s i and s i+1 Given two waist heights, the total integral area is obtained by summing the areas of all trapezoids, balancing computational accuracy and efficiency, and adapting to rapid detection needs.
[0120] The frequency domain feature extraction process in step S42 is as follows:
[0121] Signal preprocessing: The standardized signal sequence S is padded with zeros to a length of L that is closest to the power of N, in order to reduce spectral leakage.
[0122] Fast Fourier Transform (FFT): Performing an FFT on the zero-padded sequence yields a complex frequency domain signal; the frequency domain signal is: F =[ F 0 ,F 1 ,...,F L-1 The FFT calculation formula is:
[0123] ;
[0124] Where F is the complex form frequency domain signal obtained by FFT operation on the zero-padded normalized signal sequence, and L is a one-dimensional complex sequence of length L, where each element... F k It contains amplitude and phase information for the corresponding frequency point. j The imaginary unit is used to characterize the phase information of a frequency domain signal. πki / L The phase term determines the phase characteristics of the complex signal, where k For frequency point index, i For indexing data points, L To lengthen the sequence after padding with zeros, a mapping relationship between the time domain and the frequency domain is jointly constructed. e −j2πki / L The term is a complex exponential term, which can be expanded using Euler's formula as follows: cos (2 πki / L )− jsin (2 πki / L This enables the conversion of time-domain signals to frequency-domain signals.
[0125] Amplitude spectrum calculation: Taking the modulus of the frequency domain signal F yields the frequency domain amplitude spectrum.
[0126] |F|=[|F0|,|F1|,...,|F L-1 |], retain only the first L / 2 frequency components, corresponding to the positive frequencies, and eliminate conjugate redundancy;
[0127] Single-frequency amplitude calculation: For each complex element in the frequency domain signal F F k The modulo formula is:
[0128] k=0,1,...,L−1;
[0129] Positive frequency component retention rule: Only the first L / 2 elements of the amplitude spectrum are extracted to form the effective amplitude spectrum.
[0130] ;
[0131] | F k |:Frequency domain signal k The amplitude at each frequency point is determined by the complex elements. F k The modulus is taken to represent the signal response intensity at that frequency point, Re( F k ), Im ( F k ): These are complex elements. F kThe real and imaginary parts are used; modulo operation can eliminate the phase influence caused by the imaginary part, retaining only the amplitude feature; L / 2: the number of effective frequency components. Because the frequency domain signal after FFT operation exhibits conjugate symmetry, the first L / 2 are positive frequencies, and the last L / 2 are negative frequencies, resulting in information redundancy. Retaining the first L / 2 components can cover all effective frequency information, while simplifying the feature dimension; F | valid The effective amplitude spectrum serves as the data source for subsequent extraction of the main frequency components, ensuring the efficiency and accuracy of feature extraction.
[0132] Main frequency component extraction: Sort the amplitude spectrum in descending order and extract the frequency components corresponding to the top 5 largest amplitude values. f 1, f 2,..., f 5) and the corresponding amplitudes (A1, A2, ..., A5) constitute the frequency domain characteristic parameter set.
[0133] The process of extracting trend features in step S43 is as follows:
[0134] Model construction: Let the linear fitting equation for the steady-state data be:
[0135] ;
[0136] in, Signal stabilization phase i The fitted values for each data point are the predicted output of the linear fitting equation and are used for subsequent error calculation and goodness-of-fit evaluation. a To fit the slope of the straight line, b This is the intercept.
[0137] Solving for fitting parameters: Minimize the sum of squared fitting errors using the least squares method.
[0138] .
[0139] The slope is obtained by solving. a and intercept b , where the slope a The calculation formula is:
[0140] ;
[0141] Among them, molecules This is the covariance-related term in the least squares method, reflecting the index. i Compared with actual signal value s i The degree of linear correlation ensures the accuracy of slope calculation.
[0142] denominator This is a variance-related calculation term in the least squares method, to avoid invalid solutions with zero denominators and ensure the stability of the slope solution;
[0143] Goodness of fit R 2 Calculation: Reflects the degree of fit between the fitted line and the actual data; the formula is:
[0144] .
[0145] See Figure 3 In step S5, the pattern recognition model uses a convolutional neural network (CNN) as the basic framework. A new channel attention mechanism module is added to optimize feature weight allocation, and a dropout layer is embedded to suppress overfitting. The overall structure is designed progressively as follows: input layer - attention mechanism layer - convolutional layer - pooling layer - dropout layer - fully connected layer - output layer.
[0146] The specific execution process is as follows:
[0147] The input layer reshapes the odor feature vector X output by S4, converting it into a two-dimensional feature map format adapted to the CNN input:
[0148] ;
[0149] The dimensional constraint relationship is as follows: This is used to ensure that feature information is not lost or redundant.
[0150] in, X in The reconstructed 2D feature map is directly used as input to the attention mechanism module, retaining all information from the S4 features. H represents the feature map. X in The height of W is the feature map. X in The width of C is the number of channels, corresponding to the number of channels in the electronic nose sensor array. The reshaping logic is to maintain the integrity of the feature information and only adjust the data dimensions to adapt to subsequent convolution operations. Reshape The dimension reshaping function only adjusts the data arrangement structure without changing the feature values themselves. Its core function is to adapt to the input format of CNN.
[0151] The attention mechanism module introduces a channel attention mechanism (SE-Net structure), which assigns weights to the features of each channel in the input feature map, strengthens the channel weights that are strongly correlated with the degraded feature components, and weakens redundant interference features. The execution process is as follows:
[0152] Global average pooling is performed on the feature maps of each channel to compress the two-dimensional features into one-dimensional channel descriptors, as shown in the formula:
[0153] ;
[0154] Where c = 1, 2, ..., C, z c The global pooling result of the c-th channel is a one-dimensional scalar (channel descriptor), which is the core input of the subsequent weight learning module and is used to characterize the global feature response of this channel.
[0155] Double summation term : Regarding the first c All elements of the two-dimensional feature map of a channel are summed to fully capture the global feature information of that channel;
[0156] Denominator H×W: No. c The total number of elements in the two-dimensional feature map of the channel is used to compress the two-dimensional features into a one-dimensional scalar through averaging, eliminating spatial dimension interference while preserving the core feature strength of the channel.
[0157] Weight learning: Channel weights are learned through a two-layer fully connected network (FC). A sigmoid activation function is introduced to map the weights to the [0,1] interval. The formula is as follows:
[0158] ;
[0159] The order of operations is as follows:
[0160] First layer fully connected (dimensionality reduction, FC1): z fc1 =W fc1 ⋅z+b fc1 The output dimension is C / r , r =16;
[0161] ReLU activation (δ): z δ = δ (z fc1 )=max(0,z fc1 ).
[0162] Second-layer fully connected (upgraded dimension, FC2): z fc2 =W fc2 ⋅z δ +b fc2 The output dimension is restored to C;
[0163] Sigmoid activation ( σ ): ;
[0164] in, s : The set of weight coefficients for each channel s =[ s 1, s 2,..., s C ]T The dimension is C×1, and the weight values are mapped to the [0,1] interval for subsequent feature weighting.
[0165] σ The Sigmoid activation function's core function is to constrain the upgraded feature values to [0,1], achieving a reasonable weight distribution. The formula for single-element operation is: .
[0166] FC2: A fully connected layer with an increased dimension. The number of neurons is C, which is consistent with the number of channels. The output dimension matches the number of channels, and it is adapted to channel-wise weighting.
[0167] δ The ReLU activation function introduces a non-linear mapping to enhance the learning ability of weights. The formula for single-element operation is as follows: δ ( x )= max (0, x This can suppress gradient vanishing.
[0168] FC1: Dimensionally reduced fully connected layer, with C neurons. r , r =16 is the empirical dimensionality reduction coefficient, which reduces computational cost and enhances feature interaction.
[0169] z : Global pooling result set z =[ z 1, z 2,..., z C ] T The dimension is C×1, which is derived from the global pooling results of the preceding channels.
[0170] W fc1 W fc2 These are the weight matrices for two fully connected layers, with dimensions (C / r )×C、C×(C / r The model is updated iteratively through training.
[0171] b fc1 b fc2 These are the bias vectors of two fully connected layers, with dimensions (C / r )×1 and C×1 are used to adjust the feature output baseline and improve the fitting ability.
[0172] z fc1 , z δ , z fc2The intermediate operation results are, in order, the features after dimensionality reduction, the features after ReLU activation, and the features after dimensionality increase, ensuring that the operation dimensions are adapted step by step.
[0173] Feature weighting: The learned channel weights are multiplied channel by channel of the input feature map to obtain the weighted feature map. The formula is:
[0174] ;
[0175] in, The feature values of the c-th channel, h-th row, and w-th column of the weighted feature map are the output of the attention mechanism module and are directly used as the input of the subsequent convolutional layer, preserving the enhanced and degraded core features.
[0176] s c : No. c The channel weights are derived from the results of the preceding weight learning process. s c For each channel ∈[0,1]), the higher the weight, the more significantly the altered feature response of the corresponding channel is enhanced;
[0177] : Input the feature values at the corresponding positions of the input feature map, inherit the dimension reshaping results of the input layer, retain the original odor feature information extracted by S4, and are completely consistent with the definition in the global pooling and weight learning steps;
[0178] h, w : Feature map spatial index, corresponding to the feature map height and width respectively, with a value range of 100%. h ∈[1,H]、 w ∈[1,W], and is of the same origin as the input layer reshaping parameters;
[0179] c Channel index, c =1,2,...,C, corresponding to the number of channels in the electronic nose sensor array;
[0180] This operation enhances the channel response corresponding to the altered features, thereby improving the model's ability to identify altered features.
[0181] Convolutional layer: A two-dimensional convolutional kernel is used to extract features from the weighted feature map, capturing local correlation information in the feature vector. The formula is as follows:
[0182] ;
[0183] in, h ∈[1,H conv ]、 w ∈[1,W conv ]、k∈[1,K num ], where H conv=H−K+1、W conv =W−K+1, defaults to no padding, adapts to 3×3 convolutional kernel size, K num This represents the total number of convolutional kernels, i.e., the number of output channels.
[0184] X conv ( h,w,k ): The convolutional feature map k The output channel, the first h line, number w The feature values of the column are the core output of the convolutional layer, carrying deep local correlation information between features, and are directly input into the subsequent pooling layer;
[0185] h , w : Spatial index of the convolutional feature map, the value of which is determined by the size of the input feature map and the size of the convolution kernel. K The decision is made to ensure that the convolution window does not go out of bounds;
[0186] k Output channel index, corresponding to the number of convolution kernels, each k Corresponding to a set of independent convolutional kernel weights W k,c It is used to extract a class of deep features and enhance the differentiation of deterioration levels;
[0187] C Input channel number, and the feature map X after weighting with the preceding features. att The number of channels is consistent with the number of channels in the electronic nose sensor array, ensuring the continuity of the channel dimension.
[0188] K: Convolution kernel size, set to 3×3, empirically optimal value. i , j This is the internal spatial index of the convolution kernel, with a value range of [0, K−1], corresponding to the row and column positions of the convolution kernel;
[0189] W k,c ( i,j ): No. k The output channel, the first c The convolutional kernel weights corresponding to each input channel have a dimension of K×K and are updated iteratively through model training to capture the local feature patterns of input channel c.
[0190] X att ( h+i,w+j,c ): The feature value of the c-th channel of the weighted feature map and the corresponding local region (the area covered by the convolutional window) is derived from the output of the preceding attention mechanism module and has been enhanced to improve the core features;
[0191] b kThe bias term of the k-th output channel is a scalar parameter that is updated during training. It is used to adjust the baseline of the feature output of this channel and reduce the model fitting bias.
[0192] H conv W conv The height and width of the convolutional feature map are different from the input feature map X because there is no padding operation. att (Size H×W) Each is reduced by K−1 pixels to adapt to the downsampling requirements of subsequent pooling layers.
[0193] Pooling layer: Max pooling is used to downsample the feature maps after convolution, preserving core features and reducing data dimensionality, thereby reducing the computational cost of the model. The formula is:
[0194] ;
[0195] Among them, X pool ( h,w,k ): Feature map after pooling k The first channel, the first h line, number w The feature values of the column, which are the core outputs of the pooling layer, are directly input into the dropout layer to retain the core features and reduce the dimensionality.
[0196] h, w These are the spatial indices of the pooled feature map, and their values are determined by the size of the convolutional feature map and the pooling kernel size P, corresponding to the position mapping of the pooling window on the original feature map.
[0197] k Channel index, which is completely consistent with the number of output channels and the number of convolutional kernels of the convolutional layer. Max pooling is only operated independently on each channel and does not merge across channels, thus preserving channel-specific features and strengthening the exclusive features for distinguishing the level of degradation.
[0198] P Pooling kernel size, set to 2×2, is the empirically optimal value. i, j This is the internal index of the pooling kernel, with a value range of [0, P−1], corresponding to the row and column positions within the pooling window;
[0199] The core function of the dual maximum value operation is to select the maximum feature value from each P×P pooling window, retain the key response peak, and enhance the robustness of the core features.
[0200] , Pooling window in the feature map X after convolution conv The corresponding position index is used to slide a window with a step size P to achieve non-overlapping downsampling and avoid feature redundancy.
[0201] Xconv The feature map output by the preceding convolutional layer has corresponding feature values as input to the pooling operation, carrying the deep local correlation features extracted by convolution.
[0202] H pool W pool The height and width of the feature map after pooling are halved compared to the feature map after convolution due to the 2×2 pooling kernel and stride of 2, which greatly reduces the computational cost of subsequent fully connected layers.
[0203] This formula is a key step in the "feature extraction-dimensionality compression" process of CNN models. It connects the deep feature map Xconv output by the convolutional layer to the overfitting suppression operation of the dropout layer. The core logic is "maximum window value - dimensionality compression - feature enhancement".
[0204] By employing a 2×2 non-overlapping pooling window, the maximum response value is selected window-by-window from the convolutional feature map of each channel. This filters out local noise interference while preserving key feature peaks strongly correlated with the degradation level, and halves the feature map dimension, effectively reducing model computational complexity and the risk of overfitting. During the operation, the number of channels remains consistent with the number of convolutional layers, ensuring that the channel specificity of features is not lost. This perfectly adapts to the model workflow of convolution extraction-pooling dimensionality reduction-dropout suppression, while also enhancing the model's robustness to degradation features.
[0205] Dropout layer: An embedded dropout layer after the pooling layer suppresses overfitting and improves generalization ability by randomly deactivating some neurons. The operation logic is as follows: during the training phase, the output of some neurons is randomly set to 0 and the deactivation probability is set to 0.5; during the testing phase, all neurons are kept active and the output result is multiplied by the complement of the deactivation probability (0.5) to ensure that the input and output data distribution is consistent. No additional formula is needed; overfitting suppression is achieved solely through probability control.
[0206] Fully connected layer: flattens the pooled feature map into a one-dimensional feature vector.
[0207] ;
[0208] M is the feature dimension after flattening. ,
[0209] Features are mapped to the target classification space using a two-layer fully connected network.
[0210] The formula for the first fully connected layer is:
[0211] ;
[0212] The formula for the second fully connected layer is:
[0213] ;
[0214] The activation function is supplemented by the formula: the ReLU function δ(x) = max(0,x), which operates element-wise and introduces a non-linear mapping.
[0215] Among them, X pool The pre-pooling layer outputs a feature map with dimension H. pool ×Wp ool ×K num It carries the core features after pooling and dimensionality reduction, and serves as the input source for the flattening operation.
[0216] Flatten: Feature flattening function, only changes the data arrangement structure, concatenates the 3D feature map into a 1D vector in the order of channel-height-width, without changing the feature values, ensuring the integrity of feature information.
[0217] X flat : The flattened one-dimensional feature vector, X flat ∈RM is the input data of the fully connected layer, which realizes the transformation from high-dimensional feature maps to one-dimensional features.
[0218] M: The feature dimension after flattening, calculated from the feature map size and number of channels after pooling (M=H) pool ×W pool ×K num ), where H pool Wp ool These represent the height and width of the feature map after pooling, respectively, and K num This represents the number of channels, consistent with the number of channels in convolutional and pooling layers.
[0219] W fc1 W fc2 The weight matrix of the fully connected layer has dimensions D1×M and 4×D1, respectively. D1 is the number of neurons in the first fully connected layer, with an empirical value of 1024; 4 corresponds to the four levels of degradation. The feature dimension mapping is achieved through iterative updates during model training.
[0220] b fc1 b fc2 : The bias vectors of the fully connected layer, with dimensions D1×1 and 4×1 respectively, are updated during training and are used to adjust the baseline of the feature output and reduce the model fitting bias.
[0221] δ: ReLU activation function, with the formula δ(x)=max(0,x), is an element-wise non-linear activation function that suppresses gradient vanishing and improves the model's ability to fit complex features.
[0222] X fc1 The first fully connected layer outputs a feature vector with dimension D1×1. After ReLU activation, it carries non-linear feature information and serves as the input to the second fully connected layer.
[0223] X fc2 The second fully connected layer outputs a feature vector with a dimension of 4×1. It has no additional activation and is directly input into the output layer for probability mapping, corresponding to the original feature responses of the four levels of degradation.
[0224] Output layer: The Softmax activation function is used to convert the output of the fully connected layer into a probability distribution of four types of results, as shown in the formula:
[0225] m=1,2,3,4, corresponding to four levels of degradation;
[0226] This ensures that the sum of the output probabilities is 1, which conforms to the basic principle of probability distribution.
[0227] Vector form extension:
[0228] ;
[0229] y m : No. m The probability value of the class of mutation level. y m ∈[0,1], corresponding to the following categories: m =1 (not spoiled) m =2 (slightly spoiled) m =3 (moderate deterioration) m =4 (severe degradation), used for subsequent probability maximization result determination.
[0230] e The natural constant, approximately 2.71828, is used to amplify the differences in the output feature values of the fully connected layer through exponential operations, thereby enhancing the class discrimination.
[0231] x fc2,m The second fully connected layer outputs XFC2's... m Each element represents the raw feature response value before activation, derived from the preceding fully connected layer operation, X. fc2 =W fc2 ⋅X fc1 +b fc2 .
[0232] The normalized denominator term is the exponential sum of the original feature response values corresponding to the four levels, ensuring that the sum of the probabilities of all categories is 1, thus forming a reasonable probability distribution.
[0233] X fc2The preceding fully connected layer outputs a feature vector with a dimension of 4×1, which is directly used as the input to the Softmax activation function, carrying the classification and adaptation features after feature mapping.
[0234] y The output probability vector, with a dimension of 4×1, is the core output of the output layer and directly supports the final degradation level determination of S5 pattern recognition.
Claims
1. A non-destructive rapid detection method for food spoilage based on electronic nose and pattern recognition, characterized in that, Includes the following steps: S1: Select the food to be tested, pre-treat it, put it into a sealed test container, and place it in a constant temperature environment for a preset time to allow the volatile odor components released by the sample to reach a stable concentration in the sealed space. S2: Seal the sealed detection container to the sample inlet of the electronic nose detection system, turn on the electronic nose detection system to dynamically adsorb and detect the volatile odor components in the sealed space, and collect the response signals of each sensor in the sensor array in real time to obtain the original odor response signal sequence. S3: Remove high-frequency noise from the original odor response signal sequence, eliminate baseline shift caused by initial sensor drift and environmental interference, and normalize the calibrated signal sequence to obtain a preprocessed standardized signal sequence. S4: Based on the standardized signal sequence, extract time-domain features, frequency-domain features and trend features. The three types of features are spliced together in a preset order to obtain the odor feature vector of the sample to be tested. S5: Input the extracted odor feature vector into the pre-trained pattern recognition model, classify and recognize the feature vector, and output the degree of spoilage of the food sample to be detected. The specific process of step S4 is as follows: S41: Extracting temporal features: Based on the temporal response patterns of standardized signal sequences, five core temporal features are extracted; S42: Extracting Frequency Domain Features: The standardized signal sequence is transformed from the time domain to the frequency domain using Fast Fourier Transform to extract the frequency dimension features of the signal and eliminate redundant interference in the time domain signal. S43: Extracting Trend Features: Based on data from the stable signal phase, linear fitting is performed using the least squares method to uncover the changing trend after the signal stabilizes. S44: Feature Vector Construction: The extracted time-domain features, frequency-domain features, and trend features are concatenated in a preset order of time-frequency-trend to form a single-channel odor feature vector; after extracting feature vectors from the multi-channel standardized signal sequences, they are fused in channel order to form a multi-channel comprehensive odor feature vector.
2. The method for non-destructive rapid detection of food spoilage based on electronic nose and pattern recognition according to claim 1, characterized in that, The specific process of step S2 is as follows: S21: Before detection, the electronic nose sensor array of the electronic nose detection system is activated, and the sealed detection container is sealed and connected to the sample inlet of the electronic nose detection system through a polytetrafluoroethylene sealing gasket. S22: Activate the electronic nose detection system and configure the carrier gas flow rate, total detection time, and sensor array response stability judgment threshold according to preset parameters; S23: The system collects the electrical response data of each sensor in the array in real time at a set time interval, forming a multi-channel raw response data sequence that changes with the detection time, i.e., the raw odor response signal sequence; S24: When the response signal of each sensor in the sensor array does not exceed the set threshold in the fluctuation amplitude of multiple consecutive data points, it is determined that the response has reached a stable state and the data acquisition is stopped.
3. The method for non-destructive rapid detection of food spoilage based on electronic nose and pattern recognition according to claim 1, characterized in that, The specific process of step S3 is as follows: S31: Moving average filtering noise reduction: The leading edge, middle segment and trailing edge of the original odor response signal sequence are filtered separately; S32: Baseline Correction: Using the initial first 10 seconds of data from the filtered signal sequence as a reference, calculate the average signal value within this time period as the baseline value B; subtract the baseline value B from each data point in the filtered signal sequence to obtain the baseline-calibrated signal sequence; S33: Normalization processing: The baseline-calibrated signal sequence Z is mapped to the [0,1] interval using a linear normalization method to obtain a standardized signal sequence.
4. The method for non-destructive rapid detection of food spoilage based on electronic nose and pattern recognition according to claim 1, characterized in that, The temporal features extracted in step S41 include: signal peak s max : Traverse the normalized signal sequence S and extract the maximum value as the signal peak value; Peak occurrence time t max Record signal peak value s max Corresponding acquisition time t max ; signal rising edge slope k up Using the baseline value B from step S3 as a reference, determine the signal from 0.
2. s max Rise to 0.8 s max Time interval [ t a ,t b ], corresponding to the signal value range [ s a ,s b The slope is calculated using a linear regression algorithm. Average value during signal stabilization phase Based on the S2 sensor response stability threshold, the signal stability phase is determined as […]. t c [,N], t c Calculate the average signal value during the initial time when the signal first fluctuates for 10 consecutive data points ≤ the response stability judgment threshold. Signal integration area A: The area enclosed by the standardized signal sequence and the time axis during the entire detection cycle is calculated using the trapezoidal integration method, reflecting the total content of volatile components.
5. The method for non-destructive rapid detection of food spoilage based on electronic nose and pattern recognition according to claim 4, characterized in that, The frequency domain feature extraction process in step S42 is as follows: Signal preprocessing: The standardized signal sequence is padded with zeros to a length closest to the power of N. Fast Fourier Transform: Performing an FFT operation on a zero-padded sequence yields a frequency domain signal in complex form; Amplitude spectrum calculation: The frequency domain amplitude spectrum is obtained by taking the modulus of the frequency domain signal F; Main frequency component extraction: Sort the amplitude spectrum in descending order and extract the frequency components corresponding to the top 5 largest amplitude values. f 1, f 2,..., f 5) and the corresponding amplitudes (A1, A2, ..., A5) constitute the frequency domain characteristic parameter set.
6. The method for non-destructive rapid detection of food spoilage based on electronic nose and pattern recognition according to claim 5, characterized in that, The process of extracting trend features in step S43 is as follows: S431: Model Construction: Let the linear fitting equation for the steady-state data be: ; in, Signal stabilization phase i Fitted values for each data point a To fit the slope of the straight line, b The intercept; S432: Solving for fitting parameters: Minimizing the sum of squared fitting errors using the least squares method. The slope *a* and intercept *b* are obtained by solving the problem. The formula for calculating the slope *a* is: ; Among them, molecules This is the covariance-related term in the least squares method, reflecting the index. i Compared with actual signal value s i The degree of linear correlation ensures the accuracy of slope calculation; denominator This is a variance-related calculation term in the least squares method, to avoid invalid solutions with zero denominators and ensure the stability of the slope solution; S433: Goodness of fit R 2 Calculation: Reflects the degree of fit between the fitted line and the actual data; the formula is: 。 7. The method for non-destructive rapid detection of food spoilage based on electronic nose and pattern recognition according to claim 1, characterized in that, In step S5, the pattern recognition model uses a convolutional neural network as its basic framework. A new channel attention mechanism module is added to optimize feature weight allocation, and a dropout layer is embedded to suppress overfitting. The specific process of classifying and recognizing feature vectors is as follows: S51: The odor feature vector X is reshaped in dimension through the input layer and converted into a two-dimensional feature map format that is adapted to the CNN input; S52: The channel attention mechanism is introduced through the attention mechanism module to assign weights to the channel features of the input feature map, strengthen the channel weights that are strongly correlated with the deteriorated feature components, and weaken redundant interference features. S53: The two-dimensional convolutional kernel of the convolutional layer is used to extract features from the weighted feature map and capture the local correlation information in the feature vector. S54: Max pooling is used in the pooling layer to downsample the convolutional feature map, retaining core features and reducing data dimensionality, thus reducing the computational cost of the model. S55: The dropout layer embedded after the pooling layer inhibits model overfitting by randomly deactivating some neurons; S56: Flatten the pooled feature map into a one-dimensional feature vector through a fully connected layer; S57: The output of the fully connected layer is converted into a probability distribution of four types of results by using the Softmax activation function in the output layer. The four types of results are no degradation, slight degradation, moderate degradation, and severe degradation.