plotters.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:qrs-tutorial 作者: Nospoko 项目源码 文件源码
def show_objective_part2():
    """ For the model """
    # Choose a record
    records = dm.get_records()
    path = records[13]
    record = wf.rdsamp(path)
    ann = wf.rdann(path, 'atr')

    chid = 0
    print 'File:', path
    print 'Channel:', record.signame[chid]

    cha = record.p_signals[:, chid]

    # These were found manually
    sta = 184000
    end = sta + 1000
    times = np.arange(end-sta, dtype = 'float')
    times /= record.fs

    # Extract the annotations for that fragment
    where = (sta < ann.annsamp) & (ann.annsamp < end)
    samples = ann.annsamp[where] - sta
    print samples

    # Prepare dirac-comb type of labels
    qrs_values = np.zeros_like(times)
    qrs_values[samples] = 1

    # Prepare gaussian-comb type of labels
    kernel = ss.hamming(36)
    qrs_gauss = np.convolve(kernel,
                            qrs_values,
                            mode = 'same')

    # Make the plots
    fig = plt.figure()
    ax1 = fig.add_subplot(2,1,1)
    ax1.plot(times, cha[sta : end])
    ax1.set_title('Input', loc = 'left')

    ax2 = fig.add_subplot(2,1,2, sharex=ax1)
    ax2.plot(times,
             qrs_gauss,
             'C3',
             lw = 4,
             alpha = 0.888)
    ax2.set_title('Output', loc = 'left')
    ax1.grid()
    ax2.grid()
    plt.setp(ax1.get_xticklabels(), visible=False)
    plt.xlabel('Time [s]')
    plt.xlim([0, 2.5])
    plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号