Skip to content

Release v0.12.5: Reproducible Navigation & Enhanced Visualization

Choose a tag to compare

@Routhleck Routhleck released this 10 Jan 07:10
· 186 commits to master since this release
8cede97

What's New

🔬 Reproducible Navigation Tasks

  • Added rng_seed parameter 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_seed parameter 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, and ylabel parameters for improved plot customization
  • Cleaner code: Removed redundant try-except blocks from plotting functions in spatial_plots.py and spike_plots.py for 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__.py for consistency
  • Agent constructor fix: Corrected inconsistent parameter naming (environment vs Environment)

Breaking Changes

None - all additions are backward compatible.

Technical Notes

  • The rng_seed parameter is optional; omitting it maintains existing random behavior
  • Tests verify that rng_seed alone 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: Added rng_seed parameter to BaseNavigationTask
  • src/canns/task/open_loop_navigation.py: Updated OpenLoopNavigationTask with seed support
  • src/canns/analyzer/visualization/spatial_plots.py: Enhanced heatmap customization, removed try-except blocks
  • src/canns/analyzer/visualization/spike_plots.py: Removed redundant exception handling
  • tests/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