-
Notifications
You must be signed in to change notification settings - Fork 0
/
neuron.h
109 lines (104 loc) · 2.52 KB
/
neuron.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* @file neuron.h
* @brief neuron class
*
* @author Colin Branca
* @date November 2017
*/
#include <vector>
#include <math.h>
class neuron {
private:
//constant parameters
static constexpr double membraneResistance = 20.0;
static constexpr double conductivity = 1.0;
static constexpr double tau = membraneResistance * conductivity;
static constexpr int tauRef = 20;
static constexpr double V_threshold = 20.0;
static constexpr double V_reset = 0.0;
static constexpr double step = 0.1;
double potentialFactor = exp(-step/tau);
double currentFactor = membraneResistance * (1.0 - potentialFactor);
static constexpr double delay = 1.5;
static constexpr int BUFFER_SIZE = 16; // delay/step + 1
//variable parameters
double membranePotential;
int spikes;
std::vector<double> timesOfSpikes;
bool refractoring;
double i_ext;
int refractoryTime;
std::vector<neuron*> targets;
std::vector<double> buffer;
int bufferIndex = 0;
int local_clock = 0;
public:
/**
* @brief neuron constructor
*/
neuron();
/**
* @brief get the membrane potential of the neuron
* @return the membrane potential
*/
double getMembranePotential();
/**
* @brief get the number of times the neuron spiked
* @return number of spikes
*/
int getSpikes();
/**
* @brief get times the neuron spiked
* @return spike times
*/
std::vector<double> getTimesOfSpikes();
/**
* @brief get the neuron's targets
* @return targets
*/
std::vector<neuron*> getTargets();
/**
* @brief update neuron's state
* @param simTime simlutation time
* @return true if the neuron spiked, false otherwise
*/
bool updateState(int simTime);
/**
* @brief test if the neuron is refractoring
* @return true if the neuron is refractoring, false otherwise
*/
bool isRefractoring();
/**
* @brief update the refractory state of the neuron
*/
void updateRefractoring();
/**
* @brief print the spike times
*/
void printSpikeTimes();
/**
* @brief set I_ext current
*/
void setCurrent(double i);
/**
* @brief receive spike from other neuron
* @param simTime time the other neuron spiked
* @param J current given by the spike
*/
void receive(int simTime, double J);
/**
* @brief receive spike from external system
* @param J current given by the spikes
*/
void receiveFromExt(double J);
/**
* @brief add a target to the neuron
* @param n target neuron
*/
void addTarget(neuron* n);
/**
* @brief add a spike to the neuron
* @param t spike time
*/
void addSpike(int t);
};