Using a hoc cell template with Python

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
pascal
Posts: 116
Joined: Thu Apr 26, 2012 11:51 am

Using a hoc cell template with Python

Post by pascal »

I am trying to run a basic simulation using the cell defined in pyr.hoc from https://modeldb.science/267686?tab=2. I would like to load the hoc file, then use Python to run the simulation. So far, I have the following code:

Code: Select all

from neuron import h
h.load_file('pyr.hoc') 

cell = h.CA1_PC_cAC_sig()

Iext = h.IClamp(cell.soma(0.5))
The cell is made without error, but when I try to insert an IClamp in the soma, I get the error "Object is not callable." Somehow it does not like the fact that I'm trying to insert the IClamp in the middle of the soma.

When I print(cell.soma),

the output is CA1_PC_cAC_sig[0].soma[?]

So my questions are:
1) Why can't I reference cell.soma(0.5) ?
2) What does the question mark in CA1_PC_cAC_sig[0].soma[?] mean?

I'm sure I'm missing some very basic insight, and I apologize for how basic my knowledge in this space is. I've only ever used NEURON with Python, and even after reading the documentation (https://www.neuron.yale.edu/neuron/stat ... essing-hoc), I still can't answer these basic questions for myself. Thank you.
ted
Site Admin
Posts: 6361
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Using a hoc cell template with Python

Post by ted »

I haven't seen this
CA1_PC_cAC_sig[0].soma[?]
yet, but my guess would have been that it meant that "soma" is an "indexed" name, i.e., that when the "soma" thing was initially created, it was done with a statement of the form
create soma[1]
so that more than one section could have the base name
soma
and their complete names would be of the form

Code: Select all

soma[i]
where i = 0, 1 . . .

Why would anyone do something like that? Probably because the person who wrote the template wanted to be able to handle morphometric data files in which the soma is treated as a chain of chunks. And why would anyone need to do that? Because the person or algorithm that collected the morphometric data might have been dealing with a cell body that had interesting features distributed along its length (bends, bifurcations, attachments of dendrites and axon(s)). Treating the soma as a chain of chunks would allow each bend, bifurcation, or attached dendrite or axon to be located at the end of a soma chunk. The alternative would be to treat the entire soma as a single section (wouldn't work for branched somas), and all sections attached to it would have to be connected to the 0 or 1 end or an internal node--and the only internal node that is guaranteed to have a fixed location is the one at 0.5 (assuming nseg is odd, which it should always be). As they say in politics these days, "the cosmetics of that are not good."

When such a morphometric data file is imported into NEURON, each chunk would get a name of the form soma[j] where j = 0, 1 . . .

And my suspicion was confirmed: in pyr.hoc the fourth line in begintemplate CA1_PC_cAC_sig is
create soma[1], dend[1], apic[1], axon[1], myelin[1]

A couple of lines below that, note the statements

Code: Select all

public all, somatic, apical, axonal, basal, myelinated, APC
objref all, somatic, apical, axonal, basal, myelinated, APC
 . . . 
all = new SectionList()
apical = new SectionList()
axonal = new SectionList()
basal = new SectionList()
somatic = new SectionList()
myelinated = new SectionList()
so I'd guess that your "cell" has one or more "soma" sections whose names you can discover by executing
cell.somatic.printnames()
(be sure to read the documentation of the SectionList class's methods, especially printnames()).

And this turns out to be the case.

>>> cell.somatic
SectionList[4]
>>> cell.somatic.printnames()
CA1_PC_cAC_sig[0].soma[0]
1.0
>>> cell.soma[0]
CA1_PC_cAC_sig[0].soma[0]

So all you should have to do is change
Iext = h.IClamp(cell.soma(0.5))
to
Iext = h.IClamp(cell.soma[0](0.5))
pascal
Posts: 116
Joined: Thu Apr 26, 2012 11:51 am

Re: Using a hoc cell template with Python

Post by pascal »

Thanks, Ted, I really appreciate the thorough explanation. That all makes perfect sense, and my simulation is now running without issue. Thanks again.
ted
Site Admin
Posts: 6361
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Using a hoc cell template with Python

Post by ted »

Great, glad to help! Please remember to let us know when you publish something that reports work done with NEURON.
Post Reply