Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems detecting the onset of the first spike #123

Open
SvennoNito opened this issue Nov 19, 2017 · 4 comments
Open

Problems detecting the onset of the first spike #123

SvennoNito opened this issue Nov 19, 2017 · 4 comments

Comments

@SvennoNito
Copy link

Hey, I've managed to extract almost all desired spike features except for the latency of the onset of the first spike. I played around with

efel.setDerivativeThreshold(n)

using values between 1 and 20, but none of them shifted the onset. I will attach screenshots of my trials using n=1, n=10, n=20. Do you have any idea what else I could do to successfully find the beginning of the first spike? The red dots display what is found by AP_begin_time and AP_begin_voltage.

stim_2 5_1
stim_2 5_10
stim_2 5_20

@wvangeit
Copy link
Contributor

This issue was actually also brought up by another user recently (by email).
There is indeed a problem with the detection of the AP onset for the first spike in these kind of traces. The algorithm picks the first points where the derivative threshold is crossed, and unfortunately in this case it's close to stimulus onset.
We were thinking of solutions, one of them being to search backwards from the peak of the spike. I didn't have time to look at it yet. It won't be a failsafe solution either, because by searching backwards, spikes that have a biphasic onset might cause problems.
If you have any other ideas, please let me know.

@SvennoNito
Copy link
Author

Yes, actually I have. A colleague of mine suggested to start the search from a "baseline". A good "baseline" might be the average voltage of the undershoot (the green dots in my plots). I think the term "baseline" doesn't really fit, but what she meant was to look for the point in time where the data trace crosses the "baseline" for the first time and start the search from there.

As action potentials may occur before, during and after the stimulus presentation and vary in voltage values accordingly, it could make sense to calculate a baseline for each time window respectively - so before, during and after the stimulus. (As the function takes on- and offset of the stimulus as parameters, I think it could be possible).

She implemented it in her self-written spike-finder-function and it worked out for her data. Maybe worth a shot?

@wvangeit
Copy link
Contributor

That might be an option. It does however assume a stable baseline (might fail if there are irregularly firing cells, bursting cells, etc.). But I could try.
I'm also a bit afraid that for your trace you might get the point exactly at the baseline.

Can you share some of the raw traces, so that I can see what I can do ?

@SvennoNito
Copy link
Author

SvennoNito commented Nov 21, 2017

Ah ok, yeah, the slope is still highest at the baseline then, right.
Sure thing, I will attach some data to my post. Thanks for your effort!!!

You need to unzip the .mat file, which you can load by executing the following commands. It contains a 1x350.000 'stimulus' variable showing at what point in time which stimulus current (in [nA]) was applied. Besides, it contains a 1x350.000 'response' variable, containing the response of an intracellular recording (in [mV]). The recording took 35s. pcelldata_1trial.zip

import scipy.io

response = scipy.io.loadmat('pcelldata_1trial.mat')['response'] # load cell response

stimulus = scipy.io.loadmat('pcelldata_1trial.mat')['stimulus'] # load stimulus vector

If you plot the stimulus vector and the response of one trial, it will look like this.

stimulus

response

If you want the data in another format (e.g. only for one stimulus current, as in the plots of my first post, just leave a comment).

ilkilic pushed a commit that referenced this issue Dec 8, 2023
Add python 3.11 tests to github workflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants