function a=genActivities(NeuronParms,Rvalues,Type)

%genActivities generates activities for a collection of neurons
%
% 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];
%

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   
	Gain   = NeuronParms(:,2)*ones(1,M);
    Jbias  = NeuronParms(:,5)*ones(1,M);
elseif(Type==2) % Leaky integrate and fire
   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
   
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
