Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

IZNeuronBase.H

Go to the documentation of this file.
00001 /*!@file ModelNeuron/IZNeuronBase.H Class declarations for an izhikevich neuron */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00005 // University of Southern California (USC) and the iLab at USC.         //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file: David Berg <dberg@usc.edu>
00034 // $HeadURL: svn://ilab.usc.edu/trunk/saliency/src/ModelNeuron/IZNeuronBase.H $
00035 
00036 #ifndef IZNEURONBASE_H_DEFINED
00037 #define IZNEURONBASE_H_DEFINED
00038 
00039 #include "Util/SimTime.H"
00040 
00041 // ######################################################################
00042 //! An izhikevich Neural model as presented in his 2003 paper
00043 // ######################################################################
00044 
00045 class IZNeuronBase
00046 {
00047 public:
00048   //! constructor
00049   /*! Constructor with default params
00050     @param timeStep is the integration time step, in milliseconds.
00051     See the general description for the other params. */
00052   inline IZNeuronBase(const SimTime timeStep = SimTime::MSECS(.1),
00053                       const double a = 0.15,          // dimensionless
00054                       const double b = 8,           // dimensionless 
00055                       const double c = -55.0,         // dimensionless
00056                       const double d = 200.0,         // dimensionless
00057                       const double k = 1,           // dimensionless
00058                       const double Cm = 20.0,        // farads
00059                       const double V_rest = -55.0,    // in millivolts
00060                       const double V_thresh = -40.0, // in millivolts
00061                       const double V_peak = 25.0);     // in millivolts
00062                       
00063   //! set input current (A)
00064   inline void input(const double current);
00065 
00066   //! set membrane potential to given value relative to Ei (in Volts)
00067   inline void setV(const double val);
00068 
00069   //! integrate for up to given time (in msecs)
00070   /*! Returns true if a spike was generated. */
00071   virtual inline uint evolve(const SimTime& t);
00072     
00073   //! integrate 1 time step (in msecs)
00074   /*! Returns true if a spike was generated. */
00075   inline bool integrate(const SimTime& t);
00076   
00077   //! get current membrane potential (in V)
00078   inline double getV() const;
00079 
00080   inline double getU() const;
00081 
00082   inline double getI() const;
00083 
00084   //! return our internal time step:
00085   inline SimTime getTimeStep() const;
00086  
00087   //! set the current internal time:
00088   inline void setTime(const SimTime& t);
00089 
00090   //! get our internal time:
00091   inline SimTime getTime() const;
00092 
00093 private:
00094   inline void reset();// reset when a spike occurs
00095 
00096   SimTime itsTimeStep;// time step to use for difference equations (in msecs)
00097 
00098   double itsV;         // membrane potential in millivolts
00099   double itsI;         // input current in picoamperes
00100   double itsU;         //recovery variable
00101 
00102   double itsa;
00103   double itsb;
00104   double itsc;
00105   double itsd;
00106   double itsk;
00107   double itsCm;
00108   double itsVr;
00109   double itsVth;
00110   double itsVp;
00111 
00112   SimTime itsT;       // time of last integration
00113 };
00114 
00115 
00116 
00117 // ######################################################################
00118 // ##### Inline functions for IZNeuronBase:
00119 // ######################################################################
00120 
00121 inline IZNeuronBase::IZNeuronBase(const SimTime timeStep,
00122                                   const double a,
00123                                   const double b,
00124                                   const double c,
00125                                   const double d,
00126                                   const double k,
00127                                   const double cm, 
00128                                   const double vr,
00129                                   const double vth,
00130                                   const double vp) :
00131   itsTimeStep(timeStep), itsV(vr), itsI(0.0), itsU(0.0), itsa(a), itsb(b), 
00132   itsc(c), itsd(d), itsk(k), itsCm(cm), itsVr(vr), itsVth(vth), itsVp(vp), 
00133   itsT(SimTime::ZERO())
00134 {  }
00135 
00136 // ######################################################################
00137 inline void IZNeuronBase::input(const double current)
00138 { itsI = current;}
00139 
00140 
00141 inline uint IZNeuronBase::evolve(const SimTime& t)
00142 {
00143   // we run our difference equations with a time step of itsTimeStep;
00144   // let's here figure out how many iterations we will need to go from
00145   // itsT to t. We will iterate for a number of equal steps, with each
00146   // step as close to itsTimeStep as possible to that we end up at
00147   // time t after iterating for an integer number of time steps:
00148   
00149   uint spike = 0;
00150   const SimTime dt = SimTime::computeDeltaT((t - itsT), itsTimeStep);
00151   for (SimTime tt = itsT; tt < t; tt += dt)
00152     spike += (uint)integrate(dt);
00153   itsT = t;
00154   return spike;
00155 }
00156 
00157 // ######################################################################
00158 inline bool IZNeuronBase::integrate(const SimTime& dt)
00159 {
00160   // we run our difference equations with a time step of itsTimeStep;
00161   // let's here figure out how many iterations we will need to go from
00162   // itsT to t. We will iterate for a number of equal steps, with each
00163   // step as close to itsTimeStep as possible to that we end up at
00164   // time t after iterating for an integer number of time steps:
00165   
00166   bool spike = false;
00167   
00168   // Integrate U      
00169   itsU += dt.msecs() * (itsa * (itsb * (itsV-itsVr) - itsU) ); 
00170   
00171   // Integrate V
00172   double temp = itsk * (itsV - itsVr) * (itsV - itsVth) - itsU - itsI;
00173   //multiply timestip converted to ms, and devide capacitance      
00174   itsV += dt.msecs() * (temp / itsCm);
00175   
00176   
00177   // Check if voltage has exceeded threshold -> if so, then fire:
00178   if (itsV > itsVth) {spike = true; reset();}
00179   
00180   // we are done, just keep track of new current time:
00181   itsT += dt;
00182   return spike;
00183 }
00184 
00185 // ######################################################################
00186 inline void IZNeuronBase::setV(const double val)
00187 { itsV = val; }
00188 
00189 // ######################################################################
00190 inline double IZNeuronBase::getV() const
00191 { return itsV; }
00192 
00193 // ######################################################################
00194 inline double IZNeuronBase::getU() const
00195 { return itsU; }
00196 
00197 // ######################################################################
00198 inline double IZNeuronBase::getI() const
00199 { return itsI; }
00200 
00201 // ######################################################################
00202 inline void IZNeuronBase::reset()
00203 {
00204   itsV =  itsc;
00205   itsU += itsd;
00206 }
00207 
00208 // ######################################################################
00209 inline SimTime IZNeuronBase::getTimeStep() const
00210 { return itsTimeStep; }
00211 
00212 // ######################################################################
00213 inline void IZNeuronBase::setTime(const SimTime& t)
00214 {itsT = t;}
00215 
00216 // ######################################################################
00217 inline SimTime IZNeuronBase::getTime() const
00218 {return itsT;}
00219 
00220 
00221 #endif
00222 
00223 // ######################################################################
00224 /* So things look consistent in everyone's emacs... */
00225 /* Local Variables: */
00226 /* indent-tabs-mode: nil */
00227 /* End: */

Generated on Tue Dec 2 10:22:48 2008 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4