
## Core Simulation and Comparison Scripts

### `bci_simulation.py` (114 KB)
**Advanced BCI simulation framework with biologically-inspired learning mechanisms:**
- **Synthetic Neuron Model**: Directionally-tuned neurons divided into 4 quadrants with realistic firing patterns, Bernoulli spike generation, and noise injection
- **Kalman Filter Implementation**: Full state-space model with automatic parameter estimation via linear regression for observation and transition matrices, includes measurement and process noise covariance estimation
- **LSTM Regression**: Standard PyTorch implementation with configurable layers, dropout, and early stopping with validation monitoring
- **Two-Scale Meta-RL Weight Updater**: Novel biologically-plausible learning rule implementing:
  - True Hebbian principle (neurons that fire together, wire together)
  - Dopaminergic-like modulation based on prediction correlation quality
  - Hierarchical learning with fast/slow timescales for different network layers
  - Meta-learning capabilities with adaptive plasticity and sensitivity parameters
- **Correlation Analysis**: Robust Pearson correlation computation with tensor/numpy compatibility

### `decoder_comparison.py` (89 KB)
**Multi-decoder performance evaluation framework:**
- Cross-imports models from both bci_simulation.py and ZENODO_SCRIPT2.py for comprehensive comparison
- Implements standardized evaluation protocols across Kalman Filter, LSTM, and SNN decoders
- **Disruption Testing**: Systematic evaluation under neural signal disruptions (dropout, remapping, drift)
- **Phased Learning Analysis**: Tracks decoder performance through initial learning and adaptation phases
- **Synthetic Data Generation**: Controlled experiments with known ground truth for validation
- Supports both pre-trained and from-scratch learning scenarios

### `decoder_comparison_nopretrain.py` (42 KB)
Specialized version of decoder_comparison.py excluding pre-training phases, designed for evaluating pure online learning capabilities without any initial model weights.

## Ablation Study Scripts

### MC_MAZE Ablation Studies
- `MCMAZE_ABLATION_1.py` through `MCMAZE_ABLATION_5.PY` (70-84 KB each)
- **Systematic ablation studies on the MC_MAZE dataset** from Neural Latents Benchmark
- Uses nlb_tools interface with 10Hz resampling and 50ms spike smoothing
- **Sliding window processing**: Configurable bin widths (100ms) and strides (10ms) for temporal binning
- **Trial-based analysis**: Aligns data to movement onset (-130ms to +370ms) with proper trial ID intersection
- **Spike processing modes**: Binary, count, rate, and Poisson spike representations
- Tests different meta-learning configurations (fast traces, slow traces, dual traces, Hebbian vs Delta rule)

### ZENODO Ablation Studies  
- `ZENODO_ABLATION_1.py` through `ZENODO_ABLATION_5.py` (81-92 KB each)
- **Standardized ZENODO dataset processing** with 64ms binning to match Makin et al. 2019
- **Advanced preprocessing**: 4th-order 10Hz Butterworth filtering on cursor position before velocity calculation
- **Movement-only evaluation**: Optional thresholding at 2cm/s for movement-specific metrics
- **Comprehensive spike processing**: Rate, binary, count, and Poisson modes with optional normalization
- **Zero-lag analysis**: Non-overlapping bins for causal prediction evaluation
- Tests ablations of trace timescales, update mechanisms, Hebbian learning, recurrent connections, and meta-learning

### `ZENODO_SCRIPT2.py` (104 KB)
**Production-grade ZENODO dataset processing with advanced SNN architectures:**
- **Enhanced SNNRegression Model**: 3-layer SNN with recurrent connections, Leaky integrate-and-fire neurons, fast sigmoid surrogate gradients
- **Sophisticated Data Streaming**: BatchSequenceIterator for BPTT training and OnlineDataStream for true online learning with trial boundary resets
- **Advanced Training Infrastructure**: Supports both need_traces mode for Hebbian learning and standard forward pass
- **Robust Data Handling**: Comprehensive error handling for insufficient data, proper device management, and memory optimization
- **Statistical Evaluation**: Multi-dimensional correlation analysis with proper handling of edge cases

## Experimental Execution Scripts

### `run_experiments.py` (13 KB)
**High-throughput automated experiment orchestration:**
- **Multi-run experimental design**: 10 runs per disruption type with incremental seeding (base seed 42)
- **Disruption protocols**: Dropout (0.5), remapping (0.9), and drift (0.9) intensity testing
- **Reach time aggregation**: Sophisticated statistical analysis with smoothing windows (15-sample) and phase concatenation
- **Publication-quality visualization**: Arial fonts, 300 DPI, large text (18-24pt), professional color schemes
- **Statistical robustness**: Mean ± standard deviation across runs with proper NaN handling and padding
- **Phase boundary visualization**: Clear delineation between initial learning and adaptation phases

### `run_experiments_nopretrain.py` (12 KB)
Identical experimental protocol to run_experiments.py but configured for pure online learning without any pre-training initialization.

## Analysis and Visualization Tools

### `plot_ablation_results.py` (21 KB)
**Professional statistical visualization with rigorous analysis:**
- **Publication standards**: Times New Roman serif fonts, 300 DPI, print-friendly layout with horizontal grid lines only
- **Color accessibility**: Okabe-Ito palette optimized for color-blind readers and grayscale printing
- **Advanced statistics**: Paired t-tests with Benjamini-Hochberg FDR correction, Cohen's d effect sizes
- **Significance visualization**: Automatic star placement (*, **, ***) with effect size annotations
- **Dual baseline comparisons**: Support for testing against multiple reference conditions with color-coded significance markers
- **Human-readable labels**: Automatic translation of technical configuration names to readable format

### `plot_learning_curves.py` (20 KB)
**Comprehensive learning trajectory analysis:**
- **Multi-session parsing**: Automatic extraction from concatenated log files with session boundary detection
- **Online vs BPTT comparison**: Fair comparison ranges accounting for different learning paradigms
- **Robust interpolation**: Grid-based interpolation with forward-fill extrapolation for BPTT data
- **Progress normalization**: Handles different total sample counts between online and batch learning
- **Error handling**: Graceful handling of incomplete sessions and missing data with warnings

### `plotscript.py` (11 KB)
**Foundational plotting infrastructure:**
- **Okabe-Ito color standards**: Professional color palette with statistical significance visualization
- **Multi-condition bar plots**: Grouped bars with 95% CI error bars and FDR-corrected significance testing
- **Flexible baseline comparisons**: Support for primary and secondary baseline conditions with distinct visualization
- **Statistical robustness**: Multiple comparison correction and effect size reporting

### `parse_ablations.py` (2 KB)
**Robust log file parsing with regex-based extraction:**
- **Multi-format support**: Handles both ZENODO (with session filenames) and MC_MAZE (numbered sessions) formats
- **Result pattern matching**: Extracts X/Y correlations and average metrics with decimal precision
- **Session context tracking**: Maintains proper session-result associations even with complex nested logs
- **Error resilience**: Comprehensive error handling for malformed logs with clear diagnostic messages

## Memory and Performance Analysis

### `memoryscript2.py` (11 KB)
**Comprehensive memory profiling and optimization analysis:**
- **Multi-algorithm comparison**: Compares memory footprint between Online SNN (3x parameters for traces) vs BPTT SNN (4x parameters for gradients + Adam optimizer)
- **Static memory calculation**: Precise accounting of parameters, eligibility traces, gradient buffers, and optimizer states
- **Dynamic memory measurement**: Real-time measurement using tracemalloc and psutil with kernel warm-up and optimizer state priming
- **Scaling analysis**: Benchmark-based scaling for different input sizes, hidden dimensions, and sequence lengths
- **Publication-quality output**: Times New Roman fonts with professional matplotlib styling for memory usage plots
- **Caching optimization**: Intelligent caching of expensive measurements to avoid redundant profiling

## Legacy and Development Scripts

### `train_distributed_old.py` (36 KB)
Legacy distributed training implementation, likely superseded by newer versions.

### `train_dist_old_zenodo.py` (19 KB)
Older version of ZENODO dataset training script, maintained for historical comparison.

## Data Files and Logs

### Result Files
- `results_all_seeds_correlations.csv` (138 KB) - Comprehensive correlation results across all experimental seeds and sessions
- `mcmazeresults.txt` (3 KB) - Summary results from MC_MAZE experiments
- `mcmaze_valcorrs_bptt.txt` (5 KB) - Validation correlations using backpropagation through time
- `mcmaze_valcorrs_online.txt` (27 KB) - Online learning validation correlations

### Log Files
- `fullmcmaze.txt` (407 KB) - Complete experimental log for MC_MAZE dataset
- `fullzenodo.txt` (88 KB) - Complete experimental log for ZENODO dataset  
- `fullzenodoonline.txt` (84 KB) - Online learning experimental log for ZENODO dataset
- `mcmaze_val_log.txt` (139 KB) - Detailed validation logs for MC_MAZE experiments
- `mcmazelog.txt` (13 KB) - General MC_MAZE experimental logs

## Visualization Outputs

### Neural Signal Plots (PNG files, 508-794 KB each)
Time series visualizations of SNN velocity predictions:
- `snn_velocity_timeseries_slice_indy_YYYYMMDD_0X.mat.png` (12 files total)
- Each file corresponds to different experimental sessions from the Indy dataset
- Shows velocity predictions over time with neural signal correlations
- Dates range from 2016-04-07 to 2016-12-12

## Dataset Information

The experiments primarily use two datasets:
1. **MC_MAZE Dataset**: Neural data from maze navigation tasks
2. **ZENODO Dataset**: Standardized neural decoding benchmark data (Indy sessions)

## Usage Notes

- Most Python scripts require PyTorch, snntorch, scikit-learn, and matplotlib
- Scripts are designed for both CPU and GPU execution
- Many files include comprehensive logging and result caching mechanisms
- Experimental configurations emphasize reproducibility with fixed random seeds