The Virtual Brain Project

Table Of Contents

Previous topic

datatypes Package

Next topic

Simulator

This Page

simulator Package

history

Simulator history implementations.

class tvb.simulator.history.BaseHistory(weights, delays, cvars, n_mode)[source]

Bases: tvb.simulator.descriptors.StaticAttr

Abstract base class for history implementations.

cvars

Data descriptor for a NumPy array, with type, mutability and shape checking.

delays

Data descriptor for a NumPy array, with type, mutability and shape checking.

initialize(init)[source]
n_cvar

Specialization of Final to int/long type.

n_mode

Specialization of Final to int/long type.

n_node

Specialization of Final to int/long type.

n_time

Specialization of Final to int/long type.

nbytes[source]
query(step, out=None)[source]
update(step, new_state)[source]
weights

Data descriptor for a NumPy array, with type, mutability and shape checking.

class tvb.simulator.history.DenseHistory(weights, delays, cvars, n_mode)[source]

Bases: tvb.simulator.history.BaseHistory

TVB’s traditional history implementation.

buffer

Data descriptor for a NumPy array, with type, mutability and shape checking.

current_state

Data descriptor for a NumPy array, with type, mutability and shape checking.

delayed_state

Data descriptor for a NumPy array, with type, mutability and shape checking.

es_icvar

Data descriptor for a NumPy array, with type, mutability and shape checking.

es_idelays

Data descriptor for a NumPy array, with type, mutability and shape checking.

es_node_ids

Data descriptor for a NumPy array, with type, mutability and shape checking.

es_weights

Data descriptor for a NumPy array, with type, mutability and shape checking.

initialize(init)[source]
nbytes[source]
query(step, out=None)[source]
update(step, new_state)[source]
class tvb.simulator.history.SparseHistory(weights, delays, cvars, n_mode)[source]

Bases: tvb.simulator.history.DenseHistory

History implementation which stores data only for non-zero weights.

const_indices

Data descriptor for a NumPy array, with type, mutability and shape checking.

n_nnzr

Specialization of Final to int/long type.

n_nnzw

Specialization of Final to int/long type.

nbytes[source]
nnz_col_el_idx

Data descriptor for a NumPy array, with type, mutability and shape checking.

nnz_idelays

Data descriptor for a NumPy array, with type, mutability and shape checking.

nnz_mask

Data descriptor for a NumPy array, with type, mutability and shape checking.

nnz_row_el_idx

Data descriptor for a NumPy array, with type, mutability and shape checking.

nnz_row_idx

Data descriptor for a NumPy array, with type, mutability and shape checking.

nnz_weights

Data descriptor for a NumPy array, with type, mutability and shape checking.

query(step, out=None)[source]
query_sparse(step)[source]
time_stride

Specialization of Final to int/long type.

common

A module of classes and functions of common use.

class tvb.simulator.common.Buffer[source]

Bases: object

Draft of a history object that allows us to track the current state and access the history array in different but consistent ways

horizon = None
raw = None
step = 0
class tvb.simulator.common.Struct[source]

Bases: dict

the Struct class is a dictionary with matlab/C struct-like access to its fields:

>>> parameters = Struct(x=23.4345, alpha=1.522e-4)
>>> parameters.x + 1
24.4345
>>> parameters.x_init = 6
>>> parameters.x_init + 1
7
>>> print parameters.y
None

note that this class returns None if the field does not exist!

tvb.simulator.common.astr(ary)[source]

Make short str repr of numerical value.

tvb.simulator.common.heaviside(array)[source]

heaviside() returns 1 if argument > 0, 0 otherwise.

The copy operation here is necessary to ensure that the array passed in is not modified.

tvb.simulator.common.iround(number) → integer[source]

Trying to get a stable and portable result when rounding a number to the nearest integer.

NOTE: I’m introducing this because of the unstability we found when using int(round()). Should use always the same rounding strategy.

Try : >>> int(4.999999999999999) 4 >>> int(4.99999999999999999999) 5

tvb.simulator.common.linear_interp1d(start_time, end_time, start_value, end_value, interp_point)[source]

performs a one dimensional linear interpolation using two timepoints (start_time, end_time) for two floating point (possibly NumPy arrays) states (start_value, end_value) to return state at timepoint start_time < interp_point < end_time.

tvb.simulator.common.log_debug(debug=False, timestamp=False, prefix='')[source]
tvb.simulator.common.map_astr(self, names)[source]

Helper for generating a sequence of astr representation of attributes on self

tvb.simulator.common.numpy_add_at()

at(a, indices, b=None)

Performs unbuffered in place operation on operand ‘a’ for elements specified by ‘indices’. For addition ufunc, this method is equivalent to a[indices] += b, except that results are accumulated for elements that are indexed more than once. For example, a[[0,0]] += 1 will only increment the first element once because of buffering, whereas add.at(a, [0,0], 1) will increment the first element twice.

New in version 1.8.0.

a : array_like
The array to perform in place operation on.
indices : array_like or tuple
Array like index object or slice object for indexing into first operand. If first operand has multiple dimensions, indices can be a tuple of array like index objects or slice objects.
b : array_like
Second operand for ufuncs requiring two operands. Operand must be broadcastable over first operand after indexing or slicing.

Set items 0 and 1 to their negative values:

>>> a = np.array([1, 2, 3, 4])
>>> np.negative.at(a, [0, 1])
>>> print(a)
array([-1, -2, 3, 4])

Increment items 0 and 1, and increment item 2 twice:

>>> a = np.array([1, 2, 3, 4])
>>> np.add.at(a, [0, 1, 2, 2], 1)
>>> print(a)
array([2, 3, 5, 4])

Add items 0 and 1 in first array to second array, and store results in first array:

>>> a = np.array([1, 2, 3, 4])
>>> b = np.array([1, 2])
>>> np.add.at(a, [0, 1], b)
>>> print(a)
array([2, 4, 3, 4])
tvb.simulator.common.simple_gen_astr(self, names)[source]

Helper for generating str for object with only numerical attributes.

tvb.simulator.common.total_ms(duration='', hours=0, minutes=0, seconds=0)[source]
tvb.simulator.common.unravel_history(history, horizon, step, arange=<built-in function arange>)[source]

in our simulator, history is a 3D numpy array where the time dimension is periodic. This means sometimes, the layout is like

[ ... , t(horizon-1), t(horizon), t(1), t(2), ... ]

but we may need the correctly ordered version

[ t(1), t(2), ... , t(horizon-1), t(horizon) ]

given some step. This function does that.

tvb.simulator.common.zip_directory(path, zip_file)[source]

Zip a given directory... Didn’t know where to put this. I need to pack zips from the scripting interface. To avoid duplicating code I leave this small function here.

:param path – where to store the zip :param zip_file

descriptors

Data descriptors for declaring workspace for algorithms and checking usage.

class tvb.simulator.descriptors.Dim[source]

Bases: tvb.simulator.descriptors.Final

Specialization of Final to int/long type.

class tvb.simulator.descriptors.Final(type=None)[source]

Bases: object

A descriptor for an attribute, possibly type-checked, that once initialized, cannot be changed.

class State

Bases: tuple

State(value, initialized)

initialized

Alias for field number 1

value

Alias for field number 0

exception tvb.simulator.descriptors.ImmutableAttrError[source]

Bases: exceptions.AttributeError

Error due to modifying an immutable attribute.

exception tvb.simulator.descriptors.IncorrectTypeAttrError[source]

Bases: exceptions.AttributeError

Error due to using incorrect type to set attribute value.

class tvb.simulator.descriptors.NDArray(shape, dtype, read_only=True)[source]

Bases: tvb.simulator.descriptors.StaticAttr

Data descriptor for a NumPy array, with type, mutability and shape checking.

class State

Bases: tuple

State(array, initialized)

array

Alias for field number 0

initialized

Alias for field number 1

NDArray.dtype = None
NDArray.instance_state = {}
NDArray.read_only = True
NDArray.shape = ()
class tvb.simulator.descriptors.StaticAttr[source]

Bases: object

Base class which requires all attributes to be declared at class level.

class tvb.simulator.descriptors.Workspace[source]

Bases: tvb.simulator.descriptors.StaticAttr