stgen

Data

__name__ = NeuroTools.stgen

array = <built-in function array>

log = <ufunc 'log'>

Functions

check_dependency(name)

gamma_hazard(x, a, b, dt=0.0001)

Compute the hazard function for a gamma process with parameters a,b where a and b are the parameters of the gamma PDF: y(t) = x(a-1) \exp(-x/b) / (\Gamma(a)*ba)

Inputs: x - in units of seconds a - dimensionless b - in units of seconds

gamma_hazard_scipy(x, a, b, dt=0.0001)

Compute the hazard function for a gamma process with parameters a,b where a and b are the parameters of the gamma PDF: y(t) = x(a-1) \exp(-x/b) / (\Gamma(a)*ba)

Inputs: x - in units of seconds a - dimensionless b - in units of seconds

gen_g_add(spikes, tau, q, t, eps=1e-08)

shotnoise_fromspikes(spike_train, q, tau, dt, array=False, eps=1e-08)

Convolves the provided spike train with shot decaying exponentials yielding so called shot noise if the spike train is Poisson-like. Returns an AnalogSignal if array=False, otherwise (shotnoise,t) as numpy arrays.

Inputs: spike_train - a SpikeTrain object q - the shot jump for each spike tau - the shot decay time constant in milliseconds dt - the resolution of the resulting shotnoise in milliseconds array - if True, returns (shotnoise,t) as numpy arrays, otherwise an AnalogSignal. eps - a numerical parameter indicating at what value of the shot kernal the tail is cut. The default is usually fine.

Examples:

stg = stgen.StGen() st = stg.poisson_generator(10.0,0.0,1000.0) g_e = shotnoise_fromspikes(st,2.0,10.0)

See also: poisson_generator, inh_gamma_generator, OU_generator ...

Classes

StGen

_OU_generator_python2(self, dt, tau, sigma, y0, t_start=0.0, t_stop=1000.0, array=False, time_it=False)

Generates an Orstein Ulbeck process using the forward euler method. The function returns an AnalogSignal object

Inputs: dt - the time resolution in milliseconds of th signal tau - the correlation time in milliseconds sigma - std dev of the process y0 - initial value of the process, at t_start t_start - start time in milliseconds t_stop - end time in milliseconds array - if True, a numpy array of the OU signal is returned, rather than an AnalogSignal object.

Examples:

stgen.OU_generator(0.1, 2, 3, 0, 0, 10000)

OU_generator_weave1(self, dt, tau, sigma, y0, t_start=0.0, t_stop=1000.0, time_it=False)

generates an OU process using forward euler dt = resolution tau = correlation time sigma = std dev of process y0 = mean/initial value tsim = how long to simulate

__init__(self, rng=None, seed=None)

Stochastic Process Generator ============================

Object to generate stochastic processes of various kinds and return them as SpikeTrain or AnalogSignal objects.

Inputs: rng - The random number generator state object (optional). Can be None, or a numpy.random.RandomState object, or an object with the same interface.

seed - A seed for the rng (optional).

If rng is not None, the provided rng will be used to generate random numbers, otherwise StGen will create its own random number generator. If a seed is provided, it is passed to rng.seed(seed)

Examples:

x = StGen()

StGen Methods:

Spiking point processes:


poisson_generator - homogeneous Poisson process inh_poisson_generator - inhomogeneous Poisson process (time varying rate) inh_gamma_generator - inhomogeneous Gamma process (time varying a,b)

Continuous time processes:


OU_generator - Ohrnstein-Uhlenbeck process

See also: shotnoise_fromspikes

_inh_2Dadaptingmarkov_generator_python(self, a, bq, tau_s, tau_r, qrqs, t, t_stop, array=False)

Returns a SpikeList whose spikes are an inhomogeneous realization (dynamic rate) of the so-called 2D adapting markov process (see references). 2D implies the process has two states, an adaptation state, and a refractory state, both of which affect its probability to spike. The implementation uses the thinning method, as presented in the references.

For the 1d implementation, with no relative refractoriness, see the inh_adaptingmarkov_generator.

Inputs: a,bq - arrays of the parameters of the hazard function where a[i] and bq[i] will be active on interval [t[i],t[i+1]] tau_s - the time constant of adaptation (in milliseconds). tau_r - the time constant of refractoriness (in milliseconds). qrqs - the ratio of refractoriness conductance to adaptation conductance. typically on the order of 200. t - an array specifying the time bins (in milliseconds) at which to specify the rate t_stop - length of time to simulate process (in ms) array - if True, a numpy array of sorted spikes is returned, rather than a SpikeList object.

Note: - t_start=t[0]

- a is in units of Hz. Typical values are available in Fig. 1 of Muller et al 2007, a~5-80Hz (low to high stimulus)

- bq here is taken to be the quantity b*q_s in Muller et al 2007, is thus dimensionless, and has typical values bq~3.0-1.0 (low to high stimulus)

- qrqs is the quantity q_r/q_s in Muller et al 2007, where a value of qrqs = 3124.0nS/14.48nS = 221.96 was used.

- tau_s has typical values on the order of 100 ms - tau_r has typical values on the order of 2 ms

References:

Eilif Muller, Lars Buesing, Johannes Schemmel, and Karlheinz Meier Spike-Frequency Adapting Neural Ensembles: Beyond Mean Adaptation and Renewal Theories Neural Comput. 2007 19: 2958-3010.

Devroye, L. (1986). Non-uniform random variate generation. New York: Springer-Verlag.

Examples:

See also: inh_poisson_generator, inh_gamma_generator, inh_adaptingmarkov_generator

_inh_adaptingmarkov_generator_python(self, a, bq, tau, t, t_stop, array=False)

Returns a SpikeList whose spikes are an inhomogeneous realization (dynamic rate) of the so-called adapting markov process (see references). The implementation uses the thinning method, as presented in the references.

This is the 1d implementation, with no relative refractoriness. For the 2d implementation with relative refractoriness, see the inh_2dadaptingmarkov_generator.

Inputs: a,bq - arrays of the parameters of the hazard function where a[i] and bq[i] will be active on interval [t[i],t[i+1]] tau - the time constant of adaptation (in milliseconds). t - an array specifying the time bins (in milliseconds) at which to specify the rate t_stop - length of time to simulate process (in ms) array - if True, a numpy array of sorted spikes is returned, rather than a SpikeList object.

Note: - t_start=t[0]

- a is in units of Hz. Typical values are available in Fig. 1 of Muller et al 2007, a~5-80Hz (low to high stimulus)

- bq here is taken to be the quantity b*q_s in Muller et al 2007, is thus dimensionless, and has typical values bq~3.0-1.0 (low to high stimulus)

- tau_s has typical values on the order of 100 ms

References:

Eilif Muller, Lars Buesing, Johannes Schemmel, and Karlheinz Meier Spike-Frequency Adapting Neural Ensembles: Beyond Mean Adaptation and Renewal Theories Neural Comput. 2007 19: 2958-3010.

Devroye, L. (1986). Non-uniform random variate generation. New York: Springer-Verlag.

Examples:

See also: inh_poisson_generator, inh_gamma_generator, inh_2dadaptingmarkov_generator

_inh_gamma_generator_unimplemented(self, a, b, t, t_stop, array=False)

inh_poisson_generator(self, rate, t, t_stop, array=False)

Returns a SpikeList whose spikes are a realization of an inhomogeneous poisson process (dynamic rate). The implementation uses the thinning method, as presented in the references.

Inputs: rate - an array of the rates (Hz) where rate[i] is active on interval [t[i],t[i+1]] t - an array specifying the time bins (in milliseconds) at which to specify the rate t_stop - length of time to simulate process (in ms) array - if True, a numpy array of sorted spikes is returned, rather than a SpikeList object.

Note: t_start=t[0]

References:

Eilif Muller, Lars Buesing, Johannes Schemmel, and Karlheinz Meier Spike-Frequency Adapting Neural Ensembles: Beyond Mean Adaptation and Renewal Theories Neural Comput. 2007 19: 2958-3010.

Devroye, L. (1986). Non-uniform random variate generation. New York: Springer-Verlag.

Examples:

time = arange(0,1000) stgen.inh_poisson_generator(time,sin(time), 1000)

See also: poisson_generator, inh_gamma_generator

poisson_generator(self, rate, t_start=0.0, t_stop=1000.0, array=False, debug=False)

Returns a SpikeTrain whose spikes are a realization of a Poisson process with the given rate (Hz) and stopping time t_stop (milliseconds).

Note: t_start is always 0.0, thus all realizations are as if they spiked at t=0.0, though this spike is not included in the SpikeList.

Inputs: rate - the rate of the discharge (in Hz) t_start - the beginning of the SpikeTrain (in ms) t_stop - the end of the SpikeTrain (in ms) array - if True, a numpy array of sorted spikes is returned, rather than a SpikeTrain object.

Examples:

gen.poisson_generator(50, 0, 1000) gen.poisson_generator(20, 5000, 10000, array=True)

See also: inh_poisson_generator, inh_gamma_generator

seed(self, seed)

seed the gsl rng with a given seed