Example application

A minimalistic main.cpp file is shown below. The circuit consist of a ganglion cell, a relay cell and one cortical cell. The simulation settings and kernel parameters are given in Config file. The output is .h5 file.

main.cpp

#include <iostream>
#include <yaml-cpp/yaml.h>
#include <lgnSimulator.h>

using namespace std;
using namespace lgnSimulator;

int main(int argc, char* argv[])
{
    cout << "===== lgn-simulator =====" << endl;

    //read config file-----------------------------------------------------------------------
    YAML::Node cfg = YAML::LoadFile(argv[1]);

    //Output manager:---------------------------------------------------------
    OutputManager outputManager(cfg["OutputManager"]["outputFilename"].as<std::string>());

    //Integrator-----------------------------------------------------------------------------
    Integrator integrator = createIntegrator(cfg["grid"]);

    //Stim-----------------------------------------------------------------------------------
    unique_ptr<Grating> S = createGratingStimulus(&integrator, cfg["stimulus"]);

    //Ganglion cell:--------------------------------------------------------------------------
    DOG Wg_s = createSpatialDOGKernel(cfg["ganglion"]["Wg"]);
    TemporalDelta Wg_t = createTemporalDeltaKernel(cfg["ganglion"]["Wt"]);
    SeparableKernel Wg(cfg["ganglion"]["w"].as<double>(), &Wg_s, &Wg_t);

    GanglionCell ganglion(&integrator, Wg, cfg["ganglion"]["R0"].as<double>());

    //Relay cell: ------------------------------------------------------------------------------
    RelayCell relay(&integrator, cfg["relay"]["R0"].as<double>());

    // G -> R
    SpatialDelta Ks_rg = createSpatialDeltaKernel(cfg["relay"]["Krg"]["spatial"]);
    TemporalDelta Kt_rg = createTemporalDeltaKernel(cfg["relay"]["Krg"]["temporal"]);
    SeparableKernel Krg(cfg["relay"]["Krg"]["w"].as<double>(), &Ks_rg, &Kt_rg);

    // C -> R
    SpatialGaussian Ks_rc = createSpatialGaussianKernel(cfg["relay"]["Krc"]["spatial"]);
    TemporalDelta Kt_rc = createTemporalDeltaKernel(cfg["relay"]["Krc"]["temporal"]);
    SeparableKernel Krc(cfg["relay"]["Krc"]["w"].as<double>(), &Ks_rc, &Kt_rc);

    //Cortical cell: -----------------------------------------------------------------------------
    HeavisideNonlinearity heavisideNonlinearity;
    CorticalCell cortical(&integrator, cfg["cortical"]["R0"].as<double>(), &heavisideNonlinearity);

    // R -> C
    SpatialDelta Ks_cr = createSpatialDeltaKernel(cfg["cortical"]["Kcr"]["spatial"]);
    TemporalDelta Kt_cr = createTemporalDeltaKernel(cfg["cortical"]["Kcr"]["temporal"]);
    SeparableKernel Kcr(cfg["cortical"]["Kcr"]["w"].as<double>(), &Ks_cr, &Kt_cr);

    //Connect neurons:------------------------------------------------------------------------------
    relay.addGanglionCell(&ganglion, Krg);
    relay.addCorticalCell(&cortical, Krc);
    cortical.addRelayCell(&relay, Kcr);

    //Compute:--------------------------------------------------------------------------------------
    S->computeFourierTransform();
    S->computeSpatiotemporal();
    relay.computeImpulseResponse();
    relay.computeResponse(S.get());

    //Write:-----------------------------------------------------------------------------------------
    outputManager.writeIntegratorProperties(integrator);
    outputManager.writeStimulusProperties(S.get());
    outputManager.writeStimulus(S.get());
    outputManager.writeResponse(relay);
    outputManager.writeImpulseResponse(relay);

    return 0;
}

Config file

The config file is shown below. The number of spatial and temporal points is given by \( N_s = 2^{\texttt{ns}} \) and \( N_t = 2^{\texttt{nt}} \), respectively. The spatial and temporal grid spacing is set by \( \texttt{ds}\) and \( \texttt{dt}\), respectively. The stimulus settings consist of the contrast value \( \texttt{C}\), the mask size, orientation, phase, and grating frequency (spatial and temporal). \( \texttt{kId}\) and \( \texttt{wId}\) correspond to indices in the spatial and temporal frequency vectors. \( \texttt{kId=0}\) corresponds to spot stimulus and \( \texttt{wId=0}\) corresponds to a static stimulus.

The background activities are set by \( \texttt{R0}\), while the kernel weights are set by \( \texttt{w}\).

description: "config file"

#------------File manager settings-----------------#
OutputManager:
    outputFilename: "out.h5"

#------------Integrator settings-----------------#
grid:
    ns: 7
    nt: 2
    dt: &dt_id 1.0
    ds: &ds_id 0.05

#------------Stimulus settings-------------------#
stimulus:
    # Grating:
    mask: "circle"  #none/circle/cscircle/gaussian

    C: 1.0
    maskSize: 1         #deg
    orientation: 0.     #deg
    phase: 0.           #deg
    kId:  7             #[-Ns/2, Ns/2 - 1]
    wId:  0             #[-Nt/2, Nt/2 - 1]

#-------------Ganglion cell settings--------------#
ganglion:
    R0 : 0
    w: 1.0
    Wg:
    # DOG
        a: 0.62
        b: 1.26
        c: 0.85
    Wt:
    # TemporalDelta
        delay: 0
        dt: *dt_id

#---------------Relay cell settings--------------#
relay:
    R0 : 0
    #Kernels
    Krg:
        w: 1.0
        spatial:
        #Spatial delta
            ds: *ds_id
            shift: [0, 0]

        temporal:
        # TemporalDelta
            delay: 0
            dt: *dt_id

    Krc:
        w: 0.5
        spatial:
        #Gauss
            a: 0.2

        temporal:
        # TemporalDelta
            delay: 0.
            dt: *dt_id

#-------------Cortical cell settings--------------#
cortical:
    R0 : 0.
    Kcr:
        w: 1.0
        spatial:
        #Spatial delta
            ds: *ds_id
            shift: [0, 0]

        temporal:
        # TemporalDelta
            delay: 0.
            dt: *dt_id