Simulator
This is the main module of the simulator. It defines the Simulator class which
brings together all the structural and dynamic components necessary to define a
simulation and the method for running the simulation.
-
class tvb.simulator.simulator.Simulator(**kwargs)[source]
A Simulator assembles components required to perform simulations.
- connectivity : tvb.simulator.simulator.Simulator.connectivity = Attr(field_type=<class ‘tvb.datatypes.connectivity.Connectivity’>, default=None, required=True)
- A tvb.datatypes.Connectivity object which contains the
structural long-range connectivity data (i.e., white-matter tracts). In
combination with the Long-range coupling function it defines the inter-regional
connections. These couplings undergo a time delay via signal propagation
with a propagation speed of Conduction Speed
- conduction_speed : tvb.simulator.simulator.Simulator.conduction_speed = Float(field_type=<class ‘float’>, default=3.0, required=False)
- Conduction speed for Long-range connectivity (mm/ms)
- coupling : tvb.simulator.simulator.Simulator.coupling = Attr(field_type=<class ‘tvb.simulator.coupling.Coupling’>, default=<tvb.simulator.coupling.Linear object at 0x7f78e1258b90>, required=True)
- The coupling function is applied to the activity propagated
between regions by the Long-range connectivity before it enters the local
dynamic equations of the Model. Its primary purpose is to ‘rescale’ the
incoming activity to a level appropriate to Model.
- surface : tvb.simulator.simulator.Simulator.surface = Attr(field_type=<class ‘tvb.datatypes.cortex.Cortex’>, default=None, required=False)
- By default, a Cortex object which represents the
cortical surface defined by points in the 3D physical space and their
neighborhood relationship. In the current TVB version, when setting up a
surface-based simulation, the option to configure the spatial spread of
the Local Connectivity is available.
- stimulus : tvb.simulator.simulator.Simulator.stimulus = Attr(field_type=<class ‘tvb.datatypes.patterns.SpatioTemporalPattern’>, default=None, required=False)
- A Spatiotemporal stimulus can be defined at the region or surface level.
It’s composed of spatial and temporal components. For region defined stimuli
the spatial component is just the strength with which the temporal
component is applied to each region. For surface defined stimuli, a
(spatial) function, with finite-support, is used to define the strength
of the stimuli on the surface centred around one or more focal points.
In the current version of TVB, stimuli are applied to the first state
variable of the Local dynamic model.
- model : tvb.simulator.simulator.Simulator.model = Attr(field_type=<class ‘tvb.simulator.models.base.Model’>, default=<tvb.simulator.models.oscillator.Generic2dOscillator object at 0x7f78e1258e10>, required=True)
- A tvb.simulator.Model object which describe the local dynamic
equations, their parameters, and, to some extent, where connectivity
(local and long-range) enters and which state-variables the Monitors
monitor. By default the ‘Generic2dOscillator’ model is used. Read the
Scientific documentation to learn more about this model.
- integrator : tvb.simulator.simulator.Simulator.integrator = Attr(field_type=<class ‘tvb.simulator.integrators.Integrator’>, default=<tvb.simulator.integrators.HeunDeterministic object at 0x7f78db2ef410>, required=True)
- A tvb.simulator.Integrator object which is
an integration scheme with supporting attributes such as
integration step size and noise specification for stochastic
methods. It is used to compute the time courses of the model state
variables.
- initial_conditions : tvb.simulator.simulator.Simulator.initial_conditions = NArray(label=’Initial Conditions’, dtype=float64, default=None, dim_names=(), ndim=None, required=False)
- Initial conditions from which the simulation will begin. By
default, random initial conditions are provided. Needs to be the same shape
as simulator ‘history’, ie, initial history function which defines the
minimal initial state of the network with time delays before time t=0.
If the number of time points in the provided array is insufficient the
array will be padded with random values based on the ‘state_variables_range’
attribute.
- monitors : tvb.simulator.simulator.Simulator.monitors = List(of=<class ‘tvb.simulator.monitors.Monitor’>, default=(<tvb.simulator.monitors.TemporalAverage object at 0x7f78db2e6850>,), required=True)
- A tvb.simulator.Monitor or a list of tvb.simulator.Monitor
objects that ‘know’ how to record relevant data from the simulation. Two
main types exist: 1) simple, spatial and temporal, reductions (subsets
or averages); 2) physiological measurements, such as EEG, MEG and fMRI.
By default the Model’s specified variables_of_interest are returned,
temporally downsampled from the raw integration rate to a sample rate of
1024Hz.
- simulation_length : tvb.simulator.simulator.Simulator.simulation_length = Float(field_type=<class ‘float’>, default=1000.0, required=True)
- The length of a simulation (default in milliseconds).
gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)
-
backend = <tvb.simulator.backend.ref.ReferenceBackend object at 0x7f78db25a0d0>
-
bound_and_clamp(state)[source]
-
calls = 0
-
conduction_speed
Declares a float.
This is different from Attr(field_type=float).
The former enforces float subtypes.
This allows any type that can be safely cast to the declared float type
according to numpy rules.
Reading and writing this attribute is slower than a plain python attribute.
In performance sensitive code you might want to use plain python attributes
or even better local variables.
-
configure(full_configure=True)[source]
Configure simulator and its components.
The first step of configuration is to run the configure methods of all
the Simulator’s components, ie its traited attributes.
Configuration of a Simulator primarily consists of calculating the
attributes, etc, which depend on the combinations of the Simulator’s
traited attributes (keyword args).
Converts delays from physical time units into integration steps
and updates attributes that depend on combinations of the 6 inputs.
- sim: Simulator
- The configured Simulator instance.
-
connectivity
An Attr declares the following about the attribute it describes:
* the type
* a default value shared by all instances
* if the value might be missing
* documentation
It will resolve to attributes on the instance.
-
coupling
An Attr declares the following about the attribute it describes:
* the type
* a default value shared by all instances
* if the value might be missing
* documentation
It will resolve to attributes on the instance.
-
current_step = 0
-
gid
An Attr declares the following about the attribute it describes:
* the type
* a default value shared by all instances
* if the value might be missing
* documentation
It will resolve to attributes on the instance.
-
good_history_shape[source]
Returns expected history shape.
-
history = None
-
initial_conditions
Declares a numpy array.
dtype enforces the dtype. The default dtype is float32.
An optional symbolic shape can be given, as a tuple of Dim attributes from the owning class.
The shape will be enforced, but no broadcasting will be done.
domain declares what values are allowed in this array.
It can be any object that can be checked for membership
Defaults are checked if they are in the declared domain.
For performance reasons this does not happen on every attribute set.
-
integrate_next_step = None
-
integrator
An Attr declares the following about the attribute it describes:
* the type
* a default value shared by all instances
* if the value might be missing
* documentation
It will resolve to attributes on the instance.
-
is_surface_simulation[source]
-
memory_requirement()[source]
Return an estimated of the memory requirements (Bytes) for this
simulator’s current configuration.
-
model
An Attr declares the following about the attribute it describes:
* the type
* a default value shared by all instances
* if the value might be missing
* documentation
It will resolve to attributes on the instance.
-
monitors
The attribute is a list of values.
Choices and type are reinterpreted as applying not to the list but to the elements of it
-
number_of_nodes = None
-
preconfigure()[source]
Configure just the basic fields, so that memory can be estimated.
-
run(**kwds)[source]
Convenience method to call the simulator with **kwds and collect output data.
-
runtime(simulation_length)[source]
Return an estimated run time (seconds) for the simulator’s current
configuration and a specified simulation length.
-
simulation_length
Declares a float.
This is different from Attr(field_type=float).
The former enforces float subtypes.
This allows any type that can be safely cast to the declared float type
according to numpy rules.
Reading and writing this attribute is slower than a plain python attribute.
In performance sensitive code you might want to use plain python attributes
or even better local variables.
-
stimulus
An Attr declares the following about the attribute it describes:
* the type
* a default value shared by all instances
* if the value might be missing
* documentation
It will resolve to attributes on the instance.
-
storage_requirement()[source]
Return an estimated storage requirement (Bytes) for the simulator’s
current configuration and a specified simulation length.
-
summary_info()
A more structured __str__
A 2 column table represented as a dict of str->str
The default __str__ and html representations of this object are derived from
this table.
Override this method and return such a table filled with instance information
that informs the user about your instance
-
surface
An Attr declares the following about the attribute it describes:
* the type
* a default value shared by all instances
* if the value might be missing
* documentation
It will resolve to attributes on the instance.
-
tag(tag_name, tag_value=None)
Add a tag to this trait instance.
The tags are for user to recognize and categorize the instances
They should never influence the behaviour of the program
:param tag_name: an arbitrary tag
:param tag_value: an optional tag value
-
validate()
Check that the internal invariants of this class are satisfied.
Not meant to ensure that that is the case.
Use configure for that.
The default configure calls this before it returns.
It complains about missing required attrs
Can be overridden in subclasses