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

IZNeuron.H

Go to the documentation of this file.
00001 /*!@file ModelNeuron/IZNeuron.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/IZNeuron.H $
00035 
00036 #ifndef IZNEURON_H_DEFINED
00037 #define IZNEURON_H_DEFINED
00038 
00039 #include "Util/SimTime.H"
00040 #include "ModelNeuron/IZNeuronBase.H"
00041 #include "ModelNeuron/Synapse.H"
00042 #include "Util/MathFunctions.H"
00043 #include <queue>
00044 
00045 
00046 // ######################################################################
00047 //! An izhikevich Neural model as presented in his 2003 paper
00048 // ######################################################################
00049 
00050 typedef enum {AMPA,NMDA,GABAA,GABAB} SynapseType;
00051 
00052 class IZNeuron : public IZNeuronBase
00053 {
00054 public:
00055   //! constructor
00056   /*! Constructor with default params
00057     @param timeStep is the integration time step, in milliseconds.
00058     See the general description for the other params. */
00059   inline IZNeuron(const SimTime timeStep = SimTime::MSECS(.1),
00060                   const double a = 0.15,          // dimensionless
00061                   const double b = 8,           // dimensionless 
00062                   const double c = -55.0,         // dimensionless
00063                   const double d = 200.0,         // dimensionless
00064                   const double k = 1,           // dimensionless
00065                   const double Cm = 20.0,        // farads
00066                   const double V_rest = -55.0,    // in millivolts
00067                   const double V_thresh = -40.0, // in millivolts
00068                   const double V_peak = 25.0,
00069                   const double itsa = .99);     // in millivolts
00070 
00071   //! Vistual destructor for safe inheritance
00072   virtual inline ~IZNeuron();
00073 
00074   inline void inputAMPA(const float spikes);
00075   inline void inputNMDA(const float spikes);
00076   inline void inputGABAA(const float spikes);
00077   inline void inputGABAB(const float spikes);
00078   inline uint getSpikes() const;
00079   inline Synapse* getSynapse(SynapseType synname);
00080   inline uint evolve(const SimTime& t);
00081   virtual inline void updateSpikeRate(const float spike);
00082   virtual inline float getSpikeRate() const;
00083 
00084 private:
00085 
00086   AMPASynapse  ampa;
00087   NMDASynapse  nmda;
00088   GABAASynapse gabaa;
00089   GABABSynapse gabab;
00090   uint spikeCount;
00091   double itsSpikeRate;
00092   double itsAlpha;
00093 
00094 };
00095 
00096 
00097 
00098 // ######################################################################
00099 //! An izhikevich Neural model that keeps track of its own spike rate
00100 // ######################################################################
00101 
00102 class IZNeuronSR : public IZNeuron
00103 {
00104 public:
00105   //! constructor
00106   /*! Constructor with default params
00107     @param timeStep is the integration time step, in milliseconds.
00108     See the general description for the other params. */
00109   inline IZNeuronSR(const SimTime timeStep = SimTime::MSECS(.1),
00110                     const double a = 0.15,          // dimensionless
00111                     const double b = 8,           // dimensionless 
00112                     const double c = -55.0,         // dimensionless
00113                     const double d = 200.0,         // dimensionless
00114                     const double k = 1,           // dimensionless
00115                     const double Cm = 20.0,        // farads
00116                     const double V_rest = -55.0,    // in millivolts
00117                     const double V_thresh = -40.0, // in millivolts
00118                     const double V_peak = 25.0,     // in millivolts
00119                     const float itsa = 200);   //window function in ms
00120 
00121   
00122   inline float getSpikeRate() const;
00123   inline void updateSpikeRate(const float spike);
00124 
00125 private:
00126   std::deque<float> itsSr;
00127   std::vector<float> window;  
00128   float itsA;
00129 };
00130 
00131 
00132 // ######################################################################
00133 // ##### Inline functions for IZNeuron:
00134 // ######################################################################
00135 
00136 inline IZNeuron::IZNeuron(const SimTime timeStep,
00137                           const double a,
00138                           const double b,
00139                           const double c,
00140                           const double d,
00141                           const double k,
00142                           const double cm, 
00143                           const double vr,
00144                           const double vth,
00145                           const double vp,
00146                           const double itsa) :
00147   IZNeuronBase(timeStep,a,b,c,d,k,cm,vr,vth,vp),ampa(timeStep),
00148   nmda(timeStep),gabaa(timeStep),gabab(timeStep),spikeCount(0),
00149   itsSpikeRate(0.0),itsAlpha(itsa)
00150 {  }
00151 
00152 inline IZNeuron::~IZNeuron()
00153 {  }
00154 
00155 inline void IZNeuron::inputAMPA(const float spikes)
00156 {
00157   ampa.input((double)spikes);
00158 }
00159 
00160 inline void IZNeuron::inputNMDA(const float spikes)
00161 {
00162   nmda.input((double)spikes);
00163 }
00164 
00165 inline void IZNeuron::inputGABAA(const float spikes)
00166 {
00167   gabaa.input((double)spikes);
00168 }
00169 
00170 inline void IZNeuron::inputGABAB(const float spikes)
00171 {
00172   gabab.input((double)spikes);
00173 }
00174 
00175 inline Synapse* IZNeuron::getSynapse(SynapseType synname)
00176 {
00177   switch (synname)
00178     {
00179     case AMPA:
00180       return &ampa;
00181     case NMDA:
00182       return &nmda;
00183     case GABAA:
00184       return &gabaa;
00185     case GABAB:
00186       return &gabab;
00187     default:
00188       return new Synapse;  
00189     }
00190 }
00191 
00192 inline uint IZNeuron::evolve(const SimTime& t)
00193 {
00194   const SimTime dt = SimTime::computeDeltaT((t - getTime()), getTimeStep());
00195   uint spike = 0;  
00196 
00197   for (SimTime tt = getTime(); tt < t; tt += dt)
00198     {
00199       //integrate all our synapses once
00200       ampa.integrate(dt);
00201       nmda.integrate(dt);
00202       gabaa.integrate(dt);
00203       gabab.integrate(dt);
00204       
00205       //sum up the currents
00206       double current = ampa.getI(getV()) + nmda.getI(getV()) 
00207         + gabaa.getI(getV()) + gabab.getI(getV());
00208       
00209       //set the current level in picoamps
00210       input(current);
00211       
00212       //integrate our neuron one time step
00213       spike += integrate(dt);
00214 
00215       //a virtual function with no implementation 
00216       updateSpikeRate(spike);
00217     }
00218 
00219   spikeCount = spike;
00220   setTime(t);
00221   ampa.setTime(t);
00222   nmda.setTime(t);
00223   gabaa.setTime(t);
00224   gabab.setTime(t);
00225   return spike;
00226 }
00227 
00228 inline void IZNeuron::updateSpikeRate(const float spike)
00229 {
00230    itsSpikeRate *= itsAlpha;
00231    itsSpikeRate += (1-itsAlpha)*spike;
00232 }
00233 
00234 inline uint IZNeuron::getSpikes() const
00235 {
00236   return spikeCount;
00237 }
00238 
00239 inline float IZNeuron::getSpikeRate() const
00240 {
00241   return itsSpikeRate;
00242 }
00243 
00244 inline IZNeuronSR::IZNeuronSR(const SimTime timeStep,
00245                               const double a,
00246                               const double b,
00247                               const double c,
00248                               const double d,
00249                               const double k,
00250                               const double cm, 
00251                               const double vr,
00252                               const double vth,
00253                               const double vp,
00254                               const float itsa) :
00255   IZNeuron(timeStep,a,b,c,d,k,cm,vr,vth,vp),itsSr(),window(),itsA(itsa)
00256 {
00257   const float aa = 1/(itsA*timeStep.msecs());
00258   const float fl = .001;
00259   SimTime end = SimTime::MSECS(1000);
00260   SimTime ii =  SimTime::ZERO();
00261 
00262   for (; ii  < end; ii += timeStep)
00263     {
00264       float temp = (aa*aa) * ii.msecs() * exp(-1 * aa * ii.msecs());
00265       if ( (temp < fl) && (ii > SimTime::MSECS(10)) ) break;
00266       window.push_back(temp);
00267     }
00268 }
00269 
00270 
00271 inline float IZNeuronSR::getSpikeRate() const
00272 {
00273   std::vector<float>::const_iterator iter = window.begin();
00274   std::deque<float>::const_iterator iters = itsSr.begin();
00275   float val = 0;
00276   while ((iter != window.end()) && (iters != itsSr.end()))
00277     val += (*iter++) * (*iters++);
00278   return val;
00279 }
00280 
00281 
00282 inline void IZNeuronSR::updateSpikeRate(const float spike)
00283 {
00284   itsSr.push_back(spike);
00285   while (itsSr.size() > window.size() )
00286     itsSr.pop_front();
00287 }
00288 
00289 
00290 #endif
00291 
00292 // ######################################################################
00293 /* So things look consistent in everyone's emacs... */
00294 /* Local Variables: */
00295 /* indent-tabs-mode: nil */
00296 /* End: */

Generated on Thu Dec 4 10:20:26 2008 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4