MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SpikeStats.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2003-2010 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 
10 #include "header.h"
11 #include "Stats.h"
12 #include "SpikeStats.h"
13 
15 {
17  // Field Definitions
19  static ValueFinfo< SpikeStats, double > threshold(
20  "threshold",
21  "Spiking threshold. If Vm crosses this going up then the "
22  "SpikeStats object considers that a spike has happened and "
23  "adds it to the stats.",
26  );
28  // MsgDest Definitions
30 
31  static DestFinfo addSpike( "addSpike",
32  "Handles spike event time input, converts into a rate "
33  "to do stats upon.",
35 
36  static DestFinfo Vm( "Vm",
37  "Handles continuous voltage input, can be coming in much "
38  "than update rate of the SpikeStats. Looks for transitions "
39  "above threshold to register the arrival of a spike. "
40  "Doesn't do another spike till Vm falls below threshold. ",
42 
43  static Finfo* statsFinfos[] = {
44  &threshold, // Value
45  &addSpike, // DestFinfo
46  &Vm, // DestFinfo
47  };
48 
49  static string doc[] =
50  {
51  "Name", "SpikeStats",
52  "Author", "Upi Bhalla Aug 2014",
53  "Description",
54  "Object to do some minimal stats on rate of a spike train. "
55  "Derived from the Stats object and returns the same set of stats."
56  "Can take either predigested spike event input, or can handle "
57  "a continuous sampling of membrane potential Vm and decide if "
58  "a spike has occured based on a threshold. "
59  };
60 
61  static Dinfo< SpikeStats > dinfo;
62  static Cinfo spikeStatsCinfo (
63  "SpikeStats",
65  statsFinfos,
66  sizeof( statsFinfos ) / sizeof ( Finfo* ),
67  &dinfo,
68  doc,
69  sizeof( doc ) / sizeof( string )
70  );
71 
72  return &spikeStatsCinfo;
73 }
74 
76 
78 // class funcs
80 
82  : Stats(),
83  numSpikes_( 0 ), threshold_( 0.0 ), fired_( false )
84 { ; }
85 
87 // Process stuff.
89 
90 void SpikeStats::vProcess( const Eref& e, ProcPtr p )
91 {
92  double rate = static_cast< double >( numSpikes_ ) / p->dt;
93  numSpikes_ = 0;
94  Stats::input( rate );
95 }
96 
97 void SpikeStats::vReinit( const Eref& e, ProcPtr p )
98 {
99  Stats::vReinit( e, p );
100  numSpikes_ = 0;
101  fired_ = 0;
102 }
104 // DestFinfos
106 
107 void SpikeStats::Vm( double v )
108 {
109  if ( fired_ ) { // Wait for it to go below threshold
110  if ( v < threshold_ )
111  fired_ = false;
112  } else {
113  if ( v > threshold_ ) { // wait for it to go above threshold.
114  fired_ = true;
115  numSpikes_++;
116  }
117  }
118 }
119 
120 void SpikeStats::addSpike( double t )
121 {
122  numSpikes_ ++;
123 }
124 
126 // Fields
128 
130 {
131  return threshold_;
132 }
133 
134 void SpikeStats::setThreshold( double v )
135 {
136  threshold_ = v;
137 }
double getThreshold() const
Definition: SpikeStats.cpp:129
static const Cinfo * spikeStatsCinfo
Definition: SpikeStats.cpp:75
Definition: Dinfo.h:60
double threshold_
Definition: SpikeStats.h:43
unsigned int numSpikes_
Definition: SpikeStats.h:42
void setThreshold(double thresh)
Definition: SpikeStats.cpp:134
void Vm(double v)
Definition: SpikeStats.cpp:107
static const Cinfo * initCinfo()
Definition: Stats.cpp:21
void addSpike(DataId synIndex, const double time)
bool fired_
Definition: SpikeStats.h:44
void vProcess(const Eref &e, ProcPtr p)
Virtual func for handling process calls.
Definition: SpikeStats.cpp:90
virtual void vReinit(const Eref &e, ProcPtr p)
Definition: Stats.cpp:166
void vReinit(const Eref &e, ProcPtr p)
Definition: SpikeStats.cpp:97
double dt
Definition: ProcInfo.h:18
Definition: OpFunc.h:27
Definition: Eref.h:26
Definition: Stats.h:12
void input(double v)
Definition: Stats.cpp:183
static const Cinfo * initCinfo()
Definition: SpikeStats.cpp:14
Definition: Cinfo.h:18
Definition: Finfo.h:12