Skip to content

Backend Sessions

These modules are useful when you are subclassing a live backend or adjusting the default scene-building behavior.

NEURON Backend

neuron

Public NEURON backend entrypoints for live session authoring.

Classes:

Name Description
NeuronSceneBuilder

Build default morphology geometry and Scene objects for NEURON sessions.

NeuronSession

Base class for live NEURON-backed CompNeuroVis sessions.

NeuronSceneBuilder

Build default morphology geometry and Scene objects for NEURON sessions.

Methods:

Name Description
build_morphology_geometry

Convert NEURON sections with pt3d data into MorphologyGeometry.

build_scene

Build the default morphology-plus-trace Scene for a NEURON session.

Attributes:

Name Type Description
DISPLAY_FIELD_ID
HISTORY_FIELD_ID
TRACE_FIELD_ID

DISPLAY_FIELD_ID class-attribute instance-attribute

DISPLAY_FIELD_ID = 'segment_display'

HISTORY_FIELD_ID class-attribute instance-attribute

HISTORY_FIELD_ID = 'segment_history'

TRACE_FIELD_ID class-attribute instance-attribute

TRACE_FIELD_ID = HISTORY_FIELD_ID

build_morphology_geometry staticmethod

build_morphology_geometry(sections)

Convert NEURON sections with pt3d data into MorphologyGeometry.

build_scene staticmethod

build_scene(
    *,
    geometry: MorphologyGeometry,
    display_values: ndarray,
    trace_values: ndarray,
    trace_segment_ids: ndarray,
    trace_times: ndarray,
    display_field_id: str | None = None,
    history_field_id: str | None = None,
    display_unit: str | None = None,
    history_unit: str | None = None,
    morphology_color_map: str = "scalar",
    morphology_color_limits: tuple[float, float]
    | None = None,
    morphology_color_norm: str = "auto",
    trace_title: str = "Trace",
    trace_y_label: str = "Value",
    trace_y_unit: str | None = None,
    controls=None,
    actions=None,
    title: str = "CompNeuroVis",
    control_ids: tuple[str, ...] | None = None,
    action_ids: tuple[str, ...] | None = None,
) -> Scene

Build the default morphology-plus-trace Scene for a NEURON session.

NeuronSession

NeuronSession(
    *,
    dt: float = 0.1,
    v_init: float = -65.0,
    max_samples: int = 1000,
    display_dt: float | None = 0.1,
    history_capture_mode: HistoryCaptureMode
    | str = HistoryCaptureMode.ON_DEMAND,
    title: str = "CompNeuroVis",
)

Bases: BufferedSession, ABC

Base class for live NEURON-backed CompNeuroVis sessions.

Methods:

Name Description
startup_scene
read_updates
is_live
shutdown
emit
build_sections

Return the NEURON sections that define the model morphology.

setup_model

Insert mechanisms, stimuli, or recorders after sections are created.

control_specs
action_specs
control_order
action_order
trace_view_updates
display_field_id
history_field_id
display_unit
history_unit
morphology_color_map
morphology_color_limits
morphology_color_norm
trace_title
trace_y_label
trace_y_unit
apply_control
apply_action
on_action
on_key_press
on_entity_clicked
should_capture_trace_on_click
record

Register one NEURON variable ref for batched PtrVector sampling.

record_many

Register NEURON variable refs for sampling once per fadvance step.

on_recorded_samples

Handle one batched set of values registered with record()/record_many().

build_scene

Build the initial Scene from sampled values and morphology geometry.

initialize

Initialize the NEURON model, sample it once, and return the first Scene.

recorded_values
steps_per_update
idle_sleep
advance

Advance the simulation and emit incremental frontend updates.

handle

Attributes:

Name Type Description
HISTORY_CAPTURE_ON_DEMAND
HISTORY_CAPTURE_FULL
dt
v_init
max_samples
display_dt
history_capture_mode
title
sections
geometry

HISTORY_CAPTURE_ON_DEMAND class-attribute instance-attribute

HISTORY_CAPTURE_ON_DEMAND = ON_DEMAND

HISTORY_CAPTURE_FULL class-attribute instance-attribute

HISTORY_CAPTURE_FULL = FULL

dt instance-attribute

dt = dt

v_init instance-attribute

v_init = v_init

max_samples instance-attribute

max_samples = max_samples

display_dt instance-attribute

display_dt = display_dt

history_capture_mode instance-attribute

history_capture_mode = HistoryCaptureMode(
    history_capture_mode
)

title instance-attribute

title = title

sections instance-attribute

sections = None

geometry instance-attribute

geometry = None

startup_scene classmethod

startup_scene() -> Scene | None

read_updates

read_updates() -> list[SessionUpdate]

is_live

is_live() -> bool

shutdown

shutdown() -> None

emit

emit(update: SessionUpdate) -> None

build_sections abstractmethod

build_sections()

Return the NEURON sections that define the model morphology.

setup_model

setup_model(sections)

Insert mechanisms, stimuli, or recorders after sections are created.

control_specs

control_specs() -> dict[str, ControlSpec]

action_specs

action_specs() -> dict[str, ActionSpec]

control_order

control_order() -> tuple[str, ...] | None

action_order

action_order() -> tuple[str, ...] | None

trace_view_updates

trace_view_updates() -> dict[str, Any]

display_field_id

display_field_id() -> str

history_field_id

history_field_id() -> str

display_unit

display_unit() -> str | None

history_unit

history_unit() -> str | None

morphology_color_map

morphology_color_map() -> str

morphology_color_limits

morphology_color_limits() -> tuple[float, float] | None

morphology_color_norm

morphology_color_norm() -> str

trace_title

trace_title() -> str

trace_y_label

trace_y_label() -> str

trace_y_unit

trace_y_unit() -> str

apply_control

apply_control(control_id: str, value) -> bool

apply_action

apply_action(
    action_id: str, payload: dict[str, object]
) -> bool

on_action

on_action(
    action_id: str, payload: dict[str, Any], context
) -> bool

on_key_press

on_key_press(key: str, context) -> bool

on_entity_clicked

on_entity_clicked(entity_id: str, context) -> bool

should_capture_trace_on_click

should_capture_trace_on_click(
    entity_id: str, context
) -> bool

record

record(name: str, ref: Any) -> None

Register one NEURON variable ref for batched PtrVector sampling.

record_many

record_many(
    names: Sequence[str], refs: Sequence[Any]
) -> None

Register NEURON variable refs for sampling once per fadvance step.

on_recorded_samples

on_recorded_samples(
    times: ndarray, values: dict[str, ndarray]
) -> None

Handle one batched set of values registered with record()/record_many().

build_scene

build_scene(
    *, geometry, display_values: ndarray, time_value: float
) -> Scene

Build the initial Scene from sampled values and morphology geometry.

initialize

initialize()

Initialize the NEURON model, sample it once, and return the first Scene.

recorded_values

recorded_values() -> dict[str, float]

steps_per_update

steps_per_update() -> int

idle_sleep

idle_sleep() -> float

advance

advance() -> None

Advance the simulation and emit incremental frontend updates.

handle

handle(command) -> None

Jaxley Backend

jaxley

Public Jaxley backend entrypoints for live session authoring.

Classes:

Name Description
JaxleySceneBuilder

Build default morphology geometry and Scene objects for Jaxley sessions.

JaxleySession

Base class for live Jaxley-backed CompNeuroVis sessions.

JaxleySceneBuilder

Build default morphology geometry and Scene objects for Jaxley sessions.

Methods:

Name Description
build_morphology_geometry

Convert Jaxley morphology/network data into MorphologyGeometry.

build_scene

Build the default morphology-plus-trace Scene for a Jaxley session.

Attributes:

Name Type Description
DISPLAY_FIELD_ID
HISTORY_FIELD_ID
TRACE_FIELD_ID

DISPLAY_FIELD_ID class-attribute instance-attribute

DISPLAY_FIELD_ID = 'segment_display'

HISTORY_FIELD_ID class-attribute instance-attribute

HISTORY_FIELD_ID = 'segment_history'

TRACE_FIELD_ID class-attribute instance-attribute

TRACE_FIELD_ID = HISTORY_FIELD_ID

build_morphology_geometry staticmethod

build_morphology_geometry(
    nodes,
    *,
    xyzr: list[ndarray] | tuple[ndarray, ...] | None = None,
    cell_names: list[str] | tuple[str, ...] | None = None,
) -> MorphologyGeometry

Convert Jaxley morphology/network data into MorphologyGeometry.

build_scene staticmethod

build_scene(
    *,
    geometry: MorphologyGeometry,
    display_values: ndarray,
    trace_values: ndarray,
    trace_segment_ids: ndarray,
    trace_times: ndarray,
    display_field_id: str | None = None,
    history_field_id: str | None = None,
    display_unit: str | None = None,
    history_unit: str | None = None,
    morphology_color_map: str = "scalar",
    morphology_color_limits: tuple[float, float]
    | None = None,
    morphology_color_norm: str = "auto",
    trace_title: str = "Trace",
    trace_y_label: str = "Value",
    trace_y_unit: str | None = None,
    controls=None,
    actions=None,
    title: str = "CompNeuroVis",
    control_ids: tuple[str, ...] | None = None,
    action_ids: tuple[str, ...] | None = None,
) -> Scene

Build the default morphology-plus-trace Scene for a Jaxley session.

JaxleySession

JaxleySession(
    *,
    dt: float = 0.1,
    v_init: float = -70.0,
    max_samples: int = 1000,
    display_dt: float | None = 0.1,
    history_capture_mode: HistoryCaptureMode
    | str = HistoryCaptureMode.ON_DEMAND,
    title: str = "CompNeuroVis",
)

Bases: BufferedSession, ABC

Base class for live Jaxley-backed CompNeuroVis sessions.

Methods:

Name Description
startup_scene
read_updates
is_live
shutdown
emit
build_cells

Return one Jaxley cell or an iterable of cells for the session.

build_network

Build the Jaxley network from the returned cells.

setup_model

Configure channels, stimuli, recordings, or other runtime setup.

cell_names
control_specs
action_specs
control_order
action_order
trace_view_updates
display_field_id
history_field_id
display_unit
history_unit
morphology_color_map
morphology_color_limits
morphology_color_norm
trace_title
trace_y_label
trace_y_unit
apply_control
apply_action
on_action
on_key_press
on_entity_clicked
should_capture_trace_on_click
build_scene

Build the initial Scene from sampled values and morphology geometry.

initialize

Initialize the Jaxley model, sample it once, and return the first Scene.

steps_per_update
idle_sleep
refresh_runtime_parameters
refresh_runtime_externals
advance

Advance the simulation and emit incremental frontend updates.

handle

Attributes:

Name Type Description
HISTORY_CAPTURE_ON_DEMAND
HISTORY_CAPTURE_FULL
dt
v_init
max_samples
display_dt
history_capture_mode
title
cells
network
geometry

HISTORY_CAPTURE_ON_DEMAND class-attribute instance-attribute

HISTORY_CAPTURE_ON_DEMAND = ON_DEMAND

HISTORY_CAPTURE_FULL class-attribute instance-attribute

HISTORY_CAPTURE_FULL = FULL

dt instance-attribute

dt = dt

v_init instance-attribute

v_init = v_init

max_samples instance-attribute

max_samples = max_samples

display_dt instance-attribute

display_dt = display_dt

history_capture_mode instance-attribute

history_capture_mode = HistoryCaptureMode(
    history_capture_mode
)

title instance-attribute

title = title

cells instance-attribute

cells = None

network instance-attribute

network = None

geometry instance-attribute

geometry = None

startup_scene classmethod

startup_scene() -> Scene | None

read_updates

read_updates() -> list[SessionUpdate]

is_live

is_live() -> bool

shutdown

shutdown() -> None

emit

emit(update: SessionUpdate) -> None

build_cells abstractmethod

build_cells() -> Iterable['jx.Cell'] | 'jx.Cell'

Return one Jaxley cell or an iterable of cells for the session.

build_network

build_network(cells: list['jx.Cell'])

Build the Jaxley network from the returned cells.

setup_model

setup_model(network, cells)

Configure channels, stimuli, recordings, or other runtime setup.

cell_names

cell_names(cells: list['jx.Cell']) -> list[str]

control_specs

control_specs() -> dict[str, ControlSpec]

action_specs

action_specs() -> dict[str, ActionSpec]

control_order

control_order() -> tuple[str, ...] | None

action_order

action_order() -> tuple[str, ...] | None

trace_view_updates

trace_view_updates() -> dict[str, Any]

display_field_id

display_field_id() -> str

history_field_id

history_field_id() -> str

display_unit

display_unit() -> str | None

history_unit

history_unit() -> str | None

morphology_color_map

morphology_color_map() -> str

morphology_color_limits

morphology_color_limits() -> tuple[float, float] | None

morphology_color_norm

morphology_color_norm() -> str

trace_title

trace_title() -> str

trace_y_label

trace_y_label() -> str

trace_y_unit

trace_y_unit() -> str

apply_control

apply_control(control_id: str, value) -> bool

apply_action

apply_action(
    action_id: str, payload: dict[str, object]
) -> bool

on_action

on_action(
    action_id: str, payload: dict[str, Any], context
) -> bool

on_key_press

on_key_press(key: str, context) -> bool

on_entity_clicked

on_entity_clicked(entity_id: str, context) -> bool

should_capture_trace_on_click

should_capture_trace_on_click(
    entity_id: str, context
) -> bool

build_scene

build_scene(
    *, geometry, display_values: ndarray, time_value: float
) -> Scene

Build the initial Scene from sampled values and morphology geometry.

initialize

initialize()

Initialize the Jaxley model, sample it once, and return the first Scene.

steps_per_update

steps_per_update() -> int

idle_sleep

idle_sleep() -> float

refresh_runtime_parameters

refresh_runtime_parameters(
    *, preserve_state: bool = True
) -> None

refresh_runtime_externals

refresh_runtime_externals() -> None

advance

advance() -> None

Advance the simulation and emit incremental frontend updates.

handle

handle(command) -> None