function a=genActivities(NeuronParms,Rvalues,Type)
%% Generate activities for a single neuron at Rvalues specified as distance
%% along the preferred directions of each neuron.
%%
%% NeuronParms are created by genNeuronVecRep()
%%
%% Type 1 Neurons: Modified Rectified Linear
%% Neurons=[Rthres,Gain,maxFR,Sat,zeros(N,1),EUV];
%% Type 2 Neurons: LIF
%% Neurons=[Rthres,Gain,maxRF,tRC,Jbias,EUV];
%%
%% Feb. 25, 2001 Consolidation
%% August 14, 2000
%% Modified Dec. 1, 2000
%% Modified Jan. 17, 2001 (Changed TypeParms to Type)
%% Copyright (C) by Charles. H. Anderson (All Rights Reserved)
%% Dept. Anatomy and Neurobiology
%% Washington Univ. School of Medicine
%% St. Louis, MO
%% cha@shifter.wustl.edu
if((Type<1)|(Type>2))
error('Type must be 1(Rectified Linear) or 2(LIF)\n');
end
[N,M] = size(Rvalues);
if(Type==1) % Rectified Linear
% Rthres = NeuronParms(:,1)*ones(1,M);
Gain = NeuronParms(:,2)*ones(1,M);
Jbias = NeuronParms(:,5)*ones(1,M);
elseif(Type==2) % Leaky integrate and fire
% Rthres = NeuronParms(:,1)*ones(1,M);
Gain = NeuronParms(:,2)*ones(1,M);
maxFR = NeuronParms(:,3)*ones(1,M);
tRC = NeuronParms(:,4)*ones(1,M);
Jbias = NeuronParms(:,5)*ones(1,M);
epsilon = tRC.*maxFR;
end
% index = find(Rvalues>Rthres);
J = Gain.*Rvalues+Jbias;
a = zeros(N,M);
if(Type==1) % Rectified linear;
a = (J>0).*J;
elseif(Type==2)
index = find(J>1);
a(index) = maxFR(index)./(1-epsilon(index).*log(1-1./J(index)));
end