CANN Network Examples¶
This chapter covers the scripts under examples/cann/ that drive CANN models
directly—1D/2D bump tracking, tuning curves, and theta-modulated visualisations.
Each section lists the APIs involved, the typical output, and ideas for extending the demo.
cann1d_oscillatory_tracking.py¶
Location:
examples/cann/cann1d_oscillatory_tracking.pyGoal: Run a 1D CANN under
SmoothTracking1Dinput and export an energy-landscape animation.Key APIs:
Workflow:
Configure
brainstate.environ.set(dt=0.1)and initialise a 512-neuron CANN.Define
Iextanddurationsequences, then calltask.get_data()to build the stimulus buffer.Use
brainstate.compile.for_loopto advance the network and collect state/history arrays.Render the animation via
energy_landscape_1d_animation(); presets fromPlotConfigs.energy_landscape_1d_animationstill apply.
Output: produces
test_smooth_tracking_1d.gif(or the path you supply).Try next:
Swap in
CANN1D_SFAto compare adaptation behaviour.Feed a more complex stimulus sequence and pair the run with the tuning-curve utility below.
cann1d_tuning_curve.py¶
Location:
examples/cann/cann1d_tuning_curve.pyGoal: Sample firing-rate statistics from selected neurons and plot their tuning curves.
Key APIs:
Workflow:
Build a 1D CANN spanning
[-π, π]with several stimulus transitions.Run the simulation, recording both firing rates and external inputs.
Use
PlotConfigs.tuning_curveto configure neuron indices, bin count, and styling.Call
tuning_curve(); setsave_pathin the config to persist the plot.
Output: interactive matplotlib figure or PNG/SVG (depending on the config).
Try next:
Expand
neuron_indices_to_plotor align the preferred-stimulus axis withpref_stim=cann.x.Combine with
predict()to compare tuning before and after learning.
cann2d_tracking.py¶
Location:
examples/cann/cann2d_tracking.pyGoal: Demonstrate a 2D CANN following a sequence of targets and generate a heat-map animation.
Key APIs:
Workflow:
Instantiate a
length=100CANN and initialise its state.Provide a list of two-dimensional
Iexttargets with matchingdurationvalues.Execute
brainstate.compile.for_loopto step the network and collectu/r/inptensors.Render the animation with
PlotConfigs.energy_landscape_2d_animation.
Output:
CANN2D_encoding.gifby default.Try next:
Tune
lengthortime_steps_per_secondto balance resolution and runtime.Reuse the 1D scripts to compare dimensionality effects.
theta_sweep_grid_cell_network.py¶
Location:
examples/cann/theta_sweep_grid_cell_network.pyGoal: Run the theta-modulated direction/grid-cell pair and showcase diagnostic plots and animations.
Key APIs:
Workflow:
Build a
OpenLoopNavigationTaskto generate trajectories and theta gains.Step the networks with
calculate_theta_modulationdriving the oscillatory envelopes.Visualise the results using
plot_population_activity_with_theta(),plot_grid_cell_manifold(), andcreate_theta_sweep_animation().
Output:
theta_sweep_animation.gifplus intermediate figures.Try next:
Sweep
mapping_ratioortheta_strength_*to study modulation depth.Feed the generated data into
ThetaSweepPipelinefor automated processing.
More scripts¶
Tasks and Navigation Examples points to
hierarchical_path_integration.pyandimport_external_trajectory.py, which integrate the navigation task layer.If you only need a quick visual check, browse the pre-rendered GIF/PNG assets in the repository root—the files beginning with
test_match the examples above.