# Classification of Respiratory States Using Spectrogram with Convolutional Neural Network
## 3 Proposed Method
As shown in Figure 5, normal respiration has a peak value of around 13 Hz, apnea has a peak of around 20 Hz, and speaking respiration has a peak of around 3 Hz. \(\mu\) is the average frequency of respiration states in the frequency domain. Figure 4: Spectrograms of three respiratory states: (**a**) Normal respiratory state (**b**) Abnormal (Apnea) state (**c**) Normal breathing during a speaking activity. A series of processes, from inputting the respiration state to the visualization of the frequency change, using the fast Fourier transform is shown in Figure 6. First, the input respiration state divides the entire signal into regions using the window function. In addition, a region adjacent to the window divided by an overlap is used overlappedly, and the frequency is transformed by fast Fourier transform. In contrast, the \(x\)-axis visualizes the signal of the respiration state as a time domain and the \(y\)-axis as a frequency value. Figure 5: Frequency analysis of signals in the respiratory states. Figure 6: Frequency analysis of signals in the respiratory states. The window function divides the input data into units of a specified length and divides the signal. When the start and end values of the divided signal are not 0, signal discontinuity occurs. The Hamming window minimizes the discontinuity for each window in order to reduce frequency distortion. Equation (2) is the Hamming window equation. \(N\) is the number of input data, and in the case of the present work, it is 60 (respiration signal is sampled with 1 Hz, 60 samples per 1 min). \[h(n)=0.54-0.46 cos(\frac{2\pi n}{N-1}),0\leq n\leq N \tag{2}\]  
The overlap uses adjacent data utilized in the previous time window as the starting value for the current window. The input signal is divided into divided windows, and the discontinuity between the generated windows is minimized. In Equation (3), \(L\) is the length of the window used (\(L=N\)), and \(p\) (here, \(p=0.5\)) is the percentage of adjacent data to be used. A number for overlapped data is written by:  
\[o(p)=L-(L*p) \tag{3}\]  
Visualized feature values are generated in 224X224X3 RGB format. The respiration state is visualized with a spectrogram, which is one of the visualization methods. The \(x\)-axis represents the time domain, and the \(y\)-axis represents the frequency domain, indicating the frequency domain of the respiration state according to the time domain. The spectrograms for normal, apnea, and speaking, which represent respiration for each input situation, are explained in Figure 4.0  
The CNN analyzes and classifies visual images by applying filtering techniques to artificial neural networks. It consists of an input layer, a convolution block, a fully connected (FC) layer, and a softmax layer, as shown in Figure 4.1  
The input image data generate a feature map through convolution block, filter, stride, and padding processes, and the output value of the neural network is used with the activation function. The channel for the input image is determined by the input layer, and the filter extracts the features of the input data to generate a feature map. The convolution block consists of convolution, batch normalization, activation function, and max pooling. Figure 4.2 Brief structure of Convolutional Neural Networks. Convolution is an operator that finds a new function with two functions. In fact, in the convolutional neural network, the operation of the filter inversion process is omitted by cross-correlation. The convolution operation shows a loss in the size of the feature map. Padding fills the edges of the input matrix with specific values and prevents the loss of the feature map size caused by the convolution operation. In the proposed method, a zero-padding, which fills the value with \"0\", is applied. The batch normalization of artificial neural network models is the process of normalizing input values with the mean and variance of the data in the classifier learning process.