10 #include "CsNeuralModule.h"
34 m_ulSpikeTestTime = 0;
37 m_lTotalSpikesAdded = 0;
51 m_arySpikeTimes.RemoveAll();
54 {
Std_TraceMsg(0,
"Caught Error in desctructor of CsSpikingCurrentSynapse\r\n",
"", -1,
false,
true);}
57 void CsSpikingCurrentSynapse::PulseDecay(
float fltVal)
70 void CsSpikingCurrentSynapse::PulseCurrent(
float fltVal)
79 void CsSpikingCurrentSynapse::Coverage(std::string strType)
82 if(strVal ==
"INDIVIDUALS")
83 WholePopulation(
false);
84 else if(strVal ==
"WHOLEPOPULATION")
85 WholePopulation(
true);
87 THROW_PARAM_ERROR(Cs_Err_lInvalidFiringRateCoverage, Cs_Err_strInvalidFiringRateCoverage,
"Coverage", strType);
92 void CsSpikingCurrentSynapse::WholePopulation(
bool bVal)
100 void CsSpikingCurrentSynapse::Cells(std::string strXml)
103 oXml.Deserialize(strXml);
104 oXml.FindElement(
"Root");
105 oXml.FindChildElement(
"Cells");
110 void CsSpikingCurrentSynapse::CalculateStepsPerTest()
112 m_ulSpikeTestTime = 0;
114 m_ulSpikeTestTime = 0;
127 Link::TimeStepModified();
132 CalculateStepsPerTest();
135 void CsSpikingCurrentSynapse::MonitorSpikeEventFired(
int iGroupID,
int iNeuronID,
long lTimeIdx)
140 m_arySpikeTimes.Add(lTimeIdx);
155 THROW_PARAM_ERROR(Al_Err_lNodeNotFound, Al_Err_strNodeNotFound,
"ID: ",
m_strFromID);
159 THROW_PARAM_ERROR(Al_Err_lNodeNotFound, Al_Err_strNodeNotFound,
"ID: ",
m_strToID);
161 CalculateStepsPerTest();
168 if(m_MonitoredSpikeEvent.connected())
169 m_MonitoredSpikeEvent.disconnect();
171 m_MonitoredSpikeEvent =
m_lpFromNeuron->MonitoredSpikeEvent.connect(boost::bind(&CsSpikingCurrentSynapse::MonitorSpikeEventFired,
this, _1, _2, _3));
175 #pragma region DataAccesMethods
181 float *lpData = NULL;
183 if(strType ==
"APPLIEDCURRENT")
185 else if(strType ==
"DECREMENTCURRENT")
188 return Link::GetDataPointer(strDataType);
193 AnimatBase::VerifySystemPointers();
196 THROW_PARAM_ERROR(Al_Err_lStructureNotDefined, Al_Err_strStructureNotDefined,
"Link: ",
m_strID);
199 THROW_PARAM_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Link: ",
m_strID);
202 THROW_PARAM_ERROR(Al_Err_lNeuralModuleNotDefined, Al_Err_strNeuralModuleNotDefined,
"Link: ",
m_strID);
209 if(Link::SetData(strDataType, strValue,
false))
212 if(strType ==
"PULSEDECAY")
214 PulseDecay(atof(strValue.c_str()));
217 else if(strType ==
"PULSECURRENT")
219 PulseCurrent(atof(strValue.c_str()));
222 else if(strType ==
"COVERAGE")
227 else if(strType ==
"CELLS")
236 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
241 void CsSpikingCurrentSynapse::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
243 Link::QueryProperties(aryProperties);
245 aryProperties.Add(
new TypeProperty(
"AppliedCurrent", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
246 aryProperties.Add(
new TypeProperty(
"DecrementCurrent", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
248 aryProperties.Add(
new TypeProperty(
"PulseDecay", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
249 aryProperties.Add(
new TypeProperty(
"PulseCurrent", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
250 aryProperties.Add(
new TypeProperty(
"Coverage", AnimatPropertyType::String, AnimatPropertyDirection::Set));
251 aryProperties.Add(
new TypeProperty(
"Cells", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
258 Link::ResetSimulation();
264 m_ulSpikeTestTime = 0;
265 m_lTotalSpikesAdded = 0;
268 void CsSpikingCurrentSynapse::ProcessSpikes()
276 if(m_arySpikeTimes.GetSize() > 0)
279 long lNextTime = m_arySpikeTimes[iIdx];
282 while(lNextTime <= m_ulSpikeTestTime && !bDone)
285 m_lTotalSpikesAdded++;
290 if(iIdx >= m_arySpikeTimes.GetSize())
293 lNextTime = m_arySpikeTimes[iIdx];
299 for(
int iIdx2=0; iIdx2<iIdx; iIdx2++)
300 m_arySpikeTimes.RemoveAt(0);
331 void CsSpikingCurrentSynapse::LoadCells(CStdXml &oXml)
335 int iCount = oXml.NumberOfChildren();
336 for(
int iIdx=0; iIdx<iCount; iIdx++)
338 oXml.FindChildByIndex(iIdx);
339 int iNeuronIdx = oXml.GetChildInt();
342 THROW_PARAM_ERROR(Cs_Err_lInvalidNeuralIndex, Cs_Err_strInvalidNeuralIndex,
"Neuron Index", iNeuronIdx);
350 void CsSpikingCurrentSynapse::Load(CStdXml &oXml)
358 THROW_TEXT_ERROR(Std_Err_lBlankAttrib, Std_Err_strBlankAttrib,
"Attribute: FromID");
362 THROW_TEXT_ERROR(Std_Err_lBlankAttrib, Std_Err_strBlankAttrib,
"Attribute: ToID");
367 Coverage(oXml.GetChildString(
"Coverage",
"WholePopulation"));
369 if(oXml.FindChildElement(
"Cells",
false))
Contains the classes for a firing rate neural model.
float m_fltDecrementCurrent
The amount by which the current is decremented each step.
float m_fltPulseDecay
The decay rate for which a current pulse.
CStdMap< int, int > m_aryCells
An array of neuron indices for individual neurons we want to stimulate.
AnimatSim::Behavior::NeuralModule * m_lpModule
The pointer to this items parentNeuralModule. If this is not relevant for this object then this is NU...
virtual float TimeStep()
Gets the time step for this moudle in time units.
Declares the CsNeuronGroup class.
float m_fltPulseSign
The sign of the current to apply for a single pulse.
int m_iStepsPerTestCount
Keeps track of how my steps we have take tiil we are ready to test again.
virtual void AddExternalNodeInput(int iTargetDataType, float fltInput)=0
Adds an external node input.
virtual void ResetSimulation()
Resets the simulation back to time 0.
Simulator * m_lpSim
The pointer to a Simulation.
float m_fltAppliedCurrent
The actual applied current with sign.
boost::interprocess::interprocess_mutex m_AccessSpikes
mutex used to try and access matches variable.
virtual ~CsSpikingCurrentSynapse()
Destructor.
virtual void StepSimulation()
Step the simulation for this object.
virtual void Initialize()
Initializes this object.
int Std_Sign(float fltVal)
Determines the sign of a number.
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
AnimatSim::Environment::Structure * m_lpStructure
The pointer to this items parent Structure. If this is not relevant for this object then this is NULL...
std::string m_strID
The unique Id for this object.
float m_fltPulseTC
The exponential decay constant calculated from the time step and decay rate.
AnimatSim::Node * m_lpToNeuron
The pointer to post-synaptic neuron.
CsNeuronGroup * m_lpFromNeuron
The pointer to pre-synaptic neuron.
std::string m_strToID
GUID ID of the pre-synaptic neruon.
virtual void VerifySystemPointers()
Verify that system pointers have been set correctly.
Firing Rate Neuron model.
virtual AnimatBase * FindByID(std::string strID, bool bThrowError=true)
Searches for the object with the specified ID.
CsSpikingCurrentSynapse()
Default constructor.
Declares the synapse class.
int m_iStepsPerTest
Keeps track of the number of steps till we need to test for spikes to process.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
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.
bool m_bWholePopulation
Tells whether this entire population is monitored or just individual cells.
bool m_bEnabled
Tells if this item is enabled or not. If it is not enabled then it is not run.
Base class for body parts and neural network nodes.
virtual void TimeStepModified()
Notification method that the time step modified has been modified. Objects should recalculate any sli...
float m_fltCurrentMagnitude
The magnitude of the current applied to the target neuron.
bool Std_IsBlank(std::string strVal)
Trims a string and tests if a string is blank.
std::string m_strFromID
GUID ID of the pre-synaptic neruon.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
float m_fltPulseMagnitude
The magnitude amount of the current to apply for a single pulse.
Organism * m_lpOrganism
The pointer to this link's organism.
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.