This repo provides Python examples for visualizing the manifolds.
python neural_manifolds.py
The visualization consists of two main components:
- A spike raster plot showing the firing patterns of three individual neurons
- A 3D trajectory plot showing the neural manifold (the path traced by the combined neural activity)
python umap_example.py
Example of how to use UMAP for visualization of latent space.
- A neural network learns to classify MNIST digits
- Visualize the latent space using UMAP during training
- Create and activate a new conda environment:
conda create env create --name nengo --file env.yml
conda activate nengo
- Or install the required Python packages by yourself:
pip install numpy==1.26.3
pip install nengo==4.0.0
pip install matplotlib
- Install ffmpeg (for MP4 export):
On Ubuntu/Debian:
sudo apt-get install ffmpeg
On Conda:
conda install ffmpeg
- Uses 3 Leaky Integrate-and-Fire (LIF) neurons
- Each neuron has a different encoding vector aligned with one axis
- Firing rates: 200-400 Hz
- Membrane time constant (tau_rc): 0.02s
- Synaptic filtering: 0.01s on input, 0.05s on output
- Smooth circular trajectory in 3D space
- Frequency: 0.5 Hz
- Amplitude: 0.8
- Third dimension phase-shifted by π/4
- Color-coded spike trains for each neuron
- Gradient-colored trajectory showing time progression
- Rotating 3D view for better spatial perception
- 1-second sliding window for spike raster
- Continuous looping animation
The script generates two animation files:
neural_manifold.mp4
: High-quality video format- Higher quality
- Smaller file size
- Requires video player support
neural_manifold.gif
: Animated GIF format- More widely compatible
- Larger file size
- Can be viewed in any web browser
Key parameters that can be modified:
max_rates
: Adjust neuron firing ratestau_rc
: Change membrane time constantwindow
: Modify the spike raster window sizefreq
: Adjust trajectory frequencyamplitude
: Change trajectory size- FPS and bitrate for animation export