## introduce a specific type of noise

Anything that doesn't fit elsewhere.
neurite
Posts: 13
Joined: Fri Jun 22, 2007 2:06 pm
Location: Boston University

### introduce a specific type of noise

I would like to introduce a very specific type of noise to one of my channels. From the code below, I essentially need to add the variable 'dpz' to 'm' at very time step. I thought the code would work, but it doesn't. Please advise.

Code: Select all

``````NEURON {
SUFFIX nap_ch
USEION na READ ena WRITE ina
RANGE gnabar, gna, ina
GLOBAL m_inf
}

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

PARAMETER {

gnabar = 0.0001 (S/cm2)
ena = 45 (mV)
}

ASSIGNED {
v (mV)
ina (mA/cm2)
gna (S/cm2)
m_inf

}

STATE { m }

BREAKPOINT {
SOLVE states METHOD cnexp

gna = gnabar * m
ina = gna * (v - ena)
}

INITIAL {
m = m_inf
}

DERIVATIVE states {
rates(v)
noise(m)
UNITSOFF
m' = (m_inf - m)/0.1
UNITSON
}

PROCEDURE rates(v (mV)) {

m_inf = (1/(1+exp(-(v+50)/3.0 (mV))))
}

PROCEDURE noise(m) {

LOCAL randflag, dpa, dpb, dpz

:generate the random term
srand ( time(NULL) )

:generate randomflag between 0 and 1
randflag = roundf(rand()/(2^31-1))

if (randflag == 1){
dpa = cos(2*(22/7)*rand()/(2^31-1))
}

if (randflag == 0){
dpa = sin(2*(22/7)*rand()/(2^31-1))
}

dpb = -2*.001*(m_inf + m - 2*m_inf*m)/(300*.1)

dpz = dpa*(dpb*log(rand()/(2^31-1)))^(1/2)

m = m + dpz

if (m<0)
{
m=0
}

if (m>1)
{
m=1
}
}``````

hines
Posts: 1599
Joined: Wed May 18, 2005 3:32 pm
I assume you are using mswin since
on that machine you can only call
functions in the nrniv.exe file that
are listed in an export file and srand
and rand do not exist in the executable anyway. So you need to use either the built-in random generators, scop_rand, or Random
(for the latter, see src/nrnoc/netstim.mod for how to connect a hoc Random instance for use in a mod file) or else put a c implementation of a random function into a VERBATIM block in the mod file. There are examples of this in ModelDB. Search for drand48 or srand48.

neurite
Posts: 13
Joined: Fri Jun 22, 2007 2:06 pm
Location: Boston University
thanks for the pointer Michael, but it still doesn't really address the issue of adding an varying value to m at every time step.

patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

### Re: introduce a specific type of noise

Why don't you just do something like

Code: Select all

``````DERIVATIVE states {
rates(v)
dpz=whatever-random-function-you-want
UNITSOFF
m' = (m_inf - m + dpz)/0.1
UNITSON
}
``````