0001 function ThetaNeuron = theta_neuron(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 if mod(nargin,2)~=0
0051 disp('Error in theta neuron constructor: There must be an even number of inputs');
0052 ThetaNeuron=-1;
0053 return;
0054 end
0055
0056 NullFlag=0;
0057 NeuronSize=[1 1];
0058 ProtoNeuron.Alpha=1;
0059 ProtoNeuron.Io=-0.005;
0060 ProtoNeuron.InitialPhaseMethod={};
0061 NeuronFields={'Alpha','Io','InitialPhaseMethod'};
0062
0063
0064
0065 SizeFlag=0;
0066 for j=1:(nargin/2)
0067 switch varargin{2*j-1}
0068 case 'Size'
0069 if SizeFlag
0070 disp('Warning: Size attempted to be assigned more than once; ignoring...');
0071 continue;
0072 end
0073 if iscell(varargin{2*j}) && strcmp(varargin{2*j}{1},'Null')
0074 NullFlag=1;
0075 NeuronSizeTemp=varargin{2*j}{2};
0076 else
0077 NeuronSizeTemp=varargin{2*j};
0078 end
0079 if ~isnumeric(NeuronSizeTemp)
0080 disp('Error in theta neuron constructor: Invalid Size');
0081 ThetaNeuron=-1;
0082 return;
0083 end
0084 if numel(NeuronSizeTemp)==1
0085 NeuronSize(1)=NeuronSizeTemp;
0086 else
0087 NeuronSize=NeuronSizeTemp;
0088 end
0089 SizeFlag=1;
0090 case NeuronFields
0091 ProtoNeuron.(varargin{2*j-1})=varargin{2*j};
0092 otherwise
0093 disp(['Warning: Value ', varargin{2*j-1}, ' is unknown; ignoring...']);
0094 end
0095 end
0096
0097
0098 if ~isnumeric(ProtoNeuron.Alpha)
0099 disp('Error in theta neuron constructor: Invalid Alpha');
0100 ThetaNeuron=-1;
0101 return;
0102 end
0103 if ~isnumeric(ProtoNeuron.Io)
0104 disp('Error in theta neuron constructor: Invalid Io');
0105 ThetaNeuron=-1;
0106 return;
0107 end
0108 if ~iscell(ProtoNeuron.InitialPhaseMethod)
0109 disp('Error in theta neuron constructor: Invalid Initial Phase Method');
0110 ThetaNeuron=-1;
0111 return;
0112 end
0113
0114
0115 if isempty(ProtoNeuron.InitialPhaseMethod)
0116 if ProtoNeuron.Io<0
0117 ProtoNeuron.InitialPhaseMethod = {'PositiveFixedPointDelta', 0.0001};
0118 else
0119 ProtoNeuron.InitialPhaseMethod = {'GivenValue', 0};
0120 end
0121 end
0122 ProtoNeuron.Beta=sqrt(abs(ProtoNeuron.Alpha*ProtoNeuron.Io));
0123
0124 if ProtoNeuron.Io<0
0125 ProtoNeuron.PositiveFixedPoint=real(acos((1+ProtoNeuron.Alpha*ProtoNeuron.Io)/(1-ProtoNeuron.Alpha*ProtoNeuron.Io)));
0126 switch ProtoNeuron.InitialPhaseMethod{1}
0127 case 'PositiveFixedPoint'
0128 ProtoNeuron.Phase=ProtoNeuron.PositiveFixedPoint;
0129 case 'NegativeFixedPoint'
0130 ProtoNeuron.Phase=-ProtoNeuron.PositiveFixedPoint;
0131 case 'PositiveFixedPointDelta'
0132 ProtoNeuron.Phase=ProtoNeuron.PositiveFixedPoint+ProtoNeuron.InitialPhaseMethod{2};
0133 case 'NegativeFixedPointDelta'
0134 ProtoNeuron.Phase=-ProtoNeuron.PositiveFixedPoint+ProtoNeuron.InitialPhaseMethod{2};
0135 case 'GivenValue'
0136 ProtoNeuron.Phase=ProtoNeuron.InitialPhaseMethod{2};
0137 otherwise
0138 disp('Error in theta neuron constructor: Invalid Initial Phase Method');
0139 end
0140 else
0141 ProtoNeuron.PositiveFixedPoint=0;
0142 try
0143 ProtoNeuron.Phase=ProtoNeuron.InitialPhaseMethod{2};
0144 catch
0145 ProtoNeuron.Phase=0;
0146 end
0147 end
0148
0149
0150 if NullFlag
0151 ProtoNeuron.Alpha=[];
0152 ProtoNeuron.Io=[];
0153 ProtoNeuron.InitialPhaseMethod={'' ''};
0154 ProtoNeuron.Beta=[];
0155 ProtoNeuron.PositiveFixedPoint=[];
0156 ProtoNeuron.Phase=[];
0157 end
0158
0159
0160 for j=1:NeuronSize(1)
0161 for k=1:NeuronSize(2)
0162 ThetaNeuron(j,k)=ProtoNeuron;
0163 end
0164 end
0165 ThetaNeuron = class(ThetaNeuron,'theta_neuron');