function maxima_val=single_syn_stsd(AP_times)
%the destiny of this m-file is making predictions about [Ca]bouton, exocytosis of transmitter, [glutamate]cleft, and AMPAR conductance(s), among other things
%close all
plot_it=1
tic
%global waveform_holder %used for collecting data from multiple trials
%waveform_holder=[]
%AP_times=[200 400] %deterministic train of APs
% AP_times=ceil(cumsum(exprnd(100,1,3))) %stochastic train of APs
trial_duration=1000; %a timestep is roughly a millisecond
calcium_conc=.005; %in presynaptic cytoplasm (starting with above zero makes spontaneous release possible)
calcium_persistence=0.97;%the factor by which current value is multiplied each time step (larger values, slower decay)
RRP_size_max=4; %in vesicles
RRP_size=RRP_size_max;
RP_to_RRP_rate=.003; %in vesicles per time step
RP_size=100; %in vesicles
PE_size=0; %in vesicles (the post-exocytotic pool)
PE_to_RP_rate=.005; %in vesicles per time step
PE_to_RRP_rate=0; %in vesicles per time step %RP to RRP and PE to RRP sum to the RRP refilling rate
glu_per_vesicle=5; %in effective pA(?)
glu_cleft=.005; %in effective pA(?)
glutamate_cleft_persistence=.8;
exocytosis_unlikelihood=10; %this is multiplied by a random number -- if the result is greater than [Ca]bouton, release is impossible
number_of_ampars=3000;
ampar_bound=zeros(1,number_of_ampars); %at the beginning, none is bound
ampar_open=ampar_bound; %therefore none is open
ampar_conductance=ampar_bound; %therefore there is no conductance
initial_ampar_conductance=.1; %in pA/time step
ampar_open_threshold=.7; %used for determining whether a bound, closed ampar moves to the bound, open state
ampar_unbind_threshold=.3; %used for determining whether a bound, closed ampar moves to the unbound, closed state
ampar_close_threshold=.1; %used for determining whether a bound,open ampar moves to the bound, closed state
ampar_binding_unlikelihood=20; %larger values make it less likely that an unbound receptor will bind glutamate at a given [glu]cleft
ampar_conductance_persistence=.9;
synaptic_conductance=0;
calcium_hx=[];
RRP_size_hx=[];
RP_to_RRP_rate_hx=[];
RP_size_hx=[];
PE_size_hx=[];
PE_to_RP_rate_hx=[];
PE_to_RRP_rate_hx=[];
glu_cleft_hx=[];
synaptic_conductance_hx=[];
exocytosis_permitted=1;
for i=1:trial_duration
%APs drive [calcium] in the bouton (aka the release probability) to 1
if find(i==AP_times)
calcium_conc=calcium_conc+1 %summation across APs can lead to facilitation
else calcium_conc=calcium_conc*calcium_persistence;
end
if calcium_conc<.1, exocytosis_permitted=1; end %this serves to make release, if prevented immediately after release, possible again, once the [Ca] falls low enough (i.e. if ample time has passed)
%stochastic exocytosis based on the calcium concentration, as long as some other criteria are met
if (calcium_conc-(exocytosis_unlikelihood*rand))>0 & exocytosis_permitted & RRP_size>=1 %a release event -- should release affect the probability of release? (uniquantal rule) --> c.f. if calcium_concrand %the glu_per_vesicle is used as an imperfect normalizer, a proxy for max possible [glu]cleft
ampar_bound(j)=1; %binding glutamate
end
elseif ampar_bound(j)==1&ar_open(j)==0
randi=rand;
if randi>ampar_open_threshold %moves to the open state
ampar_open(j)=1;
elseif randi