Giter Site home page Giter Site logo

r13i / ecg-classify Goto Github PK

View Code? Open in Web Editor NEW
30.0 4.0 7.0 1.56 MB

Classifying Heartbeat Arrhythmia using novel features (Auto-regressive coefficients & RR inter-beat distance)

License: MIT License

Jupyter Notebook 99.89% Python 0.11%
machine-learning python ecg signal-processing qrs heartbeat heartbeats-classification veb-beats waves-autoregressive-features auto-regressive-coefficients

ecg-classify's People

Contributors

r13i avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ecg-classify's Issues

I cant read the data in feature extraction step at ECG-classify

Hello, thanks for your code it's mean a lot to help my project.

I tried to implement your code with polysomnography data. it's work until I try to implement Model Fitting, I try to solve the problem, but when I check the Feature Extraction step, I found the code cant process the data, the plot in 'if not' didn't show, here the code I mean

lst = list()

for i in DS1:
rec_index = i

# Tweak the use_filter param
lst = extract_features("slpdb/" + rec_index, length_qrs, length_stt, ar_order_qrs=3, ar_order_stt=3, use_filter=True)
df = pd.DataFrame(lst)

#I try to print the code but the output is null [ ]

if not df.empty and not df[df["type"] == "VEB"].empty and not df[df["type"] == "N"].empty:
n_pre_rr = df[df["type"] == "N"]["pre-RR"]
veb_pre_rr = df[df["type"] == "VEB"]["pre-RR"]
n_post_rr = df[df["type"] == "N"]["post-RR"]
veb_post_rr = df[df["type"] == "VEB"]["post-RR"]

    fig1 = plt.figure()
    ax1 = fig1.add_subplot(121, title="Record {} | Pre-RR")
    ax1.scatter(n_pre_rr, c="c", label="Normal")
    ax1.scatter(veb_pre_rr, c="r", label="VEB")
    
    

    n_qrs_ar_array = series2arCoeffs(df[df["type"] == "N"]["QRS_ar_coeffs"])
    veb_qrs_ar_array = series2arCoeffs(df[df["type"] == "VEB"]["QRS_ar_coeffs"])
    n_stt_ar_array = series2arCoeffs(df[df["type"] == "N"]["ST/T_ar_coeffs"])
    veb_stt_ar_array = series2arCoeffs(df[df["type"] == "VEB"]["ST/T_ar_coeffs"])

    fig = plt.figure(figsize=(20, 5))

    ax1 = fig.add_subplot(141, title="Record {} | QRS | a0 vs a1".format(rec_index))
    plt.ylim(-2.5, 0.5)
    plt.xlim(0.8, 2.6)
    ax1.scatter(x=n_qrs_ar_array[:, 0], y=n_qrs_ar_array[:, 1], c='c', label="Normal")
    ax1.scatter(x=veb_qrs_ar_array[:, 0], y=veb_qrs_ar_array[:, 1], c='r', label="VEB")
    plt.legend(loc="best")

    ax2 = fig.add_subplot(142, title="Record {} | QRS | a1 vs a2".format(rec_index))
    plt.ylim(-0.6, 0.8)
    plt.xlim(-2.5, 0.5)
    ax2.scatter(x=n_qrs_ar_array[:, 1], y=n_qrs_ar_array[:, 2], c='c', label="Normal")
    ax2.scatter(x=veb_qrs_ar_array[:, 1], y=veb_qrs_ar_array[:, 2], c='r', label="VEB")
    plt.legend(loc="best")

    ax3 = fig.add_subplot(143, title="Record {} | ST/T | a0 vs a1".format(rec_index))
    plt.ylim(-3, 0.5)
    plt.xlim(0.5, 3)
    ax3.scatter(x=n_stt_ar_array[:, 0], y=n_stt_ar_array[:, 1], c='c', label="Normal")
    ax3.scatter(x=veb_stt_ar_array[:, 0], y=veb_stt_ar_array[:, 1], c='r', label="VEB")
    plt.legend(loc="best")

    ax4 = fig.add_subplot(144, title="Record {} | ST/T | a1 vs a2".format(rec_index))
    plt.ylim(-0.6, 1)
    plt.xlim(-3, 0.5)
    ax4.scatter(x=n_stt_ar_array[:, 1], y=n_stt_ar_array[:, 2], c='c', label="Normal")
    ax4.scatter(x=veb_stt_ar_array[:, 1], y=veb_stt_ar_array[:, 2], c='r', label="VEB")
    plt.legend(loc="best")

else:
    print("Record {} : At least one empty category : VEB or N.".format(rec_index)

What should I do to solve the code?

Thanks for your help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.