10 #include "CsNeuralModule.h"
11 #include "CsSpikeGeneratorGroup.h"
52 {
Std_TraceMsg(0,
"Caught Error in desctructor of CsFiringRateStimulus\r\n",
"", -1,
false,
true);}
76 THROW_PARAM_ERROR(Al_Err_lInvalidCurrentType, Al_Err_strInvalidCurrentType,
"ID", strID);
135 void CsFiringRateStimulus::ConstantRate(
float fltVal)
145 void CsFiringRateStimulus::Coverage(std::string strType)
148 if(strVal ==
"INDIVIDUALS")
150 else if(strVal ==
"WHOLEPOPULATION")
153 THROW_PARAM_ERROR(Cs_Err_lInvalidFiringRateCoverage, Cs_Err_strInvalidFiringRateCoverage,
"Coverage", strType);
160 void CsFiringRateStimulus::CellsToStim(std::string strXml)
163 oXml.Deserialize(strXml);
164 oXml.FindElement(
"Root");
165 oXml.FindChildElement(
"Cells");
167 LoadCellsToStim(oXml);
170 void CsFiringRateStimulus::Initialize()
172 ExternalStimulus::Initialize();
177 THROW_PARAM_ERROR(Al_Err_lNodeNotFound, Al_Err_strNodeNotFound,
"ID: ",
m_strTargetNodeID);
181 THROW_PARAM_ERROR(Cs_Err_lNotSpikeGeneratorType, Cs_Err_strNotSpikeGeneratorType,
"ID: ",
m_strTargetNodeID);
199 m_lpEval->SetVariable(
"t", (m_lpSim->Time()-m_fltStartTime) );
208 bool CsFiringRateStimulus::RateChanged()
216 void CsFiringRateStimulus::ApplyRateChange()
220 for(
int iIdx=0; iIdx<
m_lpSpikeGen->NeuronCount(); iIdx++)
232 int iIdx = (*ii).first;
233 if(iIdx >= 0 && iIdx < m_lpSpikeGen->NeuronCount())
248 void CsFiringRateStimulus::StepSimulation()
262 void CsFiringRateStimulus::Activate()
264 ExternalStimulus::Activate();
276 void CsFiringRateStimulus::Deactivate()
278 ExternalStimulus::Deactivate();
291 void CsFiringRateStimulus::ResetSimulation()
293 ExternalStimulus::ResetSimulation();
298 float *CsFiringRateStimulus::GetDataPointer(
const std::string &strDataType)
303 if(strType ==
"ACTIVERATE")
306 THROW_TEXT_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"StimulusName: " + STR(m_strName) +
" DataType: " + strDataType);
311 bool CsFiringRateStimulus::SetData(
const std::string &strDataType,
const std::string &strValue,
bool bThrowError)
315 if(ExternalStimulus::SetData(strDataType, strValue,
false))
318 if(strType ==
"CONSTANTRATE")
320 ConstantRate((
float) atof(strValue.c_str()));
324 if(strType ==
"COVERAGE")
330 if(strType ==
"EQUATION")
336 if(strType ==
"CELLSTOSTIM")
338 CellsToStim(strValue);
344 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
349 void CsFiringRateStimulus::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
351 ExternalStimulus::QueryProperties(aryProperties);
353 aryProperties.Add(
new TypeProperty(
"ActiveRate", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
355 aryProperties.Add(
new TypeProperty(
"ConstantRate", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
356 aryProperties.Add(
new TypeProperty(
"Equation", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
357 aryProperties.Add(
new TypeProperty(
"Coverage", AnimatPropertyType::String, AnimatPropertyDirection::Set));
358 aryProperties.Add(
new TypeProperty(
"CellsToStim", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
361 void CsFiringRateStimulus::LoadCellsToStim(CStdXml &oXml)
365 int iCount = oXml.NumberOfChildren();
366 for(
int iIdx=0; iIdx<iCount; iIdx++)
368 oXml.FindChildByIndex(iIdx);
369 int iNeuronIdx = oXml.GetChildInt();
372 THROW_PARAM_ERROR(Cs_Err_lInvalidNeuralIndex, Cs_Err_strInvalidNeuralIndex,
"Neuron Index", iNeuronIdx);
380 void CsFiringRateStimulus::Load(CStdXml &oXml)
382 ExternalStimulus::Load(oXml);
389 Equation(oXml.GetChildString(
"Equation",
""));
390 Coverage(oXml.GetChildString(
"Coverage",
"WholePopulation"));
392 if(oXml.FindChildElement(
"Cells",
false))
393 LoadCellsToStim(oXml);
Contains the classes for a firing rate neural model.
bool m_bStimWholePopulation
Tells whether this stimulus is applied to the entire population or just individual cells...
Declares the CsNeuronGroup class.
virtual float CalculateFiringRate()
Calculates the on cycle current at this time step.
virtual unsigned int SimulationStepInterval()
Tells the number of simulation steps that other components, like stimuli, will need to use for their ...
CStdPostFixEval * m_lpEval
Pointer to the post-fix equation evaluator.
std::string m_strTargetNodeID
GUID ID of the neuron we are stimulating.
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
virtual ~CsFiringRateStimulus()
Destructor.
float m_fltActiveRate
The currently active firing rate.
Declares the synapse class.
float m_fltConstantRate
The value to use for active rate if the type is constant.
float m_fltPrevAppliedRate
The previous active firing rate.
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 current stimulus class.
virtual std::string Equation()
Gets the post-fix current equation string. If this is null then an equation is not used...
bool Std_IsBlank(std::string strVal)
Trims a string and tests if a string is blank.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
std::string m_strEquation
The post-fix string current equation.
virtual std::string TargetNodeID()
Gets the GUID ID of the node that is being stimulated.
CsSpikeGeneratorGroup * m_lpSpikeGen
The spike generator this object is stimulating.
CStdMap< int, int > m_aryCellsToStim
An array of neuron indices for individual neurons we want to stimulate.
CsFiringRateStimulus()
Default constructor.
Firing Rate Neuron model.