3

I wish to deconvolve an EDA (electrodermal activity) signal using a Bateman function as the filter as described here, using Scipy's deconvolve function.

However, when I attempt this, the deconvolution graph does not look how I expect it to. Namely, it generally takes the shape of a mostly flat line, sometimes with spikes at multiples of the filter length:

enter image description here

What am I missing here? Should I be smoothing the EDA curve? Am I hoping for too much from deconvolve? My code is below:

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()
eLillie
  • 653
  • 9
  • 17
  • *"Am I hoping for too much from `deconvolve`?"* Probably. Do you have a sample data set that you can share? Also, how did you determine the parameters of the Bateman function? Do you know for sure that it accurately represents the impulse response function (aka transfer function, aka kernel)? – Warren Weckesser Jul 22 '18 at 02:29
  • @WarrenWeckesser I can share the dataset if need be. It will reflect the EDA signal graph above. The Bateman params were selected to match the apparent time scale seen in the EDA graph. My confidence that a Bateman function with appropriately selected parameters accurately represents the IRF is based on the linked PDF. How would you recommend I proceed? Do you think curve-smoothing could prove fruitful? – eLillie Jul 26 '18 at 17:40
  • Share the data (Dropbox, GitHub, etc.) and we'll take a look. `deconvolve` should be doing better than that. What does the deconvolution look like on a log-scale (`semilogy`)? – Ahmed Fasih Aug 10 '18 at 14:47

0 Answers0