0
$\begingroup$

I have ML model which is trained on Afib, Normal, Other - 3 class. Currently when I am testing the model with unseen database, sometimes it identify PVC singals as Afib class.

For example -

enter image description here

enter image description here

enter image description here

These are normal ECG records having PVC ( Premature Ventricular Complex ) - Reversed peaks in it.

But my ML model tag it as Afib class.

So I want to tell model, that if this is the kind of signal it has, it should be PVC, and should not consider it as Afib.

What I tried.

  1. Extract P wave and train the model with p - wave feature. PVC does not have p-wave in it but afib has. So I thought it will understand that not to consider PVC as afib

def plot_peak_detection(ecg, rate):
    import matplotlib.pyplot as plt
    dt = 1.0/rate
    t = np.linspace(0, len(ecg)*dt, len(ecg))
    plt.plot(t, ecg)

    peak_i = detect_beats(ecg, rate)
    plt.scatter(t[peak_i], ecg[peak_i], color='red')
    plt.show()
def pwave_extract(ecg_arr, lpwp, rpwp):
    loc = list(zip(lpwp, rpwp))    
    pwave_arr = []
    for els in loc:
        pwave_arr.append( ecg_arr[els[0]:els[1]] )
    return pwave_arr
  1. Extract R-S peak amplitutude. Because when we have PVC R-S amplitute comes high. So add this amplitutde max and min value as two feature in model. Afib does not have R-S amplitude so high so going forward it will not mark PVC as Afib. But this logic also did not work
def QRS_test(ecg):
    R_peaks, S_peack, Q_point=EKG_QRS_detect(ecg, 320, True, True)
    scipy_plot(ecg)
    ampt_list = []
    if len(R_peaks) >= len(S_peack):
        for i in range(0, len(R_peaks)):
            try:
                ecg_slice = ecg[R_peaks[i]:S_peack[i]]
                ampt_list.append(max(ecg_slice)-min(ecg_slice))
            except:
                pass
    return ampt_list
  1. Calculate IQR ( Interquartile range ) for amplitude values of R-S peaks. And consider Q1, Q3 as additional feature in model. But this also does not help to solve the problem

Is there any other way I can clearly distingush PVC signal and give this feature to model, so that model does not tag ECg with PVC pattern in it as Afib.

$\endgroup$
1
  • $\begingroup$ Can you provide more detailed information about the ML model that you are using to label the pulses please? $\endgroup$
    – A_A
    Feb 6 at 16:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.