AnimatLab  2
Test
IntegrateFireModule.cpp
Go to the documentation of this file.
1 
7 #include "stdafx.h"
8 #include "IonChannel.h"
9 #include "SynapseType.h"
10 #include "Connexion.h"
11 #include "CaActivation.h"
12 #include "Neuron.h"
13 #include "ElectricalSynapse.h"
15 #include "SpikingChemicalSynapse.h"
16 #include "IntegrateFireModule.h"
17 #include "ClassFactory.h"
18 #include <time.h>
19 
20 namespace IntegrateFireSim
21 {
22 
30 {
32 
33 // m_fltStepSize = 0;
34  m_dTimeStep =1.;
35 
37  m_bRandomisedHebb=false;
38  m_bFreezeLearning=false;
39  m_bUseCriticalPeriod = false;
42  m_bFreezeHebb = false;
43  m_bNeedInitialiseHebb = false;
44  m_bRandomisedHebb = false;
45  m_bFreezeLearning = false;
46  m_dCurrentTime = 0;
47 
48  m_bTTX = false;
49  m_bCd = false;
50  m_bHH = false;
51 
52 
53 
54 }
55 
63 {
64 
65  try
66  {
67  m_aryNeurons.RemoveAll();
68  m_arySpikingChemSyn.RemoveAll();
69  }
70  catch(...)
71  {Std_TraceMsg(0, "Caught Error in desctructor of IntegrateFireNeuralModule\r\n", "", -1, false, true);}
72 }
73 
74 
75 #pragma region Accessor-Mutators
76 
86 
96 
106 
116 
128 
138 
150 
159 void IntegrateFireNeuralModule::Cd(bool bVal) {m_bCd = bVal;}
160 
170 
179 void IntegrateFireNeuralModule::TTX(bool bVal) {m_bTTX = bVal;}
180 
190 
199 void IntegrateFireNeuralModule::HH(bool bVal) {m_bHH = bVal;}
200 
210 
220 {
221  NeuralModule::TimeStep(fltVal);
222 
223  m_dTimeStep = m_fltTimeStep * 1000;
225 
226  PreCalc();
227 }
228 
238 
248 
258 
268 
278 
288 
298 
308 
318 
328 
338 
348 
358 
368 
378 
388 
398 
408 {
410  Neuron::m_lAbsoluteRefr = (long) ((dVal/m_dTimeStep)+0.5f);
411 }
412 
422 
432 
442 
452 
464 
474 
486 
496 
508 
517 std::string IntegrateFireNeuralModule::ModuleName() {return "IntegrateFireSim";}
518 
519 #pragma endregion
520 
530 {
531  int i;
533 
534  m_aryNeurons.RemoveAll();
535 
536  ID(oXml.GetChildString("ID", m_strID));
537  Type(oXml.GetChildString("Type", m_strType));
538  Name(oXml.GetChildString("Name", m_strName));
539 
540  //This will add this object to the object list of the simulation.
541  Simulator *m_lpSim = GetSimulator();
542  if(m_lpSim)
543  m_lpSim->AddToObjectList(this);
544 
545  //We do NOT call the TimeStep mutator here because we need to call it only after all modules are loaded so we can calculate the min time step correctly.
546  m_fltTimeStep = oXml.GetChildFloat("TimeStep");
547  m_dTimeStep = m_fltTimeStep * 1000;
548  Std_InValidRange((float) 1e-10, (float) 1, m_fltTimeStep, true, "TimeStep");
549 
550  TTX(oXml.GetChildBool("TTX", false));
551  Cd(oXml.GetChildBool("Cd", false));
552  HH(oXml.GetChildBool("HH", false));
553 
554  RetainHebbMemory(oXml.GetChildBool("RetainHebbMemory", 0));
555  UseCriticalPeriod(oXml.GetChildBool("UseCriticalPeriod"));
556  StartCriticalPeriod(oXml.GetChildDouble("StartCriticalPeriod"));
557  EndCriticalPeriod(oXml.GetChildDouble("EndCriticalPeriod"));
558  FreezeHebb(oXml.GetChildBool("FreezeHebb", 0));
559 
560  Neuron::m_dSpikePeak= oXml.GetChildDouble("SpikePeak");
561  Neuron::m_dSpikeStrength=oXml.GetChildDouble("SpikeStrength");
562  Neuron::m_dAHPEquilPot=oXml.GetChildDouble("AHPEquilPot");
563  Neuron::m_dCaEquilPot=oXml.GetChildDouble("CaEquilPot");
564  Neuron::m_dAbsoluteRefr=oXml.GetChildDouble("AbsoluteRefr");
566 
567  oXml.IntoChildElement("Synapses");
568 
569  oXml.IntoChildElement("SpikingSynapses");
570  int iTotalSpikingSynapses = oXml.NumberOfChildren();
571  for(i=0; i<iTotalSpikingSynapses; i++)
572  {
573  oXml.FindChildByIndex(i);
574  LoadSpikingChemSyn(oXml, i);
575  }
576  oXml.OutOfElem(); //OutOf SpikingSynapses Element
577 
578  oXml.IntoChildElement("NonSpikingSynapses");
579  int iTotalNonSpikingSynapses = oXml.NumberOfChildren();
580  for(i=0; i<iTotalNonSpikingSynapses; i++)
581  {
582  oXml.FindChildByIndex(i);
583  LoadNonSpikingChemSyn(oXml, i);
584  }
585  oXml.OutOfElem(); //OutOf NonSpikingSynapses Element
586 
587  oXml.IntoChildElement("ElectricalSynapses");
588  int iTotalElecSynapses = oXml.NumberOfChildren();
589  for(i=0; i<iTotalElecSynapses; i++)
590  {
591  oXml.FindChildByIndex(i);
592  LoadElecSyn(oXml, i);
593  }
594  oXml.OutOfElem(); //OutOf ElectricalSynapses Element
595 
596  oXml.OutOfElem(); //OutOf Synapses Element
597 
598 
599  //*** Begin Loading Neurons. *****
600  oXml.IntoChildElement("Neurons");
601  int iTotalNeurons = oXml.NumberOfChildren();
602  for(i=0; i<iTotalNeurons; i++)
603  {
604  oXml.FindChildByIndex(i);
605  LoadNeuron(oXml);
606  }
607  oXml.OutOfElem(); //OutOf Neurons Element
608 
609 
610  /*
611  if(oXml.FindChildElement("Stimuli", false))
612  {
613  oXml.IntoChildElement("Stimuli");
614  int iTotalStimuli = oXml.NumberOfChildren();
615  for(i=0; i<iTotalStimuli; i++)
616  {
617  oXml.FindChildByIndex(i);
618  LoadStim(oXml);
619  }
620  oXml.OutOfElem(); //OutOf Stimuli Element
621  }
622  */
623 
624  oXml.IntoChildElement("Connexions");
625  int iTotalConnexions = oXml.NumberOfChildren();
626  for(i=0; i<iTotalConnexions; i++)
627  {
628  oXml.FindChildByIndex(i);
629  //Std_TraceMsg(0, STR(i));
630  LoadConnexion(oXml);
631  }
632  oXml.OutOfElem(); //OutOf Stimuli Element
633 
634 
635 //Std_TraceMsg(0,"neuron count = "+STR(GetNeuronCount()));
636 //Std_TraceMsg(0,"stim count = "+STR(GetStimCount()));
637 //Std_TraceMsg(0,"connexion count = "+STR(GetConnexionCount()));
638 }
639 
651 {
652  Neuron *lpNeuron=NULL;
653  std::string strType;
654 
655  try
656  {
657 
658  lpNeuron = new Neuron;
659 
660  lpNeuron->SetSystemPointers(m_lpSim, m_lpStructure, this, NULL, true);
661  lpNeuron->Load(oXml);
662 
663  m_aryNeurons.Add(lpNeuron);
664 
665  return lpNeuron;
666  }
667  catch(CStdErrorInfo oError)
668  {
669  if(lpNeuron) delete lpNeuron;
670  RELAY_ERROR(oError);
671  return NULL;
672  }
673  catch(...)
674  {
675  if(lpNeuron) delete lpNeuron;
676  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
677  return NULL;
678  }
679 }
680 
692 {
693  oXml.IntoElem();
694  std::string strType = Std_ToUpper(oXml.GetChildString("Type"));
695  oXml.OutOfElem();
696 
697  SynapseType *lpType = NULL;
698 
699  if(strType == "SPIKINGCHEMICAL")
700  lpType = LoadSpikingChemSyn(oXml, m_arySpikingChemSyn.GetSize());
701  else if(strType == "NONSPIKINGCHEMICAL")
702  lpType = LoadNonSpikingChemSyn(oXml, m_aryNonSpikingChemSyn.GetSize());
703  else if(strType == "ELECTRICAL")
704  lpType = LoadElecSyn(oXml, m_aryElecSyn.GetSize());
705  else
706  THROW_PARAM_ERROR(Rn_Err_lInvalidSynapseType, Rn_Err_strInvalidSynapseType, "Type", strType);
707 
708  return lpType;
709 }
710 
723 {
724  SpikingChemicalSynapse *pSpikingChemSyn=NULL;
725  std::string strType;
726 //
727 
728  try
729  {
730 
731  pSpikingChemSyn = new SpikingChemicalSynapse;
732  pSpikingChemSyn->SetSystemPointers(m_lpSim, m_lpStructure, this, NULL, true);
733  pSpikingChemSyn->Load(oXml);
734  pSpikingChemSyn->SynapseTypeID(iIndex);
735 
736  m_arySpikingChemSyn.Add(pSpikingChemSyn);
737 
738  return pSpikingChemSyn;
739  }
740  catch(CStdErrorInfo oError)
741  {
742  if(pSpikingChemSyn) delete pSpikingChemSyn;
743  RELAY_ERROR(oError);
744  return NULL;
745  }
746  catch(...)
747  {
748  if(pSpikingChemSyn) delete pSpikingChemSyn;
749  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
750  return NULL;
751  }
752 }
753 
766 {
767  NonSpikingChemicalSynapse *pNonSpikingChemSyn=NULL;
768  std::string strType;
769 //
770 
771  try
772  {
773 
774  pNonSpikingChemSyn = new NonSpikingChemicalSynapse;
775  pNonSpikingChemSyn->SetSystemPointers(m_lpSim, m_lpStructure, this, NULL, true);
776  pNonSpikingChemSyn->Load(oXml);
777  pNonSpikingChemSyn->SynapseTypeID(iIndex);
778 
779  m_aryNonSpikingChemSyn.Add(pNonSpikingChemSyn);
780 
781  return pNonSpikingChemSyn;
782  }
783  catch(CStdErrorInfo oError)
784  {
785  if(pNonSpikingChemSyn) delete pNonSpikingChemSyn;
786  RELAY_ERROR(oError);
787  return NULL;
788  }
789  catch(...)
790  {
791  if(pNonSpikingChemSyn) delete pNonSpikingChemSyn;
792  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
793  return NULL;
794  }
795 }
796 
809 {
810  ElectricalSynapse *pElecSyn=NULL;
811  std::string strType;
812 //
813 
814  try
815  {
816 
817  pElecSyn = new ElectricalSynapse;
818  pElecSyn->SetSystemPointers(m_lpSim, m_lpStructure, this, NULL, true);
819  pElecSyn->Load(oXml);
820  pElecSyn->SynapseTypeID(iIndex);
821 
822  m_aryElecSyn.Add(pElecSyn);
823 
824  return pElecSyn;
825  }
826  catch(CStdErrorInfo oError)
827  {
828  if(pElecSyn) delete pElecSyn;
829  RELAY_ERROR(oError);
830  return NULL;
831  }
832  catch(...)
833  {
834  if(pElecSyn) delete pElecSyn;
835  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
836  return NULL;
837  }
838 }
839 
851 {
852  Connexion *pConnexion=NULL;
853  std::string strType;
854 
855  try
856  {
857 
858  pConnexion = new Connexion;
859  pConnexion->SetSystemPointers(m_lpSim, m_lpStructure, this, NULL, true);
860  pConnexion->Load(oXml);
861 
862  m_aryConnexion.Add(pConnexion);
863 
864  return pConnexion;
865  }
866  catch(CStdErrorInfo oError)
867  {
868  if(pConnexion) delete pConnexion;
869  RELAY_ERROR(oError);
870  return NULL;
871  }
872  catch(...)
873  {
874  if(pConnexion) delete pConnexion;
875  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
876  return NULL;
877  }
878 }
879 
887 {
888  int iCount = m_arySpikingChemSyn.GetSize();
889  for(int i=0; i<iCount; i++)
890  m_arySpikingChemSyn[i]->SynapseTypeID(i);
891 
892  iCount = m_aryNonSpikingChemSyn.GetSize();
893  for(int i=0; i<iCount; i++)
894  m_aryNonSpikingChemSyn[i]->SynapseTypeID(i);
895 
896  iCount = m_aryElecSyn.GetSize();
897  for(int i=0; i<iCount; i++)
898  m_aryElecSyn[i]->SynapseTypeID(i);
899 
900  iCount = m_aryNeurons.GetSize();
901  for(int i=0; i<iCount; i++)
902  m_aryNeurons[i]->NeuronID(i);
903 
904  Connexion *pCx;
905  for(int i=0; i<GetConnexionCount(); i++)
906  {
907  pCx=GetConnexionAt(i);
908  pCx->ResetIDs();
909  }
910 }
911 
913 // THE ENGINE
914 //
915 
930 double IntegrateFireNeuralModule::GetScaleElecCond(double minG,double maxG,double jV, double ThreshV,double SaturateV)
931 {
932  if (maxG==minG) // NON rectifying
933  return minG;
934  if (jV<=ThreshV)
935  return minG;
936  if (jV>SaturateV)
937  return maxG;
938 
939  return minG+(maxG-minG)*(jV-ThreshV)/(SaturateV-ThreshV);
940 }
941 
954 void IntegrateFireNeuralModule::ScaleCondForVoltDep(double& G,double postV,double maxV,double minV,double scl)
955 {
956  //dwc There was an inconsistency here. If the post-Vm was less than maxV then it
957  //could range from 1 to (1+scl), but as soon as the Vm goes to maxV or above it
958  //suddenly jumps to scaling by scl instead of (1+scl). I changed it so that it scales correclty.
959  if (postV >= maxV)
960  G*=(1+scl);
961  else if (postV > minV && postV < maxV)
962  {
963 #ifdef _DEBUG
964 double vScl=(postV-minV)/(maxV-minV);
965 //ASSERT(vScl>0 && vScl<1);
966 #endif
967  G*=(1+(scl*(postV-minV)/(maxV-minV)));
968  }
969 }
970 
971 // pass in reference to maximum conductance
972 
984 void IntegrateFireNeuralModule::ScaleCondForNonSpiking(double& G,double PreV,double ThreshV,double SaturateV)
985 {
986  if (PreV<=ThreshV)
987  G=0.0;
988  else if (PreV<SaturateV)
989  G=G*(PreV-ThreshV)/(SaturateV-ThreshV);
990 }
991 
999 {
1000  int i;
1001  Connexion *pCx;
1002 
1003  for (i=0; i<GetNeuronCount(); i++)
1004  {
1005  GetNeuronAt(i)->PostCalc(this);
1006  }
1007  for (i=0; i<GetConnexionCount(); i++)
1008  {
1009  pCx=GetConnexionAt(i);
1010  pCx->m_TransitCx.Release();
1011  pCx->m_HebbList.Release();
1012  }
1013 }
1014 
1024 {
1025  pCx->m_lpSynType = dynamic_cast<SynapseType *>(m_lpSim->FindByID(pCx->SynapseTypeID()));
1026  if(!pCx->m_lpSynType)
1027  THROW_PARAM_ERROR(Rn_Err_lInvalidSynapseID, Rn_Err_strInvalidSynapseID, "ID: ", pCx->SynapseTypeID());
1028 
1029  pCx->m_lpSource = dynamic_cast<Neuron *>(m_lpSim->FindByID(pCx->SourceID()));
1030  if(!pCx->m_lpSource)
1031  THROW_PARAM_ERROR(Rn_Err_lNeuronNotFound, Rn_Err_strNeuronNotFound, "ID: ", pCx->SourceID());
1032 
1033  pCx->m_lpTarget = dynamic_cast<Neuron *>(m_lpSim->FindByID(pCx->TargetID()));
1034  if(!pCx->m_lpTarget)
1035  THROW_PARAM_ERROR(Rn_Err_lNeuronNotFound, Rn_Err_strNeuronNotFound, "ID: ", pCx->TargetID());
1036 
1037  if (pCx->m_iType==0) // spiking synapse
1038  {
1039  pCx->m_dPreviousSpikeLatency=-1;
1040  pCx->m_dGFacilCx = pCx->m_dBaseG;
1041  pCx->m_dG = pCx->m_dBaseG;
1042  pCx->m_fltGFailCxReport = pCx->m_dGFacilCx;
1043  pCx->m_fltGReport = pCx->m_dG;
1044 
1045  if (pCx->Hebbian())
1047  }
1048 }
1049 
1051 {
1052  PreCalc();
1053 }
1054 
1062 {
1063  int i;
1064  Connexion *pCx;
1065 
1066  m_dCurrentTime=0;
1069 
1070  for (i=0; i<GetNeuronCount(); i++)
1071  {
1072  GetNeuronAt(i)->PreCalc(this);
1073  }
1074 
1075  //We must update the facilitation decay constant when we change the timestep.
1076  SpikingChemicalSynapse *lpSyn;
1077  int iCount = m_arySpikingChemSyn.GetSize();
1078  for(int iIndex=0; iIndex<iCount; iIndex++)
1079  {
1080  lpSyn = m_arySpikingChemSyn[iIndex];
1081  lpSyn->m_dFacilD = exp(-m_dTimeStep/lpSyn->m_dFacilDecay);
1082  }
1083 
1084 /*
1085 FOLLOWING COMMENTS ARE FROM NEUROSIM - I don't really understand them any more!!!!
1086 */
1087 
1088 /*
1089  THE LOGIC
1090  Normally need to set initial conductance of Hebb synapses to unaugmented
1091  state at start of run.
1092  If RetainMemory, still need to set as above, until run once.
1093  Problem: if do run, then change synapses, then set RetainMem -
1094  retains conditions of previous synapses.
1095  So set NeedInitHebb flag when change synapses or circuit (and in NewDoc).
1096  If load file, set NeedInit UNLESS memory was retained in loaded file.
1097  */
1098 
1099 // could skip all pCx initialisation if retain memory, so long as done it at least once.
1100 // since can't change circuit while retain memory, so no need to worry about
1101 // params changing.
1102 // set DoneInitHebb false when setting RetainMemory
1103 // BUT since may be loading from file, and don't want to save all m_FacilD etc,
1104 // just skip initialising the bits that hold the memory trace
1105 
1106  for (i=0; i<GetConnexionCount(); i++)
1107  {
1108  pCx=GetConnexionAt(i);
1109  InitSynapse(pCx);
1110  }
1111  m_bNeedInitialiseHebb=false;
1112  m_bRandomisedHebb=false; // randomising done in menu handler
1113 
1114  ResetIDs();
1115 // do any zero-latency stimulus
1116  //for (i=0; i<GetStimCount(); i++)
1117  //{
1118  // GetStimAt(i)->Reset();
1119  //}
1120 }
1121 
1129 {
1130  int i;
1131  Neuron *pSourceN;
1132  Neuron *pTargetN;
1133  Connexion *pCx;
1134 
1135  if(m_lpSim->TimeSlice() == 17)
1136  i = 0;
1137 
1138 // could use
1139 // Sleep(m_SlowDownFactor);
1140 // but has granularity of 1 msec, which is a bit thick
1141 
1143 
1144 
1145  //CurrentStimulus *pStim;
1146  //for (i=0; i<GetStimCount(); i++)
1147  //{
1148  // pStim=GetStimAt(i);
1149  // GetNeuronAt(pStim->GetNeuronID())->IncrementStim(pStim->GetStim(m_dCurrentTime));
1150  //}
1151 
1152 // check if in Critical Period( if used)
1155  {
1156  if (m_dCurrentTime<m_dStartCriticalPeriod || m_dCurrentTime>m_dEndCriticalPeriod)
1157  m_bFreezeLearning=true;
1158  }
1159 
1160 
1161 // We calculate the conductance of each spiking synaptic type, and pass it to
1162 // neuron. We cannot add to general conductance (as we can with non-spiking or
1163 // chemical, because of time dependence (time constant, facilitation etc)
1164 // which means that each type has to be treated separately
1165 
1166 // to add electrical synapse
1167 // 1. sum together all elect syn conds (problem with scaling different sized cells here)
1168 // (let neurons have a size factor (relative to 1), then scale defined cond by size
1169 // (increase if < 1, decrease if > 1), so get more current into small cells.
1170 // do same thing for stimulus amp
1171 // this means that chemical conds are per unit area, and so changes in cell size
1172 // have no effect on voltage, but elect syn and injected current have voltage effects
1173 // which scale with size
1174 // 2. add total elect synaptic conductance to m_GTot
1175 // 3. sum all elect syn currents (G_Elec*(other_neuron_mempot-this_neuron_restpot))
1176 // 4. put sum into current part of eqn E= ...
1177 
1178 
1179 // go through connexion list for electrical and non-spiking chemical synapses
1180  double sourceV,targetV,junctV; // source,target mempot & junctional pot (pre-post)
1181  double junctG,G;
1182  for (i=0; i<GetConnexionCount(); i++)
1183  {
1184  pCx=GetConnexionAt(i);
1185 
1186  pSourceN = pCx->m_lpSource;
1187  pTargetN = pCx->m_lpTarget;
1188  if (pSourceN->GetZapped() || pTargetN->GetZapped())
1189  continue;
1190 
1191  sourceV=pSourceN->GetMemPot();
1192  if (pCx->m_iType==0)
1193  {
1194  if (!m_bCd) // Cadmium blocks all chemical synapses
1195  {
1196  double *pTimeToNext;
1198  pCx->DecrementFacilitation();
1199  if ((pTimeToNext=pCx->GetTimeToNextSpikePtr())!=NULL) // got spike in transit
1200  {
1201  if ((*pTimeToNext)<0) // spike has arrived
1202  pTargetN->m_arySynG[pCx->m_iID]+=(pCx->ProcessOutput(m_bFreezeLearning)); //pCx->m_dPartialBlock*
1203  }
1204  }
1205  }
1206  else if (pCx->m_iType==1) // non-spiking chemical
1207  {
1208  if (!m_bCd) // Cadmium blocks all chemical synapses
1209  {
1210  G=m_aryNonSpikingChemSyn[pCx->m_iID]->m_dSynAmp; //pCx->m_dPartialBlock*
1211  //ASSERT(G>=0);
1212  ScaleCondForNonSpiking(G,sourceV,
1213  m_aryNonSpikingChemSyn[pCx->m_iID]->m_dThreshV,
1214  m_aryNonSpikingChemSyn[pCx->m_iID]->m_dSaturateV);
1215 
1216  if (G==0.0)
1217  continue;
1218 
1219  pTargetN->IncNonSpikingSynCond(G);
1220  pTargetN->IncNonSpikingSynCurr(G * (m_aryNonSpikingChemSyn[pCx->m_iID]->m_dEquil-pTargetN->m_dRestingPot));
1221  }
1222  }
1223 
1224  else // electrical
1225  {
1226 //ASSERT(pCx->m_iType==2);
1227  double sG,tG;
1228 
1229 // if it has a delay, then it just injects into the post-synaptic neuron, no feedback onto pre-synaptic neurons
1230  if (pCx->m_dDelay>0.)
1231  {
1232  double *pTimeToNext;
1234  if ((pTimeToNext=pCx->GetTimeToNextSpikePtr())!=NULL) // got spike in transit
1235  {
1236  if ((*pTimeToNext)<0) // spike has arrived
1237  {
1238  pCx->m_TransitCx.Del(); // remove spike from list
1239  targetV=pTargetN->GetMemPot();
1240  junctV=sourceV-targetV;
1241  junctG=GetScaleElecCond(m_aryElecSyn[pCx->m_iID]->m_dLowCoup,
1242  m_aryElecSyn[pCx->m_iID]->m_dHiCoup,
1243  junctV,m_aryElecSyn[pCx->m_iID]->m_dTurnOnV,
1244  m_aryElecSyn[pCx->m_iID]->m_dSaturateV); //pCx->m_dPartialBlock*
1245 
1246  tG=junctG/pTargetN->m_dSize;
1247  pTargetN->InElectricalSynapseCond(tG);
1249  }
1250  }
1251  }
1252  else
1253  {
1254 
1255  targetV=pTargetN->GetMemPot();
1256  junctV=sourceV-targetV;
1257  junctG=GetScaleElecCond(m_aryElecSyn[pCx->m_iID]->m_dLowCoup,
1258  m_aryElecSyn[pCx->m_iID]->m_dHiCoup,
1259  junctV,m_aryElecSyn[pCx->m_iID]->m_dTurnOnV,
1260  m_aryElecSyn[pCx->m_iID]->m_dSaturateV); //pCx->m_dPartialBlock*
1261  // adjust for size of cell
1262  // for small cells, the electrical conductance is relatively bigger
1263  sG=junctG/pSourceN->m_dSize;
1264  tG=junctG/pTargetN->m_dSize;
1265  pSourceN->InElectricalSynapseCond(sG);
1266  pTargetN->InElectricalSynapseCond(tG);
1267 
1268 
1269  if (pTargetN->GetSpike())
1271  else
1272  pSourceN->InElectricalSynapseCurr(sG*(pTargetN->GetMemPot()-pSourceN->m_dRestingPot));
1273 
1274 
1275  if (pSourceN->GetSpike())
1277  else
1278  pTargetN->InElectricalSynapseCurr(tG*(pSourceN->GetMemPot()-pTargetN->m_dRestingPot));
1279  }
1280  }
1281  }
1282 
1283 // Neuron::Update does stimulus, endogenous, + spontaneous spiking chem input.
1284 // it stores m_NewMemPot, so can update when all neurons have done their updates using memPot from previous iteration
1285  for (i=0; i<GetNeuronCount(); i++)
1286  {
1287  GetNeuronAt(i)->CalcUpdate(this);
1288  }
1289 
1290 // now switch newMemPot for memPot, decide if spiking etc
1291 // Draws neuron if colour-from-potential
1292  for (i=0; i<GetNeuronCount(); i++)
1293  {
1294  GetNeuronAt(i)->CalcUpdateFinal(this);
1295  }
1296 
1297 
1298 // get all spiking neurons after doing all updates
1299 // and save old membrane potentials for non-spiking and electrical synapses
1300 // ZAPPED neurons never spike
1301  for (i=0; i<GetConnexionCount(); i++)
1302  {
1303  pCx=GetConnexionAt(i);
1304  pSourceN=pCx->m_lpSource;
1305  if (pSourceN->GetSpike())
1306  pCx->AppendTransitSpike();
1307  pTargetN=pCx->m_lpTarget;
1308  if (pTargetN->GetSpike() && !m_bFreezeLearning)
1309  pCx->IncrementHebbian();
1310  }
1311 }
1312 
1313 //NeuralModule overrides
1314 
1326 int IntegrateFireNeuralModule::FindNeuronListPos(std::string strID, bool bThrowError)
1327 {
1328  std::string sID = Std_ToUpper(Std_Trim(strID));
1329 
1330  int iCount = m_aryNeurons.GetSize();
1331  for(int iIndex=0; iIndex<iCount; iIndex++)
1332  if(m_aryNeurons[iIndex]->ID() == sID)
1333  return iIndex;
1334 
1335  if(bThrowError)
1336  THROW_TEXT_ERROR(Rn_Err_lNeuronNotFound, Rn_Err_strNeuronNotFound, "ID");
1337 
1338  return -1;
1339 }
1340 
1352 int IntegrateFireNeuralModule::FindSynapseListPos(std::string strID, bool bThrowError)
1353 {
1354  std::string sID = Std_ToUpper(Std_Trim(strID));
1355 
1356  int iCount = m_aryConnexion.GetSize();
1357  for(int iIndex=0; iIndex<iCount; iIndex++)
1358  if(m_aryConnexion[iIndex]->ID() == sID)
1359  return iIndex;
1360 
1361  if(bThrowError)
1362  THROW_TEXT_ERROR(Rn_Err_lSynapseNotFound, Rn_Err_strSynapseNotFound, "ID");
1363 
1364  return -1;
1365 }
1366 
1378 int IntegrateFireNeuralModule::FindSpikingChemListPos(std::string strID, bool bThrowError)
1379 {
1380  std::string sID = Std_ToUpper(Std_Trim(strID));
1381 
1382  int iCount = m_arySpikingChemSyn.GetSize();
1383  for(int iIndex=0; iIndex<iCount; iIndex++)
1384  if(m_arySpikingChemSyn[iIndex]->ID() == sID)
1385  return iIndex;
1386 
1387  if(bThrowError)
1388  THROW_TEXT_ERROR(Rn_Err_lSynapseNotFound, Rn_Err_strSynapseNotFound, "ID");
1389 
1390  return -1;
1391 }
1392 
1404 int IntegrateFireNeuralModule::FindNonSpikingChemListPos(std::string strID, bool bThrowError)
1405 {
1406  std::string sID = Std_ToUpper(Std_Trim(strID));
1407 
1408  int iCount = m_aryNonSpikingChemSyn.GetSize();
1409  for(int iIndex=0; iIndex<iCount; iIndex++)
1410  if(m_aryNonSpikingChemSyn[iIndex]->ID() == sID)
1411  return iIndex;
1412 
1413  if(bThrowError)
1414  THROW_TEXT_ERROR(Rn_Err_lSynapseNotFound, Rn_Err_strSynapseNotFound, "ID");
1415 
1416  return -1;
1417 }
1418 
1430 int IntegrateFireNeuralModule::FindElectricalListPos(std::string strID, bool bThrowError)
1431 {
1432  std::string sID = Std_ToUpper(Std_Trim(strID));
1433 
1434  int iCount = m_aryElecSyn.GetSize();
1435  for(int iIndex=0; iIndex<iCount; iIndex++)
1436  if(m_aryElecSyn[iIndex]->ID() == sID)
1437  return iIndex;
1438 
1439  if(bThrowError)
1440  THROW_TEXT_ERROR(Rn_Err_lSynapseNotFound, Rn_Err_strSynapseNotFound, "ID");
1441 
1442  return -1;
1443 }
1444 
1445 #pragma region DataAccesMethods
1446 
1447 bool IntegrateFireNeuralModule::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
1448 {
1449  std::string strType = Std_CheckString(strDataType);
1450 
1451  if(NeuralModule::SetData(strDataType, strValue, false))
1452  return true;
1453 
1454  if(strType == "TIMESTEP")
1455  {
1456  TimeStep(atof(strValue.c_str()));
1457  return true;
1458  }
1459 
1460  if(strType == "TTX")
1461  {
1462  TTX(Std_ToBool(strValue));
1463  return true;
1464  }
1465 
1466  if(strType == "CD")
1467  {
1468  Cd(Std_ToBool(strValue));
1469  return true;
1470  }
1471 
1472  if(strType == "HH")
1473  {
1474  HH(Std_ToBool(strValue));
1475  return true;
1476  }
1477 
1478  if(strType == "RETAINHEBBMEMORY")
1479  {
1480  RetainHebbMemory(Std_ToBool(strValue));
1481  return true;
1482  }
1483 
1484  if(strType == "USECRITICALPERIOD")
1485  {
1486  UseCriticalPeriod(Std_ToBool(strValue));
1487  return true;
1488  }
1489 
1490  if(strType == "STARTCRITICALPERIOD")
1491  {
1492  StartCriticalPeriod(atof(strValue.c_str()));
1493  return true;
1494  }
1495 
1496  if(strType == "ENDCRITICALPERIOD")
1497  {
1498  EndCriticalPeriod(atof(strValue.c_str()));
1499  return true;
1500  }
1501 
1502  if(strType == "FREEZEHEBB")
1503  {
1504  FreezeHebb(Std_ToBool(strValue));
1505  return true;
1506  }
1507 
1508  if(strType == "SPIKEPEAK")
1509  {
1510  SpikePeak(atof(strValue.c_str()));
1511  return true;
1512  }
1513 
1514  if(strType == "SPIKESTRENGTH")
1515  {
1516  SpikeStrength(atof(strValue.c_str()));
1517  return true;
1518  }
1519 
1520  if(strType == "CAEQUILPOT")
1521  {
1522  CaEquilPot(atof(strValue.c_str()));
1523  return true;
1524  }
1525 
1526  if(strType == "ABSOLUTEREFR")
1527  {
1528  AbsoluteRefr(atof(strValue.c_str()));
1529  return true;
1530  }
1531 
1532  if(strType == "AHPEQUILPOT")
1533  {
1534  AHPEquilPot(atof(strValue.c_str()));
1535  return true;
1536  }
1537 
1538  //If it was not one of those above then we have a problem.
1539  if(bThrowError)
1540  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
1541 
1542  return false;
1543 }
1544 
1545 void IntegrateFireNeuralModule::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
1546 {
1547  NeuralModule::QueryProperties(aryProperties);
1548 
1549  aryProperties.Add(new TypeProperty("TimeStep", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1550  aryProperties.Add(new TypeProperty("TTX", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
1551  aryProperties.Add(new TypeProperty("Cd", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
1552  aryProperties.Add(new TypeProperty("HH", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
1553  aryProperties.Add(new TypeProperty("RetainHebbMemory", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
1554  aryProperties.Add(new TypeProperty("UseCriticalPeriod", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
1555  aryProperties.Add(new TypeProperty("StartCriticalPeriod", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1556  aryProperties.Add(new TypeProperty("EndCriticalPeriod", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1557  aryProperties.Add(new TypeProperty("FreezeHebb", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
1558  aryProperties.Add(new TypeProperty("SpikePeak", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1559  aryProperties.Add(new TypeProperty("SpikeStrength", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1560  aryProperties.Add(new TypeProperty("CaEquilPot", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1561  aryProperties.Add(new TypeProperty("AbsoluteRefr", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1562  aryProperties.Add(new TypeProperty("AHPEquilPot", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1563 }
1564 
1573 void IntegrateFireNeuralModule::AddNeuron(std::string strXml, bool bDoNotInit)
1574 {
1575  CStdXml oXml;
1576  oXml.Deserialize(strXml);
1577  oXml.FindElement("Root");
1578  oXml.FindChildElement("Neuron");
1579 
1580  Neuron *lpNeuron = LoadNeuron(oXml);
1581  PreCalc();
1582 }
1583 
1593 void IntegrateFireNeuralModule::RemoveNeuron(std::string strID, bool bThrowError)
1594 {
1595  int iPos = FindNeuronListPos(strID, bThrowError);
1596  m_aryNeurons.RemoveAt(iPos);
1597  PreCalc();
1598 }
1599 
1608 void IntegrateFireNeuralModule::AddSynapse(std::string strXml, bool bDoNotInit)
1609 {
1610  CStdXml oXml;
1611  oXml.Deserialize(strXml);
1612  oXml.FindElement("Root");
1613  oXml.FindChildElement("Connexion");
1614 
1615  Connexion *pCx = LoadConnexion(oXml);
1616  PreCalc();
1617 }
1618 
1627 void IntegrateFireNeuralModule::AddSynapseType(std::string strXml, bool bDoNotInit)
1628 {
1629  CStdXml oXml;
1630  oXml.Deserialize(strXml);
1631  oXml.FindElement("Root");
1632  oXml.FindChildElement("SynapseType");
1633 
1634  SynapseType *pType = LoadSynapseType(oXml);
1635  PreCalc();
1636 }
1637 
1647 void IntegrateFireNeuralModule::RemoveSynapse(std::string strID, bool bThrowError)
1648 {
1649  int iPos = FindSynapseListPos(strID, bThrowError);
1650  m_aryConnexion.RemoveAt(iPos);
1651  PreCalc();
1652 }
1653 
1663 void IntegrateFireNeuralModule::RemoveSynapseType(std::string strID, bool bThrowError)
1664 {
1665  SynapseType *lpType = dynamic_cast<SynapseType *>(GetSimulator()->FindByID(strID, bThrowError));
1666 
1667  if(lpType)
1668  {
1669  std::string strType = Std_ToUpper(lpType->Type());
1670  if(strType == "SPIKINGCHEMICAL")
1671  {
1672  int iPos = FindSpikingChemListPos(strID, bThrowError);
1673  m_arySpikingChemSyn.RemoveAt(iPos);
1674  }
1675  else if(strType == "NONSPIKINGCHEMICAL")
1676  {
1677  int iPos = FindNonSpikingChemListPos(strID, bThrowError);
1678  m_aryNonSpikingChemSyn.RemoveAt(iPos);
1679  }
1680  else if(strType == "ELECTRICAL")
1681  {
1682  int iPos = FindElectricalListPos(strID, bThrowError);
1683  m_aryElecSyn.RemoveAt(iPos);
1684  }
1685  else
1686  {
1687  if(bThrowError)
1688  THROW_PARAM_ERROR(Rn_Err_lInvalidSynapseType, Rn_Err_strInvalidSynapseType, "Type", strType);
1689  return;
1690  }
1691 
1692  PreCalc();
1693  }
1694 }
1695 
1696 bool IntegrateFireNeuralModule::AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError, bool bDoNotInit)
1697 {
1698  std::string strType = Std_CheckString(strItemType);
1699 
1700  if(strType == "NEURON")
1701  {
1702  AddNeuron(strXml, bDoNotInit);
1703  return true;
1704  }
1705  else if(strType == "SYNAPSE")
1706  {
1707  AddSynapse(strXml, bDoNotInit);
1708  return true;
1709  }
1710  else if(strType == "EXTERNALSYNAPSE")
1711  {
1712  AddExternalSynapse(strXml, bDoNotInit);
1713  return true;
1714  }
1715  else if(strType == "SYNAPSETYPE")
1716  {
1717  AddSynapseType(strXml, bDoNotInit);
1718  return true;
1719  }
1720 
1721  //If it was not one of those above then we have a problem.
1722  if(bThrowError)
1723  THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType, "Item Type", strItemType);
1724 
1725  return false;
1726 }
1727 
1728 bool IntegrateFireNeuralModule::RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError)
1729 {
1730  std::string strType = Std_CheckString(strItemType);
1731 
1732  if(strType == "NEURON")
1733  {
1734  RemoveNeuron(strID, bThrowError);
1735  return true;
1736  }
1737  else if(strType == "SYNAPSE")
1738  {
1739  RemoveSynapse(strID, bThrowError);
1740  return true;
1741  }
1742  else if(strType == "EXTERNALSYNAPSE")
1743  {
1744  RemoveExternalSynapse(strID);
1745  return true;
1746  }
1747  else if(strType == "SYNAPSETYPE")
1748  {
1749  RemoveSynapseType(strID, bThrowError);
1750  return true;
1751  }
1752 
1753 
1754  //If it was not one of those above then we have a problem.
1755  if(bThrowError)
1756  THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType, "Item Type", strItemType);
1757 
1758  return false;
1759 }
1760 
1761 #pragma endregion
1762 
1764 {
1765  int iSize = m_aryNeurons.GetSize(), iNeuron;
1766  for(iNeuron=0; iNeuron<iSize; iNeuron++)
1767  m_aryNeurons[iNeuron]->Kill(bState);
1768 }
1769 
1771 {
1772  NeuralModule::ResetSimulation();
1773 
1774  m_dCurrentTime = 0;
1775 
1776  PostCalc();
1777 
1778  int iSize = m_aryNeurons.GetSize(), iIndex;
1779  for(iIndex=0; iIndex<iSize; iIndex++)
1780  m_aryNeurons[iIndex]->ResetSimulation();
1781 
1782  iSize = m_aryConnexion.GetSize();
1783  for(iIndex=0; iIndex<iSize; iIndex++)
1784  m_aryConnexion[iIndex]->ResetSimulation();
1785 
1786  PreCalc();
1787 }
1788 
1790 {
1791  //srand(m_lpSim->ManualRandomSeed());
1792 
1793  NeuralModule::Initialize();
1794  PreCalc();
1795 }
1796 
1798 {
1799  NeuralModule::StepSimulation();
1800  CalcUpdate();
1801 }
1802 
1803 void IntegrateFireNeuralModule::Load(CStdXml &oXml)
1804 {
1805  CStdXml oNetXml;
1806 
1807  //if(Std_IsBlank(m_strProjectPath))
1808  // THROW_ERROR(Al_Err_lProjectPathBlank, Al_Err_strProjectPathBlank);
1809 
1810  m_lpOrganism = dynamic_cast<Organism *>(m_lpStructure);
1811  if(!m_lpOrganism)
1812  THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType, "Organism");
1813 
1814  m_arySourceAdapters.RemoveAll();
1815  m_aryTargetAdapters.RemoveAll();
1816 
1817  oXml.IntoElem(); //Into NeuralModule Element
1818 
1819  m_strNeuralNetworkFile = oXml.GetChildString("NeuralNetFile", "");
1820 
1821  TRACE_DEBUG("Loading nervous system config file.\r\nProjectPath: " + m_strProjectPath + "\r\nFile: " + m_strNeuralNetworkFile);
1822 
1824  {
1825  oNetXml.Load(AnimatSim::GetFilePath(m_strProjectPath, m_strNeuralNetworkFile));
1826 
1827  oNetXml.FindElement("NeuralModule");
1828  oNetXml.FindChildElement("UseCriticalPeriod");
1829 
1830  LoadInternal(oNetXml);
1831  }
1832  else
1833  LoadInternal(oXml);
1834 
1835  LoadExternalSynapses(oXml);
1836 
1837  oXml.OutOfElem(); //OutOf NeuralModule Element
1838 
1839  TRACE_DEBUG("Finished loading nervous system config file.");
1840 }
1841 
1842 
1843 } //IntegrateFireSim
1844 
static double m_dAbsoluteRefr
The static absolute refractory period after an action potential.
void ScaleCondForNonSpiking(double &G, double PreV, double ThreshV, double SaturateV)
Scale conductance for non-spiking chemical synapse.
void PreCalc(IntegrateFireNeuralModule *lpNS)
Initialization routine.
void ResetIDs()
Resets the IDs of the synapse types.
Definition: Connexion.cpp:212
Neuron * m_lpSource
Pointer to the source Neuron.
Definition: Connexion.h:84
bool HH()
Gets whether hodgkin-huxely model is used.
double AbsoluteRefr()
Gets the absolute refractory period.
virtual void RemoveExternalSynapse(std::string strID, bool bThrowError=true)
Removes the synapse by the GUID ID.
virtual void Kill(bool bState=true)
Kills.
void SetCurrentTime(double t)
Sets the current time.
int Del(void)
Deletes this object.
Definition: DoubleList.cpp:73
bool GetZapped()
Gets if the neuron is disabled.
void DecrementLatencies(double dt, bool FreezeLearning=false)
Decrements latencies.
Definition: Connexion.cpp:530
Connexion * GetConnexionAt(int i)
Gets a connexion at specified index.
virtual void StepSimulation()
Step the simulation for this object.
CStdArray< Adapter * > m_arySourceAdapters
An array of source adapters for this module.
Definition: NeuralModule.h:56
virtual int FindNonSpikingChemListPos(std::string strID, bool bThrowError=true)
Searches for a non-spiking chemical synapse by the specified ID and returns its position in the list...
bool m_bTTX
true if ttx drug is applied to the nervous system.
void PostCalc()
performs post-step calculations.
int m_iType
Zero-based index of the synaspe type.
Definition: Connexion.h:96
Declares the integrate fire module class.
CStdPtrArray< Connexion > m_aryConnexion
The array of connexions in this neural module.
void IncrementHebbian()
Increments hebbian values.
Definition: Connexion.cpp:570
virtual std::string ModuleName()
Gets the module name.
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.
static double m_dCaEquilPot
The static calcium equil pot.
DoubleList m_TransitCx
Sets whether there is a partial block hold.
Definition: Connexion.h:122
Simulator * GetSimulator()
Gets the simulator.
bool TTX()
Gets whether ttx is applied to the nervous system.
double m_dPreviousSpikeLatency
The partial block.
Definition: Connexion.h:149
bool m_bHH
true if this nervous system is using a hodgkin-huxely model.
Neuron * GetNeuronAt(int i)
Gets a neuron at specified index.
bool m_bFreezeHebb
true to freeze hebbian learning.
std::string m_strNeuralNetworkFile
The string neural network file name.
Definition: NeuralModule.h:50
void InElectricalSynapseCond(double cond)
Increments electrical synapse conductance.
NonSpikingChemicalSynapse * GetNonSpikingChemSynAt(int i)
Gets a non-spiking chemical synapse at the specified index.
IStdClassFactory * m_lpClassFactory
The pointer to the class factory for this module.
Definition: NeuralModule.h:53
virtual std::string Type()
returns the string type name of this object.
Definition: AnimatBase.cpp:221
bool m_bRandomisedHebb
true to randomise hebbian learning values.
bool FreezeHebb()
Sets whether to freeze hebbian learning.
double m_dGFacilCx
facilitated increase in g when input occurs
Definition: Connexion.h:105
Declares the connexion class.
std::string SynapseTypeID()
Gets the synapse type identifier.
Definition: Connexion.cpp:154
double GetCurrentTime()
Gets the current time.
double AHPEquilPot()
Gets the after-hyperpolarizing equil potential for all neurons in the IGF module. ...
double m_dRestingPot
The resting potential of the neuron.
Simulator * m_lpSim
The pointer to a Simulation.
Definition: AnimatBase.h:43
virtual int FindSpikingChemListPos(std::string strID, bool bThrowError=true)
Searches for a spiking chemical synapse by the specified ID and returns its position in the list...
virtual void RemoveSynapseType(std::string strID, bool bThrowError=true)
Removes the synapse type by ID.
virtual void ResetSimulation()
Resets the simulation back to time 0.
Integrate and fire neuron model.
virtual std::string ID()
Gets the unique GUID ID of this object.
Definition: AnimatBase.cpp:167
NonSpikingChemicalSynapse * LoadNonSpikingChemSyn(CStdXml &oXml, int iIndex)
Loads a non-spiking chemical synapse.
void InitSynapse(Connexion *pCx)
Initialises the synapse.
int GetConnexionCount()
Gets the connexion count.
bool UseCriticalPeriod()
Gets whether to use critical period.
virtual int FindElectricalListPos(std::string strID, bool bThrowError=true)
Searches for an electrical synapse by the specified ID and returns its position in the list...
virtual void TimeStepModified()
Notification method that the time step modified has been modified. Objects should recalculate any sli...
bool m_bNeedInitialiseHebb
true if hebbian learning needs to be initialized
bool RetainHebbMemory()
Gets whether to retain hebbian memory.
Neuron * LoadNeuron(CStdXml &oXml)
Loads a neuron.
virtual void Initialize()
Initializes this object.
double m_dSize
Size of the neuron. This is essentially equivalent to the membrane conductance.
virtual float TimeStep()
Gets the time step.
void CalcUpdateFinal(IntegrateFireNeuralModule *lpNS)
Calculates the final update during a step.
void InElectricalSynapseCurr(double cur)
Increments electrical synapse current.
virtual void RemoveNeuron(std::string strID, bool bThrowError=true)
Removes the neuron with the specified ID.
static double m_dSpikePeak
The static spike peak.
bool m_bRetainHebbMemory
true to retain hebbian memory
int SynapseTypeID()
Gets the synapse type identifier.
Definition: SynapseType.cpp:68
bool m_bCd
true if cadium is applied to the nervous system.
bool Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError, std::string strParamName)
Tests whether a number is within a valid range.
std::string TargetID()
Gets the target neuron ID.
Definition: Connexion.cpp:194
void IncNonSpikingSynCurr(double cur)
Increment non-spiking syn current.
static double m_dAHPEquilPot
The static after-hyperpolarizing equil pot. Typically equil pot for K.
float m_fltGReport
The reported variable for synaptic conductance.
Definition: Connexion.h:114
Declares the spiking chemical synapse class.
double ProcessOutput(bool bFreezeHebb=false)
Process the output described of the connection.
Definition: Connexion.cpp:607
AnimatSim::Environment::Structure * m_lpStructure
The pointer to this items parent Structure. If this is not relevant for this object then this is NULL...
Definition: AnimatBase.h:46
CStdArray< double > m_arySynG
Current conductance of each synaptic type.
std::string m_strID
The unique Id for this object.
Definition: AnimatBase.h:55
std::string Std_Trim(std::string strVal)
Trims a string.
double GetScaleElecCond(double minG, double maxG, double jV, double ThreshV, double SaturateV)
Gets a scale electrical conductance.
ElectricalSynapse * GetElecSynAt(int i)
Gets an electrical synapse at the specified index.
void PreCalc()
Performs pre-step calculations.
bool Cd()
Gets whether Cadmium is applied to the nervous system.
std::string SourceID()
Gets the source neuron ID.
Definition: Connexion.cpp:174
double m_dStartCriticalPeriod
The start time of the critical period for hebbian learning.
virtual int FindSynapseListPos(std::string strID, bool bThrowError=true)
Searches for a synapse by the specified ID and returns its position in the list.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
virtual int FindNeuronListPos(std::string strID, bool bThrowError=true)
Searches for a neuron by the specified ID and returns its position in the list.
Neuron * m_lpTarget
Pointer to the target Neuron.
Definition: Connexion.h:87
double GetRestingPot()
Gets the resting potential.
void AppendTransitSpike()
Appends the transit spike.
Definition: Connexion.h:157
virtual void AddSynapseType(std::string strXml, bool bDoNotInit)
Adds a synapse type by xml.
double EndCriticalPeriod()
Gets the end time of the critical period.
double m_dEndCriticalPeriod
The end time of the critical period for hebbian learning.
Declares the ca activation class.
SpikingChemicalSynapse * GetSpikingChemSynAt(int i)
Gets a spiking chemical synapse at the specified array index.
CStdArray< Adapter * > m_aryTargetAdapters
An array of target adapters for this module.
Definition: NeuralModule.h:59
CStdPtrArray< NonSpikingChemicalSynapse > m_aryNonSpikingChemSyn
The array of non-spiking chemical synapses in this neural module.
virtual std::string Name()
Gets the name of this object.
Definition: AnimatBase.cpp:195
double m_dBaseG
The base conductance.
Definition: Connexion.h:137
Organism * m_lpOrganism
The pointer to the organism.
Definition: NeuralModule.h:33
bool m_bFreezeLearning
true to freeze learning.
double m_dTimeSincePrevHebbEvent
The time since previous hebb event.
Definition: Connexion.h:143
double CaEquilPot()
Gets the calcium equilibrium potential.
void ScaleCondForVoltDep(double &G, double postV, double maxV, double minV, double scl)
Scale conductance for volt dependance.
int GetElecSynCount()
Gets the electrical synapse count.
static long m_lAbsoluteRefr
The static absolute refractory period in timeslices after an action potential.
virtual void LoadExternalSynapses(CStdXml &oXml)
Loads external synapses.
double SpikeStrength()
Gets the spike strength.
float m_fltGFailCxReport
reported variable for facilitated increase in g when input occurs
Definition: Connexion.h:108
bool Hebbian()
Gets if the synapse type is Hebbian.
Definition: Connexion.cpp:320
Connexion * LoadConnexion(CStdXml &oXml)
Loads a connexion.
virtual AnimatBase * FindByID(std::string strID, bool bThrowError=true)
Searches for the object with the specified ID.
Definition: Simulator.cpp:4008
Synapse type base class.
Definition: SynapseType.h:22
ElectricalSynapse * LoadElecSyn(CStdXml &oXml, int iIndex)
Loads an electrical synapse.
bool Std_ToBool(int iVal)
Converts a value toa bool.
CStdPtrArray< Neuron > m_aryNeurons
The array of neurons in this neural module.
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
Declares the synapse type class.
bool GetSpike()
Gets whether a spike occured.
double m_dG
The synaptic conductance.
Definition: Connexion.h:111
virtual void AddNeuron(std::string strXml, bool bDoNotInit)
Adds a neuron by using xml.
SpikingChemicalSynapse * LoadSpikingChemSyn(CStdXml &oXml, int iIndex)
Loads a spiking chemical synapse.
SynapseType * m_lpSynType
Pointer to the synapse type for this connection.
Definition: Connexion.h:81
static double m_dSpikeStrength
The static spike strength used when calculating the action potential.
Class factory for the integrate and fire neural module.
void Release(void)
Releases this object.
Definition: DoubleList.cpp:90
Declares the electrical synapse class.
virtual void LoadInternal(CStdXml &oXml)
Interal method to load the module data.
double GetMemPot()
Gets the membrane potential.
CStdPtrArray< ElectricalSynapse > m_aryElecSyn
The array of electrical synapses in this neural module.
bool Std_IsBlank(std::string strVal)
Trims a string and tests if a string is blank.
double StartCriticalPeriod()
Gets the start time of the critical period.
DoubleList m_HebbList
List of hebbian events.
Definition: Connexion.h:140
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
void ResetIDs()
Resets the integer IDs of the various objects when things move around in the array for some reason...
void PostCalc(IntegrateFireNeuralModule *lpNS)
Called when simulation is ended.
virtual void VerifySystemPointers()
Verify that system pointers have been set correctly.
int GetSpikingChemSynCount()
Gets the spiking chemical synapse count.
SynapseType * LoadSynapseType(CStdXml &oXml)
Loads a synapse type.
virtual long TimeSlice()
Gets the current time slice.
Definition: Simulator.cpp:613
int GetNonSpikingChemSynCount()
Gets the non-spiking chemical synapse count.
virtual void RemoveSynapse(std::string strID, bool bThrowError=true)
Removes the synapse with the specified ID.
CStdPtrArray< SpikingChemicalSynapse > m_arySpikingChemSyn
The array of spiking chem synapses in this neural module.
int m_iID
Identifier ID for this connection.
Definition: Connexion.h:99
std::string m_strProjectPath
Full pathname of the string project file for this module.
Definition: NeuralModule.h:47
float m_fltTimeStep
The DT time step for this neural module in seconds.
Definition: NeuralModule.h:40
virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false)
Adds a new object to this parent.
void IncNonSpikingSynCond(double cond)
Increment non-spiking syn conductance.
double m_dCurrentTime
Current time of the simulation.
double * GetTimeToNextSpikePtr()
Gets the time to next spike pointer.
Definition: Connexion.h:170
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.
void DecrementFacilitation()
Decrements the facilitation.
Definition: Connexion.cpp:278
virtual void AddSynapse(std::string strXml, bool bDoNotInit)
Adds a synapse by xml.
static double m_dDT
The statoc time step.
double m_dTimeStep
The time step of the neural module.
void CalcUpdate(IntegrateFireNeuralModule *lpNS)
Calculates the update during a time step.
std::string m_strType
The type for this object. Examples are Box, Plane, Neuron, etc..
Definition: AnimatBase.h:58
double m_dDelay
The synaptic delay.
Definition: Connexion.h:102
Contains all of the classes to implement a basic integrate and fire neural model. ...
Declares the non spiking chemical synapse class.
std::string m_strName
The name for this object.
Definition: AnimatBase.h:61
Declares the neuron class.
void CalcUpdate()
Calculates the update during the step of the simulation.
bool m_bUseCriticalPeriod
true to use critical period during hebbian learning.