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
[MRG] ENH: Function to get spike rates #155
Conversation
@ntolley I think you should take over this PR after the other one is merged. You've been working the spikes object recently, so this is right up your alley. Just add my fork as a remote on git and start pushing to the branch. Let me know if you need help. |
That sounds great to me! Perhaps not for this initial PR, but something to consider in the future is adding a convolution kernel to calculate spike rates. Here is a great example of how that sort function would work. |
As long as you don't create a dependency on Neo, feel free to do it in this PR :-) Just copy the relevant code (they are BSD-3) and keep it simple. You can have an argument called |
Reading the issue more closely it actually seems like convolved spike rates gets at a different purpose. Estimation of instantaneous rates is usually done at the single unit level, whereas @stephanie-r-jones proposes aggregating across cell types to describe the whole trial. In my mind these are rather distinct and may be better split into two functions. |
humm ... do you think the mean spiking rates (across trials and cells) could be added to this plot: https://jonescompneurolab.github.io/hnn-core/generated/hnn_core.viz.plot_spikes_raster.html#hnn_core.viz.plot_spikes_raster instead of a function since it's just 4 scalar values? and we can also have another function for instantaneous rate, but I'm wondering if that should be reserved for another PR? What's not totally obvious to me in that case is: |
That could possibly work, but it doesn't lend itself easily to accessing the data. This may be a good opportunity to create an wrt plotting I think a box-plot makes the most sense for visualizing the rates across cells so perhaps we can append a subplot to the raster. For the use case I personally intend to analyze single unit activity in my own projects. Generally it will be extremely useful to have available for highly mechanistic hypotheses. And yes the function would generally look like |
Let's worry about So, if I understand correctly are you leaning towards:
If the user wanted average spike rates across cell types, how would they get it? would they average the return value from that function? or do you want another function for that? or should they just look at the plot which will have the values? |
Honestly I think keeping these separate is the best path. For this PR I'm leaning towards a function to return mean spike rate grouped by cell. Example return would be To be clear, for this PR there would be 2 additions to the After that I can open a separate PR to introduce |
okay, let's start coding :) We can iterate the API once we have something down. Can you push to this branch? |
Sorry it looks like this branch was behind your master so the rebase included the latest PR's merged. I'll work on cleaning it up tomorrow morning. In either case all my work is on the last commit. It now computes the mean spike rates for every individual gid, you can then specify what type of average you want returned by setting |
Good luck with the rebase. Maybe the force be with you. You can go ahead and add the tests as well. |
I've taken a chainsaw to the commit tree and it's looking beautiful again. Regarding the tests, obvious ones are checking for correct |
For tests, you should create a |
amazing!! :) |
Surprisingly beefy commit. I've implemented the Also there is now an issue with legacy TODO:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's converging @ntolley slowly but surely :)
Codecov Report
@@ Coverage Diff @@
## master #155 +/- ##
==========================================
- Coverage 67.80% 67.23% -0.58%
==========================================
Files 19 19
Lines 2022 2060 +38
==========================================
+ Hits 1371 1385 +14
- Misses 651 675 +24
Continue to review full report at Codecov.
|
b08f10f
to
d695663
Compare
Definitely procrastinated on rebasing for too long. In line with the previous discussion I removed all of the code related to storing This heavily simplifies the code and cleans up the awkward logical checks. |
@ntolley looks pretty clean to me and I see you have added tests too! Fantastic. Would you mind addressing the last few comments and then we can merge. Don't forget to change the title from WIP to MRG once you are ready |
Oh, one last thing is that can you update an example to show the use of this new function? |
That should be everything! Leaving a few conversations unresolved as I think some of the comments will be useful to reference in future PR's. |
It's in, thanks @ntolley ! 🍻 🧠 |
closes #154
not sure if this is the right way to do it, just opening a "work in progress thing" and we can discuss the details. How is the spike rate typically calculated?
TODO