observation

classes.observation

Classes

Name Description
Function A named symbolic transformation applied to simulation outputs.
Observation Wrapper around the LinkML Observation datamodel with convenience
ObservationModel A directed graph of Functions transforming simulation output to observables.

Function

classes.observation.Function(instance=None, **kwargs)

A named symbolic transformation applied to simulation outputs.

Function wraps an equation (RHS string parseable by SymPy) plus parameters and metadata. Used as the building block of ObservationModels (e.g. BOLD HRF, sigmoid firing-rate, band-pass filter) and as derived quantities (e.g. coherence, PSD, FC).

Construct from a callable, from the curated ontology by name, or by passing equation=, parameters=, etc. inline.

Attributes

Name Description
function Access to the underlying callable function if available.
metadata Backward compatibility: return self (which is now the datamodel).
ontology Access to the ontology instance if available.

Methods

Name Description
from_datamodel Create Function from a datamodel instance.
from_db Load a Function by name from the tvbo database.
from_file Create Function from a file.
from_ontology Create Function from an ontology instance.
from_python Create Function from a Python callable.
list_db List available observation models in the tvbo database.
from_datamodel
classes.observation.Function.from_datamodel(datamodel_instance)

Create Function from a datamodel instance.

from_db
classes.observation.Function.from_db(name)

Load a Function by name from the tvbo database.

from_file
classes.observation.Function.from_file(filepath)

Create Function from a file.

from_ontology
classes.observation.Function.from_ontology(ontology_instance, **kwargs)

Create Function from an ontology instance.

from_python
classes.observation.Function.from_python(function_instance, **kwargs)

Create Function from a Python callable.

list_db
classes.observation.Function.list_db()

List available observation models in the tvbo database.

Observation

classes.observation.Observation(
    name=None,
    acronym=None,
    label=None,
    description=None,
    equation=None,
    parameters=empty_dict(),
    environment=None,
    time_scale='ms',
    source=empty_list(),
    aux_data=empty_list(),
    period=None,
    downsample_period=None,
    voi=None,
    imaging_modality=None,
    warmup_source=None,
    data_source=None,
    skip_t=None,
    tail_samples=None,
    aggregation=None,
    window_size=None,
    pipeline=empty_list(),
    class_reference=None,
    analysis=None,
)

Wrapper around the LinkML Observation datamodel with convenience factory methods for loading from file, database, or TVB monitors.

Methods

Name Description
execute Convert this observation to a backend monitor object.
from_db Load an Observation by name from the tvbo database.
from_file Load an Observation from a YAML file.
list_db List available observation models in the tvbo database.
plot Plot a visual summary of this observation model.
render_code Generate backend code that creates this monitor.
execute
classes.observation.Observation.execute(format='tvb')

Convert this observation to a backend monitor object.

Parameters

format : str Target backend. Currently "tvb" is supported.

Returns

tvb.simulator.monitors.Monitor Configured TVB monitor instance.

from_db
classes.observation.Observation.from_db(name)

Load an Observation by name from the tvbo database.

from_file
classes.observation.Observation.from_file(path)

Load an Observation from a YAML file.

list_db
classes.observation.Observation.list_db()

List available observation models in the tvbo database.

plot
classes.observation.Observation.plot(ax=None, **kwargs)

Plot a visual summary of this observation model.

The plot type is derived purely from the pipeline structure:

  • kernel step present (step with time_range): evaluates and plots the kernel function.
  • all other cases: draws an annotated pipeline flowchart where each box is tagged with its structural operation type (projection, temporal, transform, callable, …).
Parameters

ax : matplotlib Axes, optional Axes to draw into. A new figure is returned when ax is None. **kwargs Forwarded to the underlying plot call.

render_code
classes.observation.Observation.render_code(format='tvb')

Generate backend code that creates this monitor.

Parameters

format : str Target backend. Currently "tvb" is supported.

Returns

str Executable Python code string.

ObservationModel

classes.observation.ObservationModel(data=None)

A directed graph of Functions transforming simulation output to observables.

ObservationModel chains symbolic and numerical operations (e.g. BOLD HRF → low-pass filter → downsample → FC matrix) on a per-region time series. Nodes are Functions; edges describe data flow from Input to Output. Use add_node(name, function, ...), add_edge(src, dst) and run() to evaluate the pipeline.

Methods

Name Description
get_function_output Get the output of a specific function after execution.
get_function_output
classes.observation.ObservationModel.get_function_output(function_name)

Get the output of a specific function after execution.

Parameters
Name Type Description Default
function_name str The name of the function whose output to retrieve. required
Returns
Name Type Description
Any The result produced by the function.

Functions

Name Description
expand_to_4d Expand dimensions of the input array to ensure it has 4 dimensions.
functioninstance2metadata Normalize a function/ontology instance into datamodel kwargs.
instance2metadata

expand_to_4d

classes.observation.expand_to_4d(array)

Expand dimensions of the input array to ensure it has 4 dimensions.

functioninstance2metadata

classes.observation.functioninstance2metadata(function_instance, **kwargs)

Normalize a function/ontology instance into datamodel kwargs.

  • For Python callables: infer arguments/parameters, capture source code, record callable path (module + qualname), and infer software requirements.
  • For ontology instances: map fields from the ontology to datamodel shape.

instance2metadata

classes.observation.instance2metadata(instance, **kwargs)