From 677f96df62bf3796e2689ac321ce9f4972d4fc3d Mon Sep 17 00:00:00 2001 From: Sam Yates <halfflat@gmail.com> Date: Thu, 8 Aug 2019 18:17:58 +0200 Subject: [PATCH] Fix examples to use new cable cell API. (#832) Also remove vestigial segment::length_constant() virtual function. Fixes #831. --- arbor/include/arbor/segment.hpp | 5 ----- example/dryrun/dryrun.cpp | 9 +++++++-- example/gap_junctions/gap_junctions.cpp | 7 ++++--- example/generators/event_gen.cpp | 6 ++++++ example/ring/ring.cpp | 3 +-- example/single/single.cpp | 27 +++++++++++++++---------- 6 files changed, 34 insertions(+), 23 deletions(-) diff --git a/arbor/include/arbor/segment.hpp b/arbor/include/arbor/segment.hpp index 38f1849c..ece282fb 100644 --- a/arbor/include/arbor/segment.hpp +++ b/arbor/include/arbor/segment.hpp @@ -83,11 +83,6 @@ public: return false; } - // Approximate frequency-dependent length constant lower bound. - virtual value_type length_constant(value_type freq_Hz) const { - return 0; - } - util::optional<mechanism_desc&> mechanism(const std::string& name) { auto it = std::find_if(mechanisms_.begin(), mechanisms_.end(), [&](mechanism_desc& m) { return m.name()==name; }); diff --git a/example/dryrun/dryrun.cpp b/example/dryrun/dryrun.cpp index 12728c69..b9e5619e 100644 --- a/example/dryrun/dryrun.cpp +++ b/example/dryrun/dryrun.cpp @@ -68,6 +68,12 @@ public: return cell_kind::cable; } + arb::util::any get_global_properties(arb::cell_kind) const override { + arb::cable_cell_global_properties gprop; + gprop.default_parameters = arb::neuron_parameter_defaults; + return gprop; + } + // Each cell has one spike detector (at the soma). cell_size_type num_sources(cell_gid_type gid) const override { return 1; @@ -304,10 +310,10 @@ double interp(const std::array<T,2>& r, unsigned i, unsigned n) { arb::cable_cell branch_cell(arb::cell_gid_type gid, const cell_parameters& params) { arb::cable_cell cell; + cell.default_parameters.axial_resistivity = 100; // [Ω·cm] // Add soma. auto soma = cell.add_soma(12.6157/2.0); // For area of 500 μm². - soma->rL = 100; soma->add_mechanism("hh"); std::vector<std::vector<unsigned>> levels; @@ -336,7 +342,6 @@ arb::cable_cell branch_cell(arb::cell_gid_type gid, const cell_parameters& param auto dend = cell.add_cable(sec, arb::section_kind::dendrite, dend_radius, dend_radius, l); dend->set_compartments(nc); dend->add_mechanism("pas"); - dend->rL = 100; } } } diff --git a/example/gap_junctions/gap_junctions.cpp b/example/gap_junctions/gap_junctions.cpp index 2e8381f7..4a633a77 100644 --- a/example/gap_junctions/gap_junctions.cpp +++ b/example/gap_junctions/gap_junctions.cpp @@ -97,7 +97,8 @@ public: arb::util::any get_global_properties(cell_kind k) const override { arb::cable_cell_global_properties a; - a.temperature_K = 308.15; + a.default_parameters = arb::neuron_parameter_defaults; + a.default_parameters.temperature_K = 308.15; return a; } @@ -321,6 +322,8 @@ void write_trace_json(const std::vector<arb::trace_data<double>>& trace, unsigne arb::cable_cell gj_cell(cell_gid_type gid, unsigned ncell, double stim_duration) { arb::cable_cell cell; + cell.default_parameters.axial_resistivity = 100; // [Ω·cm] + cell.default_parameters.membrane_capacitance = 0.018; // [F/m²] arb::mechanism_desc nax("nax"); arb::mechanism_desc kdrmt("kdrmt"); @@ -337,8 +340,6 @@ arb::cable_cell gj_cell(cell_gid_type gid, unsigned ncell, double stim_duration) }; auto setup_seg = [&](auto seg) { - seg->rL = 100; - seg->cm = 0.018; seg->add_mechanism(nax); seg->add_mechanism(kdrmt); seg->add_mechanism(kamt); diff --git a/example/generators/event_gen.cpp b/example/generators/event_gen.cpp index 4106e1dc..b7acd24a 100644 --- a/example/generators/event_gen.cpp +++ b/example/generators/event_gen.cpp @@ -65,6 +65,12 @@ public: return cell_kind::cable; } + arb::util::any get_global_properties(arb::cell_kind) const override { + arb::cable_cell_global_properties gprop; + gprop.default_parameters = arb::neuron_parameter_defaults; + return gprop; + } + // The cell has one target synapse, which receives both inhibitory and exchitatory inputs. cell_size_type num_targets(cell_gid_type gid) const override { arb_assert(gid==0); // There is only one cell in the model diff --git a/example/ring/ring.cpp b/example/ring/ring.cpp index 150baf13..4bbcefd6 100644 --- a/example/ring/ring.cpp +++ b/example/ring/ring.cpp @@ -301,10 +301,10 @@ double interp(const std::array<T,2>& r, unsigned i, unsigned n) { arb::cable_cell branch_cell(arb::cell_gid_type gid, const cell_parameters& params) { arb::cable_cell cell; + cell.default_parameters.axial_resistivity = 100; // [Ω·cm] // Add soma. auto soma = cell.add_soma(12.6157/2.0); // For area of 500 μm². - soma->rL = 100; soma->add_mechanism("hh"); std::vector<std::vector<unsigned>> levels; @@ -333,7 +333,6 @@ arb::cable_cell branch_cell(arb::cell_gid_type gid, const cell_parameters& param auto dend = cell.add_cable(sec, arb::section_kind::dendrite, dend_radius, dend_radius, l); dend->set_compartments(nc); dend->add_mechanism("pas"); - dend->rL = 100; } } } diff --git a/example/single/single.cpp b/example/single/single.cpp index d1c82bdb..3855f9de 100644 --- a/example/single/single.cpp +++ b/example/single/single.cpp @@ -26,7 +26,9 @@ arb::morphology default_morphology(); arb::morphology read_swc(const std::string& path); struct single_recipe: public arb::recipe { - explicit single_recipe(arb::morphology m): morpho(m) {} + explicit single_recipe(arb::morphology m): morpho(m) { + gprop.default_parameters = arb::neuron_parameter_defaults; + } arb::cell_size_type num_cells() const override { return 1; } arb::cell_size_type num_probes(arb::cell_gid_type) const override { return 1; } @@ -46,24 +48,26 @@ struct single_recipe: public arb::recipe { return arb::cell_kind::cable; } + arb::util::any get_global_properties(arb::cell_kind) const override { + return gprop; + } + arb::util::unique_any get_cell_description(arb::cell_gid_type) const override { arb::cable_cell c = make_cable_cell(morpho); // Add HH mechanism to soma, passive channels to dendrites. // Discretize dendrites according to the NEURON d-lambda rule. - for (auto& segment: c.segments()) { - if (segment->is_soma()) { - segment->add_mechanism("hh"); - } - else { - segment->add_mechanism("pas"); + c.soma()->add_mechanism("hh"); + auto& segments = c.segments(); + for (std::size_t i = 1; i<segments.size(); ++i) { + double dx = c.segment_length_constant(100., i, gprop.default_parameters)*0.3; - double dx = segment->length_constant(100.)*0.3; - unsigned n = std::ceil(segment->as_cable()->length()/dx); - segment->set_compartments(n); + arb::cable_segment* seg = c.cable(i); + seg->add_mechanism("pas"); - } + unsigned n = std::ceil(seg->length()/dx); + seg->set_compartments(n); } // Add synapse to last segment. @@ -76,6 +80,7 @@ struct single_recipe: public arb::recipe { } arb::morphology morpho; + arb::cable_cell_global_properties gprop; }; int main(int argc, char** argv) { -- GitLab