forked from UWB-Biocomputing/BrainGrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHostSInputPoisson.cpp
94 lines (82 loc) · 2.29 KB
/
HostSInputPoisson.cpp
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
/*
* \file HostSInputPoisson.cpp
*
* \author Fumitaka Kawasaki
*
* \brief A class that performs stimulus input (implementation Poisson).
*/
#include "HostSInputPoisson.h"
#include "SingleThreadedSpikingModel.h"
#include "tinyxml.h"
/*
* The constructor for HostSInputPoisson.
*
* @param[in] psi Pointer to the simulation information
* @param[in] parms TiXmlElement to examine.
*/
HostSInputPoisson::HostSInputPoisson(SimulationInfo* psi, TiXmlElement* parms) : SInputPoisson(psi, parms)
{
}
/*
* destructor
*/
HostSInputPoisson::~HostSInputPoisson()
{
}
/*
* Initialize data.
*
* @param[in] psi Pointer to the simulation information.
*/
void HostSInputPoisson::init(SimulationInfo* psi)
{
SInputPoisson::init(psi);
if (fSInput == false)
return;
}
/*
* Terminate process.
*
* @param[in] psi Pointer to the simulation information.
*/
void HostSInputPoisson::term(SimulationInfo* psi)
{
SInputPoisson::term(psi);
}
/*
* Process input stimulus for each time step.
* Apply inputs on summationPoint.
*
* @param[in] psi Pointer to the simulation information.
*/
void HostSInputPoisson::inputStimulus(SimulationInfo* psi)
{
if (fSInput == false)
return;
#if defined(USE_OMP)
int chunk_size = psi->totalNeurons / omp_get_max_threads();
#endif
#if defined(USE_OMP)
#pragma omp parallel for schedule(static, chunk_size)
#endif
for (int neuron_index = 0; neuron_index < psi->totalNeurons; neuron_index++)
{
if (masks[neuron_index] == false)
continue;
BGSIZE iSyn = psi->maxSynapsesPerNeuron * neuron_index;
if (--nISIs[neuron_index] <= 0)
{
// add a spike
dynamic_cast<AllSpikingSynapses*>(m_synapses)->preSpikeHit(iSyn);
// update interval counter (exponectially distribution ISIs, Poisson)
BGFLOAT isi = -lambda * log(rng.inRange(0, 1));
// delete isi within refractoriness
while (rng.inRange(0, 1) <= exp(-(isi*isi)/32))
isi = -lambda * log(rng.inRange(0, 1));
// convert isi from msec to steps
nISIs[neuron_index] = static_cast<int>( (isi / 1000) / psi->deltaT + 0.5 );
}
// process synapse
m_synapses->advanceSynapse(iSyn, psi, NULL);
}
}