Page MenuHomec4science

neurone.cpp
No OneTemporary

File Metadata

Created
Wed, Sep 18, 05:26

neurone.cpp

#include "neurone.hpp"
#include "constant.h"
#include <math.h>
#include <vector>
#include <cmath>
Neurone::Neurone() :
membrane_potential_(Standard_potential),clock_rest_time_(0.0), I_ext_(0.0) {}
Neurone::~Neurone()
{}
bool Neurone::update(unsigned int t) {
bool spike(false);
spike=Spike(t);
/// 1) make the neurone spike and set it refractory (if necessary)
double new_potential(0.0);
if(not isInRest()) {
new_potential = exp(-DeltaTime/Tau)*(membrane_potential_);
new_potential += I_ext_*(Resistance)*(1-exp(-DeltaTime/Tau));
/// 2) calculate the new potential
new_potential += outsideInput();
/// 3) add the potential created by other neurones
membrane_potential_=new_potential;
/// 4) update the membrane potential
} else {
membrane_potential_=0.0;
}
buffer_.update();
return spike;
}
double Neurone::getMembranePotential () const {
return membrane_potential_-0.070;
/// -0.070 because we use a 0 origin for the membrane potential
}
bool Neurone::isInRest() {
if (not (clock_rest_time_ <= 0.0)) {
clock_rest_time_-=DeltaTime;
/// retires an unit of time
return true;
}
return false;
}
bool Neurone::Spike(unsigned int t) {
bool spike(false);
if(membrane_potential_ >= Spike_Treshold) {
spikes_times_.push_back(t);
/// stores the spike time
membrane_potential_=Standard_potential;
/// reinitialize the membrane potential
clock_rest_time_=TauR;
/// set the rest time
spike=true;
};
return spike;
}
std::vector<double> Neurone::getSpikeTimes() const {
return spikes_times_;
}
void Neurone::receive(int D) {
buffer_.addValue(D);
}
double Neurone::outsideInput() const {
double input(buffer_.valueFor());
return input;
}
void Neurone::setIext(double I) {
I_ext_=I;
}

Event Timeline