## 3 Data Preparation
### Data Preparation  
As described in the previous section, each scan of the sensor probe could cover a few rivets according to the scan length of the scanner (e.g., three rivets); therefore, it is necessary to separate each rivet data before detection of corrosion. It is observed that the rivet signal has high intensity, so it is easy to detect and separate the rivet by the peak detection algorithm [22]. However, the rivet is not always at the center of the scanned image, and the total number of images is only 720. Thus, random shifting of the magnetic image window around the rivet increases the number of magnetic images. The magnetic image window was set with a size of 56 \(\times\) 80 pixels with respect to 30 \(\times\) 40 mm (in sensor length \(\times\) scan direction), which is shorter than the sensor length (64 pixels) but enough to cover the entire the rivet. Finally, there are 18,000 magnetic images in the dataset. For performing feature extraction by PCA and machine learning algorithm, the dataset was transformed into two dimensions, which has a size of 18,000 \(\times\) 4480. There are five classes of the rivet, which have no corrosion, forward, backward, left, and right corrosion.  
Figure 4 shows samples of scanned magnetic images of the rivet with and without corrosion. The data have removed the offset by subtracting the first line scan data, as described in Equation (4). The rivet signal has two peaks with high intensity. With large corrosion in Figure 4 (e.g., \(\mathcal{O}\)10 \(\times\) d0.9), the corrosion signal could be observed clearly. However, when the corrosion size is small, it is hard to recognize the corrosion signal and be buried in the high-intensity signal of the rivet, as observed in Figure 5. The corrosion signal quickly decreases as the depth and diameter decrease.  
\[\mathbf{V}(i,j)=\mathbf{V_{RMS}}(i,j)-\mathbf{V_{RMS}}(i,0) \tag{4}\]  
where \(\mathbf{V_{RMS}}(i,j)\) is the root-mean-square voltage of the Hall sensor element \(i\)-th at scan index \(j\); \(\mathbf{V_{RMS}}(i,0)\) is the root-mean-square voltage of the Hall sensor element \(i\)-th at the first scan index. This is known as offset voltage, and \(\mathbf{V}(i,j)\) is the processed voltage after offset subtraction of the sensor \(i\)-th at scan index \(j\).  
Figure 3: Two-layer specimen with a rivet with hidden corrosion on the second layer.  
One of the big challenges when applying machine learning techniques in electromagnetic testing is the limited amount of data for training the machine-learning models. Thus, we evaluate three training/validation dataset splitting strategies which are \"mixing\", \"increasing\", and \"shifting\", as described in Figure 6. In the \"mixing\" strategy, the training/validation dataset has a ratio of 80/20 as the normal splitting approach. There is a total of 25 distinguished corrosions: 20 corrosions for training and 5 corrosions for validation. The number of corrosions in the training dataset increases from a low volume to a high volume in the \"increasing\" strategy. Each increasing step is 20% of the total corrosion  
strategy, the training dataset is fixed with only 20% of the total samples, but the volume is shifted from small to large size P\({}_{1-5}\). The detailed splitting dataset is shown in Table 2.