Skip to content

Commit

Permalink
Changed from calcium to firing rate
Browse files Browse the repository at this point in the history
  • Loading branch information
sdiazpier committed Nov 24, 2017
1 parent f415e08 commit 9dc3f24
Show file tree
Hide file tree
Showing 14 changed files with 216 additions and 259 deletions.
58 changes: 29 additions & 29 deletions nestkernel/archiving_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ nest::Archiving_Node::Archiving_Node()
, tau_minus_triplet_( 110.0 )
, tau_minus_triplet_inv_( 1. / tau_minus_triplet_ )
, last_spike_( -1.0 )
, Ca_t_( 0.0 )
, Ca_minus_( 0.0 )
, tau_Ca_( 10000.0 )
, beta_Ca_( 0.001 )
, fr_t_( 0.0 )
, fr_minus_( 0.0 )
, tau_fr_( 10000.0 )
, beta_fr_( 0.1 )
, synaptic_elements_map_()
{
}
Expand All @@ -64,10 +64,10 @@ nest::Archiving_Node::Archiving_Node( const Archiving_Node& n )
, tau_minus_triplet_( n.tau_minus_triplet_ )
, tau_minus_triplet_inv_( n.tau_minus_inv_ )
, last_spike_( n.last_spike_ )
, Ca_t_( n.Ca_t_ )
, Ca_minus_( n.Ca_minus_ )
, tau_Ca_( n.tau_Ca_ )
, beta_Ca_( n.beta_Ca_ )
, fr_t_( n.fr_t_ )
, fr_minus_( n.fr_minus_ )
, tau_fr_( n.tau_fr_ )
, beta_fr_( n.beta_fr_ )
, synaptic_elements_map_( n.synaptic_elements_map_ )
{
}
Expand Down Expand Up @@ -178,7 +178,7 @@ nest::Archiving_Node::set_spiketime( Time const& t_sp, double offset )
{
const double t_sp_ms = t_sp.get_ms() - offset;
update_synaptic_elements( t_sp_ms );
Ca_minus_ += beta_Ca_;
fr_minus_ += beta_fr_;

if ( n_incoming_ )
{
Expand Down Expand Up @@ -218,9 +218,9 @@ nest::Archiving_Node::get_status( DictionaryDatum& d ) const

def< double >( d, names::t_spike, get_spiketime_ms() );
def< double >( d, names::tau_minus, tau_minus_ );
def< double >( d, names::Ca, Ca_minus_ );
def< double >( d, names::tau_Ca, tau_Ca_ );
def< double >( d, names::beta_Ca, beta_Ca_ );
def< double >( d, names::fr, fr_minus_ );
def< double >( d, names::tau_fr, tau_fr_ );
def< double >( d, names::beta_fr, beta_fr_ );
def< double >( d, names::tau_minus_triplet, tau_minus_triplet_ );
#ifdef DEBUG_ARCHIVER
def< int >( d, names::archiver_length, history_.size() );
Expand All @@ -246,12 +246,12 @@ nest::Archiving_Node::set_status( const DictionaryDatum& d )
// We need to preserve values in case invalid values are set
double new_tau_minus = tau_minus_;
double new_tau_minus_triplet = tau_minus_triplet_;
double new_tau_Ca = tau_Ca_;
double new_beta_Ca = beta_Ca_;
double new_tau_fr = tau_fr_;
double new_beta_fr = beta_fr_;
updateValue< double >( d, names::tau_minus, new_tau_minus );
updateValue< double >( d, names::tau_minus_triplet, new_tau_minus_triplet );
updateValue< double >( d, names::tau_Ca, new_tau_Ca );
updateValue< double >( d, names::beta_Ca, new_beta_Ca );
updateValue< double >( d, names::tau_fr, new_tau_fr );
updateValue< double >( d, names::beta_fr, new_beta_fr );

if ( new_tau_minus <= 0.0 || new_tau_minus_triplet <= 0.0 )
{
Expand All @@ -263,19 +263,19 @@ nest::Archiving_Node::set_status( const DictionaryDatum& d )
tau_minus_inv_ = 1. / tau_minus_;
tau_minus_triplet_inv_ = 1. / tau_minus_triplet_;

if ( new_tau_Ca <= 0.0 )
if ( new_tau_fr <= 0.0 )
{
throw BadProperty( "All time constants must be strictly positive." );
}
tau_Ca_ = new_tau_Ca;
tau_fr_ = new_tau_fr;

if ( new_beta_Ca <= 0.0 )
if ( new_beta_fr <= 0.0 )
{
throw BadProperty(
"For Ca to function as an integrator of the electrical activity, beta_ca "
"needs to be greater than 0." );
"beta_fr needs to be greater than 0 to be able to calculate the"
"firing rate." );
}
beta_Ca_ = new_beta_Ca;
beta_fr_ = new_beta_fr;

// check, if to clear spike history and K_minus
bool clear = false;
Expand Down Expand Up @@ -333,8 +333,8 @@ nest::Archiving_Node::clear_history()
Kminus_ = 0.0;
triplet_Kminus_ = 0.0;
history_.clear();
Ca_minus_ = 0.0;
Ca_t_ = 0.0;
fr_minus_ = 0.0;
fr_t_ = 0.0;
}


Expand Down Expand Up @@ -417,18 +417,18 @@ nest::Archiving_Node::get_synaptic_elements() const
void
nest::Archiving_Node::update_synaptic_elements( double t )
{
assert( t >= Ca_t_ );
assert( t >= fr_t_ );

for ( std::map< Name, SynapticElement >::iterator it =
synaptic_elements_map_.begin();
it != synaptic_elements_map_.end();
++it )
{
it->second.update( t, Ca_t_, Ca_minus_, tau_Ca_ );
it->second.update( t, fr_t_, fr_minus_, tau_fr_ );
}
// Update calcium concentration
Ca_minus_ = Ca_minus_ * std::exp( ( Ca_t_ - t ) / tau_Ca_ );
Ca_t_ = t;
// Update the firing rate
fr_minus_ = fr_minus_ * std::exp( ( fr_t_ - t ) / tau_fr_ );
fr_t_ = t;
}

void
Expand Down
40 changes: 20 additions & 20 deletions nestkernel/archiving_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Archiving_Node : public Node
* \fn double get_Ca_minus()
* return the current value of Ca_minus
*/
double get_Ca_minus() const;
double get_fr_minus() const;

/**
* \fn double get_synaptic_elements(Name n)
Expand Down Expand Up @@ -171,10 +171,10 @@ class Archiving_Node : public Node
void set_status( const DictionaryDatum& d );

/**
* retrieve the current value of tau_Ca which defines the exponential decay
* constant of the intracellular calcium concentration
* retrieve the current value of tau_fr which defines an exponential decay
* constant for the calculation of the firing rate
*/
double get_tau_Ca() const;
double get_tau_fr() const;

protected:
/**
Expand Down Expand Up @@ -223,21 +223,21 @@ class Archiving_Node : public Node
* Structural plasticity
*/

// Time of the last update of the Calcium concentration in ms
double Ca_t_;
// Time of the last update of the firing rate in ms
double fr_t_;

// Value of the calcium concentration [Ca2+] at Ca_t_. Intracellular calcium
// concentration has a linear factor to mean electrical activity of 10^2,
// this means, for example, that a [Ca2+] of 0.2 is equivalent to a mean
// activity of 20Hz.
double Ca_minus_;
// Value of the firing rate calculated using a low pass filter algorithm.
// Each time the neuron fires, beta_FR_ is added to FR_minus_.
// Between spikes, in the function update_synaptic_elements,
// fr_minus is decreases exponentially with a time
// constant tau_FR_.
double fr_minus_;

// Time constant for exponential decay of the intracellular calcium
// concentration
double tau_Ca_;
// Time constant for exponential decay used to calculate the firing rate
double tau_fr_;

// Increase in calcium concentration [Ca2+] for each spike of the neuron
double beta_Ca_;
// Constant used to update the firing rate at each spike of the neuron
double beta_fr_;

// Map of the synaptic elements
std::map< Name, SynapticElement > synaptic_elements_map_;
Expand All @@ -250,15 +250,15 @@ Archiving_Node::get_spiketime_ms() const
}

inline double
Archiving_Node::get_tau_Ca() const
Archiving_Node::get_tau_fr() const
{
return tau_Ca_;
return tau_fr_;
}

inline double
Archiving_Node::get_Ca_minus() const
Archiving_Node::get_fr_minus() const
{
return Ca_minus_;
return fr_minus_;
}

} // of namespace
Expand Down
28 changes: 14 additions & 14 deletions nestkernel/growth_curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ nest::GrowthCurveLinear::set( const DictionaryDatum& d )
double
nest::GrowthCurveLinear::update( double t,
double t_minus,
double Ca_minus,
double fr_minus,
double z_minus,
double tau_Ca,
double tau_fr,
double growth_rate ) const
{
const double Ca = Ca_minus * std::exp( ( t_minus - t ) / tau_Ca );
const double z_value = growth_rate * tau_Ca * ( Ca - Ca_minus ) / eps_
const double fr = fr_minus * std::exp( ( t_minus - t ) / tau_fr );
const double z_value = growth_rate * tau_fr * ( fr - fr_minus ) / eps_
+ growth_rate * ( t - t_minus ) + z_minus;

return std::max( z_value, 0.0 );
Expand Down Expand Up @@ -106,9 +106,9 @@ nest::GrowthCurveGaussian::set( const DictionaryDatum& d )
double
nest::GrowthCurveGaussian::update( double t,
double t_minus,
double Ca_minus,
double fr_minus,
double z_minus,
double tau_Ca,
double tau_fr,
double growth_rate ) const
{
// Numerical integration from t_minus to t
Expand All @@ -118,13 +118,13 @@ nest::GrowthCurveGaussian::update( double t,
const double xi = ( eta_ + eps_ ) / 2.0;

double z_value = z_minus;
double Ca = Ca_minus;
double fr = fr_minus;

for ( double lag = t_minus; lag < ( t - h / 2.0 ); lag += h )
{
Ca = Ca - ( ( Ca / tau_Ca ) * h );
fr = fr - ( ( fr / tau_fr ) * h );
const double dz =
h * growth_rate * ( 2.0 * exp( -pow( ( Ca - xi ) / zeta, 2 ) ) - 1.0 );
h * growth_rate * ( 2.0 * exp( -pow( ( fr - xi ) / zeta, 2 ) ) - 1.0 );
z_value = z_value + dz;
}

Expand Down Expand Up @@ -166,23 +166,23 @@ nest::GrowthCurveSigmoid::set( const DictionaryDatum& d )
double
nest::GrowthCurveSigmoid::update( double t,
double t_minus,
double Ca_minus,
double fr_minus,
double z_minus,
double tau_Ca,
double tau_fr,
double growth_rate ) const
{
// Numerical integration from t_minus to t
// use standard forward Euler numerics
const double h = Time::get_resolution().get_ms();

double z_value = z_minus;
double Ca = Ca_minus;
double fr = fr_minus;

for ( double lag = t_minus; lag < ( t - h / 2.0 ); lag += h )
{
Ca = Ca - ( ( Ca / tau_Ca ) * h );
fr = fr - ( ( fr / tau_fr ) * h );
const double dz = h * growth_rate
* ( ( 2.0 / ( 1.0 + exp( ( Ca - eps_ ) / psi_ ) ) ) - 1.0 );
* ( ( 2.0 / ( 1.0 + exp( ( fr - eps_ ) / psi_ ) ) ) - 1.0 );
z_value = z_value + dz;
}

Expand Down
Loading

0 comments on commit 9dc3f24

Please sign in to comment.