recording HCN channels using GUI

Using the graphical user interface to build and exercise models. Includes customizing the GUI by writing a little bit of hoc or Python
Post Reply
alexandrapierri
Posts: 69
Joined: Wed Jun 17, 2015 5:31 pm

recording HCN channels using GUI

Post by alexandrapierri »

Hello

I want to record the HCN currents per some surface area in my multicompartment model using GUI.
I have searched through the following links but haven't found relevant insructions yet.
https://nrn.readthedocs.io/en/latest/se ... a=default

Thank you for any guidance with this!

sincerely,
Alexandra
ted
Site Admin
Posts: 6315
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: recording HCN channels using GUI

Post by ted »

You'll need to use the Vector class's record method. In pseudocode, the steps are

1. create a pair of vectors: one to hold the values of time (t in hoc, h.t in Python), and the other to hold the values of whatever variable you are interested in.
2. use the vector class's record method to tell NEURON to record time and the variable of interest to your pair of vectors.

The Vector class's record method is documented in the programmer's reference at nrn.readthedocs.io.

Suggestion: before you try this on an existing model, do it on a simple model (single compartment cell with a soma section that has hh and is driven by an IClamp so it produces a spike). Capture the time course of v at the middle of the soma (soma.v(0.5) in hoc, soma(0.5).v in python). Verify that it worked by plotting the recorded v values vs the corresponding t values. To make it easy on yourself, use a stimulus that starts at t=1 ms and lasts 0.1 ms, and make the simulation last for only 5 to 10 ms. After you have that working, change your program so that it captures the time course of ina (soma.ina(0.5) in hoc, soma(0.5).ina in python), and verify it by plotting the time course.
alexandrapierri
Posts: 69
Joined: Wed Jun 17, 2015 5:31 pm

Re: recording HCN channels using GUI

Post by alexandrapierri »

thank you Ted

I am doing a voltage clamp on my pyramidal cell to record Ih under different holding potentials.
Following your steps I write:

Code: Select all

    pyr1 = h.cADpyr229_L23_PC_c2e79db05a  # name of the cell template defined next to begintemplate in the model hoc file. 
    pyr1_v_vec = h.Vector()
    pyr1_i_vec = h.Vector()
    GLUSyn1_i = h.Vector() # this is to also record NMDA current. 
    HCN4Synapse_i = h.Vector()
    
    sec_pyr1 = pyr1.soma
    GLUSynapse_1 = h.NMDA(sec_pyr1(0.5)) # point process
    HCN4current_1 = h.ifun(sec_pyr1(0.5)) # distributed mechanism HCN current. "ifun" is the suffix in the mod file 
    
    GLUSyn1_i.record(GLUSynapse_1._ref_i) # this works
    HCN4Synapse_i.record(HCN4current_1._ref_i) # this syntax doesn't work. 
   
    pyr1_v_vec.record(pyr1.soma(0.5)._ref_v)
I get the error:

HCN4Synapse_i.record(HCN4current_1._ref_i)
^
SyntaxError: invalid syntax

The syntax seems to work for the NMDA point porcess, but not for the HCN.

Thank you!
ted
Site Admin
Posts: 6315
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: recording HCN channels using GUI

Post by ted »

A more important error occurred two statements earlier: in
HCN4current_1 = h.ifun(sec_pyr1(0.5))

The syntax for adding a distributed mechanism to a section is different from the syntax for attaching a point process to a section. I could just tell you the correct syntax for the former, but here's a really good tutorial that contains much useful information:
Scripting NEURON basics https://nrn.readthedocs.io/en/8.2.2/tut ... RON-basics

Even if you are already quite familiar with many other aspects of NEURON, this tutorial might introduce you to some things that are helpful when debugging a model (and if you will be writing much code, you'll be doing a lot of debugging). Scientia potentia est.

By the way, you're also going to want to capture t (h.t in python) to another vector.
alexandrapierri
Posts: 69
Joined: Wed Jun 17, 2015 5:31 pm

Re: recording HCN channels using GUI

Post by alexandrapierri »

that sounds very good, thank you.
I will post here my solution.

One clarification that always confuses me.
I dont want to "add" a distributed mechanism to the model.
The model already has distributed mechanisms added to it an I want to write a voltage clamp experiment to record them (specifically Ih).

The density of Ih channels is already specifed in the hoc template. I want to record the net current at the soma.

I am somehow confused that when I move to python instantiate my hoc model and then run expressions such as:
GLUSynapse_1 = h.NMDA(sec_pyr1(0.5)) or:
soma.insert("hh")

I am adding new point processes / mechanisms instead of accessing those already in the model.

thank you,
Alexandra
ted
Site Admin
Posts: 6315
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: recording HCN channels using GUI

Post by ted »

Sorry if some of my responses incorrectly estimate your knowledge and experience. While the Forum is a useful tool, in many ways it is quite inadequate compared to a live discussion because of its rather limited semantic bandwidth. A live discussion permits the rapid back-and-forth exchange that is so useful for quickly conveying multiple layers of information, and is particularly helpful for dealing with "model of mind" issues (like "do we really understand each other", "what level of expertise should be assumed for optimal communication").

Back to Python and hoc. If something already exists because it was created by hoc code, then it's easy for Python to refer to that something--just add the prefix h. to the hoc name. Examples:

Suppose you have a hoc file called pyr.hoc that contains the template for a cell class called Pyr. To reuse this template in Python, you'll do something like this
h.load_file('pyr.hoc') # makes NEURON read the template
pcell = h.Pyr() # now there is an instance of the Pyr cell class that you can call pcell

And all public members of the Pyr cell class are accessible to Python.
E.g. if Pyr has a public member called soma which is the model cell's soma, the python name for its length is
pcell.soma.L
and the python name for the specific membrane capacitance in the segment of pcell.soma that contains the location 0.5 is
pcell.soma(0.5).cm
If pcell.soma has a distributed mechanism called fun, then fun's state variables and parameters are all accessible via Python. Assuming that pcell.soma has a distributed mechanism called fun which generates a current called i, this refers to the value of i at location 0.5,
pcell.soma(x).fun.i

If you need to use Python to access parameters or state variables that belong to a point process that was created with hoc statements, then you will want to refer to that point process via the corresponding objref that was created in hoc. For example given a point process of the NMDA class that was created by statements like this inside the pcell template

objref nmda
soma nmda = new NMDA(0.5)

and that nmda is a public member of the Pyr class, then the python name for the current it generates would be something like
pcell.nmda.i

But if instead the template did something like this
synlist.append(new NMDA(0.5))
and synlist is a public member of the Pyr class, you'll have to refer to this synaptic mechanism's current as

pcell.synlist[j].i # or would it be pcell.synlist(j).i ? try the square brackets and if that doesn't work, use ( )

where j is the index of the element of synlist that corresponds to the synaptic mechanism you're interested in.

That's probably enough hoc to make you glad that you're using Python
alexandrapierri
Posts: 69
Joined: Wed Jun 17, 2015 5:31 pm

Re: recording HCN channels using GUI

Post by alexandrapierri »

thank you Ted!

Repetetion of fundamental concepts is very fruitful. It is very true that in person interactions are many times better, however through this forum you've been nothing but a great teacher and a mentor to all of us.

I would like to illustrate my issue in this context with a specific example. As described, I want to write a python code to do voltage clamp on my hoc model. The hoc template is complicated as it contains commands to load morphology and biophysics and synapses. Loading the template directly to python is confusing, particular due to "Import3d_SWC_read()" called by a command "load morphology" within my template.

Following a relevant topic on this forum "Neuron transforms soma that is loaded from .swc. What is the rule for it?": viewtopic.php?p=18358&hilit=Import3d_SW ... ate#p18358, I decided to create a cell class and load the template and the swc morphology seperately as two definitions of that class.

Code: Select all

CODE: SELECT ALL
class Cell():
  def __init__(self, fname_2):
    #self.fname_1 = fname_1
    #self.load_template() #(fname_1)
    self.fname_2 = fname_2
    self.load_morphology(fname_2)
  def load_template(self):
    cell = h.cADpyr229_L23_PC_c2e79db05a()
  def load_morphology(self, nom_2):
    print(nom_2)
    cell = h.Import3d_SWC_read()
    cell.input(nom_2)
    i3d = h.Import3d_GUI(cell, 0)
    i3d.instantiate(self)
Then I call the class with: my_cell_1 = Cell("morphology/P21_Rheb_021921C#7FRh_Vglut_RFP_20x_TDA_04_SNT_Data-000_radiusAPC.swc")

Now I want to record from the soma of my_cell_1.
I presume that "my_cell_1" is a python object similar to "my_cell" in the Ball and Stick tutorial. https://nrn.readthedocs.io/en/8.2.2/tut ... ick-1.html. Also following the instructions from the NEURON basics https://neuronsimulator.github.io/nrn/t ... asics.html, if I do the following I get a representation of the soma model:

Code: Select all

psoma = my_cell_1.soma[0]
psoma.psection() : --> I get a representation of the soma model succesfully
My issue is now that I can't record from the soma of the cell under a voltage clamp. If I execute the following voltage clamp code, I can't plot the membrane potential of the cell as a function of time. The graph is blank.

Code: Select all

def run_patch_clamp(pyr1, holding_v=-70, dt=0.025, tstop=10000., return_truncated=False):
           
    t_vec = h.Vector()
    t_vec.record(h._ref_t)
    h.dt   = dt
    h.tstop = tstop
    
    pyr1_v_vec = h.Vector()
    my_soma = pyr1.soma[0]
    pyr1_v_vec.record(my_soma(0.5)._ref_v)
    
    sclamp = h.SEClamp(my_soma(0.5))
    sclamp.amp1 = -70
    sclamp.amp2 = 0.
    sclamp.amp3 = -70.
    sclamp.dur1 = 600.
    sclamp.dur2 = 50.  
    sclamp.dur3 = 120.
    sclamp.rs= 0.09 #0.01

    
    h.finitialize(-65)
    h.fadvance()
    h.continuerun(h.tstop)
    return list(t_vec), list(pyr1_v_vec)
    
 tplace_data, pyr2place_data = run_patch_clamp(my_cell_1, holding_v = -70, dt=0.25, tstop=12000., return_truncated=False)
If I then plot "tplace_data" against "pyr2place_data" the plot is blank.

Have I created my cell object correctly? Any hint as to why I can't record and plot the membrane potential?

thank you,
Alexandra
ted
Site Admin
Posts: 6315
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: recording HCN channels using GUI

Post by ted »

The hoc template is complicated
but presumably it worked and was of some interest to you. So let's go back to that and see how to use it from Python and do vector record. After that is working, we can return to the issue of how to implement a cell class with Python. It will be most efficient if you can email me
ted dot carnevale at yale dot edu
the hoc code for the template, plus the source code for whatever morphometric data files (e.g. swc files) and mechanisms (mod files for ion channels, pumps, synapses if different from NEURON's built-in ExpSyn and Exp2Syn) that it needs. That way I will be able to run tests using the source code that you will be using, and we can continue this discussion via email.
Post Reply