# Processing of EMG Signals with High Impact of Power Line and Cardiac Interferences
## 2 Material and Methods
### Comb Filters  
The transfer function of the comb filter is expressed by Equation 3  
\[H(z)=\frac{b\big{(}1-z^{-M}\big{)}}{1-az^{-M}}. \tag{3}\]  
where \(M\) depends on sampling frequency. In the developed system, \(f_{\rm s}\) = 2 kHz was calculated as:  
\[M=\frac{f_{\rm s}}{f_{0}}=\frac{2000\;\rm{Hz}}{50\;\rm{Hz}}=40. \tag{4}\]  
Parameters \(a\) and \(b\) can be chosen according to the width of the 3-dB stopband (\(\Delta f\)) of the filter. The magnitude of the comb filter, raw and filtered signals, and the poles distribution on the z-plane are presented in Figures 11 and 12. Table 2 contains the values of comb filter coefficients for different widths of stopbands. To achieve the proper filtering accuracy, one can consider using high-resolution calculus with filter coefficients represented by the appropriate number of digits as presented in Table 2. \begin{table}
\begin{tabular}{c c c} \hline \hline  & \(a_{i}\), \(i\) = 0,1,2,3 & \(b_{i}\), \(i\) = 0,1,2,3 \\ \cline{2-3}  & 1.0 & 0.993736502353988 \\ \cline{2-3} \(f_{\rm c}\) = 2 Hz & \(-\)2.987433650055722 & \(-\)2.981209507061963 \\ \cline{2-3}  & 2.974946132665443 & 2.981209507061963 \\ \cline{2-3}  & \(-\)0.987512236110736 & \(-\)0.993736502353988 \\ \hline  & 1.0 & 0.969071174031813 \\ \cline{2-3} \(f_{\rm c}\) = 10 Hz & \(-\)2.937170728449890 & \(-\)2.907213522095439 \\ \cline{2-3}  & 2.876299723479331 & 2.907213522095439 \\ \cline{2-3}  & \(-\)0.939098940325283 & \(-\)0.969071174031813 \\ \hline  & 1.0 & 0.939091652311958 \\ \cline{2-3} \(f_{\rm c}\) = 20 Hz & \(-\)2.874356892677485 & \(-\)2.817274956935874 \\ \cline{2-3}  & 2.756483195225695 & 2.817274956935874 \\ \cline{2-3}  & \(-\)0.881893130592486 & \(-\)0.939091652311958 \\ \hline  & 1.0 & 0.910025430686161 \\ \cline{2-3} \(f_{\rm c}\) = 30 Hz & \(-\)2.811573677324689 & \(-\)2.730076292058484 \\ \cline{2-3}  & 2.640484392778340 & 2.730076292058484 \\ \cline{2-3}  & \(-\)0.828146275386261 & \(-\)0.910025430686161 \\ \hline  & 1.0 & 0.881838198574415 \\ \cline{2-3} \(f_{\rm c}\) = 40 Hz & \(-\)2.748835809214676 & \(-\)2.645514595723244 \\ \cline{2-3}  & 2.528231219142560 & 2.645514595723244 \\ \cline{2-3}  & \(-\)0.777638560238081 & \(-\)0.881838198574415 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Third order HP Butterworth filter coefficient value sets for removing low-frequency components from an EMG signal. RMS signal is calculated using the moving window of the length N and the chosen offset as presented in Figure 13. The window length N depends on the sampling frequency fs and should be selected as the multiple of \(f_{s}\)/50, i.e., \(n\) = 40, 80,... for \(f_{s}\) = 2 kS/s. This results from the necessity of acquiring the integer number of periods of 50 Hz and the higher \begin{table}
\begin{tabular}{c c c} \hline \hline  & \(a_{i}\) & \(b_{i}\) \\ \hline \(\Delta f=\pm 0.5\) Hz & \(-0.939062505817492\) & \(0.969531252908746\) \\ \hline \(Df=\pm 1\) Hz & \(-0.881618592363189\) & \(0.940809296181594\) \\ \hline \(\Delta f=\pm 2\) Hz & \(-0.775679511049613\) & \(0.887839755524807\) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Coefficients of comb filters for different stopbands. Figure 11: Comb filter, (**a**) magnitude for \(M\) = 40 and \(\Delta f=\pm 0.5\) Hz, (**b**) poles and zeros distribution on the z-plane for comb filter. Figure 12: EMG signal with high impact of environmental disturbances for right abdominal muscle, (**a**) after low-frequency removal (3 rd order Butterworth HP filter, \(f_{c}\) = 10 Hz), (**b**) filtered by the comb filter (\(M\) = 40 and \(\Delta f=\pm 0.5\) Hz). harmonics. It reduces the leakage problem of frequency analysis and, in consequence, allows for a better estimation of power line disturbances interfering with the EMG signals. \[\mathbf{RMS}(j)=\sqrt{\frac{\sum_{i=0}^{N-1}s^{2}(i+j)}{N}}. \tag{5}\]  
where: \(s(i)\) denotes the samples of input signal preprocessed by filtering, length \(n\) = 40, 80, 120,..., \(j\) = 0, offset, 2 offset,..., offset = \(N/k\), \(k\) = 1,..., \(N\).