Release v0.12.5: Reproducible Navigation & Enhanced Visualization
What's New
🔬 Reproducible Navigation Tasks
- Added
rng_seedparameter to navigation tasks for deterministic agent behavior - Comprehensive test suite ensuring reproducibility across runs
- Backward compatible with existing code
🎨 Enhanced Visualization Customization
- Improved heatmap plotting with customizable labels and titles
- Cleaner plotting code with streamlined error handling
Major Features / Key Changes
🔬 Reproducible Navigation Tasks (PR #78)
- BaseNavigationTask & OpenLoopNavigationTask: New
rng_seedparameter enables reproducible agent trajectories when a seed is provided - Agent instantiation: Updated to use the seed for deterministic behavior
- Comprehensive testing: Added test suite verifying reproducibility, randomness, and backward compatibility
from canns.task import OpenLoopNavigationTask
# Create reproducible navigation task
task = OpenLoopNavigationTask(
environment=env,
rng_seed=42 # Ensures reproducible agent behavior
)
# Multiple runs with same seed produce identical trajectories
trajectory1 = task.run()
trajectory2 = task.run() # Identical to trajectory1🎨 Enhanced Spatial Plot Customization
- plot_firing_field_heatmap: Added optional
title,xlabel, andylabelparameters for improved plot customization - Cleaner code: Removed redundant try-except blocks from plotting functions in
spatial_plots.pyandspike_plots.pyfor better readability and maintainability - Simplified logic: Improved tick removal and axis label handling
from canns.analyzer.visualization import plot_firing_field_heatmap
# Create customized heatmap
plot_firing_field_heatmap(
firing_field,
title="Grid Cell Firing Field",
xlabel="X Position (cm)",
ylabel="Y Position (cm)"
)Technical Improvements
Code Quality
- Exception handling: Removed redundant try-except blocks, delegating error handling to callers
- Import organization: Minor reordering in visualization
__init__.pyfor consistency - Agent constructor fix: Corrected inconsistent parameter naming (
environmentvsEnvironment)
Breaking Changes
None - all additions are backward compatible.
Technical Notes
- The
rng_seedparameter is optional; omitting it maintains existing random behavior - Tests verify that
rng_seedalone ensures reproducibility without requiring global random seeds - Plotting functions now raise exceptions directly rather than catching and re-raising them
Files Modified
src/canns/task/navigation_base.py: Addedrng_seedparameter to BaseNavigationTasksrc/canns/task/open_loop_navigation.py: Updated OpenLoopNavigationTask with seed supportsrc/canns/analyzer/visualization/spatial_plots.py: Enhanced heatmap customization, removed try-except blockssrc/canns/analyzer/visualization/spike_plots.py: Removed redundant exception handlingtests/task/open_loop_navigation/test_reproducibility.py: New comprehensive test suite (301 lines)
Use Cases
- Researchers: Ensure reproducible experiments with deterministic agent trajectories
- Developers: Debug navigation tasks with consistent behavior across runs
- Visualization users: Create publication-ready plots with custom labels and titles
Full Changelog: v0.12.4...v0.12.5