python信号滤波_PPG信号滤波过后的时频分析

PPG信号的 时域图、频域图、时频图、小波变换图

import os

import time

import traceback

import pandas as pd

import plotly.plotly as py

import plotly.graph_objs as go

from plotly.offline import iplot, init_notebook_mode

import plotly

import plotly.offline as pltoff

import numpy as np

import pandas as pd

# setting offilne

plotly.offline.init_notebook_mode(connected=True)

def isNone(d):

return (d is None or d == 'None' or

d == '?' or

d == '' or

d == 'NULL' or

d == 'null')

class Plotly2Html(object):

"""

"""

def __init__(self, dataset):

self.dataset = dataset

def ppg_single_line_plots(self, name, title):

# dataset = {'x': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],

# 'y': [5, 4, 1, 3, 11, 2, 6, 7, 19, 20],

# 'z': [12, 9, 0, 0, 3, 25, 8, 17, 22, 5]}

data_g = []

tr_x = go.Scatter(

x=self.dataset['x'],

y=self.dataset['y'],

name='PPG_G',

mode='lines'

)

data_g.append(tr_x)

# tr_z = go.Scatter(

# x=self.dataset['x'],

# y=self.dataset['z'],

# name='z'

# )

# data_g.append(tr_z)

layout = go.Layout(title=title, xaxis={'title': 'number of ppg singnal'}, yaxis={'title': 'ppg value'},

font={

'size': 16,

'family': 'sans-serif'

}, showlegend=True,

legend=dict(

x=0.9,

y=1.1

))

fig = go.Figure(data=data_g, layout=layout)

print(name)

pltoff.plot(fig, filename=name)

def hr_two_line_plots(self, name, title):

# dataset = {'x': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],

# 'y': [5, 4, 1, 3, 11, 2, 6, 7, 19, 20],

# 'z': [12, 9, 0, 0, 3, 25, 8, 17, 22, 5]}

data_g = []

tr_x = go.Scatter(

x=self.dataset['x'],

y=self.dataset['y'],

name='Products heartRate',

mode='lines'

)

data_g.append(tr_x)

tr_z = go.Scatter(

x=self.dataset['x'],

y=self.dataset['z'],

name='std heartRate',

mode='lines'

)

data_g.append(tr_z)

layout = go.Layout(title=title, xaxis={'title': 'number of samples'}, yaxis={'title': 'heartRate value'},

font={

'size': 16,

'family': 'sans-serif'

}, showlegend=True,

legend=dict(

x=0.9,

y=1.1

))

fig = go.Figure(data=data_g, layout=layout)

print(name)

pltoff.plot(fig, filename=name)

def hr_error_value_two_line_plots(self, name, title):

"""

方便观察不同信号质量下的心率测量的误差值

"""

# dataset = {'x': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],

# 'y': [5, 4, 1, 3, 11, 2, 6, 7, 19, 20],

# 'z': [12, 9, 0, 0, 3, 25, 8, 17, 22, 5]}

data_g = []

tr_x = go.Scatter(

x=self.dataset['x'],

y=self.dataset['y'],

name='Error value',

mode='lines'

)

data_g.append(tr_x)

tr_z = go.Scatter(

x=self.dataset['x'],

y=self.dataset['z'],

name='PPG Signal quality',

mode='lines'

)

data_g.append(tr_z)

layout = go.Layout(title=title, xaxis={'title': 'number of samples'},

yaxis={'title': 'PPG Signal quality and Error value'},

font={

'size': 16,

'family': 'sans-serif'

}, showlegend=True,

legend=dict(

x=0.9,

y=1.1

))

fig = go.Figure(data=data_g, layout=layout)

print(name)

pltoff.plot(fig, filename=name)

# 生成柱状图

def bar_charts(name):

dataset = {'x': ['Windows', 'Linux', 'Unix', 'MacOS'],

'y1': [45, 26, 37, 13],

'y2': [19, 27, 33, 21]}

data_g = []

tr_y1 = go.Bar(

x=dataset['x'],

y=dataset['y1'],

name='v1'

)

data_g.append(tr_y1)

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值