Application of Variational Mode Decomposition and k-Nearest Neighbor Algorithm in the Quantitative Nondestructive Testing of Wire Ropes

In this paper, we present a nondestructive testing device for wire rope by unsaturated magnetic excitation as an alternative to existing magnetic flux leakage (MFL) detection devices.0e existing devices are heavy and inconvenient and offer somewhat lower accuracy and low signal-to-noise ratios (SNRs). Our design implements variational mode decomposition (VMD) and a wavelet transformation to remove noise from the raw MFL signals. Grayscale images representing the denoised MFL data simplify visual interpretation of the results and location of defects in both axial and circumferential directions. Quantification of defects is enabled using a k-nearest neighbor (KNN) algorithm to classify broken wires. Experimental results show that our design offers lighter weight, better convenience, and high sensitivity along with better removal of noise and more accurate classification of defects.


Introduction
Wire ropes are widely used in mining, metallurgy, transportation, construction, and other similar industries due to the following advantages: high strength, flexibility, elasticity, and diversity of structure.e safe operation of wire ropes relates directly to the safety of production and personnel, making detection of damage to wire ropes of critical importance [1].Existing detection methods use ultrasonic, infrared, radiographic, acoustic emissions, and electromagnetic testing techniques.Among these, electromagnetic testing has the advantages of low cost, high precision, simple principles, and suitability for wire ropes having a complicated structure but good magnetic permeability.erefore, development of this method has developed rapidly as a nondestructive testing method, making it the most widely used testing method in current research and applications.Electromagnetic testing detects defects in ferromagnetic materials according to changes in their electromagnetic properties.After years of development, electromagnetic testing now falls into several categories, including eddy-current testing, magnetic particle testing, magnetic flux leakage (MFL) testing, microwave testing, and magnetic memory testing.MFL testing is the most popular due to its simple automation, high reliability, and ability to quantify defects.MFL testing relies on the MFL that occurs when the rope is magnetized.Distortions form in the magnetic field on the wire rope surface as a result of internal and surface defects, thus revealing defects by measuring the magnetic leakage of the field [2].
e two primary ways to magnetize the rope for MFL testing are coil magnetization [3,4] and permanent magnet magnetization [5,6].Sharatchandra Singh et al. [3] designed a saddle coil capable of applying variable DC as a magnetization device.Its magnetic field intensity can be changed by varying the current.Jomdecha [4] improved the traditional coil magnetization method using a solenoid magnetizer, which can change the magnetization level by changing the current or the number of coil turns. is method has the problem that the device gets hot and cannot continue to be used as the service time increases.e permanent magnet magnetization method uses permanent magnets as an excitation source, usually with a magnetic yoke structure using multiple permanent magnets distributed symmetrically around the circumference of the wire rope to magnetize the rope uniformly.Wang et al. [7] considered that the removal of the magnetizing device affects the defect detection accuracy and improved the traditional device.Xu et al. [8] used finite element analysis to establish the excitation device model and carried out theoretical calculations and experimental verification of the structure and size of the optimal excitation device.
Usually, a magnetic field measuring probe collects the magnetic field leakage (MFL) of the wire rope.In actual use, the magnetic field is converted into an electrical signal for subsequent processing.Common magnetoelectric conversion devices include induction coils, fluxgates, Hall effect sensors, and magnetoresistive sensors.In order to improve the signalto-noise ratio (SNR) of data collected from the nondestructive testing (NDT) induction coil sensor and along with the convenience of installation, Yan et al. [9] improved the structure of the traditional coil sensor, adding a wedge-shaped iron core and removing the arcs on both sides of the iron core to simplify the winding.Kim and Park [10] designed a fourchannel Hall sensor array for local defect MFL testing and subsequently improved it to make an eight-channel Hall sensor array for collecting two-dimensional (2D) MFL information [11].Li and Zhang [12] designed a wire rope MFL acquisition system using Hall sensors.He created a sensor array made of 30 sensors arranged perpendicularly to the surface of the wire rope to acquire the MFL around the circumference of the wire rope.Wu et al. [13] designed a TMR array to collect the MFL information and optimized the sensor array structure using an orthogonal test.However, sensor limitations offer resolution of a coarse 2 mm.Hong et al. [14] analyzed the influences of defect depth and sensor lift-off on MFL testing through experiment and theory and designed a planar Hall magnetoresistive sensor, which had the advantages of a high SNR, small temperature drift, a large bipolar response range, and capable of detection with ultralow magnetization.
e signal collected by the sensor contains large amounts of noise, so the raw signal needs to be denoised.Li and Zhang [12] proposed a baseline estimation method for the MFL signal to reduce the low frequency and DC noise due to lift-off and the excitation structure.Using the inherent characteristics of the wire rope MFL signal, Li normalized the signal peak-valley values of different channels to balance all of the channels and improve the contrast and SNR of the MFL defect image.Kim and Park [10] used a Hilbert transform to process the signal to obtain the signal envelope.
is algorithm is simple and efficient, but the denoising effect is general.Zhang and Tan [15] adopted a wavelet filtering method by compressed sensing to denoise the strand wave and high-frequency noise of the MFL signal and achieved good results.To further improve the denoising effect, they designed a filtering algorithm combining the Hilbert-Huang transformation with compression sensing to suppress system noise [16].However, both algorithms have the disadvantages of long computation time.
In MFL testing, the evaluation of the damage degree falls into two categories.One uses the characteristics of the MFL signals for evaluation.e other converts MFL signals into grayscale images and uses image classification technology to classify defects.By correlating the characteristic values of MFL signals with the detection status information, Sun et al. [17] proposed a method to evaluate defects using multiple MFL signal characteristics, which overcomes the chief limitation of traditional evaluation systems that use only the peak value of signals and cannot reflect the specific shape of defects.Kim and Park [11] used a Hilbert transform to process the MFL signal and then compared the signal with the threshold established through the generalized extreme distribution to establish the damage index.e extracted multiscale damage index was used to establish the multistage pattern recognition of an artificial neural network to estimate the degree of damage automatically.Kandroodi et al. [18] proposed the defect length estimation method using the axial MFL horizontal contour using the signal level contour map of the corresponding defect area and a radial basis function (RBF) neural network to evaluate the defect depth.All of the preceding methods rely on the characteristics of MFL signals for defect assessment, which offers less information in the signal and less-detailed classification of the defect damage degree.Zhang et al. [19] transformed MFL data into grayscale images, extracted image features, used a back-propagation (BP) neural network to classify defects, and then performed quantitative recognition of defects.Moreover, they designed an RBF classification network to identify the number of broken wires in a wire rope [16].Both these methods use neural networks for classification, which offers good generalization.However, image features must be extracted before classification, which adds feature selection and extraction steps.In addition, the complex structure of the neural network leads to a long network training time with high computational complexity.
In view of the disadvantages of existing wire rope MFL testing equipment, including its bulk, inconvenience, low sensitivity, and low SNR, we designed nondestructive testing equipment for wire ropes by unsaturated magnetic excitation.We use a permanent magnet as an unsaturated magnetic excitation source and 18 channels of newly designed and highly sensitive magnetic sensor arrays for magnetic field acquisition.To solve the problem of multiple noise sources in the collected raw data, we designed a denoising algorithm using VMD and wavelets to denoise the raw signal.To locate and recognize broken wires, we convert the denoised MFL data into grayscale images and use the modulus maximum.Finally, to solve the existing problems in current defect evaluation methods, we use a KNN to classify broken wires quickly and accurately.

Data Collection
In this section, we present a wire rope MFL acquisition system under unsaturated magnetic excitation.As shown in Figure 1, the system includes an unsaturated magnetic excitation module, a sensor array module, a pulse generation and acquisition module, a main control module, and a data storage module.e device we designed has an external size 2 Shock and Vibration of 310 mm × 180 mm × 206 mm and a weight of 1.25 kg, which is smaller in size and weight than the traditional strong magnetic detection device.e unsaturated magnetic excitation module is made of permanent magnets, with multiple bar permanent magnets uniformly distributed around the circumference of the wire rope to produce a uniform excitation magnetic field.Figure 2 shows the sensor array.Using a high-precision giant magnetoresistive (GMR) sensor as the magnetic field acquisition probe, 18 GMR sensors uniformly cover the circumference of the wire rope.We use an encoder as a pulse generator to ensure equal space sampling.Figure 3 shows the main control and data storage modules including the analog-todigital (A/D) interface signal conditioning circuit, the data storage unit, and the control chip.Data are stored on an secure digital (SD) card.
e control chip is an ARM processor.
We collect the MFL on the surface of the wire rope using this acquisition system according to the following process.
e sensitive surface of the GMR sensor in the sensor array is perpendicular to the wire rope surface, so the obtained MFL component is the radial component.We store the collected MFL data on an SD card for subsequent processing.As shown in Figure 4, we circumferentially expand the experimental data of the 18 channels collected from the equal space sampling starting from a sensor.From this, we obtain a 2D image of size M × N, where M is the number of sensor channels and N is the number of readings collected by each channel.In our case, M � 18.
Figure 5 shows the raw data expanded from the first sensor.Shock and Vibration spiral structure of the wire rope, the high-frequency magnetic leakage noise, the noise caused by uneven excitation between channels, and the channel imbalance caused by the lift-off during data collection.ese noises greatly affect later positioning and quantitative identification, so it is necessary to denoise the raw data.In this section, we present our denoising algorithm using VMD and a wavelet transform to denoise the raw signal.e principle is as follows: after decomposing the signal using VMD, we apply the wavelet soft threshold to the mode containing useful information and remove the mode without useful information.Finally, we reconstruct the signal using the mode after denoising.

Wavelet eory.
e wavelet transform is a transform analysis method.Its main feature is that it fully highlights some features of a problem through the transformation.
erefore, wavelet transforms, and the discrete digital wavelet transform algorithm in particular, have been successfully applied in many fields to transform complex problems [20].
Most common signals are nonstationary.eir frequency varies with time, and the variation is both fast and slow.Fast variations correspond to the high-frequency component, which provides the signal details, and the slow variations correspond to the low-frequency component, which provides the general picture of the signal.In order to separate the high and low-frequency parts, Mallat [21] proposed a pyramid wavelet decomposition and reconstruction algorithm based on multiresolution analysis.According to the Mallat algorithm, signals can be decomposed and reconstructed using the following formulas: where h − (k) � h(−k), h 0 is a low-pass filter, and h 1 is a highpass filter.Formula (1) is the decomposition formula of the Mallat algorithm.Formula (2) is the reconstruction formula for the signal.

Variational Mode Decomposition.
Variational mode decomposition is a new signal decomposition algorithm proposed by Dragomiretskiy and Zosso [22] in 2014.e overall framework is the variational problem.e VMD is the solution of the variational problem.e algorithm includes both the construction and solution of the variational problem.

Construction of Variational Problems.
For a signal f(t) decomposed into K modes u k (k � 1, 2, 3, . .., K), each mode has a central frequency and limited bandwidth.First, the analytical signal of each mode is obtained by a Hilbert transform to acquire the unilateral spectrum (δ(t)+ (j/πt)) * u k (t).Second, an exponential term is added to the analysis signal of each mode to adjust its estimated center frequency, with the spectrum of each mode modulated to the corresponding base frequency band [(δ(t) + (j/πt)) * u k (t)]e −jω k t .Finally, the gradient squared L2 bound norm of the demodulation signal is calculated, and the signal bandwidth of each mode is estimated.A constrained variational problem is constructed as follows: where is the central frequency set of all modes, and  k ≔  K k�1 is the sum of the modes.

Solution of the Variational Problem.
Using the second penalty factor α and the Lagrangian multiplication operator 4 Shock and Vibration λ(t), the constraint variation problem is changed into a nonconstraint variation problem.When the quadratic multiplication factor can guarantee the signal reconstruction accuracy in the presence of Gaussian noise, the Lagrangian operator keeps the constraint condition strict.e extended Lagrange expression is as follows: e alternate direction method of multipliers (ADMM) is used to update u n+1 k , ω n+1 k , and λ n+1 k and to seek to the "saddle point" of the extended Lagrange expression.e value problem of u n+1 k is expressed as follows: where ω k is equivalent to ω n+1 k and  i u i (t) is equivalent to  i u n+1 i (t).By using the Parseval/Plancherel Fourier equidistant transformation, formula (5) can be transformed from the time domain to the frequency domain: We replace ω of the first term with ω − ω k to obtain the following formula: Formula ( 7) is converted into the form of the nonnegative frequency interval integral: At this point, the solution of the quadratic optimization problem is as follows: Similarly, the value problem of the central frequency is converted to the frequency domain: e updating method for the central frequency is solved as follows: where  u n+1 k (ω) corresponds to the Wiener filter of the current residual amount  f(ω) −  i≠k  u i (ω), ω n+1 k is the center of gravity of power spectrum of current mode function, and the real part of the Fourier transform of  u k (ω)   : is u k (t)   :.As a whole, the VMD algorithm updates each mode continuously through the frequency domain directly and then transforms it to the time domain via the Fourier transform.

Algorithm Description.
e VMD requires a given number of modes, known as K. e main difference between each mode is the central frequency.erefore, we use the observed central frequency to determine K.When K � 11, the mode with a similar central frequency appears.We consider the decomposition for K � 11 to be excessive and set K � 10 as a result.
e proposed filtering algorithm is as follows: Step 1.For the signal x i of the sensor array channel i, use VMD to decompose x i according to the following sequence: ) For a given discrimination accuracy e > 0, if ) < e, stop the iteration.Otherwise, return to step (2).
Step 2. Use the wavelet soft threshold algorithm to denoise the mode containing the defect information according to the following sequence:

Shock and Vibration
(1) Select Coiflets (coif2) wavelet base function and apply the Mallat algorithm to decompose the mode with 8 levels.(2) Clear the low-frequency coefficient and perform the soft threshold quantization with the universal threshold ������ 2 log()  for the high-frequency coefficients at each decomposition scale.
(3) Reconstruct the processed wavelet coefficients using a one-dimensional wavelet to obtain the filtered mode.
Step 3. Remove the modes without defect information.
Step 4. Superimpose the processed modes to obtain the denoised data.
Figure 6 shows several single channel data before and after processing with the above algorithm.Figures 6(a We process the 18 channels of MFL data with the above algorithm to obtain the data without baseline and noise.Figure 7 shows a sample of the expanded data comparison before and after denoising.

Denoising Effect Comparison.
In order to describe the effect of denoising quantitatively, we define the SNR as SNR � 20Lg (V s /V n ).V s is the maximum peak-to-peak value of the defect signal, and V n is the maximum peak-to-peak value of the noise.After selecting 10 representative signals from the MFL data, we have applied several denoising methods to them: the empirical wavelet transform (EWT) algorithm [23], the Hilbert-Huang transform denoising algorithm (HHT-WFCS) [16], the EEMD-based wavelet denoising (EEMD-wavelet) algorithm [19], and our proposed algorithm.Table 1 shows the SNR calculated for each method, and Figure 8 shows a representative sample likewise.Our proposed algorithm yielded much better results when denoising the unsaturated magnetic excitation signal.

Image Processing
Images often make complex data easier to express and understand.In this section, we describe how we present defects with the help of mature image processing techniques.Our processing includes grayscale normalization, circumferential interpolation, defect localization, and segmentation.

Grayscale Normalization.
Grayscale normalization transforms MFL data into gray values as the basis of data visualization.We normalize the MFL data into the range [0, 255] using equal ratio scaling to ensure that the data features after normalization remain unchanged.Figure 9 shows normalization results from a representative sample.e broken wires of this representative sample are located at one meter in the axial direction of the wire rope and 14 and 15 sensor channels in the circumferential direction.
e intensity of MFL is normalized to the gray value of unsigned 8bit integer type, and the range is [0, 255].

Circumferential Interpolation.
Our acquisition system uses an 18-channel GMR sensor array, so the data acquired has a circumferential resolution of only 18, which is much lower than the axial resolution.Circumferential interpolation is needed to make the MFL data more intuitive.We improve the circumferential resolution from 18 to 300 using cubic spline interpolation.Figure 10 shows a data sample after improving the circumferential resolution.We convert the interpolated data to 8-bit unsigned integer data to match the grayscale level of pixels in the MFL grayscale image.e MFL grayscale image of a wire rope is shown in Figure 11.

Defect Location and Segmentation.
We locate and segment defects using the modulus maximum method.We implement the method with the following sequence of steps: (1) Calculate the circumferential average and obtain a one-dimensional mean signal d(j)(1 ≦ j ≦ N), where N is the number of sampling points.(2) Implement a threshold to d(j), retaining the largest value and setting others to 0. Obtain d′(j) and determine the position of the maximum of d′(j), which is the axial position of the defect.(3) Segment the image into 300 × 300 pixel subimages along the axis, matching the 300 pixel axial length.(4) Add the pixels along the circumference to obtain the one-dimensional a(i) (1 ≤ i ≤ 300).e position of the maximum of a(i) is the defect's circumferential location.
After the above processes, the defect appears in a 300 × 00 pixel image.Figure 12 shows the grayscale image and a photograph for several instances of broken wires.

k-Nearest Neighbor Algorithm.
e k-nearest neighbor algorithm is a commonly used method for supervised learning.Given a test sample, the algorithm finds k samples in the training set closest to the test sample based on a distance measurement.
e algorithm then makes a prediction on the basis of the information of the k "neighbors.""Voting" is usually used in classification applications, which mean that the most common category markers in the k samples are selected as the prediction results [24].
KNN is a type of lazy learning method.During training, it only saves the samples, with a training time cost of zero.Only after receiving test samples will KNN process the training data.KNN avoids the matching problem between objects by calculating the nonsimilarity index as the distance between objects.e commonly used distance measures are the Euclidean and Manhattan distances, according to the following equations: At the same time, KNN makes decisions based on the dominant categories of k objects rather than a single object.erefore, the algorithm has the following advantages: (1) e theory is mature, simple, and applicable to both classification and regression (2) It is usable for nonlinear classification (3) e training time complexity is only O(n), which is lower than that for algorithms such as support vector machines (4) Compared with naive Bayes classifiers and other algorithms, it adds no hypothesis to the data, offers high accuracy, and is not sensitive to outliers (5) By relying on a limited number of neighboring samples rather than class domains to determine the category, it is more suited to sample sets with overlapping class domains e KNN algorithm processes according to the following sequence of steps: (1) Calculate the distance between the test data and each training data (2) Sort the results by increasing distance (3) Select the k points with the smallest distance (4) Count the frequency of occurrence of the category with k points (5) Return the category with the highest frequency in the first k points as the prediction classification of the test data

Quantitative Identification Experiment.
In our quantitative identification experiment, we used a 28 mm diameter wire rope with a 6 × 36 structure.We obtained a total of 499 samples, including 1, 2, 3, 4, 5, and 7 deliberately broken wires.Among the samples, 66 had 1 broken wire, 88 had 2 broken wires, 115 had 3 broken wires, 115 had 4 broken wires, 64 had 5 broken wires, and 51 had 7 broken wires.In actual use for classification, the model sometimes performs well with the training data but less so for the test data.Table 3 likewise shows results when the percentage error of broken wires is 0.49%.
Based on the results shown in Tables 2 and 3, we selected model 1 as the model for quantitative identification.
Figure 13 shows the recognition accuracy for different values of k.Table 2 and Figure 13 show that setting k to 9 produced the best recognition results.For a percentage error of 0.93%, the recognition accuracy was 98.4%, and the percentage error cannot exceed 1.39%.e percentage of broken wire refers to the percentage of the number of broken wire of the wire rope in the total number of wire rope, and the percentage error refers to the resolution of the recognition model, which means that when the allowable percentage error is less than this value, it is considered to be the correct recognition result.

Results and Discussion
As a quick summary, our design for a nondestructive wire rope testing system makes use of unsaturated magnetic excitation, data denoising with VMD and wavelets, and KNN to identify broken wires in the tested ropes.eoretical analysis and experiments have both verified the validity of our nonsaturated magnetic testing system.According to the results given in Table 2 and Figure 13, our method achieved a recognition rate of 98.4% when the percentile error was controlled at 0.93%.In comparison with [15], the identification accuracy rate was 94% when the allowable error was 1.5%.Compared with [16], the accuracy was 93.75%.Our method outperforms existing methods.
During our experiment, we also found that when using the same aperture acquisition board for data collection, different wire ropes with different structures would result in different lift-off behaviors, causing the data amplitude of the wire rope MFL with different structures at the same number of broken wires to differ significantly.
ese differences affected the subsequent quantitative identification.
erefore, a fixed lift-off improves the accuracy of the detection system.In the process of data noise reduction, we also found that the VMD needs to determine the number of modes in advance.In the VMD, the difference between modes is the difference of central frequencies.erefore, it is necessary to use the observed central frequency method to determine the number of modes, which requires some subjectivity and guesswork.Furthermore, when using the KNN algorithm for classification, different k values produce different recognition results.
erefore, multiple runs are needed to determine the optimal value of k.

Conclusions
In this paper, we have done three research works.Firstly, we have presented a system for nondestructive testing of wire ropes to address the disadvantages of traditional MFL testing.
Our system uses unsaturated magnetic excitation to detect various types of damage effectively.Compared with traditional strong magnetic and remanent magnetic testing devices, our system offers a simple structure, small volume, lightweight, and high sensitivity.Secondly, to combat noise within the raw MFL signals, we have also proposed a denoising algorithm based on VMD and wavelet transformations.And the modemaximum method was used to locate the defects axially and circumferentially.Finally, we use a KNN classification algorithm to identify the broken wires quantitatively.Our experiments show that our method offers good recognition results.Our research provides a useful means to determine the remaining strength and service life of wire ropes.In the future, we plan to seek improvements to our detection device and optimizations of the quantitative identification algorithm.In addition, we will further investigate other types of defects.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

( 1 )
Connect the sensor array board, encoder, control board, and unsaturated magnetic excitation module as shown in Figure 1.Align the axis of the sensor array along the axis of the rope wire.(2) Translate the collection system along the axial direction of the wire rope.e encoder rotates synchronously during the movement to ensure equal step sizes.(3) For each axial displacement step, collect flux data from each sensor element to obtain a full circle of radial flux leakage.Repeat step (2) four to five times.

eFigure 1 :
Figure 1: Schematic diagram of the data acquisition device.

(1) Initialize 􏽢 u 1 k􏼈 􏼉, ω 1 k􏼈 􏼉, 􏽢 λ 1 􏼚 􏼛, and n. ( 2 )
Update u k and ω k according to formulas (9) and (10).(3)Update λ: Figure6shows several single channel data before and after processing with the above algorithm.Figures6(a), 6(c), 6(e), and 6(g) are the single channel raw data; Figures 6(b), 6(d), 6(f ), and 6(h) are the corresponding single channel data after denoising.We process the 18 channels of MFL data with the above algorithm to obtain the data without baseline and noise.Figure7shows a sample of the expanded data comparison before and after denoising.

Figure 9 :
Figure 9: e normalization results from a representative sample.

Figure 10 :
Figure 10: Data after improving the circumferential resolution.
To evaluate the model's generalization ability and choose the right model, we performed k-fold cross-validation by separating the dataset into training and validation (test) sets.

Table 2 :
Recognition accuracy for different values of k and percentage error of broken wires is 0.93%.

Table 3 :
Recognition accuracy for different values of k and percentage error of broken wires is 0.49%.