% This file is licensed under the Allen Institute Terms of Use, which can be found at:
%http://www.alleninstitute.org/Media/policies/terms_of_use_content.html

%------------------------------------------------------------------------------------

function [cellpop connect] = init_cellpop_no_dep;

%Function to initialize network with structures for cell populations and connections between
%them. In this network, synaptic depression is ABSENT and synaptic utility parameters are 
%chosen appropriately.
%
%For feed-forward networks considered in this paper, network consists
%of a source and target population and a single connection between them
%
%Each population structure has a voltage discretization vector, an initial
%probability distribution vector, a vector of synaptic utilities (set to be a 
%trivial scalar here since depression is absent), a flag to differentiate between
%external (not dynamical) and internal (dynamical) populations and an
%vector for external firing rate. 
%
%Each connection structure has a source and a target population identifier,
%a flag specifiying conductance or current-based synapse, a flag specifying
%Poisson or non-Poisson input, a number specifying the number of input
%cells per target neuron (in-degree for the connection), a 3-row vector qdw
%containing information about the synaptic weight distribution and finally, a number
%(voltage_fraction) between 0 and 1 that corresponds to fraction of post-threshold 
%voltage that gets "wrapped around" resting potential
%
%For current-based synapses, the first row of qdw contains the discretized weights (w) of the synaptic weight
%distribution q(w), all elements in the second row are set to unity and the third row contains
%the probability q(w) corresponding to given synaptic weight w. For
%conductance-based synapses, the first row contains the non-dimensional
%quantity (w) as explained below equation (21) in the paper, the second row
%corresponds to the reversal potential and the third row again corresponds
%to the probabilities q(w)

%Temporary parameters for cell populations (actual values set in main scripts that generate data)

th=20*10^-3;                          %V Threshold
lk=1/(20*10^-3);                      %s^-1 leak constant 1/RC

dt=1*10^-4;                           %s time step
tf=500*10^-3;                         %s final time
tvec=0:dt:tf;

dv=0.2*10^-3;                         %V defines max step in potential
v0=(0:dv:th);                         %V defines the grid for the membrane potential      

voltage_fraction=1;                  %fraction of post-threshold voltage that gets 
                                     %"wrapped around" resting potential

%external population 
cellpop(1).lk=lk;                                   
cellpop(1).th=th;
cellpop(1).v0=v0;
cellpop(1).p0=zeros(size(cellpop(1).v0));           %Initial probability distribution
cellpop(1).p0(1)=1;                                 %Start from rest
cellpop(1).external_fr=100*ones(size(tvec));        %(Hz), external firing rate
cellpop(1).u_frac=1;                                %fraction of synaptic utility available after a spike
cellpop(1).u_tau=0;                                 %(s), time constant of recovery from depression
cellpop(1).u_vec=1;                                 %Initial utility vector
cellpop(1).u_prob=1;                                %Initial utility distribution
cellpop(1).u_pts=1;                                 %Set of points to which to interpolate the utility values (to speed up computation)
cellpop(1).flag_ext=1;                              %External input

%internal population
cellpop(2).lk=lk;
cellpop(2).th=th;
cellpop(2).v0=v0;
cellpop(2).p0=zeros(size(cellpop(2).v0));
cellpop(2).p0(1)=1;
cellpop(2).external_fr=zeros(size(tvec));
cellpop(2).u_frac=1;                             
cellpop(2).u_tau=0;
cellpop(2).u_vec=1;
cellpop(2).u_prob=1;
cellpop(2).u_pts=1;
cellpop(2).flag_ext=0;

%connection 1: external population to internal population
connect(1).source=1;                %source population
connect(1).target=2;                %target population
connect(1).flag_cond_syn=0;         %conductance-based synapses
connect(1).flag_poisson=1;          %Poisson input
connect(1).nsyn=100;                %number of input cells per target neuron (overridden by firing rate for external input)
connect(1).qdw=[5*10^-3;1;1];       %qdw(1,:)-> synaptic weights, qdw(2,:)->reversal potentials (=1 for current), qdw(3,:)->probabilities
connect(1).voltage_frac=voltage_fraction; %fraction of post-threshold voltage that gets "wrapped around" resting potential

