parameters name in inserted modules.

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

Moderator: hines

Post Reply
rth
Posts: 38
Joined: Thu Jun 21, 2012 4:47 pm

parameters name in inserted modules.

Post by rth » Wed Aug 21, 2013 12:50 am

Hi all,

I have strange problem with using NEURON+Python.

According Hines et.al. 2009 'NEURON and Python', parameters of inserted modules should be accessible through object's attribute with same name as SUFFIX.

Code: Select all

soma = h.Section()
soma.insert ('pas')
soma.pas.g = 0.0003
For example, I inserted a simple module:

Code: Select all

TITLE passive  (leak) membrane channel

UNITS {
	(mV) = (millivolt)
	(mA) = (milliamp)
}

NEURON {
	SUFFIX vcnleak
	NONSPECIFIC_CURRENT i
	RANGE g, erev
}

PARAMETER {
	v (mV)
	g = .001	(mho/cm2)
	erev = -65	(mV)
}

ASSIGNED { i	(mA/cm2)}

BREAKPOINT {
	i = g*(v - erev)
}
and tried manipulate with leak reversal potential:

Code: Select all

		self.soma = h.Section(name='soma', cell=self)
		self.soma.insert('vcnleak')
		self.soma.vcnleak.g	= 1./10000.
NEURON returned error:

Code: Select all

nrngui -nogui -python RaM03.py 
NEURON -- Release 7.2 (562:42a47463b504) 2011-12-21
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html

loading membrane mechanisms from /home/rth/i686/.libs/libnrnmech.so
.....
.....
    self.soma.vcnleak.g = 1./10000.
AttributeError: 'nrn.Section' object has no attribute 'vcnleak'
Should I use suffix instead object's attribute? BTW this form works perfect.

Code: Select all

h('soma g_vcnleak = 1./10000. ')
Thank you,
Ruben

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

Re: parameters name in inserted modules.

Post by ted » Fri Aug 23, 2013 3:09 pm

rth wrote:

Code: Select all

    self.soma.vcnleak.g = 1./10000.
AttributeError: 'nrn.Section' object has no attribute 'vcnleak'
I've seen that error. Segments have the attribute. Here are a few examples of the use of range variables in Python:

Code: Select all

>>> soma.nseg  = 3
>>> soma.insert('pas')
>>> for seg in soma:
...   print seg.x, seg.pas.g
... 
0.166666666667 0.001
0.5 0.001
0.833333333333 0.001
>>> for seg in soma:
...   seg.pas.g = 0.002
... 
>>> for seg in soma:
...   print seg.x, seg.pas.g
... 
0.166666666667 0.002
0.5 0.002
0.833333333333 0.002
>>> seg.x=0.1
>>> seg.pas.g
0.002
>>> seg.pas.g = 4
>>> seg.pas.g
4.0
>>> for seg in soma:
...   print seg.x, seg.pas.g
... 
0.166666666667 4
0.5 0.002
0.833333333333 0.002
>>> soma(0.5).pas.g
0.002
>>> soma(0.5).pas.g = 0.003
>>> soma(0.5).pas.g
0.0030000000000000001
>>> for seg in soma:
...   print seg.x, seg.pas.g
... 
0.166666666667 4
0.5 0.003
0.833333333333 0.002

rth
Posts: 38
Joined: Thu Jun 21, 2012 4:47 pm

Re: parameters name in inserted modules.

Post by rth » Sat Aug 24, 2013 12:56 pm

Thank you, Ted.

I just want set all segments without iterations like in hoc notation:

Code: Select all

soma g_pas = 0.05
However I've figured out how I can do this in python also:

Code: Select all

>>> soma = h.Section()
>>> soma.insert('pas')
<nrn.Section object at 0x96edc08>
>>> soma.nseg=7
>>> print soma.g_pas
0.001
>>> for seg in soma: print seg.pas.g
... 
0.001
0.001
0.001
0.001
0.001
0.001
0.001
>>> soma.g_pas = 0.02
>>> for seg in soma: print seg.pas.g
... 
0.02
0.02
0.02
0.02
0.02
0.02
0.02
>>> 

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

Re: parameters name in inserted modules.

Post by ted » Sat Aug 24, 2013 2:20 pm

Just like hoc. Nice that it works.

Post Reply