我希望使用Scipy的反卷积功能,使用here中所述的贝特曼函数作为滤波器对EDA(皮肤电活动)信号进行反卷积。
但是,当我尝试这样做时,反卷积图看起来并不像我期望的那样。也就是说,它通常采用大致为扁平线的形状,有时在滤波器长度的倍数处具有尖峰:
我在这里想念什么?我应该平滑EDA曲线吗?我是否希望deconvolve
取得太多收益?我的代码如下:
import csv
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal as signal
import math
with open('test session 1.csv', newline='') as csvfile:
filereader = csv.reader(csvfile, delimiter=' ')
i = 0
timestamps = []
conductances = []
for row in filereader:
i += 1
fields = ' '.join(row).split()
if i > 3:
timestamps.append(float(fields[0]))
conductances.append(float(fields[5]))
timestamps = [timestamp - timestamps[0] for timestamp in timestamps]
c = 10.
tau1 = 300
tau2 = 2000
bateman = [c * ( math.exp(-time / tau2) - math.exp(-time / tau1)) for time in timestamps]
bateman = bateman[3:1700]
deconv, remain = signal.deconvolve(conductances, bateman)
fig, ax = plt.subplots(nrows=4)
ax[0].plot(conductances, label="EDA Signal")
ax[1].plot(bateman, label="Bateman Function")
ax[2].plot(deconv, label="Deconvolution Result")
ax[3].plot(remain, label="Remainder")
for i in range(len(ax)):
ax[i].legend(loc=4)
plt.show()