11 #include "CsNeuralModule.h"
29 m_iNeuralType = EXCITATORY_NEURON;
52 m_lTotalSpikesCollected = 0;
79 {
Std_TraceMsg(0,
"Caught Error in desctructor of CsNeuronGroup\r\n",
"", -1,
false,
true);}
82 void CsNeuronGroup::NeuronCount(
unsigned int iVal)
90 void NeuralType(std::string strType);
92 void CsNeuronGroup::NeuralType(std::string strType)
96 if(strNtype ==
"EXCITATORY")
97 m_iNeuralType = EXCITATORY_NEURON;
98 else if(strNtype ==
"INHIBITORY")
99 m_iNeuralType = INHIBITORY_NEURON;
101 THROW_PARAM_ERROR(Cs_Err_strInvalidNeuralType, Cs_Err_lInvalidNeuralType,
"Type: ",
m_strType);
104 void CsNeuronGroup::NeuralType(
int iVal)
106 m_iNeuralType = iVal;
109 int CsNeuronGroup::NeuralType() {
return m_iNeuralType;}
111 void CsNeuronGroup::GroupID(
int iVal)
119 int CsNeuronGroup::GroupID() {
return m_iGroupID;}
121 void CsNeuronGroup::A(
float fltVal) {
m_fltA = fltVal;}
123 float CsNeuronGroup::A() {
return m_fltA;}
125 void CsNeuronGroup::StdA(
float fltVal) {
m_fltStdA = fltVal;}
127 float CsNeuronGroup::StdA() {
return m_fltStdA;}
129 void CsNeuronGroup::B(
float fltVal) {
m_fltB = fltVal;}
131 float CsNeuronGroup::B() {
return m_fltB;}
133 void CsNeuronGroup::StdB(
float fltVal) {
m_fltStdB = fltVal;}
135 float CsNeuronGroup::StdB() {
return m_fltStdB;}
137 void CsNeuronGroup::C(
float fltVal) {
m_fltC = fltVal;}
139 float CsNeuronGroup::C() {
return m_fltC;}
141 void CsNeuronGroup::StdC(
float fltVal) {
m_fltStdC = fltVal;}
143 float CsNeuronGroup::StdC() {
return m_fltStdC;}
145 void CsNeuronGroup::D(
float fltVal) {
m_fltD = fltVal;}
147 float CsNeuronGroup::D() {
return m_fltD;}
149 void CsNeuronGroup::StdD(
float fltVal) {
m_fltStdD = fltVal;}
151 float CsNeuronGroup::StdD() {
return m_fltStdD;}
153 void CsNeuronGroup::EnableCOBA(
bool bVal) {
m_bEnableCOBA = bVal;}
157 void CsNeuronGroup::TauAMPA(
float fltVal)
165 void CsNeuronGroup::TauNMDA(
float fltVal)
173 void CsNeuronGroup::TauGABAa(
float fltVal)
181 void CsNeuronGroup::TauGABAb(
float fltVal)
189 void CsNeuronGroup::EnableSTP(
bool bVal) {
m_bEnableSTP = bVal;}
193 void CsNeuronGroup::U(
float fltVal)
199 float CsNeuronGroup::U() {
return m_fltU;}
201 void CsNeuronGroup::TauDepression(
float fltVal)
209 void CsNeuronGroup::TauFacilitation(
float fltVal)
211 Std_IsAboveMin((
float) 0, fltVal,
true,
"TauFacilitation",
false);
217 void CsNeuronGroup::EnableSTDP(
bool bVal) {
m_bEnableSTDP = bVal;}
221 void CsNeuronGroup::MaxLTP(
float fltVal)
227 float CsNeuronGroup::MaxLTP() {
return m_fltMaxLTP;}
229 void CsNeuronGroup::TauLTP(
float fltVal)
235 float CsNeuronGroup::TauLTP() {
return m_fltTauLTP;}
237 void CsNeuronGroup::MaxLTD(
float fltVal)
243 float CsNeuronGroup::MaxLTD() {
return m_fltMaxLTD;}
245 void CsNeuronGroup::TauLTD(
float fltVal)
251 float CsNeuronGroup::TauLTD() {
return m_fltTauLTD;}
253 void CsNeuronGroup::CollectFromWholePopulation(
bool bVal)
265 bool CsNeuronGroup::CollectFromWholePopulation()
273 std::multimap<int, unsigned long> *CsNeuronGroup::SpikeTimes() {
return &
m_arySpikeTimes;}
275 void CsNeuronGroup::IncrementCollectSpikeDataForNeuron(
int iIdx)
277 CStdMap<int, int>::iterator oPos;
281 int iVal = oPos->second;
288 void CsNeuronGroup::DecrementCollectSpikeDataForNeuron(
int iIdx)
290 CStdMap<int, int>::iterator oPos;
294 int iVal = oPos->second-1;
302 bool CsNeuronGroup::CollectingSpikeDataForNeuron(
int iIdx)
309 Node::Copy(lpSource);
315 m_iNeuralType = lpOrig->m_iNeuralType;
345 void CsNeuronGroup::SetCARLSimulation()
382 for (
int t=0; t<10; t++)
384 for (
int i=0; i<timeCounts[t]; i++)
386 int id = NeuronIds[pos];
393 m_lTotalSpikesCollected++;
395 MonitoredSpikeEvent(grpId,
id, lTime);
426 Node::ResetSimulation();
433 m_lTotalSpikesCollected = 0;
440 void CsNeuronGroup::SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode,
bool bVerify)
442 Node::SetSystemPointers(lpSim, lpStructure, lpModule, lpNode,
false);
451 Node::VerifySystemPointers();
454 THROW_PARAM_ERROR(Al_Err_lUnableToCastNeuralModuleToDesiredType, Al_Err_strUnableToCastNeuralModuleToDesiredType,
"ID: ",
m_lpCsModule->
ID());
457 THROW_PARAM_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Link: ",
m_strID);
460 #pragma region DataAccesMethods
466 if(Node::SetData(strDataType, strValue,
false))
469 if(strType ==
"NEURONCOUNT")
471 NeuronCount((
unsigned int) atoi(strValue.c_str()));
475 if(strType ==
"NEURALTYPE")
477 NeuralType(strValue);
483 A(atof(strValue.c_str()));
487 if(strType ==
"STDA")
489 StdA(atof(strValue.c_str()));
495 B(atof(strValue.c_str()));
499 if(strType ==
"STDB")
501 StdB(atof(strValue.c_str()));
507 C(atof(strValue.c_str()));
511 if(strType ==
"STDC")
513 StdC(atof(strValue.c_str()));
519 D(atof(strValue.c_str()));
523 if(strType ==
"STDD")
525 StdD(atof(strValue.c_str()));
529 if(strType ==
"ENABLECOBA")
535 if(strType ==
"TAUAMPA")
537 TauAMPA(atof(strValue.c_str()));
541 if(strType ==
"TAUNMDA")
543 TauNMDA(atof(strValue.c_str()));
547 if(strType ==
"TAUGABAA")
549 TauGABAa(atof(strValue.c_str()));
553 if(strType ==
"TAUGABAB")
555 TauGABAb(atof(strValue.c_str()));
559 if(strType ==
"ENABLESTP")
567 U(atof(strValue.c_str()));
571 if(strType ==
"TAUD")
573 TauDepression(atof(strValue.c_str()));
577 if(strType ==
"TAUF")
579 TauFacilitation(atof(strValue.c_str()));
583 if(strType ==
"ENABLESTDP")
589 if(strType ==
"MAXLTP")
591 MaxLTP(atof(strValue.c_str()));
595 if(strType ==
"TAULTP")
597 TauLTP(atof(strValue.c_str()));
601 if(strType ==
"MAXLTD")
603 MaxLTD(atof(strValue.c_str()));
607 if(strType ==
"TAULTD")
609 TauLTD(atof(strValue.c_str()));
615 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
620 void CsNeuronGroup::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
622 Node::QueryProperties(aryProperties);
624 aryProperties.Add(
new TypeProperty(
"NeuronCount", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
625 aryProperties.Add(
new TypeProperty(
"NeuralType", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
626 aryProperties.Add(
new TypeProperty(
"A", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
627 aryProperties.Add(
new TypeProperty(
"StdA", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
628 aryProperties.Add(
new TypeProperty(
"B", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
629 aryProperties.Add(
new TypeProperty(
"StdB", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
630 aryProperties.Add(
new TypeProperty(
"C", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
631 aryProperties.Add(
new TypeProperty(
"StdC", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
632 aryProperties.Add(
new TypeProperty(
"D", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
633 aryProperties.Add(
new TypeProperty(
"StdD", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
635 aryProperties.Add(
new TypeProperty(
"EnableCOBA", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
636 aryProperties.Add(
new TypeProperty(
"TauAMPA", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
637 aryProperties.Add(
new TypeProperty(
"TauNMDA", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
638 aryProperties.Add(
new TypeProperty(
"TauGABAa", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
639 aryProperties.Add(
new TypeProperty(
"TauGABAb", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
641 aryProperties.Add(
new TypeProperty(
"EnableSTP", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
642 aryProperties.Add(
new TypeProperty(
"U", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
643 aryProperties.Add(
new TypeProperty(
"TauD", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
644 aryProperties.Add(
new TypeProperty(
"TauF", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
646 aryProperties.Add(
new TypeProperty(
"EnableSTDP", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
647 aryProperties.Add(
new TypeProperty(
"MaxLTP", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
648 aryProperties.Add(
new TypeProperty(
"TauLTP", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
649 aryProperties.Add(
new TypeProperty(
"MaxLTD", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
650 aryProperties.Add(
new TypeProperty(
"TauLTD", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
657 float *lpData = NULL;
659 if(strType ==
"ENABLE")
661 else if(strType ==
"GROUPFIRINGRATE")
663 else if(strType ==
"GROUPTOTALSPIKES")
665 else if(strType ==
"SPIKE")
668 return Node::GetDataPointer(strDataType);
673 void CsNeuronGroup::Load(CStdXml &oXml)
679 Enabled(oXml.GetChildBool(
"Enabled",
true));
682 NeuralType(oXml.GetChildString(
"NeuralType",
"Excitatory"));
683 A(oXml.GetChildFloat(
"A",
m_fltA));
684 StdA(oXml.GetChildFloat(
"StdA",
m_fltStdA));
685 B(oXml.GetChildFloat(
"B",
m_fltB));
686 StdB(oXml.GetChildFloat(
"StdB",
m_fltStdB));
687 C(oXml.GetChildFloat(
"C",
m_fltC));
688 StdC(oXml.GetChildFloat(
"StdC",
m_fltStdC));
689 D(oXml.GetChildFloat(
"D",
m_fltD));
690 StdD(oXml.GetChildFloat(
"StdD",
m_fltStdD));
698 EnableSTP(oXml.GetChildBool(
"EnableSTP",
m_bEnableSTP));
699 U(oXml.GetChildFloat(
"U",
m_fltU));
float m_fltMaxLTD
the max magnitude for LTD change for STDP
Contains the classes for a firing rate neural model.
int createGroup(const string &_name, unsigned int _numN, int _nType, int configId=ALL)
creates a group of Izhikevich spiking neurons
bool m_bEnableSTDP
Tells whether this group of neurons exhibits spike-timing dependent plasticity.
virtual ~CsNeuronGroup()
Destructor.
std::multimap< int, unsigned long > m_arySpikeTimes
A map for keeping track of a spike times in ms for individual neurons in this group throughout the cu...
boost::interprocess::interprocess_mutex m_AccessRecentSpikes
mutex used to try and access matches variable.
Declares the CsNeuronGroup class.
unsigned int m_uiNeuronCount
The number of neurons in this group.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
float m_fltStdC
The standard deviation for Izhikevich parameter C.
void setSpikeMonitor(int gid, SpikeMonitor *spikeMon=NULL, int configId=ALL)
virtual void ResetSimulation()
Resets the simulation back to time 0.
float m_fltEnabled
This is used for reporting the enabled state in a GetDataPointer call.
float m_fltTauNMDA
Time constant of NMDA decay (ms); for example, 150.0.
float m_fltTauFacilitation
the time constant for facilitation term for STP
virtual std::string ID()
Gets the unique GUID ID of this object.
float m_fltMaxLTP
the max magnitude for LTP change for STDP
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
int m_iGroupID
The group ID of this set of neurons.
float m_fltTauGABAa
Time constant of GABAa decay (ms); for example, 6.0.
CsNeuronGroup()
Default constructor.
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 Enabled()
Tells whether this node is enabled.
std::string m_strID
The unique Id for this object.
float m_fltTauLTD
the decay time constant for LTD change for STDP
float m_fltGroupTotalSpikes
The total number of spikes generated by this group of neurons in the last time slice.
void setNeuronParameters(int groupId, float _a, float a_sd, float _b, float b_sd, float _c, float c_sd, float _d, float d_sd, int configId=ALL)
Sets the Izhikevich parameters a, b, c, and d of a neuron group.
Firing rate neural module.
float m_fltC
The Izhikevich C parameter.
float m_fltB
The Izhikevich B parameter.
virtual void Initialize()
Initializes this object.
CsNeuralModule * m_lpCsModule
Pointer to parent CsNeuralModule.
Declares the synapse class.
float m_fltStdB
The standard deviation for Izhikevich parameter B.
Firing Rate Neuron model.
virtual void update(CpuSNN *s, int grpId, unsigned int *NeuronIds, unsigned int *timeCounts, unsigned int total_spikes, float firing_Rate)
Controls actions that are performed when certain neurons fire (user-defined).
float m_fltStdD
The standard deviation for Izhikevich parameter D.
bool Std_ToBool(int iVal)
Converts a value toa bool.
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.
float m_fltD
The Izhikevich D parameter.
float m_fltTauGABAb
Time constant of GABAb decay (ms); for example, 150.0.
bool m_bEnabled
Tells if this item is enabled or not. If it is not enabled then it is not run.
CStdMap< int, int > m_aryCollectSpikeData
An array of neuron indices for individual neurons we want to collect spike data for throughout the cu...
virtual void AddExternalNodeInput(int iTargetDataType, float fltInput)
Adds an external node input.
float m_fltTauLTP
the decay time constant for LTP change for STDP
virtual void StepSimulation()
Step the simulation for this object.
unsigned long m_lLastUpdateTime
The last time step for which the monitor method ran.
float m_fltA
The Izhikevich A parameter.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual void VerifySystemPointers()
Verify that system pointers have been set correctly.
float m_fltU
the increment of u due to a spike for STP
bool m_bEnableSTP
Tells whether this group of neurons exhibits Short term plasticity.
float m_fltTauDepression
the time constant for depression term for STP
float m_fltStdA
The standard deviation for Izhikevich parameter A.
float m_fltTauAMPA
Time constant of AMPA decay (ms); for example, 5.0.
std::string m_strType
The type for this object. Examples are Box, Plane, Neuron, etc..
int m_iCollectWholePopulation
If > 0 it collects data from the whole population. This is an iterator keeping track of how many thin...
Contains all of CARLsim's core functionality.
std::string m_strName
The name for this object.
float m_fltGroupFiringRate
The firing rate of this entire group of neurons.