Skip to content

Commit

Permalink
Allow probing of point state by tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
thorstenhater committed Sep 30, 2024
1 parent 3f31da1 commit 292ea4e
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 138 deletions.
47 changes: 30 additions & 17 deletions arbor/fvm_lowered_cell_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <arbor/assert.hpp>
#include <arbor/common_types.hpp>
#include <arbor/cable_cell.hpp>
#include <arbor/cable_cell_param.hpp>
#include <arbor/recipe.hpp>
#include <arbor/util/any_visitor.hpp>
Expand Down Expand Up @@ -882,15 +883,15 @@ void resolve_probe(const cable_probe_density_state_cell& p, probe_resolution_dat
}

inline
auto point_info_of(cell_lid_type target,
auto point_info_of(cell_tag_type target,
cell_lid_type lid,
int mech_index,
const mlocation_map<synapse>& instances,
const std::vector<arb_index_type>& multiplicity) {

auto opt_i = util::binary_search_index(instances, target, [](auto& item) { return item.lid; });
auto opt_i = util::binary_search_index(instances, lid, [](auto& item) { return item.lid; });
if (!opt_i) throw arbor_internal_error("inconsistent mechanism state");

return cable_probe_point_info {target,
return cable_probe_point_info {std::move(target),
lid,
multiplicity.empty() ? 1u: multiplicity.at(mech_index),
instances[*opt_i].loc};
}
Expand All @@ -903,6 +904,7 @@ void resolve_probe(const cable_probe_point_state& p, probe_resolution_data<B>& R
const auto& mech = p.mechanism;
const auto& state = p.state;
const auto& target = p.target;
const auto& t_hash = hash_value(target);
const auto& data = R.mechanism_state(mech, state);
if (!R.mech_instance_by_name.count(mech)) return;
const auto mech_id = R.mech_instance_by_name.at(mech)->mechanism_id();
Expand All @@ -913,17 +915,27 @@ void resolve_probe(const cable_probe_point_state& p, probe_resolution_data<B>& R
// Convert cell-local target number to cellgroup target number.
const auto& divs = R.M.target_divs;
auto cell = R.cell_idx;
auto cg = target + divs.at(cell);
if (cg >= divs.at(cell + 1)) return;

const auto& handle = R.handles.at(cg);
if (handle.mech_id != mech_id) return;
auto mech_index = handle.mech_index;
R.result.push_back(fvm_probe_scalar{{data + mech_index},
point_info_of(target,
mech_index,
synapses.at(mech),
R.M.mechanisms.at(mech).multiplicity)});
auto cg_lo = divs.at(cell);
auto cg_hi = divs.at(cell + 1);
const auto& [lr_beg, lr_end] = R.cell
.synapse_ranges()
.equal_range(t_hash);
for (auto lr = lr_beg; lr != lr_end; ++lr) {
const auto& [lid_beg, lid_end] = lr->second;
for (auto lid = lid_beg; lid != lid_end; ++lid) {
auto cg = lid + cg_lo;
if (cg >= cg_hi) continue;
const auto& handle = R.handles.at(cg);
if (handle.mech_id != mech_id) return;
auto mech_index = handle.mech_index;
R.result.push_back(fvm_probe_scalar{{data + mech_index},
point_info_of(target,
lid,
mech_index,
synapses.at(mech),
R.M.mechanisms.at(mech).multiplicity)});
}
}
}

template <typename B>
Expand Down Expand Up @@ -954,7 +966,8 @@ void resolve_probe(const cable_probe_point_state_cell& p, probe_resolution_data<
auto mech_index = handle.mech_index;
r.raw_handles.push_back(data + mech_index);

metadata.push_back(point_info_of(target - cell_targets_beg, // Convert to cell-local target index.
metadata.push_back(point_info_of("",
target - cell_targets_beg, // Convert to cell-local target index.
mech_index,
placed_instances,
multiplicity));
Expand Down
13 changes: 9 additions & 4 deletions arbor/include/arbor/cable_cell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ using cable_sample_range = std::pair<const double*, const double*>;
//
// Metadata for point process probes.
struct ARB_SYMBOL_VISIBLE cable_probe_point_info {
cell_lid_type target; // Target number of point process instance on cell.
cell_tag_type target; // Target tag of point process instance on cell.
cell_lid_type lid; // Target lid of point process instance on cell.
unsigned multiplicity; // Number of combined instances at this site.
mlocation loc; // Point on cell morphology where instance is placed.
};
Expand Down Expand Up @@ -108,6 +109,7 @@ struct ARB_SYMBOL_VISIBLE cable_probe_density_state {
};

// Value of state variable `state` in density mechanism `mechanism` across components of the cell.
//
// Sample value type: `cable_sample_range`
// Sample metadata type: `mcable_list`
struct ARB_SYMBOL_VISIBLE cable_probe_density_state_cell {
Expand All @@ -116,16 +118,19 @@ struct ARB_SYMBOL_VISIBLE cable_probe_density_state_cell {
};

// Value of state variable `key` in point mechanism `source` at target `target`.
//
// Sample value type: `double`
// Sample metadata type: `cable_probe_point_info`
struct ARB_SYMBOL_VISIBLE cable_probe_point_state {
cell_lid_type target;
cell_tag_type target;
std::string mechanism;
std::string state;
};

// Value of state variable `key` in point mechanism `source` at every target with this mechanism.
// Metadata has one entry of type cable_probe_point_info for each matched (possibly coalesced) instance.
// Value of state variable `key` in point mechanism `source` at every target
// with this mechanism. Metadata has one entry of type cable_probe_point_info
// for each matched (possibly coalesced) instance.
//
// Sample value type: `cable_sample_range`
// Sample metadata type: `std::vector<cable_probe_point_info>`
struct ARB_SYMBOL_VISIBLE cable_probe_point_state_cell {
Expand Down
2 changes: 1 addition & 1 deletion arbor/include/arbor/util/expected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ struct expected<void, E> {
// Swap ops.

void swap(expected& other) {
data_.swap(other.data);
data_.swap(other.data_);
}

// Accessors.
Expand Down
Loading

0 comments on commit 292ea4e

Please sign in to comment.