# comsee-research/predictive-coding-light architecture

> Architecture diagram of the GitHub repository comsee-research/predictive-coding-light, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/comsee-research/predictive-coding-light
- Repository: https://github.com/comsee-research/predictive-coding-light

## Overview

##### Project type and purpose
- This is primarily a C++ library (“Neuvisys”) implementing a neuromorphic vision system (Predictive Coding Light network).
- It ships as a core library (network simulation), a command-line tool (“neuvisys-exe”), a Qt-based GUI (“neuvisys-qt”), plus unit tests.
- In parallel there is a Python module (PCL_Python_Analysis) with Jupyter notebooks and scripts for event data analysis, stimulus generation and fitting (SVM, Gabor).

##### File structure
Top-level directories and files
– CMakeLists.txt, externals/, libs/, test/, data/, tools/, PCL_Python_Analysis/
– version.h, README.md
externals/
– Third-party C++ code (cnpy for .npz, json.hpp, libserie) bundled locally
libs/
– network/: core library (SpikingNetwork, Event, SurroundSuppression, config)
– gui/: Qt GUI library (GLWidget, Neuvisysgui, thread)
– apps/: two executables – neuvisys (CLI) and neuvisys-qt (GUI)
test/
– C++ unit tests for NetworkHandle and SpikingNetwork
data/
– Example HDF5 event files and network directories
tools/
– Installation scripts (INSTALL.sh)
PCL_Python_Analysis/
– Python package (pyproject.toml, scripts.py, dev utilities)
– src/events (data loaders, generators, modifiers)
– src/spiking_network (Python wrappers/analyses of the C++ network?)
– Jupyter notebooks demonstrating plots, tuning curves, video conversion

##### README for additional insights
- Describes the build workflow via CMake: core library, optional GUI
- Describes external dependencies: OpenCV, HDF5, Qt Charts, Python packages
- Explains runtime: how the CLI/GUI load events (HDF5), feed them to the network, save weights
- Configuration via JSON files under network/configs

##### Elements
– Build dependencies (externals → core → gui → apps/tests)
– Runtime data flow (HDF5/.npz → core or Python → outputs)
– C++ modules vs Python modules vs data files vs build tools
– Highlight JSON config as a separate artifact

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Dependencies
    subgraph "External Dependencies"
        direction TB
        EXT_EXT["externals/"]:::external
        CN["cnpy"]:::external
        JSONH["json.hpp"]:::external
        LIBS["libserie"]:::external
        EXT_EXT --> CN
        EXT_EXT --> JSONH
        EXT_EXT --> LIBS
    end

    %% Build System
    subgraph "Build & Tools"
        direction TB
        CMAKE["CMakeLists.txt"]:::build
        INSTALL["INSTALL.sh"]:::build
        CMAKE --> INSTALL
    end

    %% Core Library
    subgraph "Neuvisys Core Library (C++)"
        direction TB
        CORE["libs/network/"]:::core
        NH["NetworkHandle"]:::core
        SN["SpikingNetwork"]:::core
        SS["SurroundSuppression"]:::core
        CFG["Config Loader"]:::core
        NEU1["SimpleNeuron"]:::core
        NEU2["ComplexNeuron"]:::core
        CORE --> NH
        CORE --> SN
        CORE --> SS
        CORE --> CFG
        CORE --> NEU1
        CORE --> NEU2
    end

    %% GUI Library
    subgraph "GUI Library (Qt)"
        direction TB
        GUI_LIB["libs/gui/"]:::gui
        WID["GLWidget"]:::gui
        GUICTRL["NeuvisysThread"]:::gui
        UI["neuvisysgui.ui"]:::gui
        GUI_LIB --> WID
        GUI_LIB --> GUICTRL
        GUI_LIB --> UI
    end

    %% Executables
    subgraph "Executables"
        direction TB
        CLI["neuvisys-exe"]:::app
        QTAPP["neuvisys-qt"]:::app
        CLI -->|links against| CORE
        QTAPP -->|links against| CORE
        QTAPP -->|uses| GUI_LIB
    end

    %% Python Analysis Module
    subgraph "Python Analysis Module"
        direction TB
        PYROOT["PCL_Python_Analysis/"]:::python
        SCRIPTS["scripts.py & dev utilities"]:::python
        EVENTS["src/events/"]:::python
        PYNET["src/spiking_network/"]:::python
        NOTEBOOKS["Jupyter Notebooks"]:::python
        PYROOT --> SCRIPTS
        PYROOT --> EVENTS
        PYROOT --> PYNET
        PYROOT --> NOTEBOOKS
    end

    %% Data Storage
    subgraph "Data Storage"
        direction TB
        HDF5["shapes.h5"]:::data
        NETDIR["data/networks/"]:::data
    end

    %% Tests
    subgraph "C++ Unit Tests"
        direction TB
        TESTROOT["test/"]:::test
        T1["NetworkHandleTest"]:::test
        T2["SpikingNetworkTest"]:::test
        TESTROOT --> T1
        TESTROOT --> T2
        TESTROOT --> CORE
    end

    %% Build Dependencies
    CMAKE --> EXT_EXT
    CMAKE --> CORE
    CMAKE --> GUI_LIB
    CMAKE --> CLI
    CMAKE --> QTAPP
    CMAKE --> TESTROOT

    %% Runtime Data Flow
    HDF5 -->|loads events| CLI
    HDF5 -->|loads events| QTAPP
    HDF5 -->|loads events| EVENTS
    HDF5 -->|loads events| PYNET
    CLI -->|writes weights| NETDIR
    QTAPP -->|writes weights| NETDIR
    EVENTS -->|generates/reads npz| CN

    %% Classes and Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef build fill:#ffa,stroke:#333,stroke-width:1px
    classDef core fill:#bbf,stroke:#333,stroke-width:1px
    classDef gui fill:#bfb,stroke:#333,stroke-width:1px
    classDef app fill:#fbf,stroke:#333,stroke-width:1px
    classDef python fill:#ffb,stroke:#333,stroke-width:1px
    classDef data fill:#aff,stroke:#333,stroke-width:1px
    classDef test fill:#faf,stroke:#333,stroke-width:1px

    %% Click Events
    click EXT_EXT "https://github.com/comsee-research/predictive-coding-light/tree/main/externals/"
    click CN "https://github.com/comsee-research/predictive-coding-light/tree/main/externals/cnpy/"
    click JSONH "https://github.com/comsee-research/predictive-coding-light/blob/main/externals/json/json.hpp"
    click LIBS "https://github.com/comsee-research/predictive-coding-light/tree/main/externals/libserie/"
    click CORE "https://github.com/comsee-research/predictive-coding-light/tree/main/libs/network/"
    click NH "https://github.com/comsee-research/predictive-coding-light/blob/main/libs/network/include/network/NetworkHandle.hpp"
    click SN "https://github.com/comsee-research/predictive-coding-light/blob/main/libs/network/include/network/SpikingNetwork.hpp"
    click SS "https://github.com/comsee-research/predictive-coding-light/blob/main/libs/network/include/network/SurroundSuppression.hpp"
    click CFG "https://github.com/comsee-research/predictive-coding-light/blob/main/libs/network/include/network/config/Config.hpp"
    click NEU1 "https://github.com/comsee-research/predictive-coding-light/blob/main/libs/network/include/network/neurons/SimpleNeuron.hpp"
    click NEU2 "https://github.com/comsee-research/predictive-coding-light/blob/main/libs/network/include/network/neurons/ComplexNeuron.hpp"
    click CLI "https://github.com/comsee-research/predictive-coding-light/blob/main/libs/apps/neuvisys/src/main.cpp"
    click QTAPP "https://github.com/comsee-research/predictive-coding-light/blob/main/libs/apps/gui/src/main.cpp"
    click GUI_LIB "https://github.com/comsee-research/predictive-coding-light/tree/main/libs/gui/"
    click WID "https://github.com/comsee-research/predictive-coding-light/blob/main/libs/gui/include/gui/GLWidget.h"
    click GUICTRL "https://github.com/comsee-research/predictive-coding-light/blob/main/libs/gui/include/gui/Neuvisysthread.h"
    click UI "https://github.com/comsee-research/predictive-coding-light/blob/main/libs/gui/src/neuvisysgui.ui"
    click PYROOT "https://github.com/comsee-research/predictive-coding-light/tree/main/PCL_Python_Analysis/"
    click SCRIPTS "https://github.com/comsee-research/predictive-coding-light/blob/main/PCL_Python_Analysis/src/scripts.py"
    click EVENTS "https://github.com/comsee-research/predictive-coding-light/blob/main/PCL_Python_Analysis/src/events/Events.py"
    click PYNET "https://github.com/comsee-research/predictive-coding-light/blob/main/PCL_Python_Analysis/src/spiking_network/network/neuvisys.py"
    click HDF5 "https://github.com/comsee-research/predictive-coding-light/blob/main/data/events/shapes.h5"
    click NETDIR "https://github.com/comsee-research/predictive-coding-light/tree/main/data/networks/"
    click TESTROOT "https://github.com/comsee-research/predictive-coding-light/tree/main/test/"
    click T1 "https://github.com/comsee-research/predictive-coding-light/blob/main/test/NetworkHandleTest.cpp"
    click T2 "https://github.com/comsee-research/predictive-coding-light/blob/main/test/SpikingNetworkTest.cpp"
    click CMAKE "https://github.com/comsee-research/predictive-coding-light/blob/main/CMakeLists.txt"
    click INSTALL "https://github.com/comsee-research/predictive-coding-light/blob/main/tools/INSTALL.sh"
```
