Clear Filters
Clear Filters

Taking the derivative of an Action Potential to find the inflection point

6 views (last 30 days)

Hello,

MATLAB newbie here, please go easy on me. I need to determine the slope of a membrane depolarization before the marked inflection point in this voltage vs. time graph:

The purpose is to compare the pre-inflection point slopes of several action potentials. The recording was taken at 20kHz. Since this is discrete data, would it be possible to take a derivative of the data so that I can observe when the slope changes? I'd rather not do this arbitrarily.

Thanks

Accepted Answer

Stefan
Stefan on 8 Mar 2011
Thanks for the response! I've gotten MATLAB to define dy. Both y and t are (301x1 double), however dy comes out as (300x1 double).
This means that I can't plot (dy, t), and I'm also losing a data point somewhere. I suppose by definition, taking diff(y) of n will have n-1 time points. I'll try removing a point from t to make it (300x1 double) as well.
  2 Comments
Matt Tearle
Matt Tearle on 8 Mar 2011
Yes, that's expected because it's a finite difference approximation -- the derivative at t is approximated using y(t) and y(t+dt). This means there's no derivative for the last t value. (Or you can shift t by one and think of it as a backward difference, so there's no derivative for the first point.) The simplest solution is just plot(t(1:end-1),dy). But if you really want all 301 derivatives, you'll have to use a different finite diff approximation for the last point... but you could just use a backward difference there, in which case the derivative at the 301 point is the same as the 300th:
dy = zeros(size(y));
dy(1:end-1) = diff(y)*Fs;
dy(end) = dy(end-1);
plot(t,dy)

Sign in to comment.

More Answers (2)

Matt Tearle
Matt Tearle on 3 Mar 2011
Approximate derivative of a discrete signal y (with discrete independent variable t) can be obtained using
dy = diff(y)./diff(t)
If you want more accuracy, you'd need to find a higher-order finite difference formula.
In your case, the sampling is, presumably, uniform (20kHz), so you can just do
Fs = 2e4;
dy = diff(y)*Fs;
Another approach would be to perform some kind of interpolation or local least-squares fit, then use the interpolant to determine the derivative. This works better if the signal is noisy.

andy
andy on 3 Dec 2014
hi, @stevan, can you give your script about action potential ?
  1 Comment
Stefan
Stefan on 3 Dec 2014
Absolutely!
Attached is the function that I ended up with. It takes the sample rate in kHz (I use 50), the voltage trace, and an onset time (when the postsynaptic potential begins, I use 0.6).
I'm also attaching a sample spike that works with this code, marked 'V'. I commented it fairly well on my first pass through, but feel free to ask questions if you get stuck.
To run the script, load V into your workspace, and input this command:
V_thresh_fun3(50,V,.6);
All the best,
Stefan

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!