Coder Social home page Coder Social logo

plot_distrib fails about hrv-analysis HOT 2 OPEN

aura-healthcare avatar aura-healthcare commented on June 15, 2024
plot_distrib fails

from hrv-analysis.

Comments (2)

robinchampseix avatar robinchampseix commented on June 15, 2024

Hi,

Thanks for raising this issue :-) Yep I will try to do that soon.
It is actually due to the fact that the method expects a list of int as input.

Regards,
Robin

from hrv-analysis.

 avatar commented on June 15, 2024

For those still waiting, you can fix it by simply casting the max and min values to int's (as range expects int values not floats). By doing something like:

def plot_distrib(nn_intervals, bin_length: int = 8):
    """
    Function plotting histogram distribution of the NN Intervals. Useful for geometrical features.
    Arguments
    ---------
    nn_intervals : list
        list of Normal to Normal Interval.
    bin_length : int
        size of the bin for histogram in ms, by default = 8.
    """

    max_nn_i = max(nn_intervals)
    min_nn_i = min(nn_intervals)

    style.use("seaborn-darkgrid")
    plt.figure(figsize=(12, 8))
    plt.title("Distribution of Rr Intervals", fontsize=20)
    plt.xlabel("Time (s)", fontsize=15)
    plt.ylabel("Number of Rr Interval per bin", fontsize=15)
    #Range expects an integer rather than a float
    plt.hist(nn_intervals, bins=range(int(min_nn_i) - 10, int(max_nn_i) + 10, bin_length), rwidth=0.8)
    plt.show()

from hrv-analysis.

Related Issues (20)

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.