Problem with setdata on NEURON+Python

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

Moderator: hines

Post Reply
vgoudar
Posts: 19
Joined: Fri Dec 03, 2010 3:41 am

Problem with setdata on NEURON+Python

Post by vgoudar »

Hi,

Im trying to instantiate a distributed mechanism that continuously injects random noise into an IAF cell. To generate a random sample for the noise, Im passing in a random object from python. In the mod file for the noise mechanism, this is handled identically to the random variable in netstim.mod.

Code: Select all

FUNCTION randGen() {
VERBATIM
	if (_p_randObjPtr) {
		/*
		:Supports separate independent but reproducible streams for
		: each instance. However, the corresponding hoc Random
		: distribution MUST be set to Random.uniform(0,1)
		*/
		_lrandGen = nrn_random_pick(_p_randObjPtr);
	}else{
		hoc_execerror("Random object ref not set correctly for randObjPtr"," only via hoc Random");
	}
ENDVERBATIM
}

PROCEDURE setRandObjRef() {
VERBATIM
	void** pv = (void**)(&_p_randObjPtr);
	if (ifarg(1)) {
		*pv = nrn_random_arg(1);
	}else{
		*pv = (void*)0;
	}
ENDVERBATIM
}
Whereas netstim is an artifical cell, my noise mechanism is declared as SUFFIX. So, when passing random object into the noise mechanism, I need to call setdata_NOISE first as in hoc.

Code: Select all

self.soma.insert('NOISE')
self.noiseRandObj.uniform(0,1)
self.soma.setdata_NOISE(0.5)
self.soma.setRandObjRef_NOISE(self.noiseRandObj)

However, Im unable to gain access to any of the noise mechanisms custom procedures in python:

Code: Select all

File "cells.py", line 77, in biophys
    self.soma.setdata_NOISE(0.5)
AttributeError: 'nrn.Section' object has no attribute 'setdata_NOISE'
Any suggestions will be highly appreciated.

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

Re: Problem with setdata on NEURON+Python

Post by ted »

Im trying to instantiate a distributed mechanism that continuously injects random noise into an IAF cell.
. . .
Whereas netstim is an artifical cell, my noise mechanism is declared as SUFFIX.
The strategy for achieving your goal depends on exactly what you're trying to do, but key aspects of that are mostly implicit in your post. Here's my initial guess at the important implicit information:
(1) Your "IAF cell" is a "biophysical model cell" i.e. it actually has one or more sections with membrane capacitance.
(2) It may have more than one compartment.
(3) You want each of its compartments to be perturbed by "noise."
(4) You intend this "noise" to be current noise
Are these guesses correct?
vgoudar
Posts: 19
Joined: Fri Dec 03, 2010 3:41 am

Re: Problem with setdata on NEURON+Python

Post by vgoudar »

Hi Ted,

Yes, you're absolutely right. FYI, IAF has a single compartment.

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

Re: Problem with setdata on NEURON+Python

Post by ted »

At long last, I have some code that may be useful for your purpose. Pick up
https://www.neuron.yale.edu/ftp/ted/neuron/idriven.zip
expand it, compile the mod files, then use NEURON to execute initr123.hoc

Your particular application only requires one "noise current source" per model cell, but this implementation allows adding independently fluctuating current to as many compartments in a multicompartment model as one wishes.

Be sure to read the readme.txt file and the hoc files. The mod files are interesting, but not essential to understand; if you're tempted to modify them, be very cautious and test to make sure you didn't break anything. When it comes to principled generation and use of pseudorandom sequences, proper initialization and reproducibility are of paramount importance.
Post Reply