Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arbor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
arbor-sim
arbor
Commits
d4b76875
Commit
d4b76875
authored
8 years ago
by
Benjamin Cumming
Browse files
Options
Downloads
Patches
Plain Diff
work on spike source <remove>
parent
3553ac8b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/spike_source.hpp
+12
-8
12 additions, 8 deletions
src/spike_source.hpp
with
12 additions
and
8 deletions
src/spike_source.hpp
+
12
−
8
View file @
d4b76875
...
...
@@ -11,7 +11,7 @@ namespace mc {
class
spike_source
{
public:
virtual
std
::
vector
<
float
>
test
(
float
t
)
=
0
;
virtual
util
::
optional
<
float
>
test
(
float
t
)
=
0
;
};
// spike detector for a lowered cell
...
...
@@ -36,15 +36,15 @@ class spike_detector : public spike_source
is_spiking_
=
previous_v_
>=
thresh
?
true
:
false
;
}
std
::
vector
<
float
>
test
(
float
t
)
override
{
std
::
vector
<
float
>
spike_times
;
util
::
optional
<
float
>
test
(
float
t
)
override
{
util
::
optional
<
float
>
result
=
util
::
nothing
;
auto
v
=
cell_
->
voltage
(
location_
);
if
(
!
is_spiking_
)
{
if
(
v
>=
threshold_
)
{
// the threshold has been passed, so estimate the time using
// linear interpolation
auto
pos
=
(
threshold_
-
previous_v_
)
/
(
v
-
previous_v_
);
spike_times
.
push_back
(
previous_t_
+
pos
*
(
t
-
previous_t_
)
)
;
result
=
previous_t_
+
pos
*
(
t
-
previous_t_
);
is_spiking_
=
true
;
}
...
...
@@ -58,7 +58,7 @@ class spike_detector : public spike_source
previous_v_
=
v
;
previous_t_
=
t
;
return
spike_times
;
return
result
;
}
bool
is_spiking
()
const
{
...
...
@@ -88,21 +88,25 @@ class poisson_generator : public spike_source
public:
poisson_generator
(
float
r
)
:
firing_rate_
(
r
)
:
dist_
(
0.0
f
,
1.0
f
),
firing_rate_
(
r
)
{}
util
::
optional
<
float
>
test
(
float
t
)
{
// generate a uniformly distrubuted random number x \in [0,1]
// if (x > r*dt) we have a spike in the interval
std
::
vector
<
float
>
spike_times
;
if
(
rand
(
)
>
firing_rate_
*
(
t
-
previous_t_
))
{
if
(
dist_
(
generator_
)
>
firing_rate_
*
(
t
-
previous_t_
))
{
return
t
;
}
return
util
::
optional
<
float
>::
nothing
;
return
util
::
nothing
;
}
private
:
std
::
mt19937
generator_
;
// for now default initialized
std
::
uniform_real_distribution
<
float
>
dist_
;
// firing rate in spikes/ms
float
firing_rate_
;
float
previous_t_
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment