当前位置:   article > 正文

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

python3 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)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/78299
推荐阅读
相关标签
  

闽ICP备14008679号