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

New features for AHP after burst #131

Closed
elisabettai opened this issue May 18, 2018 · 10 comments
Closed

New features for AHP after burst #131

elisabettai opened this issue May 18, 2018 · 10 comments

Comments

@elisabettai
Copy link

image

This feature should calculate the voltage (absolute value) at the points marked with "x".

Possible steps are:

  • identify peaks that belong to bursts (set of spike with frequency > 150 Hz in this case). The trace 'burst_1' should have 2 bursts, while the others just one.
  • calculate the slow AHPs (absolute value) after the last spike in the burst ("sAHP_after_burst_abs") . This could be the minimum during a certain time range after the last peak in the burst (e.g. between 10 and 50 ms after the last peak, to be discussed). However, I'm not sure this would be the best way for trace "burst_2".
  • Calculate additional features for:
    • sAHP amplitude from voltage base
    • sAHP from steady_state_voltage_stimend
    • amplitude of the first sAHP
    • amplitude of the second sAHP

I hope it's clear, feel free to add any comments.

Below the 3 traces used to produce the figure.
burst_1.txt
burst_2.txt
burst_3.txt

@wvangeit
Copy link
Contributor

wvangeit commented Jun 5, 2018

I've implemented a first version of the feature you request in #132
This has been pushed to master, and available on PyPi as version 3.0.3

The feature is called 'initburst_sahp' (there is also 'initburst_sahp_vb' for voltage_base, and 'initburst_sahp_ssse' for steady-state-stim-end).
I've a test that uses your three traces, and they visually return the voltages that are expected.
It will only detect the first burst.

You can see the implementation here:
https://github.com/BlueBrain/eFEL/blob/master/efel/pyfeatures/pyfeatures.py#L91

I've made some initial changes to the eFEL to allow for features defined in pure python. For now all these features go in the file mentioned above. The getFeatureValues call stays the same, it works for both cpp features and python features.

This feature could be a bit unstable because it's difficult to implement this for the general case.
You can control it by setting: (use efel.setDoubleSetting, bluepyopt also allows you to set these settings).
initburst_freq_threshold: frequency in Hz, if an ISI is lower than this frequency it break the burst
initburst_sahp_start: time after last spike of burst when sahp interval starts
initburst_sahp_end: time after last spike of burst when sahp interval ends, if there is a spike before this is reached, that spike time will become the end. The same for the stimulus end.

Let me know how it goes, or if you need something more.

@elisabettai
Copy link
Author

elisabettai commented Jun 12, 2018

Thanks. I've also checked with those traces and the values are as expected.

One issue I found in using Python-only features during optimisation is that getDistance function knows only about c++ features names.

(https://github.com/BlueBrain/eFEL/blob/master/efel/api.py#L196)

@wvangeit
Copy link
Contributor

Good point, sorry forgot about that. Let me have a look at how I can solve that.

@elisabettai
Copy link
Author

elisabettai commented Jun 19, 2018

Thanks. If it can help, I've quickly fixed it in the api.py, by adding this to distance():

if featureName in pyfeatures.all_pyfeatures: return get_py_distance(trace, featureName, mean, std, trace_check, error_dist) else: return efel.cppcore.getDistance(**kwargs)

And creating get_py_distance() function:

`def get_py_distance(trace, featureName, mean, std, trace_check, error_dist):

featValue = get_py_feature(featureName)
if featValue:
    dists = numpy.abs(featValue-mean)/std
    return dists[0]
else:
    return error_dist`

However it may miss something (like what to do with trace_check and if feature calculation return error).

@elisabettai
Copy link
Author

Another problem I had using 'initburst_sahp' during optimization, is this error:
ValueError: attempt to get argmin of an empty sequence
from this line https://github.com/BlueBrain/eFEL/blob/master/efel/pyfeatures/pyfeatures.py#L162

I'm trying to see in I can output the trace and reproduce the error.

@wvangeit
Copy link
Contributor

wvangeit commented Jun 21, 2018

I fixed your last issue here:
#133
If you have a trace that can reproduce it, please send it to me, then I can add it in a test

@elisabettai
Copy link
Author

Regarding the ValueError, I saved traces when the features calculation hits the condition here: https://github.com/BlueBrain/eFEL/blob/master/efel/pyfeatures/pyfeatures.py#L164

I'm attaching one here.
initburst_sahp_error.txt

@wvangeit
Copy link
Contributor

wvangeit commented Jul 5, 2018

This PR adds the python features to getDistance():
#135

This pypi version includes that code:
https://pypi.org/project/efel/3.0.12/

@wvangeit
Copy link
Contributor

wvangeit commented Jul 5, 2018

I've tried hard to implement the python getDistance function in a way so that it exactly replicates the values generated by the cpp version. Let me know if you see any discrepancies in bluepyopt etc.

@wvangeit
Copy link
Contributor

wvangeit commented Jul 5, 2018

Also added @elisabettai 's trace in a test:
#136
Will close this issue now.

@wvangeit wvangeit closed this as completed Jul 5, 2018
ilkilic pushed a commit that referenced this issue Dec 8, 2023
* gh#130 use auto_threshold value in compute_spikecount

* make Recording an abstract class

* extract set_autothreshold as method
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