85 {
Std_TraceMsg(0,
"Caught Error in desctructor of Neuron\r\n",
"", -1,
false,
true);}
389 Std_InValidRange((
float) 0, (
float) 1, fltVal,
true,
"RelativeAccomodation");
435 void Neuron::Iinit(
float fltVal) {
m_fltIinit = fltVal;}
439 void Neuron::InitTime(
float fltVal)
526 {
return RUGULAR_NEURON;}
530 Node::Copy(lpSource);
585 THROW_ERROR(Nl_Err_lSynapseToAddNull, Nl_Err_strSynapseToAddNull);
600 oXml.Deserialize(strXml);
601 oXml.FindElement(
"Root");
602 oXml.FindChildElement(
"Synapse");
620 THROW_ERROR(Std_Err_lInvalidIndex, Std_Err_strInvalidIndex);
652 THROW_ERROR(Std_Err_lInvalidIndex, Std_Err_strInvalidIndex);
672 for(
int iIndex=0; iIndex<iCount; iIndex++)
677 THROW_TEXT_ERROR(Nl_Err_lSynapseNotFound, Nl_Err_strSynapseNotFound,
"ID");
787 if(fltFreq<1e-6) fltFreq = 0;
788 if(fltFreq>1) fltFreq = 1;
804 if(fltFreq<1e-6) fltFreq = 0;
805 if(fltFreq>1) fltFreq = 1;
837 unsigned char iSynapse, iCount;
838 float fltSynapticI=0;
842 for(iSynapse=0; iSynapse<iCount; iSynapse++)
847 lpSynapse->
Process(fltSynapticI);
872 for(
int iIndex=0; iIndex<iCount; iIndex++)
878 Node::SetSystemPointers(lpSim, lpStructure, lpModule, lpNode,
false);
887 Node::VerifySystemPointers();
890 THROW_PARAM_ERROR(Al_Err_lUnableToCastNeuralModuleToDesiredType, Al_Err_strUnableToCastNeuralModuleToDesiredType,
"ID: ",
m_lpFRModule->
ID());
893 THROW_PARAM_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Link: ",
m_strID);
919 for(
int iSynapse=0; iSynapse<iCount; iSynapse++)
929 #pragma region DataAccesMethods
935 if(strType ==
"INTRINSICCURRENT")
938 if(strType ==
"EXTERNALCURRENT")
941 if(strType ==
"SYNAPTICCURRENT")
944 if(strType ==
"ADAPTERCURRENT")
947 if(strType ==
"TOTALCURRENT")
950 if(strType ==
"MEMBRANEVOLTAGE")
953 if(strType ==
"FIRINGFREQUENCY")
956 if(strType ==
"NOISEVOLTAGE")
959 if(strType ==
"THRESHOLD")
965 if(strType ==
"VREST")
968 if(strType ==
"ACCOMTIMEMOD")
972 THROW_PARAM_ERROR(Nl_Err_lInvalidNeuronDataType, Nl_Err_strInvalidNeuronDataType,
"Neuron Data Type", strDataType);
977 bool Neuron::SetData(
const std::string &strDataType,
const std::string &strValue,
bool bThrowError)
981 if(Node::SetData(strDataType, strValue,
false))
986 Cn(atof(strValue.c_str()));
992 Gn(atof(strValue.c_str()));
998 Vth(atof(strValue.c_str()));
1002 if(strType ==
"VREST")
1004 Vrest(atof(strValue.c_str()));
1008 if(strType ==
"RELATIVEACCOMMODATION")
1014 if(strType ==
"ACCOMMODATIONTIMECONSTANT")
1020 if(strType ==
"VNOISEMAX")
1026 if(strType ==
"FMIN")
1028 Fmin(atof(strValue.c_str()));
1032 if(strType ==
"GAIN")
1034 Gain(atof(strValue.c_str()));
1038 if(strType ==
"GAINTYPE")
1044 if(strType ==
"ADDEXTERNALCURRENT")
1050 if(strType ==
"IINIT")
1052 Iinit(atof(strValue.c_str()));
1056 if(strType ==
"INITTIME")
1058 InitTime(atof(strValue.c_str()));
1064 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
1069 void Neuron::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
1071 Node::QueryProperties(aryProperties);
1073 aryProperties.Add(
new TypeProperty(
"IntrinsicCurrent", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1074 aryProperties.Add(
new TypeProperty(
"ExternalCurrent", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1075 aryProperties.Add(
new TypeProperty(
"SynapticCurrent", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1076 aryProperties.Add(
new TypeProperty(
"AdapterCurrent", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1077 aryProperties.Add(
new TypeProperty(
"TotalCurrent", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1078 aryProperties.Add(
new TypeProperty(
"MembraneVoltage", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1079 aryProperties.Add(
new TypeProperty(
"FiringFrequency", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1080 aryProperties.Add(
new TypeProperty(
"NoiseVoltage", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1081 aryProperties.Add(
new TypeProperty(
"Threshold", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1082 aryProperties.Add(
new TypeProperty(
"AccomTimeMod", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1084 aryProperties.Add(
new TypeProperty(
"Cm", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1085 aryProperties.Add(
new TypeProperty(
"Gm", AnimatPropertyType::Float, AnimatPropertyDirection::Both));
1086 aryProperties.Add(
new TypeProperty(
"Vth", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1087 aryProperties.Add(
new TypeProperty(
"Vrest", AnimatPropertyType::Float, AnimatPropertyDirection::Both));
1088 aryProperties.Add(
new TypeProperty(
"RelativeAccommodation", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1089 aryProperties.Add(
new TypeProperty(
"AccommodationTimeConstant", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1090 aryProperties.Add(
new TypeProperty(
"VNoiseMax", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1091 aryProperties.Add(
new TypeProperty(
"Fmin", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1092 aryProperties.Add(
new TypeProperty(
"Gain", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1093 aryProperties.Add(
new TypeProperty(
"GainType", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
1094 aryProperties.Add(
new TypeProperty(
"AddExternalCurrent", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1095 aryProperties.Add(
new TypeProperty(
"Iinit", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1096 aryProperties.Add(
new TypeProperty(
"InitTime", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1099 bool Neuron::AddItem(
const std::string &strItemType,
const std::string &strXml,
bool bThrowError,
bool bDoNotInit)
1103 if(strType ==
"SYNAPSE")
1112 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Item Type", strItemType);
1121 if(strType ==
"SYNAPSE")
1129 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Item Type", strItemType);
1144 memcpy((
void *) (aryBytes+lIndex), (
void *)
m_aryVn,
sizeof(
m_aryVn));
1156 memcpy((
void *) (aryBytes+lIndex), (
void *)&
m_fltVn,
sizeof(
m_fltVn));
1165 memcpy((
void *)
m_aryVn, (
void *) (aryBytes+lIndex) ,
sizeof(
m_aryVn));
1177 memcpy((
void *)&
m_fltVn, (
void *) (aryBytes+lIndex),
sizeof(
m_fltVn));
1184 void Neuron::Load(CStdXml &oXml)
1194 Enabled(oXml.GetChildBool(
"Enabled",
true));
1196 Cn(oXml.GetChildFloat(
"Cn"));
1197 Gn(oXml.GetChildFloat(
"Gn"));
1198 Vrest(oXml.GetChildFloat(
"Vrest", 0));
1199 Vth(oXml.GetChildFloat(
"Vth"));
1200 Fmin(oXml.GetChildFloat(
"Fmin"));
1201 Gain(oXml.GetChildFloat(
"Gain"));
1202 ExternalI(oXml.GetChildFloat(
"ExternalI"));
1204 Iinit(oXml.GetChildFloat(
"Iinit",
m_fltIinit));
1210 GainType(oXml.GetChildBool(
"GainType",
true));
1228 if(oXml.FindChildElement(
"Synapses",
false))
1232 iCount = oXml.NumberOfChildren();
1233 for(iIndex=0; iIndex<iCount; iIndex++)
1235 oXml.FindChildByIndex(iIndex);
1259 std::string strType;
1265 strType = oXml.GetChildString(
"Type");
1270 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Synapse");
1273 lpSynapse->Load(oXml);
1278 catch(CStdErrorInfo oError)
1280 if(lpSynapse)
delete lpSynapse;
1281 RELAY_ERROR(oError);
1286 if(lpSynapse)
delete lpSynapse;
1287 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
virtual void Process(float &fltCurrent)
Processes this synapse.
float m_fltIinit
The initialization current to turn on at the beginning of the simulation.
Firing rate neural module.
bool InactiveArray()
Gets the inactive array.
virtual bool UseNoise()
Gets whether to use noise.
float m_fltAdapterI
current added from all of the adapters.
virtual void Initialize()
Initializes this object.
float m_fltAccomTimeConst
The accomodation time constant tells how fast the neuron accomodates to a new membrane potential...
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
virtual float Gn()
Gets the membrane conductance.
virtual float Fmin()
Gets the minimum firing frequency.
virtual float TimeStep()
Gets the time step for this moudle in time units.
virtual void Initialize()
Initializes this object.
virtual float AccommodationTimeConstant()
Gets the accomodation time constant.
virtual Synapse * GetSynapse(int iIndex)
Gets a synapse by its index in the array.
float m_fltFiringFreq
Current firing frequency.
virtual void AddSynapse(Synapse *lpSynapse)
Adds a synapse to this neuron.
Simulator * m_lpSim
The pointer to a Simulation.
virtual void RemoveSynapse(int iIndex)
Removes the synapse described by iIndex.
virtual std::string ID()
Gets the unique GUID ID of this object.
float m_fltVndisp
this is the membrane voltage that is reported back to animatlab.
float m_fltAccomTimeMod
If we are setting the accomodation time constant through modulation then this keeps track of it...
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual float Vth()
Gets the voltage threshold for firing.
virtual float Cn()
Gets the membrane capacitance.
virtual float Vrest()
Gets the rest potential.
float m_fltVNoise
This is the random noise that should be added to the membrane voltage at a timestep.
float m_fltVthadd
The component added to Vthi for accomodation.
float m_fltVNoiseMax
Tells the maximum noise to use when running sim.
bool Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError, std::string strParamName)
Tests whether a number is within a valid range.
CStdPtrArray< Synapse > m_arySynapses
The array of synapses that are in-coming to this neuron.
virtual bool SimRunning()
Gets whether the simulation is running.
Organism * m_lpOrganism
The pointer to this node's organism.
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
AnimatSim::Environment::Structure * m_lpStructure
The pointer to this items parent Structure. If this is not relevant for this object then this is NULL...
virtual bool Enabled()
Tells whether this node is enabled.
std::string m_strID
The unique Id for this object.
virtual float CalculateIntrinsicCurrent(FiringRateModule *lpModule, float fltInputCurrent)
Calculates the intrinsic current.
std::string Std_Trim(std::string strVal)
Trims a string.
virtual ~Neuron()
Destructor.
float m_aryVn[2]
Current and next Membrane voltage. Vn.
float m_fltExternalI
Externally injected current.
virtual void StepSimulation()
Step the simulation for this object.
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.
virtual void ClearSynapses()
Clears the synapses list.
virtual int TotalSynapses()
Gets the total number of synapses.
virtual CStdSerialize * CreateObject(std::string strModule, std::string strClassName, std::string strType, bool bThrowError=true)
Creates an object using a class factory.
float m_fltAdapterMemoryI
Used to allow datacharts to track current input from adapters.
virtual unsigned char NeuronType()
Gets the neuron type.
virtual bool UseAccom()
Gets whether to use accommodation.
float m_fltFmin
Minimum Firing frequency.
virtual float ExternalI()
Gets the external current.
float m_fltIntrinsicI
Intrinsic current.
float m_fltInvCn
Inverse membrane capacitance.
Firing Rate Neuron model.
virtual CStdPtrArray< Synapse > * GetSynapses()
Gets a pointer to the synapses array.
bool m_bUseAccom
true use accomodation
virtual long CalculateSnapshotByteSize()
Calculates the snapshot byte size.
virtual float CalculateSynapticCurrent(FiringRateModule *lpModule)
Calculates the total incoming synaptic current.
virtual void VerifySystemPointers()
Verify that system pointers have been set correctly.
float m_fltInitTime
The duration for how long the Iinit current is on at the beginning of the simulation.
float m_fltVn
Current membrane voltage.
virtual float FiringFreq(FiringRateModule *lpModule)
Calculates the current firing frequency.
virtual float Vn()
Gets the membrane voltage.
virtual void SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Saves a key frame snapshot.
Declares the synapse class.
virtual void AddExternalNodeInput(int iTargetDataType, float fltInput)
Adds an external node input.
bool Std_ToBool(int iVal)
Converts a value toa bool.
virtual int FindSynapseListPos(std::string strID, bool bThrowError=true)
Searches for a synapse with the specified ID and returns its position in the list.
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.
virtual float VNoiseMax()
Gets the maximum noise voltage.
float m_fltVth
Firing frequency voltage threshold.
Declares the firing rate module class.
bool m_bEnabled
Tells if this item is enabled or not. If it is not enabled then it is not run.
virtual float Gain()
Gets the firing frequency gain.
virtual float RelativeAccommodation()
Gets the relative accomodation.
float Std_FRand(float low, float high)
Generates a random number between two values.
float m_fltRelativeAccom
The relative accomodation rate.
virtual float IntrinsicCurrent()
Gets the intrinsic current.
float m_fltCn
Membrane capacitance.
float m_fltVthi
Initial firing frequency voltage threshold.
virtual void AddExternalI(float fltVal)
Adds to the external current.
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
Neuron * FromNeuron()
Gets the pre-synaptic neuron.
virtual void LoadKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Loads a key frame snapshot.
bool ActiveArray()
Gets the active array.
Contains the classes for a firing rate neural model.
virtual void ResetSimulation()
Resets the simulation back to time 0.
Firing rate synapse model.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual void TimeStepModified()
Notification method that the time step modified has been modified. Objects should recalculate any sli...
Neuron()
Default constructor.
float m_fltTotalMemoryI
Total current applied to the neuron.
virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false)
Adds a new object to this parent.
bool m_bUseNoise
Tells if we should use noise or not.
float m_fltGn
Membrane conductance.
virtual float Time()
Gets the current simulation time in seconds.
float m_fltDCTH
expon decline working factor for thresh accomm
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.
virtual float CalculateFiringFrequency(float fltVn, float fltVth)
Calculates the firing frequency of the neuron.
virtual void InjectCurrent(float fltVal)
Injects current into this neuron.
bool m_bGainType
Tells whether to use the old type gain or new type gain.
virtual bool Enabled()
Gets whether the link is enabled.
Synapse * LoadSynapse(CStdXml &oXml)
Loads a synapse.
float m_fltSynapticI
Current synaptic current.
float m_fltVthdisp
this is the theshold voltage that is reported back to animatlab.
float m_aryVth[2]
Current and next threshold voltage. Vth.
FiringRateModule * m_lpFRModule
Pointer to the parent FiringRateModule.
float m_fltVrest
this is the resting potential of the neuron.
virtual bool GainType()
Gets the gain type. (Old way or new way)