Skip to content

Commit

Permalink
Add SEClamp to LFP calculation (#2360)
Browse files Browse the repository at this point in the history
* Add SEClamp to LFP calculation in coreneuron
* Create function to avoid code repetition
  • Loading branch information
jorblancoa committed May 17, 2023
1 parent d8e07da commit c685dfc
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/coreneuron/io/reports/report_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,24 @@ VarsToReport ReportHandler::get_synapse_vars_to_report(
return vars_to_report;
}

void add_clamp_current(const char* clamp,
const NrnThread& nt,
std::unordered_map<size_t, std::vector<std::pair<double*, int>>>& currents,
int gid,
const std::vector<int>& nodes_to_gids) {
auto mech_id = nrn_get_mechtype(clamp);
Memb_list* ml = nt._ml_list[mech_id];
if (ml) {
for (int i = 0; i < ml->nodecount; i++) {
auto segment_id = ml->nodeindices[i];
if ((nodes_to_gids[segment_id] == gid)) {
double* var_value = get_var_location_from_var_name(mech_id, "i", ml, i);
currents[segment_id].push_back(std::make_pair(var_value, -1));
}
}
}
}

VarsToReport ReportHandler::get_lfp_vars_to_report(const NrnThread& nt,
const std::vector<int>& gids_to_report,
ReportConfiguration& report,
Expand All @@ -368,18 +386,9 @@ VarsToReport ReportHandler::get_lfp_vars_to_report(const NrnThread& nt,
VarsToReport vars_to_report;
off_t offset_lfp = 0;
for (const auto& gid: gids_to_report) {
// IClamp is needed for the LFP calculation
auto mech_id = nrn_get_mechtype("IClamp");
Memb_list* ml = nt._ml_list[mech_id];
if (ml) {
for (int j = 0; j < ml->nodecount; j++) {
auto segment_id = ml->nodeindices[j];
if ((nodes_to_gids[segment_id] == gid)) {
double* var_value = get_var_location_from_var_name(mech_id, "i", ml, j);
summation_report.currents_[segment_id].push_back(std::make_pair(var_value, -1));
}
}
}
// IClamp & SEClamp are needed for the LFP calculation
add_clamp_current("IClamp", nt, summation_report.currents_, gid, nodes_to_gids);
add_clamp_current("SEClamp", nt, summation_report.currents_, gid, nodes_to_gids);
const auto& cell_mapping = mapinfo->get_cell_mapping(gid);
if (cell_mapping == nullptr) {
std::cerr << "[LFP] Error : Compartment mapping information is missing for gid " << gid
Expand Down

0 comments on commit c685dfc

Please sign in to comment.