accessing the same instantiation of a cell template from another python script

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

Moderator: hines

Post Reply
alexandrapierri
Posts: 69
Joined: Wed Jun 17, 2015 5:31 pm

accessing the same instantiation of a cell template from another python script

Post by alexandrapierri »

Hello developers

I have the following novice problem. I want to call a given cell template from a hoc script and then access the exact same instantiation of that cell from a different python script. I fall upon a couple of syntax errors as I try to do that and was hoping for some guidance.

my hoc cell file is the: "class_bistratifiedcell.hoc" which contains the template: bistratifiedcell

It is loaded successfully from another hoc script in the following manner:

Code: Select all

default_var("celltype2use", "bistratifiedcell")
sprint(tempFileStr,"./cells/class_%s.hoc",celltype2use)                                                                                                                                  load_file(tempFileStr) 
To call the same cell template from python I could simply do:

Code: Select all

    h.load_file('class_bistratifiedcell.hoc')
    my_cell= h.bistratifiedcell()
    soma_loc=my_cell.soma[0]
    soma_center=soma_loc(0.5)
However this would create a different instantiation of the same cell.

I need to access the exact same instantiation of that cell from python, and for that reason I do the following:

Code: Select all

my_cell=h.celltype2use
print my_cell #successfully prints: "bistratifiedcell"
soma_loc=my_cell.soma[0] #error: 'str' object has no attribute soma
The above syntax is wrong. I have tried different combinations of the above syntax but nothing has worked yet.
I believe this is a knowledge gap on my part. Any advice on what is the correct way to access the same instantiation of bistratifiedcell from python would be much appreciated.

thank you in advance for your help!
Alexandra
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: accessing the same instantiation of a cell template from another python script

Post by ted »

Use a GLOBAL parameter. If the values of the parameter are precalculated (known before the start of the simulation), use the Vector class's play() method to drive the GLOBAL parameter. I'll dig up an example and post it.
alexandrapierri
Posts: 69
Joined: Wed Jun 17, 2015 5:31 pm

Re: accessing the same instantiation of a cell template from another python script

Post by alexandrapierri »

thank you Ted. I will work on your instructions.
If you could also point me to an example that would be really helpful.

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

Re: accessing the same instantiation of a cell template from another python script

Post by ted »

Download
https://www.neuron.yale.edu/ftp/ted/ine ... nd_rec.zip
and examine xtra.mod. See how the GLOBAL variable called "is" is used to tell every instance of xtra the value of the current applied by the stimulating electrode. Note the use of
BEFORE BREAKPOINT
to ensure that all local extracellular potentials are set to the correct value before fadvance() is executed (fadvance() causes execution of the BREAKPOINT blocks).
alexandrapierri
Posts: 69
Joined: Wed Jun 17, 2015 5:31 pm

Re: accessing the same instantiation of a cell template from another python script

Post by alexandrapierri »

thank you, I believe I got it!
Post Reply