TheVirtualBrain:

TheDocumentationwebsite.

Table Of Contents

Previous topic

run 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.

classmethod from_simulator(sim, initial_conditions=None)[source]

Set initial conditions for the simulation using either the provided initial_conditions or, if none are provided, the model’s initial() method. This method is called durin the Simulator’s __init__().

Any initial_conditions that are provided as an argument are expected to have dimensions 1, 2, and 3 with shapse corresponding to the number of state_variables, nodes and modes, respectively. If the provided inital_conditions are shorter in time (dim=0) than the required history the model’s initial() method is called to make up the difference.

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.Struct[source]

Bases: builtins.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.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])
>>> 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)
>>> 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)
>>> 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.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: builtins.object

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

class State

Bases: builtins.tuple

State(value, initialized)

initialized

Alias for field number 1

value

Alias for field number 0

exception tvb.simulator.descriptors.ImmutableAttrError[source]

Bases: builtins.AttributeError

Error due to modifying an immutable attribute.

exception tvb.simulator.descriptors.IncorrectTypeAttrError[source]

Bases: builtins.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: builtins.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: builtins.object

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

class tvb.simulator.descriptors.Workspace[source]

Bases: tvb.simulator.descriptors.StaticAttr