Page 1 of 1

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

Posted: Wed Oct 16, 2019 5:38 pm
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

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

Posted: Fri Oct 18, 2019 2:00 pm
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.

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

Posted: Tue Oct 22, 2019 11:07 am
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

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

Posted: Tue Oct 22, 2019 6:46 pm
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).

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

Posted: Thu Oct 24, 2019 12:37 pm
by alexandrapierri
thank you, I believe I got it!