The Design and Implementation of Cardiotocography Signals Classification Algorithm Based on Neural Network

Mobile medical care is a hot issue in current medical research. Due to the inconvenience of going to hospital for fetal heart monitoring and the limited medical resources, real-time monitoring of fetal health on portable devices has become an urgent need for pregnant women, which helps to protect the health of the fetus in a more comprehensive manner and reduce the workload of doctors. For the feature acquisition of the fetal heart rate (FHR) signal, the traditional feature-based classification methods need to manually read the morphological features from the FHR curve, which is time-consuming and costly and has a certain degree of calibration bias. This paper proposes a classification method of the FHR signal based on neural networks, which can avoid manual feature acquisition and reduce the error caused by human factors. The algorithm will directly learn from the FHR data and truly realize the real-time diagnosis of FHR data. The convolution neural network classification method named “MKNet” and recurrent neural network named “MKRNN” are designed. The main contents of this paper include the preprocessing of the FHR signal, the training of the classification model, and the experiment evaluation. Finally, MKNet is proved to be the best algorithm for real-time FHR signal classification.


Introduction
With the general improvement of people's living standards in today's society, people's demands for health are constantly increasing, especially for the health of the next generation. More people want their children to be well cared for during their unborn childbirth. During the development of the fetus, parents hope to be able to grasp the physiological information of the fetus in real time, such as the fetal heart rate and contraction pressure, to help early detection of potential risks, and to guide fetal health development [1]. Due to psychological or physiological stress, the physiological parameters detected by some patients in the hospital and the physiological parameters detected in their familiar environment will be greatly different. Recent studies have shown that patients who are clinically diagnosed with high blood pressure and are likely to develop heart disease, after a 24-hour blood pressure monitoring at home, found that only one-third of the users' monitoring results are consistent with clinical diagnosis [2]. Professor Johnson has demonstrated the use of remote fetal monitoring methods to allow pregnant women and fetuses to measure important physiological indicators such as blood pressure, blood oxygen, and electrocardiogram at home [3]. is environment that allows pregnant women to feel at ease is more conducive to pregnant women, fetuses, and to detect the condition of the newborncorrectly [4]. erefore, the use of remote fetal monitoring systems at home in perinatal pregnant women can improve the quality of perinatal care. e purpose of this paper is to use neural network to classify the fetal heart rate monitoring data and realize realtime fetal health or abnormal development on the remote fetal heart monitoring system. Because the traditional FHR data classification uses complex professional features, these features require personnel with professional medical knowledge to accurately calibrate, and collection is slow and difficult [5]. In fact, the analysis of these FHR features is time consuming and laborious, and it is impossible to obtain medical conclusions in real time, which greatly delays the progress of medical diagnosis [6]. e latest neural network model can directly use the fetal heart rate data as input and automatically extract key features using relevant algorithms to obtain accurate classification results [7]. erefore, we use neural network to explore the method of fetal heart monitoring data prediction. However, fetal heart rate monitoring data are faced with problems such as large data volume, high data noise, and serious data defects, which seriously affect the classification results. How to preprocess the collected raw data and design a neural network model that fits the data is the problem to be solved in this paper.
Based on the neural network algorithm, this paper design different FHR data classification models [8]. By comparing and evaluating the performance of different FHR data classification models, we summarize the performance of the above models and select the optimal FHR data classification model and finally use it to guide medical practice. is paper will setup the control group and the experimental group. e control group adopts the traditional data classification methods, including the support vector machine (SVM) and the random forest (RF) method [9]. e experimental group adopts an artificial neural network (ANN) method, including convolution neural networks (CNN) and recurrent neural network (RNN) methods. ese methods include the following: (1) data collection, (2) data preprocessing, (3) model training, and (4) evaluation.

Results
On the whole, the neural network-based training algorithm is superior to the feature-based training algorithm. As shown in Table 1, the length of the training time reflects the training speed of the classification model. By comparison, we can see that in the speed of the classification model, RF > SVM > MKNet (1330s � 19s * 70epoch) > MKRNN (350s � 5s * 70epoch). However, the length of training time is also related to the size of the data set and the complexity of the model [10]. In this paper, the simple comparison training time does not have great practical significance. Although the feature-based method is shorter in training time, the long manual marking time is also something we have to consider. In terms of accuracy, MKNet-C > MKRNN > RF > SVM. e experimental results of different classification models will be described in detail below.

Support Vector Machine Evaluation.
e highest accuracy rate obtained on the feature classification method SVM is 83.46%, and the highest F1-score is 0.8334. e specific results are shown in Table 2. e ROC (receiver operating characteristic) curve is drawn for the trained SVM classifier, as shown in Figure 1(a). e ROC curve in the graph shows the results for each of the 5-fold cross validation. e thicker broken line shows the average ROC with an average AUC (area under the curve) of 0.85 [11].

Random Forest Evaluation.
e highest accuracy obtained on RF is 84.50%, and the highest F1-score is 0.8334. e specific results are shown in Table 3. e ROC curve is plotted against the trained RF classifier, as shown in Figure 1(b). e ROC curve in the graph shows the results for each of the 5-fold cross validations. e thicker dashed line shows the average ROC curve with an average AUC of 0.86 [11].
Comparing Figures 1(a) and 1(b), and Tables 2 and 3, the  performance of SVM and RF are similar. erefore, the accuracy of feature-based method is around 84%.

MKNet Evaluation.
e highest accuracy of the MKNet model is 94.70%. e model for obtaining the highest classification accuracy is the model MKNet-C, with a 17layer network. Next, the experimental results of the models MKNet-A, MKNet-B, and MKNet-C are analyzed in detail.
MKNet-A contains only one convolution block conv1. e convolution kernel size of this convolution block is 9 * 9, which is replaced by four 3 * 3 convolution kernels, to reduce the computing complexity [12]. e learning curve of MKNet-A is shown in Figure 2 [13]. e highest accuracy rate of the model is about 76%, which is quite different from the expected value. A convolution block is added to MKNet-B on the basis of A, from the 5th layer of MKNet-A to the 9th layer of MKNet-B. e learning curve of MKNet-B is shown in Figure 3. e accuracy rate of MKNet-B is about 80%, which is 5% higher than that of MKNet-A, but it is still low. erefore, using MKNet-C with one more convolution block conv3, it is expected to improve the accuracy [14]. And add some dropout layer based on MKNet-B to prevent the overfitting problem caused by the increase of model complexity [15]. e learning curve of MKNet-C is shown in Figure 4(a). MKNet-C has one more convolution block on the basis of MKNet-B and adds 1 * 1 convolution layer to each convolution block to increase the fully connected layer fc2. erefore, the 9-layer MKNet-B becomes the 17-layer MKNet-C.
MKNet-C has an 11% improvement in accuracy over MKNet-B. However, there is still a slight overfitting of the model, so MKNet-C continues to be optimized and trained, using the image enhancement function to increase the original data set [16]. e learning curve of MKNet-C is shown in Figure 4(b). e data enhancement parameter is set to width_shift_range � 0.2, and the original image is randomly moved 20% in the horizontal direction to increase the data set size [16]. e data set after data enhancement is input into MKNet-C for training, which solves the overfitting problem of MKNet-C and finally obtains the accuracy of 94.70%. e ROC curve is drawn for the trained MKNet-C (with data enhancement), as shown in Figure 6(a), AUC � 0.95, which achieves a good classification performance.

MKRNN Evaluation.
e highest accuracy of MKRNN is 90.30%, and the learning curve is shown in Figure 5. e model converges quickly and the highest accuracy rate is 90.30%, AUC � 0.91. e AUC value of MKRNN is lower than that of MKNet-C, but higher than that of the traditional featurebased classification method [11]. As shown in Figure 6, the accuracy of MKNet is significantly higher than that of MKRNN.
e AUC of MKNet is larger than that of MKRNN. erefore, MKNet shows better performance in the classification of FHR data [11].

Discussion
e following is a summary of the work of the research topic: (1) Research the current research status and research methods for classification of fetal heart monitoring, including support vector machines, random forests in traditional feature classification methods, CNN in neural network algorithms, and recurrent neural networks. e explanation of the advantages and disadvantages of each research method is given. Focusing on the CNN, this paper analyzes the guiding significance of the CNN on the classification of fetal heart monitoring and proposes the research ideas of this article, pointing out that the neural network is innovative and feasible for fetal heart monitoring classification.
(2) Preprocessing the fetal heart monitoring data, sequentially removing the fetal heart rate data for sample deletion with a high proportion of deletions, consecutive missing values, linear interpolation, smooth denoising, and then adjusting the data structure to obtain three different types of data format. (3) Set the control group and the experimental group, and design different algorithms according to different data formats. e support vector machine algorithm and random forest algorithm are used to classify the fetal heart features data. MKNet algorithm and MKRNN algorithm are used to design the classification model of fetal heart rate data. e principle and design process of each model are introduced in detail, and the advantages and disadvantages of the above methods are analyzed. (4) Make comparative analysis of the experimental results of different classification models, optimize and improve the optimal CNN model, prove that the neural network is innovative and feasible for fetal heart rate monitoring classification, and finally get MKNet as the best fetal heart monitoring classification prediction model.
In this chapter, we compare and analyze the experimental results of the four classification models designed and implemented, and conclude that the neural network algorithm is more advantageous in the classification of fetal heart    e MKNet-C is the most complex in implementation, and it also obtains optimal prediction results that are superior to all the above models. e accuracy of the feature-based classification method largely depends on the quality of the training data set, but it is difficult to form a high-quality data set by the manually labeled features. A neural network-based classification method can process data by a data preprocessing algorithm to form a high-quality data set. From the results of comprehensive experiments,      MKNet outperforms feature-based classification in the difficulty of data set collection and it also outperforms traditional feature classification in classification performance. In summary, this paper trains MKNet as the final model, which has obvious advantages both from the rigorousness of the algorithm design principle and the comparison of the prediction results.

Materials and Methods
is section introduces data collection, data preprocessing, and model design.

Data Collection.
e FHR data set used in this paper was collected by the micro fetal heart monitor, which was from more than 20 hospitals' gynecology across the country. e patient uses a fetal heart rate monitor to perform fetal heart monitoring and uploads the monitoring graphic to the system. e qualified obstetrician remotely interprets the data through a networked computer and a smartphone.
In terms of software, the terminal control device judges the data initially collected by the fetal heart rate instrument to determine the start time of collecting the fetal heart data, record the fetal heart data and the fetal movement time point, and generate a corresponding detection report. On the hardware side, the fetal heart rate Doppler signal received by the probe of the fetal heart monitor is preamplified, demodulated, amplified, and filtered by the posterior pole and sent to the microprocessor for A/D conversion, and then a series of complex calculations are carried out to get the frequency of fetal heartbeats per minute [17].
e label of each sample is reinterpreted by a specially formed panel of experts consisting of three professional authoritative experts. e sample label is based on the consensus of the experts.

Data Preprocessing.
e original data are divided into two parts: one is the FHR data collected by the fetal heart monitor, and the other is the medical feature marked by the doctor based on the fetal heart rate curve. In total, there are   Computational and Mathematical Methods in Medicine 24,360 samples. e FHR feature is stored as data fields and used as control group data. is article selects 60% of the data samples as a training set, 20% as a test set, and 20% as a validation set. A part of the original data has a large amount of data missing, and the missing data exist in the raw data as a zero value. e sample in Figure 7 is missing in a small amount and can be filled by a simple missing value padding method. e sample in Figure 8 has a large number of zeros. ere are multiple long consecutive missing lines in Figure 9. e missing interval may lose the acceleration or deceleration characteristics. e statistics of the missing data of the raw data are shown in Figure 10. 1.2% of the data has a missing of about 1000 points, and 14.7% of the data has a missing of 200 to 500 points. 51.1% of the data is relatively complete; there are only about 100 data points missing and 33% of the data is not missing. Moreover, due to environmental factors such as fetal heart rate monitoring and maternal physical factors, the measured FHR data may be unstable, which may seriously interfere with the results. is unstable data are called dirty data.
In this paper, the methods used for the data preprocessing are as follows: (1) e missing heart value of the FHR signal curve is counted, and the sample whose ratio is greater than the 10 s is rejected [18]. (2) Breakpoint detection is performed on the FHR signal curve, and samples with consecutive breakpoints exceeding 30 s are rejected. (3) Linear interpolation missing value repair for FHR signal curve [19]. (4) For FHR signal curve for noise reduction, heart rate five times lower than 10 bpm (beats per minute) is regarded as the stable heart rate. Whenever the difference between neighboring heart rates is higher than 25 bpm, the sample will be replaced by a linear interpolation between the previous heart rate and the new stable heart rate. Figure 11 shows the curve after a small number of missing samples are filled by linear interpolation, in which the upper image is the original curve and the lower image is the corrected FHR curve.
From the figure, we can significantly see data still exist small jagged unstable fetal heart rate signal, largely by instrument measurement error result in. In order to reduce jagged graphic image of the trend, the use of filters smoothes the curve. Ignoring local small curve change on overall curve trend. is paper for FHR data used Savitzky-Golay filter, which is a digital filter [20]. Figure 12 shows the FHR curve after processed by the smoothing algorithm. It can be observed that the local fine jagged unstable signal is replaced by a smooth curve while retaining the original curve trend.
Each sample was a continuous FHR monitoring sample for 20 minutes; a total of 2400 times were recorded in the time of 20 minutes [21]. us, each sample contains 2400 fetal heart rate values. e raw FHR data are in json format storage; Figure 13 shows the fetal heart rate time series data extracted from the json format data, which will be used as input data for the circulating neural network.
In the raw data, there are medical features manually calibrated according to the FHR curve; these feature fields will be used as input data for feature-based classification methods, as shown in Figure 14. e 11 fields of the 24360 samples in the experimental data set are used as input for the feature-based classification method. Some of the input data samples are shown in Table 4. e raw FHR data exist in the form of continuous data points, and the result presented to the doctor is the fetal heart monitoring image, which is the FHR curve transformed from the original continuous data points. Expressed in the form of curves, it is more intuitive and more convenient to see the characteristics of curves and the medical information represented by these characteristics. In order to unify the size of the image data, the rate of fetal heart rate below 80 beats/ minute is regulated to 80 beats/minute, and the heart beat rate of more than 200 beats/minute is standardized to 200 beats/ minute. e resulting image has 120 pixels on the vertical axis and 2400 pixels on the horizontal axis, so the image size is 120 * 2000 pixels. e fetal heart monitoring image will serve as input data to the convolution neural network.
We performed a format conversion of the fetal heart monitoring data, converting the original fetal heart rate data to continuous data containing only the fetal heart rate values, and displaying images of the fetal heart rate curve. e database fields were extracted and the fields with categorical value were selected. erefore, after data preprocessing, a total of three types of data are obtained. Different algorithms will be used to model different data types.
(1) Continuous fetal heart rate values represent changes in fetal heart rate as a function of time, which is a time series data. e model MKRNN will be used to train the model based on the recurrent neural network. (2) e FHR curve represents the changing trend of the fetal heart rate throughout the monitoring time and is the image data. Model training based on the convolution neural network algorithm MKNet will be used. (3) e FHR feature field, which represents the medical characteristic value analyzed from the fetal heart rate curve [22]. Support vector machines and random forests will be used for model training [9].
is article will focus on these three different types of data features: (1) and (2) groups for the experiment and (3) the control group, respectively, for the model design and experiment, and the experimental results were compared.

MKNet Based on Convolution Neural Network.
is paper designs a convolution neural network model named "MKNet"; firstly, the important parameters involved in MKNet are introduced, as is shown in Table 5. e Keras deep learning framework is used in this experiment. Ten-sorFlow is served as backend. Figure 15 is the simplification of the VGG (Visual Geometry Group) network structure. e VGG network is mainly composed of five convolution blocks, three full connection layers, and one softmax layer [23].
Each convolution block contains three convolution layers, which are characterized by continuous convolution layers and large calculations. is article will use the VGG network structure as a reference, starting from a convolution block, gradually build a convolution neural network suitable for fetal heart monitoring image classification. e input data of MKNet in this paper are gray image data, with a size of 120 * 2400 pixels.
In the neural network training process, one problem often encountered is overfitting. To improve the ability to generalize, one way is to use more training data, as the size of the data set is limited in this paper, the data enhancement can be used to solve this problem. In Keras, data enhancements can be implemented with function keras.preprocessing.image.ImageGenerator, which can set random transformations to be applied to data during training [26]. Table 6 shows the parameters used in data enhancement. Because the FHR curve in this article represents the corresponding medical meaning, it cannot be reversed up or down or left or right without violating its original meaning. e feasible method is to carry out small-scale horizontal random movement of the image so that the key information of the image is not lost.  1  47  93  139  185  231  277  323  369  415  461  507  553  599  645  691  737  783  829  875  921  967  1013  1059  1105  1151  1197  1243  1289  1335  1381  1427  1473  1519  1565  1611  1657  1703  1749  1795  1841  1887  1933  1979  2025  2071  2117  2163  2209  2255  2301  2347  2393   0   20   40   60   80   100   120   140   160   180   200   1  50  99  148  197  246  295  344  393  442  491  540  589  638  687  736  785  834  883  932  981  1030  1079  1128  1177  1226  1275  1324  1373  1422  1471  1520  1569  1618  1667  1716  1765  1814  1863  1912  1961  2010  2059  2108  2157  2206  2255  2304 2353 2402       Table 7. e input layer of the LSTM (long shortterm memory) is specified by the input_shape parameter on the first hidden layer of the neural network. e LSTM layer

Feature-Based
Method. e feature-based classification method is build as control group in this paper, SVM and RF are chosen as the classifier.
After the search of the grid search algorithm, the combination of the optimal hyperparameters of the SVM is {'kernel': 'rbf', 'C': 1000, 'gamma': 0.0001}, all the other hyperparameters are set in default value.

Conclusions
e following is a summary of the work of the research topic: (1) Research the current research status and research methods for classification of fetal heart monitoring, including support vector machines, random forests in traditional feature classification methods, convolutional neural networks in neural network algorithms, and recurrent neural networks. e explanation of the advantages and disadvantages of each research method is given. Focusing on the convolutional neural network, this paper analyzes the guiding significance of the convolutional neural network on the classification of fetal heart monitoring, and proposes the research ideas of this article, pointing out that the neural network is innovative and feasible for fetal heart monitoring classification.
(2) Preprocessing the fetal heart monitoring data, sequentially removing the fetal heart rate data for sample deletion with a high proportion of deletions, consecutive missing values, linear interpolation, smooth denoising, and then adjusting the data structure to obtain three different types of data format. (3) Set the control group and the experimental group, and design different algorithms according to different data formats. e support vector machine algorithm and random forest algorithm are used to classify the fetal heart features data. MKNet algorithm and MK-RNN algorithm are used to design the classification model of fetal heart rate data. e principle and design process of each model are introduced in detail, and the advantages and disadvantages of the above methods are analyzed. (4) Make comparative analysis of the experimental results of different classification models, optimize and improve the optimal convolutional neural network model, prove that the neural network is innovative and feasible for fetal heart rate monitoring classification, and finally get MKNet as the best fetal heart monitoring classification prediction model.

Data Availability
e fetal heart monitoring data used to support the findings of this study are currently under embargo, while the research findings are commercialized. Requests for data (6/12 months after publication of this article) will be considered by the corresponding author.

Conflicts of Interest
e authors declare no conflicts of interest.

Authors' Contributions
Haijing Tang and Xu Yang conceived and designed the experiments, Mengke Li performed the experiments, Taoyi Wang and Mengke Li analyzed the data, and Taoyi Wang wrote the paper.