【发布时间】:2022-11-15 15:31:37
【问题描述】:
我正在尝试去除包含 ECG 数据的数据集。我能够使用三次样条插值来创建数据的多项式拟合,但是,我不知道如何从数据中删除基线。 这是我到目前为止的代码:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
from scipy.interpolate import CubicSpline
import csv
import peakutils
file = open("ECG_data.csv")
csv = csv.reader(file)
rows = []
for row in csv:
rows.append(row)
d = np.array(rows)
start = 1
end = start + 5000
x = (d[start:end,1]).astype(float)
y = (d[start:end,0]).astype(float)
n = len(x)
cs = CubicSpline(x,y)
csx = np.arange(start=x[0], stop=x[n-1], step=0.0001)
figure(figsize = (15,8), dpi = 80)
plt.plot(csx,cs(csx))
我希望我的数据是平坦的。有什么建议么?这是一个分配,所以我必须使用某种插值来解决这个问题。谢谢你。
【问题讨论】:
标签: python interpolation cubic-spline