Page MenuHomec4science

neurone.cpp
No OneTemporary

File Metadata

Created
Tue, Sep 17, 20:52

neurone.cpp

#include "neurone.hpp"
#include "constant.h"
#include <iomanip>
#include <vector>
#include <cmath>
Neurone::Neurone() :
membrane_potential_(Standard_potential),rest_time_(0.0), J_(Standard_potential) {}
void Neurone::update(double const Input_current, double time_i) {
double new_potential(0.0);
if(not isInRest()) {
new_potential = exp(-DeltaTime/Tau)*(membrane_potential_);
new_potential += Input_current*(Resistance)*(1-exp(-DeltaTime/Tau));
/// 1) calculate the new potential
if(time_i > J_time_) {
new_potential += J_;
J_=0.0;
}
membrane_potential_=new_potential;
/// 2) update the membrane potential
}
}
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 (rest_time_ <= 0.0)) {
rest_time_-=DeltaTime;
/// retires an unit of time
return true;
}
return false;
}
bool Neurone::Spike(double time_i) {
if(membrane_potential_ >= Spike_Treshold) {
spikes_times_.push_back(time_i);
/// stores the spike time
membrane_potential_=Standard_potential;
/// reinitialize the membrane potential
rest_time_=TauR;
/// set the rest time
return true;
};
return false;
}
std::vector<double> Neurone::getSpikeTimes() const {
return spikes_times_;
}
void Neurone::Receive(double time_eff, double J) {
J_=J;
J_time_=time_eff;
}
/*void Neurone::print(std::ofstream& donnees, int time) {
donnees << std::setw(20) << membrane_potential_*mV;
donnees << std::setw(20) << (time+1)*DeltaTime*ms << std::endl;
}*/

Event Timeline