Thanks for the information. I think I've got it basically working using the convlv() function, but it's a little hack-y, so I may end up going with the LinearCircuit approach anyway.
Convolving the voltage with a kernel of the form described by Colquhoun and Sigworth seems to work. There seems to be a little strangeness at the edges, though I don't need to fit at the edges. Another issue I ran into is that it looks like the MRF gets its data by using record(), which, if I understand correctly, is set in fadvance(). Since my filter is applied after continuerun() ends, I wasn't sure how to get it into the MRF without setting the data vector used by the MRF directly. It doesn't seem like an ideal way of doing it, but it apparently works. I haven't tested it very extensively yet, though.
Anyway, here's the code I've come up with (I haven't done a lot of hoc programming, so I'm sure it's not very idiomatic):
Code: Select all
objref filt_v, filt_kernel
proc run() {
running_ = 1
stdinit()
continuerun(tstop)
apply_filter()
}
proc apply_filter() { local n, i, s, fc
n = FitnessGenerator[0].yveclist.object(0).size()
// Gaussian filter kernel from Colquhoun and Sigworth (1995), Section 2.2.1, Eq. 6
filt_kernel = new Vector(n)
fc = 5000 / 1000 // cutoff frequency of 5 kHz
for i = 0, filt_kernel.size()-1 {
filt_kernel.x[i] = 3.011 * 5 * exp(-(5.336*fc*i*dt))
}
// Put the kernel in "wrap-around" order (see Numerical Recipes in C 13.1)
for i = int(filt_kernel.size()/2), filt_kernel.size()-1 {
filt_kernel.x[i] = filt_kernel.x[filt_kernel.size() - i]
}
// Normalize the kernel
s = filt_kernel.sum()
filt_kernel.div(s)
filt_v = new Vector()
filt_v = filt_v.convlv(FitnessGenerator[0].yveclist.object(0), filt_kernel)
for i = 0, FitnessGenerator[0].yveclist.object(0).size()-1 {
FitnessGenerator[0].yveclist.object(0).x[i] = filt_v.x[i]
}
}