cleo.viz module#
Tools for visualizing models and simulations
- class cleo.viz.VideoVisualizer(devices: collections.abc.Iterable[Union[cleo.base.InterfaceDevice, Tuple[cleo.base.InterfaceDevice, dict]]] = NOTHING, dt: brian2.units.fundamentalunits.Quantity = 1. * msecond, *, name: str = NOTHING, save_history: bool = True)[source]#
Bases:
cleo.base.InterfaceDevice
Device for visualizing a simulation.
Must be injected after all other devices and before the simulation is run.
Method generated by attrs for class VideoVisualizer.
- connect_to_neuron_group(neuron_group: brian2.groups.neurongroup.NeuronGroup, **kwparams) None [source]#
Connect device to given neuron_group.
If your device introduces any objects which Brian must keep track of, such as a NeuronGroup, Synapses, or Monitor, make sure to add these to
brian_objects
.- Parameters
neuron_group (NeuronGroup) –
**kwparams (optional) – Passed from inject
- devices: collections.abc.Iterable[Union[cleo.base.InterfaceDevice, Tuple[cleo.base.InterfaceDevice, dict]]]#
list of devices or (device, vis_kwargs) tuples to include in the plot, just as in the
plot()
function, by default “all”, which will include all recorders and stimulators currently injected when this visualizer is injected into the simulator.
- dt: brian2.units.fundamentalunits.Quantity#
length of each frame—that is, every
dt
the visualizer takes a snapshot of the network, by default 1*ms
- generate_Animation(plotargs: dict, slowdown_factor: float = 10, **figargs: Any) matplotlib.animation.Animation [source]#
Create a matplotlib Animation object from the recorded simulation
- Parameters
plotargs (dict) – dictionary of arguments as taken by
plot()
. can include xlim, ylim, zlim, colors, axis_scale_unit, invert_z, and/or scatterargs. neuron groups and devices are automatically added and **figargs are specified separately.slowdown_factor (float, optional) – how much slower the animation will be rendered, as a multiple of real-time, by default 10
**figargs (Any, optional) – keyword arguments passed to plt.figure(), such as figsize
- Returns
An Animation object capturing the desired visualization. See matplotlib’s docs for saving and rendering options.
- Return type
- init_for_simulator(simulator: cleo.base.CLSimulator)[source]#
Initialize device for simulator on initial injection.
This function is called only the first time a device is injected into a simulator and performs any operations that are independent of the individual neuron groups it is connected to.
- Parameters
simulator (CLSimulator) – simulator being injected into
- neuron_groups: list[brian2.groups.neurongroup.NeuronGroup]#
- cleo.viz.plot(*neuron_groups: brian2.groups.neurongroup.NeuronGroup, xlim: Optional[Tuple[float, float]] = None, ylim: Optional[Tuple[float, float]] = None, zlim: Optional[Tuple[float, float]] = None, colors: Optional[collections.abc.Iterable] = None, axis_scale_unit: brian2.units.fundamentalunits.Unit = umetre, devices: collections.abc.Iterable[Union[cleo.base.InterfaceDevice, Tuple[cleo.base.InterfaceDevice, dict]]] = [], invert_z: bool = True, scatterargs: dict = {}, sim: Optional[cleo.base.CLSimulator] = None, **figargs: Any) None [source]#
Visualize neurons and interface devices
- Parameters
xlim (Tuple[float, float], optional) – xlim for plot, determined automatically by default
ylim (Tuple[float, float], optional) – ylim for plot, determined automatically by default
zlim (Tuple[float, float], optional) – zlim for plot, determined automatically by default
colors (Iterable, optional) – colors, one for each neuron group, automatically determined by default
axis_scale_unit (Unit, optional) – Brian unit to scale lim params, by default mm
devices (Iterable[Union[InterfaceDevice, Tuple[InterfaceDevice, dict]]], optional) – devices to add to the plot or (device, kwargs) tuples.
add_self_to_plot()
is called for each, using the kwargs dict if given. By default []invert_z (bool, optional) – whether to invert z-axis, by default True to reflect the convention that +z represents depth from cortex surface
scatterargs (dict, optional) – arguments passed to plt.scatter() for each neuron group, such as marker
sim (CLSimulator, optional) – Optional shortcut to include all neuron groups and devices
**figargs (Any, optional) – keyword arguments passed to plt.figure(), such as figsize
- Raises
ValueError – When neuron group doesn’t have x, y, and z already defined