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] Improve cell classes #322
[MRG] Improve cell classes #322
Conversation
20c71da
to
27fa011
Compare
Codecov Report
@@ Coverage Diff @@
## master #322 +/- ##
==========================================
- Coverage 90.54% 90.31% -0.24%
==========================================
Files 14 13 -1
Lines 2496 2416 -80
==========================================
- Hits 2260 2182 -78
+ Misses 236 234 -2
Continue to review full report at Codecov.
|
ae3a2c2
to
a151d0f
Compare
hnn_core/cell_classes.py
Outdated
@@ -0,0 +1,295 @@ | |||
"""Model for Pyramidal cell class.""" |
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.
all cell classes included
hnn_core/cell_classes.py
Outdated
return dend_props | ||
|
||
|
||
def _get_soma_props(p_all, cell_type): |
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.
_get_soma_props_from_params
?
Edit: the "from_params" is too much, but confusing that there's this and _get_basket_soma_props
below.
This looks awesome! Left a few notes on what to clean up. I realise this is still WIP, but liking it a lot! |
Code is becoming simpler and simpler. I'm not done yet but if you want a sneak peek, see here. Pardon the use of nested dictionaries in some places. I'm sure they will go away or be replaced by proper objects but it's a necessary intermediate step to conceptualize the code. I also realized that with these changes, it should be pretty straightforward to write a function that ingests a cell defined in Netpyne or another specification language without losing access to the underlying Neuron objects. |
----- | ||
By default neuron uses xy plane | ||
for height and xz plane for depth. This is opposite for model as a | ||
whole, but convention is followed in this function ease use of gui. |
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.
whole, but convention is followed in this function ease use of gui. | |
whole, but the convention is followed in this function | |
for ease use of with the gui. |
Not sure I understand the connection with the gui
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.
I guess in the past the GUI had a visualization of the cells in 3D space. The z coordinate is along the trunk of the pyramidal cells (depth) but the Neuron convention is y coordinate. I just copy pasted the old comment. Feel free to suggest a better rephrasing!
if sec.L > 100.: | ||
sec.nseg = int(sec.L / 50.) | ||
# make dend.nseg odd for all sections | ||
if not sec.nseg % 2: |
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.
Not your change, but I am so confused by why this is necessary
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.
See the Neuron FAQ: https://neuron.yale.edu/neuron/faq/general-questions
hnn_core/cell.py
Outdated
|
||
# Connects sections of THIS cell together. | ||
for connection in topology: | ||
# XXX: risky to use self.soma as default. Unfortunately there isn't |
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.
This always confused me, is it not sufficient to add self.soma
to p_secs
? I guess I don't fully grasp why it's risky.
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.
If connection[0] = 'blah'
then parent_sec = self.soma
which is not correct. It should have failed instead. I pushed a more readable and safer version in: f1c2d9b
f2222cc
to
f1c2d9b
Compare
comments addressed. Let me know if something was not properly addressed etc. The peer review is super-useful since it's not always clear to me what's not clear to others. Now I hope you'll push me to write some tests as I'm lazy as everyone else ;-) What else is unclear in the code? |
8d2d27d
to
4958167
Compare
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.
I certainly think you should write a lot of tests ;) I think the Cell
class is probably fine as it is, but the new pyramidal
and basket
functions deserve some scrutiny. Here's some code I wrote recently, maybe some of it is useful:
from neuron import h
from hnn_core.network_builder import load_custom_mechanisms
from hnn_core.cells_default import pyramidal, basket
load_custom_mechanisms()
h.load_file("stdrun.hoc")
h.tstop = 40
h.dt = 0.025
h.celsius = 37
l5p = pyramidal(pos=(0, 0, 0), celltype='L5_pyramidal')
h_soma_v = l5p.rec_v.record(l5p.soma(0.5)._ref_v)
h_t = h.Vector().record(h._ref_t)
stim = h.IClamp(l5p.soma(0.5))
stim.delay = 5
stim.dur = 5.
stim.amp = 2.
h.finitialize()
h.fcurrent()
h.run()
times = np.array(t.to_python())
v_soma = np.array(h_soma_v.to_python())
plt.plot(times, v_soma) # elicits two spikes
f609e1c
to
9557f02
Compare
b6b8dc0
to
5d38fec
Compare
Okay did some more simplifications. No more |
f730ebc
to
b1ac056
Compare
b1ac056
to
abac3b2
Compare
if cell.celltype in ('L5_pyramidal', 'L2_pyramidal'): | ||
self.dipoles[cell.celltype].add(cell.dipole) | ||
if cell.name in ('L5Pyr', 'L2Pyr'): | ||
self.dipoles[_long_name(cell.name)].add(cell.dipole) |
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.
Is it possible for us to finally consolidate the short and long name usage?
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.
I think we certainly can and should. We just need to get to it. I would leave it for another PR though ...
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.
Probably a good starting point for one of the undergrads
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.
Looks good @jasmainak! Our next PR will strive to make cell attributes accessible from Network
!
Thanks for the huge effort in clarifying the code around `Cells @jasmainak ! CIs are green, and all three of us have had a chance to review, so I'm going to go ahead and merge. I have a feeling new/more tests will arise in #150 and after, smoke test is fine here for now. |
Perfect, I'll sit quite for a bit now while you guys make some PRs ;-) Thanks for reviewing! |
This builds on top of #319 so the diff may not be super clear until that PR is merged and I do a rebase.
The goal is to unify the
Basket
andPyramidal
class representation as much as possible.TODO
self.secs should go into p_dend and be a cell property(another PR, I had enough of this PR)