maedoc/autotvb/boilerplate

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Essential TVB simulation boilerplate and core building blocks. Use when starting any TVB workflow, importing libraries, configuring connectivity, models, coupling, monitors, and the simulator. Triggers on `tvb.simulator.lab`, `connectivity.Connectivity`, `simulator.Simulator`, `configure()`.

Install

npx vskill@latest install maedoc/autotvb/boilerplate

SKILL.md

TVB Driver: Boilerplate & Core Simulation

Essential Imports

python
from tvb.simulator.lab import *
import numpy
import matplotlib.pyplot as plt

Forward Monitors (EEG, MEG, iEEG)

Forward solution monitors require sensor objects loaded from TVB data files. Always import and configure sensors before the monitor.

python
from tvb.datatypes.sensors import SensorsEEG, SensorsMEG, SensorsInternal
from tvb.datatypes.projections import ProjectionSurfaceEEG
from tvb.simulator import monitors
# EEG
sensors_eeg = SensorsEEG.from_file('eeg_unitvector_62.txt.bz2')
proj_eeg = ProjectionSurfaceEEG.from_file('projection_eeg_62_surface_16k.mat')
mon_eeg = monitors.EEG(
sensors=sensors_eeg,
projection=proj_eeg,
region_mapping=rm, # RegionMapping object from surface setup
period=5.0
)
mon_eeg.configure()
# iEEG / sEEG
sensors_ieeg = SensorsInternal.from_file('seeg_588.txt')
proj_ieeg = ProjectionSurfaceEEG.from_file('projection_seeg_588_surface_16k.mat')
mon_ieeg = monitors.iEEG(
sensors=sensors_ieeg,
projection=proj_ieeg,
region_mapping=rm,
period=1.0
)
mon_ieeg.configure()
# MEG
from tvb.datatypes.sensors import SensorsMEG
from tvb.datatypes.projections import ProjectionSurfaceMEG
sensors_meg = SensorsMEG.from_file('meg_sensors_306.txt.bz2')
proj_meg = ProjectionSurfaceMEG.from_file('projection_meg_306_surface_16k.mat')
mon_meg = monitors.MEG(
sensors=sensors_meg,
projection=proj_meg,
region_mapping=rm,
period=5.0
)
mon_meg.configure()

Critical: forward monitors must have their configure() called before they are passed to Simulator(). The simulator's own configure() does not auto-configure monitor internals.

Building a Simulation

Every TVB simulation follows this pattern:

python
# 1. Connectivity
conn = connectivity.Connectivity.from_file() # or from_file("custom.zip")
conn.speed = numpy.array([4.0])
conn.configure()
# 2. Model
model = models.Generic2dOscillator(a=numpy.array([-0.5]), b=numpy.array([-15.0]))
# 3. Coupling
coup = coupling.Linear(a=numpy.array([0.0154]))
# 4. Integrator
heunint = integrators.HeunDeterministic(dt=2**-4)
# 5. Monitors
mon_raw = monitors.Raw(period=0.5)
mon_avg = monitors.TemporalAverage(period=5.0)
# 6. Simulator
sim = simulator.Simulator(
model=model,
connectivity=conn,
coupling=coup,
integrator=heunint,
monitors=(mon_raw, mon_avg)
)
sim.configure()
# 7. Run
# Option A: sim.run() returns a LIST of monitor result tuples.
# Best for: standard post-hoc analysis after the full simulation.
(t_raw, y_raw), (t_avg, y_avg) = sim.run(simulation_length=1e3)
# Option B: sim() is a generator yielding per-step monitor tuples.
# Best for: custom per-step logic, streaming, or when monitors have different periods.
raw_data = []
avg_data = []
for monitor_tuple in sim(simulation_length=1e3):
if monitor_tuple[0] is not None:
raw_data.append(monitor_tuple[0])
if monitor_tuple[1] is not None:
avg_data.append(monitor_tuple[1])
# Convert collected tuples to arrays
if raw_data:
t_raw = numpy.array([r[0] for r in raw_data])
y_raw = numpy.array([r[1] for r in raw_data])
if avg_data:
t_avg = numpy.array([a[0] for a in avg_data])
y_avg = numpy.array([a[1] for a in avg_data])

Critical Rules

  • Always `configure()` connectivity before running.
  • Forward monitors (EEG, MEG, iEEG) must have their own configure() called before being passed to Simulator().
  • Array wrapping: Parameters must be numpy arrays, even scalars: numpy.array([value]).
  • Region numbering: Default connectivity has 76 regions. V1/V2 are usually regions 35, 36.
  • Prose/code drift: If markdown says "amp = 1e-3", the code must literally set amp to 1e-3.
  • Conduction speed belongs on Connectivity, NOT Simulator(): conn.speed = numpy.array([4.0]); conn.configure().
  • simulation_length belongs on sim(...) or sim.run(...), NOT in the Simulator() constructor.

Common API Mistakes to Avoid

WrongWhyRight
monitors.EEG(period=5.0) without sensorsMissing required sensors attr → configure() raises TraitAttributeErrormonitors.EEG(sensors=sensors_eeg, projection=proj_eeg, period=5.0); mon_eeg.configure()
monitors.SEEG(...)Class removed in TVB 2.x; use monitors.iEEGmonitors.iEEG(sensors=sensors_ieeg, ...)
conduction_speed=4.0 in Simulator(...)Must be set on Connectivityconn.speed = numpy.array([4.0]); conn.configure()
simulation_length=1e3 in Simulator(...)Must be in sim(...) or sim.run(...)sim.run(simulation_length=1e3)
numpy.concatenate([a[0] for a in data]) on scalar timesconcatenate fails for 0-d scalarsnumpy.array([a[0] for a in data])
for (t1, y1), (t2, y2) in sim(...) when periods differA monitor may yield None, cannot unpackUse None-safe check per index

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/maedoc/autotvb/boilerplate/badge)](https://verified-skill.com/skills/maedoc/autotvb/boilerplate)

Something wrong with this skill or its page? Tell us.