Revision 15:35af36fe0a35 MAP/MAP1_14.m

View differences:

MAP/MAP1_14.m
83 83
segmentTime=dt*(1:segmentLength); % used in debugging plots
84 84

  
85 85
% all spiking activity is computed using longer epochs
86
ANspeedUpFactor=5;  % 5 times longer
86
ANspeedUpFactor=AN_IHCsynapseParams.ANspeedUpFactor;  % e.g.5 times
87 87

  
88 88
% inputSignal must be  row vector
89 89
[r c]=size(inputSignal);
......
443 443
CNcurrentPerSpike=MacGregorMultiParams.currentPerSpike;
444 444
CNspikeToCurrentTau=1/(2*pi*CNdendriteLPfreq);
445 445
t=ANdt:ANdt:5*CNspikeToCurrentTau;
446
CNalphaFunction=...
447
    (CNcurrentPerSpike/CNspikeToCurrentTau)*t.*exp(-t/CNspikeToCurrentTau);
446
CNalphaFunction= (1 / ...
447
    CNspikeToCurrentTau)*t.*exp(-t /CNspikeToCurrentTau);
448
CNalphaFunction=CNalphaFunction*CNcurrentPerSpike;
449

  
448 450
% figure(98), plot(t,CNalphaFunction)
449 451
% working memory for implementing convolution
452

  
450 453
CNcurrentTemp=...
451 454
    zeros(nCNneurons,reducedSegmentLength+length(CNalphaFunction)-1);
452 455
% trailing alphas are parts of humps carried forward to the next segment
......
877 880
                for idx=1:nCNneuronsPerChannel
878 881
                    % determine candidate fibers for this unit
879 882
                    fibersUsed=CNinputfiberLists(synapseNo,:);
880
                    % ANpsth has a bin width of dt
883
                    % ANpsth has a bin width of ANdt
881 884
                    %  (just a simple sum across fibers)
882 885
                    AN_PSTH(synapseNo,:) = ...
883 886
                        sum(ANspikes(fibersUsed,:), 1);
......
892 895
                CNcurrentTemp(unitNo,:)= ...
893 896
                    conv(AN_PSTH(unitNo,:),CNalphaFunction);
894 897
            end
898
%             disp(['sum(AN_PSTH)= ' num2str(sum(AN_PSTH(1,:)))])
895 899
            % add post-synaptic current  left over from previous segment
896 900
            CNcurrentTemp(:,1:alphaCols)=...
897 901
                CNcurrentTemp(:,1:alphaCols)+ CNtrailingAlphas;
898 902

  
899 903
            % take post-synaptic current for this segment
900 904
            CNcurrentInput= CNcurrentTemp(:, 1:reducedSegmentLength);
905
%                 disp(['mean(CNcurrentInput)= ' num2str(mean(CNcurrentInput(1,:)))])
901 906

  
902 907
            % trailingalphas are the ends of the alpha functions that
903 908
            % spill over into the next segment
......
907 912
            if CN_c>0
908 913
                % variable threshold condition (slow)
909 914
                for t=1:reducedSegmentLength
910
                    CNtimeSinceLastSpike=CNtimeSinceLastSpike-dts;
915
                    CNtimeSinceLastSpike=CNtimeSinceLastSpike-ANdt;
911 916
                    s=CN_E>CN_Th & CNtimeSinceLastSpike<0 ;
912 917
                    CNtimeSinceLastSpike(s)=0.0005;         % 0.5 ms for sodium spike
913 918
                    dE =(-CN_E/CN_tauM + ...
914
                        CNcurrentInput(:,t)/CN_cap+(CN_Gk/CN_cap).*(CN_Ek-CN_E))*dt;
915
                    dGk=-CN_Gk*dt./tauGk + CN_b*s;
916
                    dTh=-(CN_Th-CN_Th0)*dt/CN_tauTh + CN_c*s;
919
                        CNcurrentInput(:,t)/CN_cap+(...
920
                        CN_Gk/CN_cap).*(CN_Ek-CN_E))*ANdt;
921
                    dGk=-CN_Gk*ANdt./tauGk + CN_b*s;
922
                    dTh=-(CN_Th-CN_Th0)*ANdt/CN_tauTh + CN_c*s;
917 923
                    CN_E=CN_E+dE;
918 924
                    CN_Gk=CN_Gk+dGk;
919 925
                    CN_Th=CN_Th+dTh;
......
921 927
                end
922 928
            else
923 929
                % static threshold (faster)
930
                E=zeros(1,reducedSegmentLength);
931
                Gk=zeros(1,reducedSegmentLength);
932
                ss=zeros(1,reducedSegmentLength);
924 933
                for t=1:reducedSegmentLength
925
                    CNtimeSinceLastSpike=CNtimeSinceLastSpike-dt;
926
                    s=CN_E>CN_Th0 & CNtimeSinceLastSpike<0 ;  % =1 if both conditions met
927
                    CNtimeSinceLastSpike(s)=0.0005;          % 0.5 ms for sodium spike
934
                    % time of previous spike moves back in time
935
                    CNtimeSinceLastSpike=CNtimeSinceLastSpike-ANdt;
936
                    % action potential if E>threshold
937
                    %  allow time for s to reset between events
938
                    s=CN_E>CN_Th0 & CNtimeSinceLastSpike<0 ;  
939
                    ss(t)=s(1);
940
                    CNtimeSinceLastSpike(s)=0.0005; % 0.5 ms for sodium spike
928 941
                    dE = (-CN_E/CN_tauM + ...
929
                        CNcurrentInput(:,t)/CN_cap+(CN_Gk/CN_cap).*(CN_Ek-CN_E))*dt;
930
                    dGk=-CN_Gk*dt./tauGk +CN_b*s;
942
                        CNcurrentInput(:,t)/CN_cap +...
943
                        (CN_Gk/CN_cap).*(CN_Ek-CN_E))*ANdt;
944
                    dGk=-CN_Gk*ANdt./tauGk +CN_b*s;
931 945
                    CN_E=CN_E+dE;
932 946
                    CN_Gk=CN_Gk+dGk;
947
                    E(t)=CN_E(1);
948
                    Gk(t)=CN_Gk(1);
933 949
                    % add spike to CN_E and add resting potential (-60 mV)
934
                    CNmembranePotential(:,t)=CN_E+s.*(CN_Eb-CN_E)+CN_Er;
950
                    CNmembranePotential(:,t)=CN_E +s.*(CN_Eb-CN_E)+CN_Er;
935 951
                end
936 952
            end
953
%             disp(['CN_E= ' num2str(sum(CN_E(1,:)))])
954
%             disp(['CN_Gk= ' num2str(sum(CN_Gk(1,:)))])
955
%             disp(['CNmembranePotential= ' num2str(sum(CNmembranePotential(1,:)))])
956
%             plot(CNmembranePotential(1,:))
957

  
937 958

  
938 959
            % extract spikes.  A spike is a substantial upswing in voltage
939
            CN_spikes=CNmembranePotential> -0.01;
960
            CN_spikes=CNmembranePotential> -0.02;
961
%             disp(['CNspikesbefore= ' num2str(sum(sum(CN_spikes)))])
940 962

  
941 963
            % now remove any spike that is immediately followed by a spike
942 964
            % NB 'find' works on columns (whence the transposing)
965
            % for each spike put a zero in the next epoch
943 966
            CN_spikes=CN_spikes';
944 967
            idx=find(CN_spikes);
945 968
            idx=idx(1:end-1);
946 969
            CN_spikes(idx+1)=0;
947 970
            CN_spikes=CN_spikes';
971
%             disp(['CNspikes= ' num2str(sum(sum(CN_spikes)))])
948 972

  
949 973
            % segment debugging
950 974
            % plotInstructions.figureNo=98;
......
988 1012
                    for t=1:reducedSegmentLength
989 1013
                        s=IC_E>IC_Th0;
990 1014
                        dE = (-IC_E/IC_tauM + inputCurrent(:,t)/IC_cap +...
991
                            (IC_Gk/IC_cap).*(IC_Ek-IC_E))*dt;
992
                        dGk=-IC_Gk*dt/IC_tauGk +IC_b*s;
1015
                            (IC_Gk/IC_cap).*(IC_Ek-IC_E))*ANdt;
1016
                        dGk=-IC_Gk*ANdt/IC_tauGk +IC_b*s;
993 1017
                        IC_E=IC_E+dE;
994 1018
                        IC_Gk=IC_Gk+dGk;
995 1019
                        ICmembranePotential(:,t)=IC_E+s.*(IC_Eb-IC_E)+IC_Er;
......
999 1023
                    for t=1:reducedSegmentLength
1000 1024
                        dE = (-IC_E/IC_tauM + ...
1001 1025
                            inputCurrent(:,t)/IC_cap + (IC_Gk/IC_cap)...
1002
                            .*(IC_Ek-IC_E))*dt;
1026
                            .*(IC_Ek-IC_E))*ANdt;
1003 1027
                        IC_E=IC_E+dE;
1004 1028
                        s=IC_E>IC_Th;
1005 1029
                        ICmembranePotential(:,t)=IC_E+s.*(IC_Eb-IC_E)+IC_Er;
1006
                        dGk=-IC_Gk*dt/IC_tauGk +IC_b*s;
1030
                        dGk=-IC_Gk*ANdt/IC_tauGk +IC_b*s;
1007 1031
                        IC_Gk=IC_Gk+dGk;
1008 1032

  
1009 1033
                        % After a spike, the threshold is raised
1010 1034
                        % otherwise it settles to its baseline
1011
                        dTh=-(IC_Th-Th0)*dt/IC_tauTh +s*IC_c;
1035
                        dTh=-(IC_Th-Th0)*ANdt/IC_tauTh +s*IC_c;
1012 1036
                        IC_Th=IC_Th+dTh;
1013 1037
                    end
1014 1038
                end
......
1027 1051
                lastCell=nCellsPerTau;
1028 1052
                for tauCount=1:nANfiberTypes
1029 1053
                    % separate rates according to fiber types
1054
                    % currently only the last segment is saved
1030 1055
                    ICfiberTypeRates(tauCount, ...
1031 1056
                        reducedSegmentPTR:shorterSegmentEndPTR)=...
1032 1057
                        sum(ICspikes(firstCell:lastCell, :))...
......
1034 1059
                    firstCell=firstCell+nCellsPerTau;
1035 1060
                    lastCell=lastCell+nCellsPerTau;
1036 1061
                end
1037
                ICoutput(:, reducedSegmentPTR:shorterSegmentEndPTR)=ICspikes;
1038

  
1062
                
1063
                ICoutput(:,reducedSegmentPTR:shorterSegmentEndPTR)=ICspikes;
1064
                
1065
                % store membrane output on original dt scale
1039 1066
                if nBFs==1  % single channel
1040 1067
                    x= repmat(ICmembranePotential(1,:), ANspeedUpFactor,1);
1041 1068
                    x= reshape(x,1,segmentLength);
1042 1069
                    if nANfiberTypes>1  % save HSR and LSR
1043
                        y= repmat(ICmembranePotential(end,:), ANspeedUpFactor,1);
1070
                        y=repmat(ICmembranePotential(end,:),...
1071
                            ANspeedUpFactor,1);
1044 1072
                        y= reshape(y,1,segmentLength);
1045 1073
                        x=[x; y];
1046 1074
                    end

Also available in: Unified diff