AnimatLab  2
Test
PacemakerNeuron.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 
9 #include "Synapse.h"
10 #include "Neuron.h"
11 #include "PacemakerNeuron.h"
12 #include "FiringRateModule.h"
13 
14 namespace FiringRateSim
15 {
16  namespace Neurons
17  {
25 {
26  m_fltIl=(float) 0;
27  m_fltIh=(float) 0;
28  m_fltVssm=(float) -20e-3;
29  m_fltMtl=(float) -31.25;
30  m_fltBtl=(float) 175e-3;
31  m_fltTh=(float) 75e-3;
32  m_fltVss = 0;
33 
34  //Start off with Ih current.
35  m_fltITime=0;
36  m_iIntrinsicType=IH_CURRENT;
39 }
40 
48 {
49 
50 }
51 
61 {return m_fltIl;}
62 
71 void PacemakerNeuron::Il(float fltVal)
72 {
73  m_fltIl=fltVal;
74 }
75 
85 {return m_fltIh;}
86 
95 void PacemakerNeuron::Ih(float fltVal)
96 {
97  m_fltIh=fltVal;
98 }
99 
109 {return m_fltVssm;}
110 
119 void PacemakerNeuron::Vssm(float fltVal)
120 {
121  m_fltVssm=fltVal;
122 }
123 
133 {return m_fltMtl;}
134 
143 void PacemakerNeuron::Mtl(float fltVal)
144 {
145  m_fltMtl=fltVal;
146 }
147 
157 {return m_fltBtl;}
158 
167 void PacemakerNeuron::Btl(float fltVal)
168 {
169  m_fltBtl=fltVal;
170 }
171 
181 {return m_fltTh;}
182 
191 void PacemakerNeuron::Th(float fltVal)
192 {
193  m_fltTh=fltVal;
194 }
195 
205 {return m_fltITime;}
206 
215 void PacemakerNeuron::ITime(float fltVal)
216 {
217  m_fltITime=fltVal;
218 }
219 
229 {return m_iIntrinsicType;}
230 
239 void PacemakerNeuron::IntrinsicType(unsigned char iVal)
240 {
241  m_iIntrinsicType=iVal;
242 }
243 
253 {return PACEMAKER_NEURON;}
254 
255 void PacemakerNeuron::Copy(CStdSerialize *lpSource)
256 {
257  Neuron::Copy(lpSource);
258 
259  PacemakerNeuron *lpOrig = dynamic_cast<PacemakerNeuron *>(lpSource);
260 
261  m_fltIl = lpOrig->m_fltIl;
262  m_fltIh = lpOrig->m_fltIh;
263  m_fltVssm = lpOrig->m_fltVssm;
264  m_fltMtl = lpOrig->m_fltMtl;
265  m_fltBtl = lpOrig->m_fltBtl;
266  m_fltTh = lpOrig->m_fltTh;
267  m_fltITime = lpOrig->m_fltITime;
269  m_fltVss = lpOrig->m_fltVss;
271 }
272 
273 float PacemakerNeuron::CalculateIntrinsicCurrent(FiringRateModule *lpModule, float fltInputCurrent)
274 {
275  m_fltITime-=lpModule->TimeStep();
276 
277  m_fltVss=(fltInputCurrent/m_fltGn);
278 
279  if(m_fltITime<0)
280  {
281  if(m_iIntrinsicType==IH_CURRENT)
283  else
284  HighCurrentOn();
285  }
286 
287  return m_fltIntrinsicI;
288 }
289 
297 {
300  m_iIntrinsicType=IH_CURRENT;
301 }
302 
312 {
313  if(m_iIntrinsicType == IL_CURRENT)
314  return;
315 
316  m_iIntrinsicType=IL_CURRENT;
318 
319 
320  if(fltVss>=m_fltVssm)
321  {
322  m_fltITime = m_fltMtl*fltVss + m_fltBtl;
323 
324  if(m_fltITime<=0)
325  {
326  m_fltITime=0;
327  m_iIntrinsicType=IH_CURRENT;
329  }
330 
332  }
333  else
334  {
335  m_fltITime=0;
336  m_iIntrinsicType=IH_CURRENT;
337  }
338 }
339 
341 {
343 
344  m_fltVss = 0;
345  m_fltITime=0;
346  m_iIntrinsicType=IH_CURRENT;
348 }
349 
351 {
352  //float fltTime = lpSim->Time();
353  //if(m_strName == "U Obstacle Mem" && fltTime > 3.672)
354  // fltTime=fltTime;
355 
357 
358 // //Now we need to check if this neuron has crossed the firing threshold.
359 // //If it has then we initiate High current.
360  if( ((m_aryVn[m_lpFRModule->InactiveArray()] - m_fltVth) > 1e-6) && ((m_aryVn[m_lpFRModule->ActiveArray()] - m_fltVth) < 1e-6) )
361  HighCurrentOn();
362 
363  if( ((m_aryVn[m_lpFRModule->InactiveArray()] - m_fltVth) < 1e-6) && ((m_aryVn[m_lpFRModule->ActiveArray()] - m_fltVth) > 1e-6) )
364  LowCurrentOn(0);
365 }
366 
368 {
369  //We need bytes for the internal state variables for this neuron.
370  return (Neuron::CalculateSnapshotByteSize() + sizeof(m_fltITime) + sizeof(m_iIntrinsicType));
371 }
372 
373 #pragma region DataAccesMethods
374 
375 float *PacemakerNeuron::GetDataPointer(const std::string &strDataType)
376 {
377  std::string strType = Std_CheckString(strDataType);
378 
379  if(strType == "STEADYSTATEVOLTAGE")
380  return &m_fltVss;
381 
382  if(strType == "INTERBURSTINTERVAL")
383  return &m_fltInterburstInterval;
384 
385  if(strType == "INTERBURSTTIMER")
386  return &m_fltITime;
387 
388  return Neuron::GetDataPointer(strDataType);
389 }
390 
391 bool PacemakerNeuron::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
392 {
393  std::string strType = Std_CheckString(strDataType);
394 
395  if(Neuron::SetData(strDataType, strValue, false))
396  return true;
397 
398  if(strType == "VSSM")
399  {
400  Vssm(atof(strValue.c_str()));
401  return true;
402  }
403 
404  if(strType == "BTL")
405  {
406  Btl(atof(strValue.c_str()));
407  return true;
408  }
409 
410  if(strType == "MTL")
411  {
412  Mtl(atof(strValue.c_str()));
413  return true;
414  }
415 
416  if(strType == "TH")
417  {
418  Th(atof(strValue.c_str()));
419  return true;
420  }
421 
422  if(strType == "IL")
423  {
424  Il(atof(strValue.c_str()));
425  return true;
426  }
427 
428  if(strType == "IH")
429  {
430  Ih(atof(strValue.c_str()));
431  return true;
432  }
433 
434  //If it was not one of those above then we have a problem.
435  if(bThrowError)
436  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
437 
438  return false;
439 }
440 
441 void PacemakerNeuron::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
442 {
443  Neuron::QueryProperties(aryProperties);
444 
445  aryProperties.Add(new TypeProperty("SteadStateVoltage", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
446  aryProperties.Add(new TypeProperty("InterburstInterval", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
447  aryProperties.Add(new TypeProperty("InterburstTimer", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
448 
449  aryProperties.Add(new TypeProperty("Vssm", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
450  aryProperties.Add(new TypeProperty("Btl", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
451  aryProperties.Add(new TypeProperty("Mtl", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
452  aryProperties.Add(new TypeProperty("Th", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
453  aryProperties.Add(new TypeProperty("Il", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
454  aryProperties.Add(new TypeProperty("Ih", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
455 }
456 
457 #pragma endregion
458 
459 void PacemakerNeuron::SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex)
460 {
461  Neuron::SaveKeyFrameSnapshot(aryBytes, lIndex);
462 
463  memcpy((void *) (aryBytes+lIndex), (void *)&m_fltITime, sizeof(m_fltITime));
464  lIndex += sizeof(m_fltITime);
465 
466  memcpy((void *) (aryBytes+lIndex), (void *)&m_iIntrinsicType, sizeof(m_iIntrinsicType));
467  lIndex += sizeof(m_iIntrinsicType);
468 }
469 
470 void PacemakerNeuron::LoadKeyFrameSnapshot(byte *aryBytes, long &lIndex)
471 {
472  Neuron::LoadKeyFrameSnapshot(aryBytes, lIndex);
473 
474  memcpy((void *)&m_fltITime, (void *) (aryBytes+lIndex), sizeof(m_fltITime));
475  lIndex += sizeof(m_fltITime);
476 
477  memcpy((void *)&m_iIntrinsicType, (void *) (aryBytes+lIndex), sizeof(m_iIntrinsicType));
478  lIndex += sizeof(m_iIntrinsicType);
479 }
480 
481 void PacemakerNeuron::Load(CStdXml &oXml)
482 {
483  Neuron::Load(oXml);
484 
485  oXml.IntoElem(); //Into Neuron Element
486 
487  Il(oXml.GetChildFloat("Il"));
488  Ih(oXml.GetChildFloat("Ih"));
489  Vssm(oXml.GetChildFloat("Vssm"));
490  Mtl(oXml.GetChildFloat("Mtl"));
491  Btl(oXml.GetChildFloat("Btl"));
492  Th(oXml.GetChildFloat("Th"));
493 
494  oXml.OutOfElem(); //OutOf Neuron Element
495 }
496 
497 
498  } //Neurons
499 } //FiringRateSim
500 
float m_fltVss
The steady state voltage.
float Th()
Gets the time that the high current is active.
Firing rate neural module.
bool InactiveArray()
Gets the inactive array.
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
float Mtl()
Gets the slope used to calculate length of time that Il current remains active.
virtual float TimeStep()
Gets the time step for this moudle in time units.
float m_fltITime
Time that the current intrinsic current mode is active.
float m_fltBtl
The intercept of the linear function that is used to calculate the length of time that Il current rem...
unsigned char m_iIntrinsicType
Type of the intrinsic current that is active. (HI or LOW)
float m_fltVssm
A lower steady state threshold. If the steady state voltage of the neuron goes below this value then ...
virtual void StepSimulation()
Step the simulation for this object.
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual void ResetSimulation()
Resets the simulation back to time 0.
float Il()
Gets the low intrinsic current value.
virtual unsigned char NeuronType()
Gets the neuron type.
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_aryVn[2]
Current and next Membrane voltage. Vn.
virtual void StepSimulation()
Step the simulation for this object.
float m_fltInterburstInterval
The interburst interval.
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
float m_fltIntrinsicI
Intrinsic current.
float Ih()
Gets the high intrinsic current value.
float m_fltIl
The hyperpolarizing current that brings the membrane potential back down after it has been firing...
void LowCurrentOn(float fltVss)
Turns the low current on.
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 long CalculateSnapshotByteSize()
Calculates the snapshot byte size.
float m_fltTh
This is the length of time that the Ih current remains active.
virtual void SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Saves a key frame snapshot.
virtual float CalculateIntrinsicCurrent(FiringRateModule *lpModule, float fltInputCurrent)
Calculates the intrinsic current.
float Vssm()
Gets the lower steady state threshold.
Declares the synapse class.
void HighCurrentOn()
Turns the high current on.
float Btl()
Gets the intercept used to calculate length of time that Il current remains active.
float m_fltVth
Firing frequency voltage threshold.
Declares the firing rate module class.
Declares the pacemaker neuron class.
float m_fltMtl
The slope of the linear function that is used to calculate the length of time that Il current remains...
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.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual void SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Saves a key frame snapshot.
virtual void LoadKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Loads a key frame snapshot.
float m_fltGn
Membrane conductance.
virtual long CalculateSnapshotByteSize()
Calculates the snapshot byte size.
float ITime()
Gets the duration for the current mode.
unsigned char IntrinsicType()
Gets the intrinsic current type. (HI or LOW)
FiringRateModule * m_lpFRModule
Pointer to the parent FiringRateModule.
float m_fltIh
The slope of the linear function that is used to calculate the length of time that Il current remains...