From 146b95791f7e78fd9185d249c13e73299f045337 Mon Sep 17 00:00:00 2001
From: Nora Abi Akar <nora.abiakar@gmail.com>
Date: Tue, 30 Mar 2021 10:08:40 +0200
Subject: [PATCH] Fix bug in `single_cell_model`, fix frequency in examples
 (#1458)

* Fix the regular schedule generated in `single_cell_model::run`
* Adjust frequency of probes in python examples to the correct unit (KHz).

Fixes #1457
---
 python/example/single_cell_detailed.py | 2 +-
 python/example/single_cell_model.py    | 2 +-
 python/example/single_cell_nml.py      | 6 +++---
 python/example/single_cell_swc.py      | 6 +++---
 python/single_cell_model.cpp           | 2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/python/example/single_cell_detailed.py b/python/example/single_cell_detailed.py
index d0223839..71e1346a 100755
--- a/python/example/single_cell_detailed.py
+++ b/python/example/single_cell_detailed.py
@@ -92,7 +92,7 @@ model.catalogue.extend(arbor.allen_catalogue(), "")
 
 # (7) Add probes.
 
-model.probe('voltage', where='"custom_terminal"',  frequency=50000)
+model.probe('voltage', where='"custom_terminal"',  frequency=50)
 
 # (8) Run the simulation.
 
diff --git a/python/example/single_cell_model.py b/python/example/single_cell_model.py
index 319c8ee3..76f0153e 100755
--- a/python/example/single_cell_model.py
+++ b/python/example/single_cell_model.py
@@ -25,7 +25,7 @@ cell = arbor.cable_cell(tree, labels, decor)
 m = arbor.single_cell_model(cell)
 
 # (6) Attach voltage probe sampling at 10 kHz (every 0.1 ms).
-m.probe('voltage', '"midpoint"', frequency=10000)
+m.probe('voltage', '"midpoint"', frequency=10)
 
 # (7) Run simulation for 30 ms of simulated activity.
 m.run(tfinal=30)
diff --git a/python/example/single_cell_nml.py b/python/example/single_cell_nml.py
index cb5e668f..838cb925 100755
--- a/python/example/single_cell_nml.py
+++ b/python/example/single_cell_nml.py
@@ -80,9 +80,9 @@ print(cell.locations('"axon_end"'))
 m = arbor.single_cell_model(cell)
 
 # Attach voltage probes that sample at 50 kHz.
-m.probe('voltage', where='"root"',  frequency=50000)
-m.probe('voltage', where='"stim_site"',  frequency=50000)
-m.probe('voltage', where='"axon_end"', frequency=50000)
+m.probe('voltage', where='"root"',  frequency=50)
+m.probe('voltage', where='"stim_site"',  frequency=50)
+m.probe('voltage', where='"axon_end"', frequency=50)
 
 # Simulate the cell for 15 ms.
 tfinal=15
diff --git a/python/example/single_cell_swc.py b/python/example/single_cell_swc.py
index 63113384..07609347 100755
--- a/python/example/single_cell_swc.py
+++ b/python/example/single_cell_swc.py
@@ -72,9 +72,9 @@ print(cell.locations('"axon_end"'))
 m = arbor.single_cell_model(cell)
 
 # Attach voltage probes that sample at 50 kHz.
-m.probe('voltage', where='"root"',  frequency=50000)
-m.probe('voltage', where='"stim_site"',  frequency=50000)
-m.probe('voltage', where='"axon_end"', frequency=50000)
+m.probe('voltage', where='"root"',  frequency=50)
+m.probe('voltage', where='"stim_site"',  frequency=50)
+m.probe('voltage', where='"axon_end"', frequency=50)
 
 # Simulate the cell for 15 ms.
 tfinal=15
diff --git a/python/single_cell_model.cpp b/python/single_cell_model.cpp
index 6fd99c82..22b17ada 100644
--- a/python/single_cell_model.cpp
+++ b/python/single_cell_model.cpp
@@ -194,7 +194,7 @@ public:
 
             traces_.push_back({"voltage", p.site, {}, {}});
 
-            auto sched = arb::regular_schedule(p.frequency);
+            auto sched = arb::regular_schedule(1.0/p.frequency);
 
             // Now attach the sampler at probe site, with sampling schedule sched, writing to voltage
             sim_->add_sampler(arb::one_probe({0,i}), sched, trace_callback(traces_[i]));
-- 
GitLab