# jakexxh/srnn-2afc architecture

> Architecture diagram of the GitHub repository jakexxh/srnn-2afc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jakexxh/srnn-2afc
- Repository: https://github.com/jakexxh/srnn-2afc

## Overview

This research code trains and evaluates a spiking recurrent neural network on rule-dependent cue-and-sensory trials, then supports analysis of recorded neural activity. The principal workflow is trial generation → model training/testing → saved recordings and metrics → neural-data visualization. The graph separates task data, training orchestration, network implementation, and analysis. The README documents TensorBoard logging and checkpoint-based testing; the supplied excerpts do not show every persistence detail or the full analysis implementation.

Main entry points: [`main.py`](https://github.com/jakexxh/srnn-2afc/blob/main/main.py) (Training and testing), [`model.py`](https://github.com/jakexxh/srnn-2afc/blob/main/model.py) (Sequence model), [`snn_PFC.py`](https://github.com/jakexxh/srnn-2afc/blob/main/snn_PFC.py) (Spiking network), [`results_visualization.py`](https://github.com/jakexxh/srnn-2afc/blob/main/results_visualization.py) (Analysis tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_task["Task inputs"]
  node_data["Trial generation<br/>[data_generator.py]"]
  node_params["Model parameters<br/>[parameters.py]"]
end

subgraph group_training["Training and evaluation"]
  node_entry["Experiment runner<br/>[main.py]"]
  node_trainer["Training and testing<br/>[main.py]"]
  node_early["Early stopping<br/>[early_stopping.py]"]
  node_checkpoint["Model checkpoints<br/>[main.py]"]
  node_metrics["Training metrics<br/>[main.py]"]
end

subgraph group_network["Spiking network"]
  node_model["Sequence model<br/>[model.py]"]
  node_snn["Spiking network<br/>[snn_PFC.py]"]
  node_cell["Refractory SFA cell<br/>[lif_refrac_cell.py]"]
end

subgraph group_analysis["Neural analysis"]
  node_recordings["Test recordings<br/>[main.py]"]
  node_visualization["Analysis tools"]
  node_notebook["Analysis notebook"]
end

node_researcher(("Researcher"))
node_tensorboard["TensorBoard"]

node_researcher -->|"starts run"| node_entry
node_entry -->|"creates trials"| node_data
node_entry -->|"configures"| node_params
node_entry -->|"runs epochs"| node_trainer
node_trainer -->|"requests batches"| node_data
node_trainer -->|"trains and evaluates"| node_model
node_trainer -->|"checks stopping"| node_early
node_trainer -->|"saves and loads"| node_checkpoint
node_trainer -->|"records metrics"| node_metrics
node_metrics -->|"logs scalars"| node_tensorboard
node_trainer -->|"saves neural data"| node_recordings
node_model -->|"runs sequence"| node_snn
node_snn -->|"steps recurrent cell"| node_cell
node_visualization -->|"loads recordings"| node_recordings
node_notebook -->|"uses analysis"| node_visualization

click node_data "https://github.com/jakexxh/srnn-2afc/blob/main/data_generator.py"
click node_params "https://github.com/jakexxh/srnn-2afc/blob/main/parameters.py"
click node_entry "https://github.com/jakexxh/srnn-2afc/blob/main/main.py"
click node_trainer "https://github.com/jakexxh/srnn-2afc/blob/main/main.py"
click node_early "https://github.com/jakexxh/srnn-2afc/blob/main/early_stopping.py"
click node_model "https://github.com/jakexxh/srnn-2afc/blob/main/model.py"
click node_snn "https://github.com/jakexxh/srnn-2afc/blob/main/snn_PFC.py"
click node_cell "https://github.com/jakexxh/srnn-2afc/blob/main/lif_refrac_cell.py"
click node_checkpoint "https://github.com/jakexxh/srnn-2afc/blob/main/main.py"
click node_metrics "https://github.com/jakexxh/srnn-2afc/blob/main/main.py"
click node_recordings "https://github.com/jakexxh/srnn-2afc/blob/main/main.py"
click node_visualization "https://github.com/jakexxh/srnn-2afc/blob/main/results_visualization.py"
click node_notebook "https://github.com/jakexxh/srnn-2afc/blob/main/ResultsVisualization.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_data,node_params toneBlue
class node_entry,node_trainer,node_early,node_checkpoint,node_metrics toneAmber
class node_model,node_snn,node_cell toneMint
class node_recordings,node_visualization,node_notebook toneRose
class node_researcher,node_tensorboard toneIndigo
```

## Components

### Task inputs

- [Trial generation](https://github.com/jakexxh/srnn-2afc/blob/main/data_generator.py): `data_generator.py`
- [Model parameters](https://github.com/jakexxh/srnn-2afc/blob/main/parameters.py): `parameters.py`

### Training and evaluation

- [Experiment runner](https://github.com/jakexxh/srnn-2afc/blob/main/main.py): `main.py`
- [Training and testing](https://github.com/jakexxh/srnn-2afc/blob/main/main.py): `main.py`
- [Early stopping](https://github.com/jakexxh/srnn-2afc/blob/main/early_stopping.py): `early_stopping.py`
- [Model checkpoints](https://github.com/jakexxh/srnn-2afc/blob/main/main.py): `main.py`
- [Training metrics](https://github.com/jakexxh/srnn-2afc/blob/main/main.py): `main.py`

### Spiking network

- [Sequence model](https://github.com/jakexxh/srnn-2afc/blob/main/model.py): `model.py`
- [Spiking network](https://github.com/jakexxh/srnn-2afc/blob/main/snn_PFC.py): `snn_PFC.py`
- [Refractory SFA cell](https://github.com/jakexxh/srnn-2afc/blob/main/lif_refrac_cell.py): `lif_refrac_cell.py`

### Neural analysis

- [Test recordings](https://github.com/jakexxh/srnn-2afc/blob/main/main.py): `main.py`
- [Analysis tools](https://github.com/jakexxh/srnn-2afc/blob/main/results_visualization.py): `results_visualization.py`
- [Analysis notebook](https://github.com/jakexxh/srnn-2afc/blob/main/ResultsVisualization.ipynb): `ResultsVisualization.ipynb`

### Other components

- **Researcher**
- **TensorBoard**

## Connections

- Researcher → Experiment runner: starts run
- Experiment runner → Trial generation: creates trials
- Experiment runner → Model parameters: configures
- Experiment runner → Training and testing: runs epochs
- Training and testing → Trial generation: requests batches
- Training and testing → Sequence model: trains and evaluates
- Training and testing → Early stopping: checks stopping
- Training and testing → Model checkpoints: saves and loads
- Training and testing → Training metrics: records metrics
- Training metrics → TensorBoard: logs scalars
- Training and testing → Test recordings: saves neural data
- Sequence model → Spiking network: runs sequence
- Spiking network → Refractory SFA cell: steps recurrent cell
- Analysis tools → Test recordings: loads recordings
- Analysis notebook → Analysis tools: uses analysis
