I do like you write and now I have swc files as hoc files and i read in python everything is alright till I want ot connect the cells (I want to connect cells, put some current and have a graph of voltage in time and have graph with the concentration of ions inside and outside the cells )
Code: Select all
from neuron import h
h.load_file('neu.hoc')
cell1 = h.pira('cell1')
cell2 = h.pira('cell2')
cell3 = h.pira('cell3')
cell4 = h.pira('cell4')
cell5 = h.pira('cell5')
cell6 = h.pira('cell6')
cell7 = h.pira('cell7')
cell8 = h.pira('cell8')
cell1.position(1,2,0)
cell2.position(1,1,0)
cell3.position(2,2,0)
cell4.position(2,1,0)
cell5.position(3,2,0)
cell6.position(3,1,0)
cell7.position(4,2,0)
cell8.position(4,1,0)
If I write dir(cell1) i have this results:
['Section', '__call__', '__class__', '__delattr__', '__delitem__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__len__', '__new__', '__nonzero__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'all', 'allsec', 'apic', 'apical', 'basal', 'baseattr', 'basic_shape', 'biophys', 'biophys_inhomo', 'cas', 'connect2target', 'dend', 'geom', 'geom_nseg', 'hname', 'hocobjptr', 'init', 'next', 'position', 'ref', 'setpointer', 'soma', 'somatic', 'subsets', 'synlist', 'topol', 'x', 'y', 'z']
I don't have for example Exp2Sync, how to connect cells ( I try connect2target but i have an error like this:
Traceback (most recent call last):
File "C:\Users\Właściciel\Desktop\komórki\hh.py", line 40, in <module>
cell1.connect2target(cell2)
RuntimeError: hoc error
Please help now I really don't know what to do :(
ramcdougal wrote:Stepping back a bit, if the goal is to use Python to create a network of some fixed pool of cell types, it's probably easiest and most efficient to use NEURON's GUI tools to convert swc files into cell templates (this is a manual process, but you only have to do it once per cell type) rather than have NEURON convert each file at each run.
To transform an swc file into a neuron template file:
- Tools - Miscellaneous - Import 3D
- "choose a file" button, then select a file and click "Read"
- export - CellBuilder
- use the Biophysics tab to place mechanisms (ion channels, etc...) throughout the cell
- Use the management tab to export by selecting "Cell type", optionally entering a "Classname" and then selecting "Save hoc code in file"
If, by doing the above, you created a file "myneuron.hoc" with a cell type called "MyCell", you can load the template via:
Code: Select all
from neuron import h
h.load_file('myneuron.hoc')
You can create multiple copies by invoking the constructor repeatedly:
Code: Select all
cell1 = h.MyCell()
cell2 = h.MyCell()
To translate one of the cells, use .position, e.g.
The same basic procedure can be used programmatically, but again, you may be better off letting the GUI help you with this part of the initial setup. To transfer to a cell builder use i3d.cbexport() instead of i3d.instantiate(). If you have a CellBuilder cb, the management tab options are in cb.manage, and the main function for exporting as a HOC template is cb.manage.save_class.