layer.hpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. #ifndef _HPP_LAYER
  2. #define _HPP_LAYER
  3. #include <vector>
  4. #include "simelement.hpp"
  5. #include "libcsim.hpp"
  6. enum csimNeuronType {
  7. csimNType_Izhikevich5,
  8. csimNType_Izhikevich7,
  9. csimNType_Izhikevich8,
  10. csimNType_Izhikevich8_integrator,
  11. csimNType_Izhikevich9,
  12. csimNType_MMN02,
  13. csimNType_DecoLif,
  14. // add new layer types above here
  15. csimNumberNTypes
  16. };
  17. class SpikeTrain;
  18. /*! \brief Klasse layer
  19. * von layer stammen alle layer-Klassen ab
  20. *
  21. * Detailed description starts here.
  22. */
  23. class layer : public SimElement
  24. {
  25. protected:
  26. float *v, *u;
  27. std::string SpikeFileName, FileType, MemPotFileName;
  28. bool Binary;
  29. float RandomSpikeFrequency;
  30. int RestProb, nris;
  31. float NumRandomInputSpikes;
  32. float RandomInputStrength;
  33. float NoiseSigma;
  34. double PoissonLambda;
  35. float NoiseAmplitude;
  36. float BalancedInhibition;
  37. void ThrowTooManySpikes(int time);
  38. bool TooManySpikes;
  39. private:
  40. SpikeTrain* mSpikeTrain;
  41. public:
  42. T_NNeurons N;
  43. T_NNeurons Nx, Ny; // numbers of raws and collumns for 2d layer
  44. T_NNeurons NNeurons() {
  45. return N;
  46. };
  47. T_NNeurons NeuronsNx() {
  48. return Nx;
  49. };
  50. T_NNeurons NeuronsNy() {
  51. return Ny;
  52. };
  53. vector2d *Pos;
  54. vector<vector2d> mPositions;
  55. bool NormPos;
  56. int N_firings; // the number of fired neurons
  57. int last_N_firings;
  58. int **firings;
  59. int N_firings_max;
  60. int Dmax;
  61. float *Input; // input current
  62. layer (int n=1000);
  63. virtual ~layer();
  64. virtual void hallo();
  65. virtual int proceede(int);
  66. virtual int prepare(int =0);
  67. virtual int reset(int);
  68. virtual int SetupPositions();
  69. virtual int SetupPositions(int _nx, int ny, bool Normalize=false);
  70. virtual int SetupPositionsShift(int _nx, int ny, float xshift,float yshift, bool Normalize=false);
  71. virtual int SetupPositionsLinDiscrete(int NeuronsPerPatch);
  72. const vector<vector2d>& getPositions();
  73. bool isPositionNormalized() {return NormPos;}
  74. virtual void SetName(const char*);
  75. void SetSpikeFileName(char*);
  76. void SetRandomInputStrength(float);
  77. void SetRandomSpikeFrequency(float);
  78. void SetNoiseSigma(float);
  79. void SetBalancedInhibition(float);
  80. void SetNoiseAmplitude(float);
  81. int TuneNoiseAmplitude(float DesiredFrequency);
  82. int TuneBalancedInhibition(float DesiredFrequency);
  83. virtual float* GetInputPointer(csimInputChannel);
  84. virtual float* GetPspPointer(csimInputChannel);
  85. virtual int StartBinRec(int n, int StartNumber=0);
  86. virtual long calcMemoryConsumption();
  87. float GetDt();
  88. virtual int SaveSimInfo();
  89. virtual int WriteSimInfo(fstream &fw);
  90. virtual int WriteSimInfo(fstream &fw, const string &ChildInfo);
  91. virtual SpikeTrain* GetSpikeTrain();
  92. };
  93. struct LevyShuntingParas {
  94. LevyShuntingParas(float _k0, float _k1, float _k2, float _kffi, float _kfbi)
  95. : K0(_k0), K1(_k1), K2(_k2), Kffi(_kffi), Kfbi(_kfbi)
  96. {}
  97. float K0,K1, K2, Kffi, Kfbi;
  98. } ;
  99. static const LevyShuntingParas DefaultShunt (1,4,4,1,1);
  100. class liflayer : public layer
  101. {
  102. protected:
  103. float TauM; // membrane time constant
  104. float TauMfac;
  105. float Threshold;
  106. float K0,K1, K2, Kffi, Kfbi; // inhibition parameters
  107. float InputSaturation;
  108. float TauS; // synaptic time constant
  109. float TauSfac;
  110. int *LastSpike;
  111. float* mquer; // number of spikes in last ms
  112. float* squer;
  113. float RunAvgFac;
  114. float Iinh;
  115. int InhibitionDelay; // in timesteps =(ms/dt)
  116. int RefractoryPeriod;
  117. public:
  118. liflayer(
  119. int n,
  120. float tau=20, float thresh=0.0033, float k0=1,
  121. float k1=4, float k2=4, float kffi=1, float kfbi=1,
  122. float taus=2, float _InputSat=1.0, float _NoiseSigma=0);
  123. ~liflayer();
  124. virtual int proceede(int);
  125. virtual int prepare(int =0);
  126. virtual float* GetInputPointer(csimInputChannel num=csimInputChannel_AMPA);
  127. int InitInhibitionPot(float _mquer, float _squer);
  128. int SetKfbi(float);
  129. float *Input1;
  130. };
  131. // leaky integrate and fire neuron with theta rhythmic deactivation of recurrent input
  132. class thetaliflayer: public liflayer
  133. {
  134. protected:
  135. int ThetaPeriod; // in ms
  136. int ThetaPhase;
  137. bool ThetaOn;
  138. public:
  139. thetaliflayer(
  140. int n,
  141. float tau=20, float thresh=0.0033, float k0=1,
  142. float k1=4, float k2=4, float kffi=1, float kfbi=1,
  143. float taus=2, float _InputSat=1.0, float _NoiseSigma=0,
  144. int _ThetaPeriod=100);
  145. ~thetaliflayer();
  146. virtual int proceede(int);
  147. virtual int prepare(int =0);
  148. void SetThetaOn(bool status);
  149. };
  150. // leaky integrate and fire neuron with adaptive synapses to inhibitory interneuron
  151. class lif2layer: public liflayer
  152. {
  153. private:
  154. float *Dinh;
  155. float DesiredActivity;
  156. float *InhibitoryActivity;
  157. float PyrToInhLearningRate;
  158. bool learnpti;
  159. float TauInhLearn;
  160. float InhLearnFac;
  161. public:
  162. lif2layer(int, float =20, float =0.0033, float =1, float =4, float=4, float=1, float=1, float =2, float =0.012, float =0.1);
  163. ~lif2layer();
  164. virtual int proceede(int);
  165. virtual int prepare(int =0);
  166. int SetLearnPti(bool);
  167. };
  168. struct IzhParas {
  169. IzhParas(float a, float b, float c, float d, float e, float f, float sigma=0): A(a), B(b), C(c), D(d), E(e), F(f) {}
  170. float A, B, C, D, E, F, sigma;
  171. int print();
  172. };
  173. static const IzhParas IzhParaRegularSpiking (0.02, 0.2 , -65, 8. , 140, 5. , 0.0);
  174. static const IzhParas IzhParaIntrinsicallyBursting(0.02, 0.2 , -55, 4. , 140, 5. , 0.0);
  175. static const IzhParas IzhParaChattering (0.02, 0.2 , -50, 2. , 140, 5. , 0.0);
  176. static const IzhParas IzhParaFastSpiking (0.1 , 0.2 , -65, 2. , 140, 5. , 0.0);
  177. static const IzhParas IzhParaLowThreshold (0.02, 0.25, -65, 2. , 140, 5. , 0.0);
  178. static const IzhParas IzhParaThalamoCortical (0.02, 0.25, -65, 0.05, 140, 5. , 0.0);
  179. static const IzhParas IzhParaResonator (0.1 , 0.26, -65, 2. , 140, 5. , 0.0);
  180. static const IzhParas IzhParaIntegrator (0.02, -0.1, -55, 6. , 108, 4.1, 0.0);
  181. static const IzhParas IzhParaIntegrator2 (0.02, -0.1, -55, 6. , 110, 4.1, 0.0);
  182. static const IzhParas IzhParaClass2 (0.2 , 0.26, -65, 0. , 139, 5. , 0.0);
  183. static const IzhParas IzhLowDIntegrator (0.02, -0.1, -55, 2. , 108, 4.1, 0.0);
  184. enum IzhType {Integrator, FastSpiking};
  185. class izhlayer : public layer
  186. {
  187. protected:
  188. float A, B, C, D, E, F; //first version: uniform dynamics, same parameters for every neuron
  189. // of the layer; later a,b,c... have to be pointers
  190. float TauS; // synaptic time constant
  191. float TauSfac;
  192. float TauInh, TauInhFac; // inhibitory synaptic time constant
  193. float EquilibriumPot;
  194. int InitEquilibriumPotentials();
  195. float *ExSynPot; // excitatory synaptic potential
  196. // float *InhInput; // Inhibitory Input
  197. float *InhSynPot; // ShuntingInhibitionPotential
  198. float InputSaturation;
  199. float InhInputSaturation;
  200. int Init();
  201. public:
  202. izhlayer(int n=1000, float a=0.02, float b=-0.1, float c=-55, float d=4, float e=108, float f=4.1, float _InputSat=1, float _InhInputSat=1);
  203. izhlayer(int n=1000, IzhParas _paras=IzhParaIntegrator, float _InputSat=1, float _InhInputSat=1);
  204. izhlayer(IzhType type, int n=1000, float _InputSat=30, float _InhInputSat=1);
  205. ~izhlayer();
  206. virtual int proceede(int);
  207. virtual float* GetInputPointer(csimInputChannel num=csimInputChannel_AMPA);
  208. virtual int StartBinRec(int n, int StartNumber=0);
  209. virtual int SetTauInh(float _TauInh);
  210. virtual int SetTauEx(float _TauEx);
  211. virtual int WriteSimInfo(fstream &fw);
  212. virtual int WriteSimInfo(fstream &fw, const string &ChildInfo);
  213. };
  214. // inhibitory potential is also subtracted from membrane potential v
  215. class izh2layer : public izhlayer
  216. {
  217. protected:
  218. public:
  219. izh2layer(int n=1000, float a=0.02, float b=-0.1, float c=-55, float d=4, float e=108, float f=4.1, float _InputSat=1);
  220. izh2layer(int n=1000, IzhParas _paras=IzhParaIntegrator, float _InputSat=1);
  221. ~izh2layer();
  222. virtual int proceede(int);
  223. };
  224. // conductance based inhibition, noise is addet to excitatory input
  225. class izh3layer : public izhlayer
  226. {
  227. protected:
  228. float InhReversePot;
  229. public:
  230. float *InhInput; // inhibitory input current
  231. izh3layer(int n=1000, float a=0.02, float b=-0.1, float c=-55, float d=4, float e=108, float f=4.1, float _InputSat=1, float IRPotDiff=10, float _InhInputSaturation=1);
  232. izh3layer(int n=1000, IzhParas _paras=IzhParaIntegrator, float _InputSat=1, float IRPotDiff=10, float _InhInputSaturation=1);
  233. ~izh3layer();
  234. virtual int proceede(int);
  235. virtual float* GetInputPointer(csimInputChannel InputNumber=csimInputChannel_AMPA);
  236. };
  237. // conductance based inhibition, noise is addet to excitatory input
  238. // plus linking input
  239. class izh4layer : public izh3layer
  240. {
  241. protected:
  242. float TauLink, TauLinkFac;
  243. float *LinkSynPot; // LinkingInputPotential
  244. public:
  245. izh4layer(int n=1000, IzhParas _paras=IzhParaIntegrator, float _InputSat=1, float IRPotDiff=10, float _TauLink=10);
  246. ~izh4layer();
  247. virtual int proceede(int);
  248. virtual float* GetInputPointer(csimInputChannel num=csimInputChannel_AMPA);
  249. };
  250. // my currend STANDARD IZH-Neuron
  251. // conductance based inhibition, noise is addet to excitatory input
  252. // like izh3layer, but input saturation occurs before adding synaptic
  253. // input to the membrane potential and not before adding input to
  254. // synaptic potential.
  255. class izh5layer : public izhlayer
  256. {
  257. protected:
  258. float InhReversePot;
  259. public:
  260. izh5layer(int n=1000, float a=0.02, float b=-0.1, float c=-55, float d=4, float e=108, float f=4.1, float _InputSat=200, float IRPotDiff=10, float _InhInputSaturation=4.5);
  261. izh5layer(int n=1000, IzhParas _paras=IzhParaIntegrator, float _InputSat=200, float IRPotDiff=10, float _InhInputSaturation=4.5);
  262. ~izh5layer();
  263. virtual int proceede(int);
  264. virtual float* GetInputPointer(csimInputChannel num=csimInputChannel_AMPA);
  265. };
  266. // like izh5layer,
  267. // but with additionall NMDA conductance
  268. class izh6layer : public izhlayer
  269. {
  270. protected:
  271. float InhReversePot;
  272. float *NmdaSynPot; // NMDA synaptic potential
  273. float NmdaSaturation;
  274. float TauNmda, TauNmdaFac;
  275. float NmdaAmpaRatio;
  276. public:
  277. izh6layer(int n=1000, IzhParas _paras=IzhParaIntegrator, float _InputSat=200, float IRPotDiff=10, float _InhInputSaturation=4.5, float _NmdaInputSaturation=10);
  278. ~izh6layer();
  279. virtual int proceede(int);
  280. virtual float* GetInputPointer(csimInputChannel num=csimInputChannel_AMPA);
  281. virtual void SetNmdaAmpaRatio(float ratio);
  282. virtual void SetTauNmda(float value);
  283. virtual int WriteSimInfo(fstream &fw);
  284. virtual int StartBinRec(int n, int StartNumber=0);
  285. };
  286. inline double DoubleExpCorrectionFactor(double Tau1, double Tau2)
  287. {
  288. double PeakTime = log(Tau2/Tau1)/(1/Tau1 - 1/Tau2);
  289. return 1.0/(exp(-PeakTime/Tau2)-exp(-PeakTime/Tau1));
  290. }
  291. // like izh6layer,
  292. // but with double exponential PSPs (with rise and fall time constants)
  293. class izh7layer : public izhlayer
  294. {
  295. protected:
  296. float InhReversePot;
  297. float *NmdaRisePot; // NMDA synaptic potential
  298. float *NmdaFallPot; // NMDA synaptic potential
  299. float *AmpaRisePot; // AMPA synaptic potential
  300. float *AmpaFallPot; // AMPA synaptic potential
  301. float *GabaRisePot; // GABA synaptic potential
  302. float *GabaFallPot; // GABA synaptic potential
  303. float *InhInput;
  304. float *NmdaAmpaInput;
  305. float NmdaSaturation;
  306. float TauAmpaRise, TauAmpaFall, TauAmpaRiseFac, TauAmpaFallFac;
  307. float TauGabaRise, TauGabaFall, TauGabaRiseFac, TauGabaFallFac;
  308. float TauNmdaRise, TauNmdaFall, TauNmdaRiseFac, TauNmdaFallFac;
  309. float AmpaCorr, GabaCorr, NmdaCorr;
  310. float NmdaAmpaRatio;
  311. public:
  312. izh7layer(int n=1000, IzhParas _paras=IzhParaIntegrator, float _InputSat=200, float IRPotDiff=10, float _InhInputSaturation=4.5, float _NmdaInputSaturation=10);
  313. ~izh7layer();
  314. virtual int proceede(int);
  315. virtual float* GetInputPointer(csimInputChannel num=csimInputChannel_AMPA);
  316. virtual void SetNmdaAmpaRatio(float ratio);
  317. virtual void SetTauNmda(float rise, float fall);
  318. virtual void SetTauAmpa(float rise, float fall);
  319. virtual void SetTauGaba(float rise, float fall);
  320. virtual int WriteSimInfo(fstream &fw);
  321. virtual int StartBinRec(int n, int StartNumber=0);
  322. };
  323. // like izh6layer,
  324. // but with double exponential PSPs (with rise and fall time constants)
  325. // and NO input saturation
  326. class izh8layer : public izhlayer
  327. {
  328. protected:
  329. float InhReversePot;
  330. float *NmdaRisePot; // NMDA synaptic potential
  331. float *NmdaFallPot; // NMDA synaptic potential
  332. float *AmpaRisePot; // AMPA synaptic potential
  333. float *AmpaFallPot; // AMPA synaptic potential
  334. float *AmpaPot; // AMPA synaptic potential (fall-rise)
  335. float *GabaRisePot; // GABA synaptic potential
  336. float *GabaFallPot; // GABA synaptic potential
  337. float *InhInput;
  338. float *NmdaAmpaInput;
  339. float TauAmpaRise, TauAmpaFall, TauAmpaRiseFac, TauAmpaFallFac;
  340. float TauGabaRise, TauGabaFall, TauGabaRiseFac, TauGabaFallFac;
  341. float TauNmdaRise, TauNmdaFall, TauNmdaRiseFac, TauNmdaFallFac;
  342. float AmpaCorr, GabaCorr, NmdaCorr;
  343. float NmdaAmpaRatio;
  344. public:
  345. izh8layer(int n=1000, IzhParas _paras=IzhParaIntegrator, float IRPotDiff=10);
  346. ~izh8layer();
  347. virtual int proceede(int);
  348. virtual float* GetInputPointer(csimInputChannel num=csimInputChannel_AMPA);
  349. virtual float* GetPspPointer(csimInputChannel);
  350. virtual void SetNmdaAmpaRatio(float ratio);
  351. virtual void SetTauNmda(float rise, float fall);
  352. virtual void SetTauAmpa(float rise, float fall);
  353. virtual void SetTauGaba(float rise, float fall);
  354. virtual int WriteSimInfo(fstream &fw);
  355. virtual int StartBinRec(int n, int StartNumber=0);
  356. };
  357. // like izh8layer,
  358. // but with GabaA and GabaB inhibition
  359. class izh9layer : public izhlayer
  360. {
  361. protected:
  362. float InhReversePot;
  363. float *NmdaRisePot; // NMDA synaptic potential
  364. float *NmdaFallPot; // NMDA synaptic potential
  365. float *AmpaRisePot; // AMPA synaptic potential
  366. float *AmpaFallPot; // AMPA synaptic potential
  367. float *AmpaPot; // AMPA synaptic potential (fall-rise)
  368. float *GabaARisePot; // GABA synaptic potential
  369. float *GabaAFallPot; // GABA synaptic potential
  370. float *GabaBRisePot; // GABA synaptic potential
  371. float *GabaBFallPot; // GABA synaptic potential
  372. float *InhInput;
  373. float *NmdaAmpaInput;
  374. float NmdaSaturation;
  375. float TauAmpaRise, TauAmpaFall, TauAmpaRiseFac, TauAmpaFallFac;
  376. float TauGabaARise, TauGabaAFall, TauGabaARiseFac, TauGabaAFallFac;
  377. float TauGabaBRise, TauGabaBFall, TauGabaBRiseFac, TauGabaBFallFac;
  378. float TauNmdaRise, TauNmdaFall, TauNmdaRiseFac, TauNmdaFallFac;
  379. float AmpaCorr, GabaACorr, GabaBCorr, NmdaCorr;
  380. float NmdaAmpaRatio;
  381. float GabaABRatio;
  382. float GabaBReversePot;
  383. public:
  384. izh9layer(int n=1000, IzhParas _paras=IzhParaIntegrator, float GabaARPotDiff=0, float GabaBRPotDiff=30);
  385. ~izh9layer();
  386. virtual int proceede(int);
  387. virtual float* GetInputPointer(csimInputChannel num=csimInputChannel_AMPA);
  388. virtual float* GetPspPointer(csimInputChannel);
  389. virtual void SetNmdaAmpaRatio(float ratio);
  390. virtual void SetGabaABRatio(float ratio);
  391. virtual void SetTauNmda(float rise, float fall);
  392. virtual void SetTauAmpa(float rise, float fall);
  393. virtual void SetTauGabaA(float rise, float fall);
  394. virtual void SetTauGabaB(float rise, float fall);
  395. virtual int WriteSimInfo(fstream &fw);
  396. virtual int StartBinRec(int n, int StartNumber=0);
  397. };
  398. // izhikevich neuron layer with levy like global shunting inhibition
  399. class izhshuntlayer : public izhlayer
  400. {
  401. protected:
  402. LevyShuntingParas inh; // inhibition parameters
  403. /* float TauS; // synaptic time constant */
  404. /* float TauSfac; */
  405. // int *LastSpike;
  406. float* mquer; // running average of last spikes
  407. float* squer; // input running avarage
  408. float RunAvgFac;
  409. float Iinh;
  410. int InhibitionDelay; // in timesteps =(ms/dt)
  411. float NoiseSigma;
  412. float *Input1;
  413. public:
  414. izhshuntlayer(
  415. int n=1000, IzhParas _paras=IzhParaIntegrator,
  416. LevyShuntingParas _shuntparas= DefaultShunt,
  417. float _InputSat=60.0, float _NoiseSigma=0);
  418. ~izhshuntlayer();
  419. virtual int proceede(int);
  420. virtual int prepare(int step);
  421. virtual float* GetInputPointer(csimInputChannel num=csimInputChannel_AMPA);
  422. int SetKfbi(float);
  423. };
  424. // izhkevich neuron layer with levy like global shunting inhibition
  425. // and presynaptic inhibition of recurrent excitation
  426. class PresynIzhShuntLayer: public izhshuntlayer
  427. {
  428. protected:
  429. float *PresynInhInput; // input nr 2
  430. public:
  431. PresynIzhShuntLayer(
  432. int n=1000, IzhParas _paras=IzhParaIntegrator,
  433. LevyShuntingParas _shuntparas= DefaultShunt,
  434. float _InputSat=60.0, float _NoiseSigma=0);
  435. ~PresynIzhShuntLayer();
  436. virtual float* GetInputPointer(csimInputChannel num=csimInputChannel_AMPA);
  437. virtual int proceede(int TotalTime);
  438. };
  439. class MMN01Layer: public layer
  440. {
  441. protected:
  442. float TauFeeding, FeedingFac;
  443. float TauThreshold, ThresholdFac;
  444. float RestingThreshold, ThresInc;
  445. float *inh;
  446. public:
  447. MMN01Layer(int n=1000, float _TauThres=10,
  448. float _RestingThres=1, float _ThresInc=1,
  449. float _TauFeeding=10);
  450. ~MMN01Layer();
  451. virtual int proceede(int TotalTime);
  452. virtual float* GetInputPointer(csimInputChannel);
  453. virtual int StartBinRec(int n, int StartNumber=0);
  454. };
  455. // mit Inhibitorischem Potential
  456. class MMN02Layer: public MMN01Layer
  457. {
  458. protected:
  459. float TauInhibition, InhibitionFac;
  460. public:
  461. MMN02Layer(int n=1000, float _TauThres=10,
  462. float _RestingThres=1, float _ThresInc=1,
  463. float _TauFeeding=10, float _TauInhibition=10);
  464. ~MMN02Layer();
  465. virtual int proceede(int TotalTime);
  466. virtual float* GetInputPointer(csimInputChannel);
  467. virtual int StartBinRec(int n, int StartNumber=0);
  468. };
  469. // mit Linking-Potential
  470. class MMN03Layer: public MMN02Layer
  471. {
  472. protected:
  473. float TauLinking, LinkingFac;
  474. float *Linking;
  475. public:
  476. MMN03Layer(int n=1000, float _TauThres=10,
  477. float _RestingThres=1, float _ThresInc=1,
  478. float _TauFeeding=2.4, float _TauInhibition=7, float _TauLinking=10);
  479. ~MMN03Layer();
  480. virtual int proceede(int TotalTime);
  481. virtual float* GetInputPointer(csimInputChannel);
  482. virtual int StartBinRec(int n, int StartNumber=0);
  483. virtual int reset(int t);
  484. virtual int WriteSimInfo(fstream &fw);
  485. };
  486. class MMN04Layer: public MMN03Layer
  487. {
  488. protected:
  489. float TauEnduFeeding, EnduFeedingFac;
  490. float TauEnduLinking, EnduLinkingFac;
  491. float *endu;
  492. float *enduL;
  493. float *v_Self;
  494. public:
  495. MMN04Layer(int n=1000, float _TauThres=10,
  496. float _RestingThres=1, float _ThresInc=1,
  497. float _TauFeeding=2.4, float _TauInhibition=7, float _TauLinking=2.4, float _TauEnduFeeding=100, float _TauEnduLinking=100);
  498. ~MMN04Layer();
  499. virtual int proceede(int TotalTime);
  500. virtual float* GetInputPointer(csimInputChannel);
  501. virtual int StartBinRec(int n, int StartNumber=0);
  502. virtual int reset(int t);
  503. virtual int WriteSimInfo(fstream &fw);
  504. };
  505. class MMN05Layer: public MMN03Layer
  506. {
  507. protected:
  508. float TauEnduFeeding, EnduFeedingFac;
  509. float TauEnduLinking, EnduLinkingFac;
  510. float *endu;
  511. float *enduL;
  512. float *v_Self;
  513. public:
  514. MMN05Layer(int n=1000, float _TauThres=10,
  515. float _RestingThres=1, float _ThresInc=1,
  516. float _TauFeeding=2.4, float _TauInhibition=7, float _TauLinking=2.4, float _TauEnduFeeding=100, float _TauEnduLinking=100);
  517. ~MMN05Layer();
  518. virtual int proceede(int TotalTime);
  519. virtual float* GetInputPointer(csimInputChannel);
  520. virtual int StartBinRec(int n, int StartNumber=0);
  521. virtual int reset(int t);
  522. virtual int WriteSimInfo(fstream &fw);
  523. };
  524. /*! \brief Klasse AmpaNmdaGabaChannels
  525. * kuemmert sich um alle Arrays fuer NMDA, AMPA, GABAa und GABAb-Synapsen
  526. *
  527. * Detailed description starts here.
  528. */
  529. class AmpaNmdaGabaChannels
  530. {
  531. private:
  532. float DeltaT;
  533. SimLoop* MainSimLoop;
  534. int NNeurons;
  535. protected:
  536. float *NmdaRisePot; // NMDA synaptic potential
  537. float *NmdaFallPot; // NMDA synaptic potential
  538. float *AmpaRisePot; // AMPA synaptic potential
  539. float *AmpaFallPot; // AMPA synaptic potential
  540. float *AmpaPot; // AMPA synaptic potential (fall-rise)
  541. float *GabaARisePot; // GABAa synaptic potential
  542. float *GabaAFallPot; // GABAa synaptic potential
  543. float *GabaBRisePot; // GABAb synaptic potential
  544. float *GabaBFallPot; // GABAb synaptic potential
  545. float *InhInput;
  546. float *NmdaAmpaInput;
  547. float NmdaSaturation;
  548. float TauAmpaRise, TauAmpaFall, TauAmpaRiseFac, TauAmpaFallFac;
  549. float TauGabaARise, TauGabaAFall, TauGabaARiseFac, TauGabaAFallFac;
  550. float TauGabaBRise, TauGabaBFall, TauGabaBRiseFac, TauGabaBFallFac;
  551. float TauNmdaRise, TauNmdaFall, TauNmdaRiseFac, TauNmdaFallFac;
  552. float AmpaCorr, GabaACorr, GabaBCorr, NmdaCorr;
  553. float NmdaAmpaRatio;
  554. float NmdaAmpaEPSPRatio;
  555. float GabaABRatio;
  556. float NaReversePot;
  557. float GabaAReversePot;
  558. float GabaBReversePot;
  559. public:
  560. AmpaNmdaGabaChannels(int N,
  561. float TauAmpaRise=0.5,
  562. float TauAmpaFall=2.4,
  563. float TauNmdaRise=5.5,
  564. float TauNmdaFall=100,
  565. float TauGabaARise=1.0,
  566. float TauGabaAFall=7.0,
  567. float TauGabaBRise=13.5,
  568. float TauGabaBFall=140,
  569. float GabaABRatio=0.0,
  570. float NmdaAmpaRatio=0.0);
  571. ~AmpaNmdaGabaChannels();
  572. virtual void SetTauNmda(float rise, float fall);
  573. virtual void SetTauAmpa(float rise, float fall);
  574. virtual void SetTauGabaA(float rise, float fall);
  575. virtual void SetTauGabaB(float rise, float fall);
  576. virtual void SetNmdaAmpaRatio(float ratio);
  577. long calcMemConsumption();
  578. void WriteSimInfo(stringstream &sstr);
  579. virtual void reset();
  580. };
  581. struct DecoParas {
  582. DecoParas(float a, float b, float c, float d, float e, float f, float g):
  583. RestingPot(a),
  584. ResetPot(b),
  585. Threshold(c),
  586. CMembrane(d),
  587. GLeak(e),
  588. AbsoluteRefractoryPeriod(f),
  589. SpikePot (g) {}
  590. float RestingPot, ResetPot, Threshold, CMembrane, GLeak, AbsoluteRefractoryPeriod, SpikePot;
  591. int print();
  592. };
  593. static const DecoParas DecoParaExcitatory (-70,-55,-50,0.5,25,1,-40);
  594. static const DecoParas DecoParaInhibitory (-70,-55,-50,0.2,20,1,-40);
  595. /*! \brief Klasse DecoLifLayer
  596. * Implementation eines leaky integrate-and-fire neurons nach Deco und rolls 2005
  597. *
  598. * inspired by Deco and Rolls 2005,
  599. * "Neurodynamics of biased competition and cooperation for attention:
  600. * A model with spiking neurons., Journal of Neurophysiology, 94:295-331
  601. */
  602. //
  603. class DecoLifLayer: public layer, public AmpaNmdaGabaChannels
  604. {
  605. protected:
  606. float RestingPot; // etwa -60 bis -70 mV
  607. float ResetPot; // ==RestingPot
  608. float Threshold; // 40-50 mV
  609. float TauMembrane; // Membran-Zeitkonstante, meist 20 ms
  610. float CMembrane; // Membran-Kapazitaet, nach Deco/Rolls 2005: 0.5nF bzw. 0.2 nF fuer ex/inh Neuronen
  611. float CMembraneFac; //==dt/CMembrane;
  612. float GLeak; // leak conductance, Deco/Rolls 2005: 25nS/20nS for ex/inh neurons
  613. int* Refractory;
  614. float AbsoluteRefractoryPeriod;
  615. int arf;
  616. float SpikePot;
  617. int t;
  618. public:
  619. DecoLifLayer(int n, DecoParas Paras=DecoParaExcitatory);
  620. ~DecoLifLayer();
  621. virtual float* GetInputPointer(csimInputChannel num=csimInputChannel_AMPA);
  622. virtual float* GetPspPointer(csimInputChannel);
  623. virtual int proceede(int);
  624. virtual int WriteSimInfo(fstream &fw);
  625. virtual int StartBinRec(int n, int StartNumber=0);
  626. virtual int reset(int t);
  627. virtual long calcMemoryConsumption();
  628. int proceedeInThread(int TotalTime);
  629. int calculateInThread(int Start_Index, int Stop_Index);
  630. };
  631. //Hodgkin-Huxley-Model-Neuron
  632. enum HodgHuxGate {HodgHux_h,HodgHux_m,HodgHux_n};
  633. class HodgHuxLayer : public layer, public AmpaNmdaGabaChannels
  634. {
  635. protected:
  636. float *hAlphaArr,*mAlphaArr,*nAlphaArr,*hBetaArr,*mBetaArr,*nBetaArr;
  637. float VL,VNa,VK,gL,gNa,gK,CM,VShift,SpikeDetectionThreshold;
  638. float hParas[6],mParas[6],nParas[6];
  639. float *hNa,*mNa,*nK,*M;
  640. float Mmin,Mmax,Mstart;
  641. int MN;
  642. bool *alreadySpiked;
  643. public:
  644. HodgHuxLayer(int n,float vl=10.6,float vna=120.,float vk=-12.,float gl=0.3,float gna=120.,float gk=36.,float cm=1.,float vshift=70,float spikedetectionthreshold=50,float mmin=-100,float mmax=200,float mstart=-65, int mn=1000);
  645. ~HodgHuxLayer();
  646. virtual int proceede(int);
  647. void setxAlphaBeta(HodgHuxGate ,float [6]);
  648. int M2index(float );
  649. virtual float* GetInputPointer(csimInputChannel num=csimInputChannel_AMPA);
  650. virtual int WriteSimInfo(fstream &fw);
  651. virtual int StartBinRec(int n, int StartNumber=0);
  652. };
  653. /////////////////
  654. #endif /*_HPP_LAYER */