Miind
GeomInputConvertor.cpp
Go to the documentation of this file.
1 // Copyright (c) 2005 - 2014 Marc de Kamps
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5 //
6 // * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation
8 // and/or other materials provided with the distribution.
9 // * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software
10 // without specific prior written permission.
11 //
12 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
13 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
14 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
15 // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
16 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 //
18 // If you use this software in work leading to a scientific publication, you should include a reference there to
19 // the 'currently valid reference', which can be found at http://miind.sourceforge.net
20 #include "../MPILib/include/AlgorithmInterface.hpp"
21 #include "GeomInputConvertor.hpp"
22 #include "MuSigmaScalarProduct.hpp"
23 #include "NeuronParameter.hpp"
24 #include "GeomLibException.hpp"
25 
26 
27 using namespace GeomLib;
28 
30 (
31  const NeuronParameter& par_neuron,
32  const DiffusionParameter& par_diff,
33  const CurrentCompensationParameter& par_curr,
34  const std::vector<MPILib::Potential>& vec_int,
35  bool b_force_small
36 ):
37 _par_neuron (par_neuron),
38 _par_diff (par_diff),
39 _par_curr (par_curr),
40 _vec_interpretation (vec_int),
41 _vec_direct (0),
42 _vec_diffusion (0),
43 _force_small_bins (b_force_small)
44 {
45 }
46 
48 {
49  return _vec_direct.size();
50 }
51 
53 (
54  const MuSigma& par,
56 ) const
57 {
58  double mu = par._mu;
59  double sigma = par._sigma;
60 
61  if (mu == 0.0 && sigma ==0.0){
62  set._h_exc = 0.0;
63  set._h_inh = 0.0;
64  set._rate_exc = 0.0;
65  set._rate_inh = 0.0;
66  return;
67  }
68 
69  MPILib::Potential h = (mu != 0.0) ? sigma*sigma/mu : std::numeric_limits<double>::max();
70 
71  if (mu != 0 && IsSingleDiffusionProcess(h) ){
72 
73  if (fabs(h) < 2*_min_step && _force_small_bins)
74  throw GeomLibException("Increase the number of bins.");
75 
76  MPILib::Rate rate = mu*mu/(sigma*sigma*_par_neuron._tau);
77 
78  if ( h > 0 ){
79  set._h_exc = h;
80  set._h_inh = 0.0;
81  set._rate_exc = rate;
82  set._rate_inh = 0.0;
83  }
84  else {
85  set._h_exc = 0.0;
86  set._h_inh = h; // removed - sign, MdK 04/08/2012; the step size need to be forwarded as a negative number
87  set._rate_exc = 0.0;
88  set._rate_inh = rate;
89  }
90  }
91  else {
92  double h = _par_diff._diffusion_jump*(_par_neuron._theta - _vec_interpretation[0]);
93 
94  if (fabs(h) < 2*_min_step && _force_small_bins)
95  throw GeomLibException("Increase the number of bins.");
96 
97  double tau = _par_neuron._tau;
98  set._h_exc = h;
99  set._h_inh = -h;
100 
101  set._rate_exc = (sigma*sigma + h*mu)/(2*h*h*tau);
102  set._rate_inh = (sigma*sigma - h*mu)/(2*h*h*tau);
103 
104  assert( set._rate_exc >= 0.0);
105  assert( set._rate_inh >= 0.0);
106  }
107 }
108 
110 {
112 }
113 
115 (
116  const std::vector<MPILib::Rate>& vec_rates,
117  const std::vector<MPILib::DelayedConnection>& vec_con,
118  const std::vector<MPILib::NodeType>& vec_type
119 )
120 {
121  assert(vec_rates.size() == vec_con.size());
122  assert(vec_type.size() == vec_rates.size());
123 
124  // it is guaranteed that there is exist a parameter vector that is large enough
125  if (_vec_set.size() == 0)
126  // If all inputs are direct, still one extra input is needed for diffusion
127  _vec_set = std::vector<InputParameterSet>(vec_type.size() + 1);
128 
129  _vec_direct.clear();
130  _vec_diffusion.clear();
131 
132  for (MPILib::Index i = 0; i < vec_type.size(); i++)
133  if (vec_type[i] == MPILib::EXCITATORY_GAUSSIAN ||
134  vec_type[i] == MPILib::INHIBITORY_GAUSSIAN)
135  _vec_diffusion.push_back(i);
136  else
137  _vec_direct.push_back(i);
138 
139  this->AddDiffusionParameter (vec_con, vec_rates);
140  this->AddBurstParameters (vec_con, vec_rates);
141 }
142 
144 (
145  const std::vector<MPILib::DelayedConnection>& vec_con,
146  const std::vector<MPILib::Rate>& vec_rates
147 )
148 {
149  MPILib::Index start = 1;
150  for(auto i: _vec_direct){
151 
152  double h = vec_con[i]._efficacy;
153  double N = vec_con[i]._number_of_connections;
154  double rate = vec_rates[i];
155 
156  if (h >= 0 ){
157  _vec_set[start]._h_exc = h;
158  _vec_set[start]._h_inh = 0;
159  _vec_set[start]._rate_exc = rate*N;
160  _vec_set[start]._rate_inh = 0.0;
161  } else
162  {
163  _vec_set[start]._h_exc = 0;
164  _vec_set[start]._h_inh = h;
165  _vec_set[start]._rate_exc = 0.0;
166  _vec_set[start]._rate_inh = rate*N;
167  }
168  start++;
169  }
170 }
171 
173 (
174  const std::vector<MPILib::DelayedConnection>& vec_con,
175  const std::vector<MPILib::Rate>& vec_rates,
176  std::vector<MPILib::DelayedConnection>* p_vec_con_diff,
177  std::vector<MPILib::Rate>* p_vec_rates_diff
178 )
179 {
180  for (auto i: _vec_diffusion){
181  p_vec_con_diff->push_back(vec_con[i]);
182  p_vec_rates_diff->push_back(vec_rates[i]);
183  }
184 }
185 
186 
188 (
189  const std::vector<MPILib::DelayedConnection>& vec_con,
190  const std::vector<MPILib::Rate>& vec_rates
191 )
192 {
193  std::vector<MPILib::DelayedConnection> vec_diff_con;
194  std::vector<MPILib::Rate> vec_diff_rates;
195 
196  SortDiffusionInput(vec_con,vec_rates, &vec_diff_con,&vec_diff_rates);
197 
199  MuSigma par =
200  scalar.Evaluate
201  (
202  vec_diff_rates,
203  vec_diff_con,
204  _par_neuron._tau
205  );
206 
207  par._mu += _par_curr._I;
208  par._sigma += _par_curr._sigma;
209 
210  SetDiffusionParameters(par,_vec_set[0]);
211 }
212 
214 (
215  const std::vector<MPILib::Potential>& vec_interpretation
216 ) const
217 {
218  assert (vec_interpretation.size() > 0);
219  double min = std::numeric_limits<double>::max();
220  for (MPILib::Index i = 0; i < vec_interpretation.size() - 1; i++){
221  double dif = fabs(vec_interpretation[i+1] - vec_interpretation[i]);
222  if (min > dif)
223  min = dif;
224  }
225  return min;
226 }
227 
MPILib::Number NumberDirect() const
number of external inputs that are interpreted as direct input
bool IsSingleDiffusionProcess(MPILib::Potential h) const
MPILib::Potential _h_inh
Synaptic efficacy in mV or V, do not interpret as a number of bins.
Indicates that Dale's law should not be checked for this node.
Definition: NodeType.hpp:33
double Potential
std::vector< MPILib::Index > _vec_direct
void SortConnectionvector(const std::vector< MPILib::Rate > &, const std::vector< MPILib::DelayedConnection > &, const std::vector< MPILib::NodeType > &)
When to switch to a two Poisson input approximation, and what input jump to use then.
unsigned int Number
GeomInputConvertor(const NeuronParameter &, const DiffusionParameter &, const CurrentCompensationParameter &, const std::vector< MPILib::Potential > &, bool force_small_bins=false)
MPILib::Rate _rate_inh
Excitatory input rate driving the population, usually in spikes/s.
void SetDiffusionParameters(const MuSigma &par, InputParameterSet &set) const
unsigned int Index
MPILib::Potential _h_exc
Inhibitory efficacy in terms of bins. The real number of bins is rounded to the next integer...
Parameter for setting current compensation values for the neural models that use it.
MPILib::Potential _theta
threshold potential in V
void SortDiffusionInput(const std::vector< MPILib::DelayedConnection > &, const std::vector< MPILib::Rate > &vec_rates, std::vector< MPILib::DelayedConnection > *, std::vector< MPILib::Rate > *)
void AddBurstParameters(const std::vector< MPILib::DelayedConnection > &, const std::vector< MPILib::Rate > &)
Base class for all exceptions thrown in GeomLib.
const NeuronParameter _par_neuron
Parameters necessary for the configuration of a GeomAlgorithm or an OUAlgorithm.
MPILib::Potential MinVal(const std::vector< MPILib::Potential > &) const
Indicates that Dale's law should be checked and that the contribution oof this excitatory node is to ...
Definition: NodeType.hpp:34
const DiffusionParameter _par_diff
MPILib::Rate _rate_exc
When the efficacy needs to be expressed as a number of bins, add this number to _H_inh for an accurat...
MPILib::Potential _sigma
Definition: MuSigma.hpp:36
std::vector< MPILib::Potential > _vec_interpretation
void AddDiffusionParameter(const std::vector< MPILib::DelayedConnection > &, const std::vector< MPILib::Rate > &)
The objective is find a numerical solution for this equation This requires a numerical representation of the density We will work in the state space of a two dimensional and define a mesh there We first give two examples and then define the general procedure and given in Table for given fixed Delta g see Fig and we will denote coordinates in this dimension by a small letter $v The second dimension can be used to represent parameters as varied as and will represented by $w A strip is constructed by choosing two neighbouring points in state e g and integrating the vector field for a time $T that is assumed to be an integer multiple of a period of time Delta which we assume to be a defining characteristic of the grid Let then the set of points the set of points which is quadrilateral in shape The quadrilateral should be but not necessarily as long as they are but it is convenient to number them in order of creation In the we will assume that strip numbers created by the integration procedure start and are so that the numbers i in each identify a unique strip Strip no is reserved for stationary points There may or more cells in strip The number of cells in strip $i denoted by with $i the strip number and $j the cell as the i
Definition: 2D.hpp:145
MuSigma Evaluate(const std::vector< MPILib::Rate > &nodeVector, const std::vector< WeightType > &weightVector, MPILib::Time tau) const
double Rate
MPILib::Potential _mu
Definition: MuSigma.hpp:32