ReferencesBiosimulant LibraryVisualization Contract

Visualization Contract

Standard format for module visualization output. Modules implement visualize() to return renderer-agnostic specs that SimUI and the platform render automatically.

Timeseries

def visualize(self):
    return {
        "render": "timeseries",
        "data": {
            "title": "Membrane Potential",
            "xlabel": "Time (ms)",
            "ylabel": "Voltage (mV)",
            "series": [
                {"name": "Neuron 1", "points": self.v1_history},
                {"name": "Neuron 2", "points": self.v2_history}
            ]
        }
    }

Each points entry is a list of [x, y] pairs: [[0.0, -65.0], [0.1, -60.2], ...].

Bar Chart

def visualize(self):
    return {
        "render": "bar",
        "data": {
            "title": "Spike Counts",
            "items": [
                {"label": "Excitatory", "value": self.exc_count},
                {"label": "Inhibitory", "value": self.inh_count}
            ]
        }
    }

Table

def visualize(self):
    return {
        "render": "table",
        "data": {
            "columns": ["Metric", "Value"],
            "rows": [
                ["Mean Rate", f"{self.mean_rate:.2f} Hz"],
                ["Total Spikes", str(self.total_spikes)]
            ]
        }
    }

Image (Raster Plot, Heatmap, etc.)

For complex visualizations generated with matplotlib or similar:

def visualize(self):
    return {
        "render": "image",
        "data": {
            "src": self.raster_image_base64,  # data:image/png;base64,... or raw base64
            "alt": "Spike Raster",
            "width": 800,
            "height": 400
        }
    }

Specification

FieldTypeRequiredDescription
renderstrYesOne of: "timeseries", "bar", "table", "image"
datadictYesRender-type-specific content

Timeseries data

FieldTypeDescription
titlestrChart title
xlabelstrX-axis label
ylabelstrY-axis label
serieslist[{name, points}]Named data series

Bar data

FieldTypeDescription
titlestrChart title
itemslist[{label, value}]Labeled values

Table data

FieldTypeDescription
columnslist[str]Column headers
rowslist[list[str]]Row data (strings)

Image data

FieldTypeDescription
srcstrBase64-encoded image (PNG/JPEG)
altstrAlt text
widthintDisplay width in pixels
heightintDisplay height in pixels

See Also