From 10fd756a71eabeb34e9050d1f2c512a5064f1d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandru=20S=C4=83vulescu?= Date: Tue, 28 Jun 2022 13:37:51 +0200 Subject: [PATCH 01/14] Revert "semantic version 9.0.0 (#828)" This reverts commit 53796632df93e81e59bd9e746d0293bbee544df5. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 183639480..cfe7bc8c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) # standalone. project( coreneuron - VERSION 9.0.0 + VERSION 8.2.0 LANGUAGES CXX) # ~~~ From 02273318b7a7aa40a6cde64fd6b8df9b96ee896e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandru=20S=C4=83vulescu?= Date: Tue, 9 Aug 2022 11:18:57 +0200 Subject: [PATCH 02/14] semantic version: 8.2.1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfe7bc8c3..0a02ec93d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) # standalone. project( coreneuron - VERSION 8.2.0 + VERSION 8.2.1 LANGUAGES CXX) # ~~~ From fd7fe614d876b82d41411e8856528203f9fa7974 Mon Sep 17 00:00:00 2001 From: Jorge Blanco Alonso Date: Wed, 27 Oct 2021 16:07:58 +0200 Subject: [PATCH 03/14] Read lfp factors from neurodamus --- coreneuron/io/nrn_filehandler.hpp | 8 +++++++- coreneuron/io/nrn_setup.cpp | 2 +- coreneuron/io/nrnsection_mapping.hpp | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/coreneuron/io/nrn_filehandler.hpp b/coreneuron/io/nrn_filehandler.hpp index 65cab4b97..26d960ef0 100644 --- a/coreneuron/io/nrn_filehandler.hpp +++ b/coreneuron/io/nrn_filehandler.hpp @@ -14,6 +14,7 @@ #include #include "coreneuron/utils/nrn_assert.h" +#include "coreneuron/io/nrnsection_mapping.hpp" namespace coreneuron { /** Encapsulate low-level reading of coreneuron input data files. @@ -110,7 +111,7 @@ class FileHandler { * Read count no of mappings for section to segment */ template - int read_mapping_info(T* mapinfo) { + int read_mapping_info(T* mapinfo, NrnThreadMappingInfo* ntmapping) { int nsec, nseg, n_scan; char line_buf[max_line_length], name[max_line_length]; @@ -123,14 +124,19 @@ class FileHandler { if (nseg) { std::vector sec, seg; + std::vector lfp_factors; sec.reserve(nseg); seg.reserve(nseg); + lfp_factors.reserve(nseg); read_array(&sec[0], nseg); read_array(&seg[0], nseg); + read_array(&lfp_factors[0], nseg); for (int i = 0; i < nseg; i++) { mapinfo->add_segment(sec[i], seg[i]); + ntmapping->add_segment_id(seg[i]); + ntmapping->add_segment_lfp_factor(seg[i], lfp_factors[i]); } } return nseg; diff --git a/coreneuron/io/nrn_setup.cpp b/coreneuron/io/nrn_setup.cpp index 703e853d8..e24f1d424 100644 --- a/coreneuron/io/nrn_setup.cpp +++ b/coreneuron/io/nrn_setup.cpp @@ -959,7 +959,7 @@ void read_phase3(NrnThread& nt, UserParams& userParams) { // read section-segment mapping for every section list for (int j = 0; j < nseclist; j++) { SecMapping* smap = new SecMapping(); - F.read_mapping_info(smap); + F.read_mapping_info(smap, ntmapping); cmap->add_sec_map(smap); } diff --git a/coreneuron/io/nrnsection_mapping.hpp b/coreneuron/io/nrnsection_mapping.hpp index d7524fc42..9756fca8d 100644 --- a/coreneuron/io/nrnsection_mapping.hpp +++ b/coreneuron/io/nrnsection_mapping.hpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace coreneuron { @@ -153,6 +154,12 @@ struct NrnThreadMappingInfo { /** list of cells mapping */ std::vector mappingvec; + /** list of segment ids */ + std::vector segment_ids; + + /** map containing segment ids an its respective lfp factors */ + std::unordered_map lfp_factors; + /** @brief number of cells */ size_t size() const { return mappingvec.size(); @@ -181,5 +188,15 @@ struct NrnThreadMappingInfo { void add_cell_mapping(CellMapping* c) { mappingvec.push_back(c); } + + /** @brief add a new segment */ + void add_segment_id(const int segment_id) { + segment_ids.push_back(segment_id); + } + + /** @brief add the lfp factor of a segment_id */ + void add_segment_lfp_factor(const int segment_id, double factor) { + lfp_factors.insert({segment_id, factor}); + } }; } // namespace coreneuron From fb3503dfa7323d9a7f7e7c726e5da6901a985534 Mon Sep 17 00:00:00 2001 From: Jorge Blanco Alonso Date: Fri, 5 Nov 2021 17:32:51 +0100 Subject: [PATCH 04/14] Add lfp report type --- coreneuron/io/nrn_filehandler.hpp | 3 ++ coreneuron/io/nrnsection_mapping.hpp | 2 ++ coreneuron/io/reports/nrnreport.hpp | 3 +- .../reports/report_configuration_parser.cpp | 3 ++ coreneuron/io/reports/report_event.cpp | 21 +++++++++++ coreneuron/io/reports/report_event.hpp | 1 + coreneuron/io/reports/report_handler.cpp | 36 +++++++++++++++++++ coreneuron/io/reports/report_handler.hpp | 3 ++ .../io/reports/sonata_report_handler.cpp | 1 + 9 files changed, 72 insertions(+), 1 deletion(-) diff --git a/coreneuron/io/nrn_filehandler.hpp b/coreneuron/io/nrn_filehandler.hpp index 26d960ef0..ad3ed2eca 100644 --- a/coreneuron/io/nrn_filehandler.hpp +++ b/coreneuron/io/nrn_filehandler.hpp @@ -133,6 +133,9 @@ class FileHandler { read_array(&seg[0], nseg); read_array(&lfp_factors[0], nseg); + std::cout << "=====> NEW CoreNEURON!" << std::endl; + std::cout << "nseg = " << nseg << std::endl; + for (int i = 0; i < nseg; i++) { mapinfo->add_segment(sec[i], seg[i]); ntmapping->add_segment_id(seg[i]); diff --git a/coreneuron/io/nrnsection_mapping.hpp b/coreneuron/io/nrnsection_mapping.hpp index 9756fca8d..29836a24b 100644 --- a/coreneuron/io/nrnsection_mapping.hpp +++ b/coreneuron/io/nrnsection_mapping.hpp @@ -160,6 +160,8 @@ struct NrnThreadMappingInfo { /** map containing segment ids an its respective lfp factors */ std::unordered_map lfp_factors; + std::vector _lfp; + /** @brief number of cells */ size_t size() const { return mappingvec.size(); diff --git a/coreneuron/io/reports/nrnreport.hpp b/coreneuron/io/reports/nrnreport.hpp index 7cdc05806..ac85d75be 100644 --- a/coreneuron/io/reports/nrnreport.hpp +++ b/coreneuron/io/reports/nrnreport.hpp @@ -76,7 +76,8 @@ enum ReportType { SynapseReport, IMembraneReport, SectionReport, - SummationReport + SummationReport, + LFPReport }; // enumerate that defines the section type for a Section report diff --git a/coreneuron/io/reports/report_configuration_parser.cpp b/coreneuron/io/reports/report_configuration_parser.cpp index 6c69662b7..528c269a6 100644 --- a/coreneuron/io/reports/report_configuration_parser.cpp +++ b/coreneuron/io/reports/report_configuration_parser.cpp @@ -138,6 +138,9 @@ std::vector create_report_configurations(const std::string& report_type = SynapseReport; } else if (report.type_str == "summation") { report_type = SummationReport; + } else if (report.type_str == "lfp") { + nrn_use_fast_imem = true; + report_type = LFPReport; } else { std::cerr << "Report error: unsupported type " << report.type_str << std::endl; nrn_abort(1); diff --git a/coreneuron/io/reports/report_event.cpp b/coreneuron/io/reports/report_event.cpp index 78eb6b268..139fc88b0 100644 --- a/coreneuron/io/reports/report_event.cpp +++ b/coreneuron/io/reports/report_event.cpp @@ -10,6 +10,7 @@ #include "coreneuron/sim/multicore.hpp" #include "coreneuron/io/reports/nrnreport.hpp" #include "coreneuron/utils/nrn_assert.h" +#include "coreneuron/io/nrnsection_mapping.hpp" #ifdef ENABLE_BIN_REPORTS #include "reportinglib/Records.h" #endif // ENABLE_BIN_REPORTS @@ -72,12 +73,32 @@ void ReportEvent::summation_alu(NrnThread* nt) { } } +void ReportEvent::lfp_calc(NrnThread* nt) { + // Calculate lfp only on reporting steps + if (step > 0 && (static_cast(step) % reporting_period) == 0) { + auto* mapinfo = static_cast(nt->mapping); + double sum = 0.0; + double* fast_imem_rhs = nt->nrn_fast_imem->nrn_sav_rhs; + for (const auto& kv: mapinfo->lfp_factors) { + int segment_id = kv.first; + double factor = kv.second; + if(std::isnan(factor)) { + factor = 0.0; + } + std::cout << segment_id << " - " << factor << std::endl; + sum += fast_imem_rhs[segment_id] * factor; + } + mapinfo->_lfp[0] = sum; + }mdi +} + /** on deliver, call ReportingLib and setup next event */ void ReportEvent::deliver(double t, NetCvode* nc, NrnThread* nt) { /* reportinglib is not thread safe */ #pragma omp critical { summation_alu(nt); + lfp_calc(nt); // each thread needs to know its own step #ifdef ENABLE_BIN_REPORTS records_nrec(step, gids_to_report.size(), gids_to_report.data(), report_path.data()); diff --git a/coreneuron/io/reports/report_event.hpp b/coreneuron/io/reports/report_event.hpp index 20d325614..cf2d7bd19 100644 --- a/coreneuron/io/reports/report_event.hpp +++ b/coreneuron/io/reports/report_event.hpp @@ -42,6 +42,7 @@ class ReportEvent: public DiscreteEvent { void deliver(double t, NetCvode* nc, NrnThread* nt) override; bool require_checkpoint() override; void summation_alu(NrnThread* nt); + void lfp_calc(NrnThread* nt); private: double dt; diff --git a/coreneuron/io/reports/report_handler.cpp b/coreneuron/io/reports/report_handler.cpp index 84341e7a4..fd385cd68 100644 --- a/coreneuron/io/reports/report_handler.cpp +++ b/coreneuron/io/reports/report_handler.cpp @@ -35,6 +35,7 @@ void ReportHandler::create_report(double dt, double tstop, double delay) { continue; } const std::vector& nodes_to_gid = map_gids(nt); + auto* mapinfo = static_cast(nt.mapping); VarsToReport vars_to_report; bool is_soma_target; switch (m_report_config.type) { @@ -58,6 +59,13 @@ void ReportHandler::create_report(double dt, double tstop, double delay) { nodes_to_gid); register_custom_report(nt, m_report_config, vars_to_report); break; + case LFPReport: + mapinfo->_lfp.resize(12); + vars_to_report = get_lfp_vars_to_report(nt, m_report_config, mapinfo->_lfp.data()); + is_soma_target = m_report_config.section_type == SectionType::Soma || + m_report_config.section_type == SectionType::Cell; + register_section_report(nt, m_report_config, vars_to_report, is_soma_target); + break; default: vars_to_report = get_synapse_vars_to_report(nt, m_report_config, nodes_to_gid); register_custom_report(nt, m_report_config, vars_to_report); @@ -341,6 +349,34 @@ VarsToReport ReportHandler::get_synapse_vars_to_report( return vars_to_report; } +VarsToReport ReportHandler::get_lfp_vars_to_report(const NrnThread& nt, + ReportConfiguration& report, + double* report_variable) const { + VarsToReport vars_to_report; + /*const auto* mapinfo = static_cast(nt.mapping); + if (!mapinfo) { + std::cerr << "[LFP] Error : mapping information is missing for a Cell group " + << nt.ncell << '\n'; + nrn_abort(1); + }*/ + for (int i = 0; i < nt.ncell; i++) { + int gid = nt.presyns[i].gid_; + if (report.target.find(gid) == report.target.end()) { + continue; + } + + std::vector to_report; + // Add all electrodes to the first gid for now + std::vector electrode_ids = {0}; + for (const auto& electrode_id : electrode_ids) { + double* variable = report_variable + electrode_id; + to_report.push_back(VarWithMapping(electrode_id, variable)); + } + vars_to_report[gid] = to_report; + } + return vars_to_report; +} + // map GIDs of every compartment, it consist in a backward sweep then forward sweep algorithm std::vector ReportHandler::map_gids(const NrnThread& nt) const { std::vector nodes_gid(nt.end, -1); diff --git a/coreneuron/io/reports/report_handler.hpp b/coreneuron/io/reports/report_handler.hpp index 084886c96..db62bf993 100644 --- a/coreneuron/io/reports/report_handler.hpp +++ b/coreneuron/io/reports/report_handler.hpp @@ -44,6 +44,9 @@ class ReportHandler { VarsToReport get_synapse_vars_to_report(const NrnThread& nt, ReportConfiguration& report, const std::vector& nodes_to_gids) const; + VarsToReport get_lfp_vars_to_report(const NrnThread& nt, + ReportConfiguration& report, + double* report_variable) const; std::vector map_gids(const NrnThread& nt) const; #endif // defined(ENABLE_BIN_REPORTS) || defined(ENABLE_SONATA_REPORTS) protected: diff --git a/coreneuron/io/reports/sonata_report_handler.cpp b/coreneuron/io/reports/sonata_report_handler.cpp index 99f5709d5..bc38ef27b 100644 --- a/coreneuron/io/reports/sonata_report_handler.cpp +++ b/coreneuron/io/reports/sonata_report_handler.cpp @@ -57,6 +57,7 @@ std::pair SonataReportHandler::get_population_info(int gid) { void SonataReportHandler::register_report(const NrnThread& nt, ReportConfiguration& config, const VarsToReport& vars_to_report) { + std::cout << "Registering report " << config.output_path.data() << std::endl; sonata_create_report(config.output_path.data(), config.start, config.stop, From b5551bcf375cf039cded0936efd191e010cedfa8 Mon Sep 17 00:00:00 2001 From: Jorge Blanco Alonso Date: Fri, 3 Dec 2021 11:52:28 +0100 Subject: [PATCH 05/14] Calculate 1 lfp value per gid/timestep --- coreneuron/io/nrn_filehandler.hpp | 7 ++--- coreneuron/io/nrn_setup.cpp | 2 +- coreneuron/io/nrnsection_mapping.hpp | 16 +++++----- coreneuron/io/reports/report_event.cpp | 38 ++++++++++++++++-------- coreneuron/io/reports/report_event.hpp | 4 ++- coreneuron/io/reports/report_handler.cpp | 20 ++++--------- 6 files changed, 45 insertions(+), 42 deletions(-) diff --git a/coreneuron/io/nrn_filehandler.hpp b/coreneuron/io/nrn_filehandler.hpp index ad3ed2eca..9688f9575 100644 --- a/coreneuron/io/nrn_filehandler.hpp +++ b/coreneuron/io/nrn_filehandler.hpp @@ -111,7 +111,7 @@ class FileHandler { * Read count no of mappings for section to segment */ template - int read_mapping_info(T* mapinfo, NrnThreadMappingInfo* ntmapping) { + int read_mapping_info(T* mapinfo, NrnThreadMappingInfo* ntmapping, CellMapping* cmap) { int nsec, nseg, n_scan; char line_buf[max_line_length], name[max_line_length]; @@ -133,13 +133,10 @@ class FileHandler { read_array(&seg[0], nseg); read_array(&lfp_factors[0], nseg); - std::cout << "=====> NEW CoreNEURON!" << std::endl; - std::cout << "nseg = " << nseg << std::endl; - for (int i = 0; i < nseg; i++) { mapinfo->add_segment(sec[i], seg[i]); ntmapping->add_segment_id(seg[i]); - ntmapping->add_segment_lfp_factor(seg[i], lfp_factors[i]); + cmap->add_segment_lfp_factor(seg[i], lfp_factors[i]); } } return nseg; diff --git a/coreneuron/io/nrn_setup.cpp b/coreneuron/io/nrn_setup.cpp index e24f1d424..19d5b5297 100644 --- a/coreneuron/io/nrn_setup.cpp +++ b/coreneuron/io/nrn_setup.cpp @@ -959,7 +959,7 @@ void read_phase3(NrnThread& nt, UserParams& userParams) { // read section-segment mapping for every section list for (int j = 0; j < nseclist; j++) { SecMapping* smap = new SecMapping(); - F.read_mapping_info(smap, ntmapping); + F.read_mapping_info(smap, ntmapping, cmap); cmap->add_sec_map(smap); } diff --git a/coreneuron/io/nrnsection_mapping.hpp b/coreneuron/io/nrnsection_mapping.hpp index 29836a24b..5b9c7bd57 100644 --- a/coreneuron/io/nrnsection_mapping.hpp +++ b/coreneuron/io/nrnsection_mapping.hpp @@ -74,6 +74,9 @@ struct CellMapping { /** list of section lists (like soma, axon, apic) */ std::vector secmapvec; + /** map containing segment ids an its respective lfp factors */ + std::unordered_map lfp_factors; + CellMapping(int g) : gid(g) {} @@ -138,6 +141,11 @@ struct CellMapping { return count; } + /** @brief add the lfp factor of a segment_id */ + void add_segment_lfp_factor(const int segment_id, double factor) { + lfp_factors.insert({segment_id, factor}); + } + ~CellMapping() { for (size_t i = 0; i < secmapvec.size(); i++) { delete secmapvec[i]; @@ -157,9 +165,6 @@ struct NrnThreadMappingInfo { /** list of segment ids */ std::vector segment_ids; - /** map containing segment ids an its respective lfp factors */ - std::unordered_map lfp_factors; - std::vector _lfp; /** @brief number of cells */ @@ -195,10 +200,5 @@ struct NrnThreadMappingInfo { void add_segment_id(const int segment_id) { segment_ids.push_back(segment_id); } - - /** @brief add the lfp factor of a segment_id */ - void add_segment_lfp_factor(const int segment_id, double factor) { - lfp_factors.insert({segment_id, factor}); - } }; } // namespace coreneuron diff --git a/coreneuron/io/reports/report_event.cpp b/coreneuron/io/reports/report_event.cpp index 139fc88b0..9deaff30c 100644 --- a/coreneuron/io/reports/report_event.cpp +++ b/coreneuron/io/reports/report_event.cpp @@ -25,11 +25,13 @@ ReportEvent::ReportEvent(double dt, double tstart, const VarsToReport& filtered_gids, const char* name, - double report_dt) + double report_dt, + ReportType type) : dt(dt) , tstart(tstart) , report_path(name) , report_dt(report_dt) + , report_type(type) , vars_to_report(filtered_gids) { nrn_assert(filtered_gids.size()); step = tstart / dt; @@ -77,19 +79,27 @@ void ReportEvent::lfp_calc(NrnThread* nt) { // Calculate lfp only on reporting steps if (step > 0 && (static_cast(step) % reporting_period) == 0) { auto* mapinfo = static_cast(nt->mapping); - double sum = 0.0; double* fast_imem_rhs = nt->nrn_fast_imem->nrn_sav_rhs; - for (const auto& kv: mapinfo->lfp_factors) { - int segment_id = kv.first; - double factor = kv.second; - if(std::isnan(factor)) { - factor = 0.0; - } - std::cout << segment_id << " - " << factor << std::endl; - sum += fast_imem_rhs[segment_id] * factor; + + for (const auto& kv: vars_to_report) { + int gid = kv.first; + const auto& to_report = kv.second; + const auto& cell_mapping = mapinfo->get_cell_mapping(gid); + + int count = 0; + double sum = 0.0; + for (const auto& kv: cell_mapping->lfp_factors) { + int segment_id = kv.first; + double factor = kv.second; + if(std::isnan(factor)) { + factor = 0.0; + } + sum += fast_imem_rhs[segment_id] * factor; + count++; + } + *(to_report.front().var_value) = sum; } - mapinfo->_lfp[0] = sum; - }mdi + } } /** on deliver, call ReportingLib and setup next event */ @@ -98,7 +108,9 @@ void ReportEvent::deliver(double t, NetCvode* nc, NrnThread* nt) { #pragma omp critical { summation_alu(nt); - lfp_calc(nt); + if (report_type == ReportType::LFPReport) { + lfp_calc(nt); + } // each thread needs to know its own step #ifdef ENABLE_BIN_REPORTS records_nrec(step, gids_to_report.size(), gids_to_report.data(), report_path.data()); diff --git a/coreneuron/io/reports/report_event.hpp b/coreneuron/io/reports/report_event.hpp index cf2d7bd19..0f1a07358 100644 --- a/coreneuron/io/reports/report_event.hpp +++ b/coreneuron/io/reports/report_event.hpp @@ -36,7 +36,8 @@ class ReportEvent: public DiscreteEvent { double tstart, const VarsToReport& filtered_gids, const char* name, - double report_dt); + double report_dt, + ReportType type); /** on deliver, call ReportingLib and setup next event */ void deliver(double t, NetCvode* nc, NrnThread* nt) override; @@ -53,6 +54,7 @@ class ReportEvent: public DiscreteEvent { std::vector gids_to_report; double tstart; VarsToReport vars_to_report; + ReportType report_type; }; #endif // defined(ENABLE_BIN_REPORTS) || defined(ENABLE_SONATA_REPORTS) diff --git a/coreneuron/io/reports/report_handler.cpp b/coreneuron/io/reports/report_handler.cpp index fd385cd68..1b69cd6ff 100644 --- a/coreneuron/io/reports/report_handler.cpp +++ b/coreneuron/io/reports/report_handler.cpp @@ -60,7 +60,8 @@ void ReportHandler::create_report(double dt, double tstop, double delay) { register_custom_report(nt, m_report_config, vars_to_report); break; case LFPReport: - mapinfo->_lfp.resize(12); + // 1 lfp value per gid + mapinfo->_lfp.resize(nt.ncell); vars_to_report = get_lfp_vars_to_report(nt, m_report_config, mapinfo->_lfp.data()); is_soma_target = m_report_config.section_type == SectionType::Soma || m_report_config.section_type == SectionType::Cell; @@ -75,7 +76,8 @@ void ReportHandler::create_report(double dt, double tstop, double delay) { t, vars_to_report, m_report_config.output_path.data(), - m_report_config.report_dt); + m_report_config.report_dt, + m_report_config.type); report_event->send(t, net_cvode_instance, &nt); m_report_events.push_back(std::move(report_event)); } @@ -353,12 +355,6 @@ VarsToReport ReportHandler::get_lfp_vars_to_report(const NrnThread& nt, ReportConfiguration& report, double* report_variable) const { VarsToReport vars_to_report; - /*const auto* mapinfo = static_cast(nt.mapping); - if (!mapinfo) { - std::cerr << "[LFP] Error : mapping information is missing for a Cell group " - << nt.ncell << '\n'; - nrn_abort(1); - }*/ for (int i = 0; i < nt.ncell; i++) { int gid = nt.presyns[i].gid_; if (report.target.find(gid) == report.target.end()) { @@ -366,12 +362,8 @@ VarsToReport ReportHandler::get_lfp_vars_to_report(const NrnThread& nt, } std::vector to_report; - // Add all electrodes to the first gid for now - std::vector electrode_ids = {0}; - for (const auto& electrode_id : electrode_ids) { - double* variable = report_variable + electrode_id; - to_report.push_back(VarWithMapping(electrode_id, variable)); - } + double* variable = report_variable + i; + to_report.push_back(VarWithMapping(i, variable)); vars_to_report[gid] = to_report; } return vars_to_report; From 7699327876b4d53dca351aec29527df435e6a8f8 Mon Sep 17 00:00:00 2001 From: Jorge Blanco Alonso Date: Thu, 6 Jan 2022 18:05:14 +0100 Subject: [PATCH 06/14] Remove cout message --- coreneuron/io/reports/sonata_report_handler.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/coreneuron/io/reports/sonata_report_handler.cpp b/coreneuron/io/reports/sonata_report_handler.cpp index bc38ef27b..99f5709d5 100644 --- a/coreneuron/io/reports/sonata_report_handler.cpp +++ b/coreneuron/io/reports/sonata_report_handler.cpp @@ -57,7 +57,6 @@ std::pair SonataReportHandler::get_population_info(int gid) { void SonataReportHandler::register_report(const NrnThread& nt, ReportConfiguration& config, const VarsToReport& vars_to_report) { - std::cout << "Registering report " << config.output_path.data() << std::endl; sonata_create_report(config.output_path.data(), config.start, config.stop, From f2866c3ea06dd6cbd98559e201ae8c7c24f03bad Mon Sep 17 00:00:00 2001 From: Jorge Blanco Alonso Date: Tue, 5 Apr 2022 18:32:03 +0200 Subject: [PATCH 07/14] Take into account IClamp for the lfp calculation --- coreneuron/io/reports/report_event.cpp | 16 ++++++++++++---- coreneuron/io/reports/report_handler.cpp | 17 ++++++++++++++--- coreneuron/io/reports/report_handler.hpp | 3 ++- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/coreneuron/io/reports/report_event.cpp b/coreneuron/io/reports/report_event.cpp index 9deaff30c..5a943bf02 100644 --- a/coreneuron/io/reports/report_event.cpp +++ b/coreneuron/io/reports/report_event.cpp @@ -80,7 +80,7 @@ void ReportEvent::lfp_calc(NrnThread* nt) { if (step > 0 && (static_cast(step) % reporting_period) == 0) { auto* mapinfo = static_cast(nt->mapping); double* fast_imem_rhs = nt->nrn_fast_imem->nrn_sav_rhs; - + auto& summation_report = nt->summation_report_handler_->summation_reports_[report_path]; for (const auto& kv: vars_to_report) { int gid = kv.first; const auto& to_report = kv.second; @@ -94,7 +94,13 @@ void ReportEvent::lfp_calc(NrnThread* nt) { if(std::isnan(factor)) { factor = 0.0; } - sum += fast_imem_rhs[segment_id] * factor; + double iclamp = 0.0; + for (const auto& value: summation_report.currents_[segment_id]) { + double current_value = *value.first; + int scale = value.second; + iclamp += current_value * scale; + } + sum += (fast_imem_rhs[segment_id] + iclamp) * factor; count++; } *(to_report.front().var_value) = sum; @@ -107,8 +113,10 @@ void ReportEvent::deliver(double t, NetCvode* nc, NrnThread* nt) { /* reportinglib is not thread safe */ #pragma omp critical { - summation_alu(nt); - if (report_type == ReportType::LFPReport) { + if (report_type == ReportType::SummationReport) { + summation_alu(nt); + } + else if (report_type == ReportType::LFPReport) { lfp_calc(nt); } // each thread needs to know its own step diff --git a/coreneuron/io/reports/report_handler.cpp b/coreneuron/io/reports/report_handler.cpp index 1b69cd6ff..53efb137d 100644 --- a/coreneuron/io/reports/report_handler.cpp +++ b/coreneuron/io/reports/report_handler.cpp @@ -62,7 +62,7 @@ void ReportHandler::create_report(double dt, double tstop, double delay) { case LFPReport: // 1 lfp value per gid mapinfo->_lfp.resize(nt.ncell); - vars_to_report = get_lfp_vars_to_report(nt, m_report_config, mapinfo->_lfp.data()); + vars_to_report = get_lfp_vars_to_report(nt, m_report_config, mapinfo->_lfp.data(), nodes_to_gid); is_soma_target = m_report_config.section_type == SectionType::Soma || m_report_config.section_type == SectionType::Cell; register_section_report(nt, m_report_config, vars_to_report, is_soma_target); @@ -353,14 +353,25 @@ VarsToReport ReportHandler::get_synapse_vars_to_report( VarsToReport ReportHandler::get_lfp_vars_to_report(const NrnThread& nt, ReportConfiguration& report, - double* report_variable) const { + double* report_variable, + const std::vector& nodes_to_gids) const { + auto& summation_report = nt.summation_report_handler_->summation_reports_[report.output_path]; VarsToReport vars_to_report; for (int i = 0; i < nt.ncell; i++) { int gid = nt.presyns[i].gid_; if (report.target.find(gid) == report.target.end()) { continue; } - + // IClamp is needed for the LFP calculation + auto mech_id = nrn_get_mechtype("IClamp"); + Memb_list* ml = nt._ml_list[mech_id]; + 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)); + } + } std::vector to_report; double* variable = report_variable + i; to_report.push_back(VarWithMapping(i, variable)); diff --git a/coreneuron/io/reports/report_handler.hpp b/coreneuron/io/reports/report_handler.hpp index db62bf993..746edbaee 100644 --- a/coreneuron/io/reports/report_handler.hpp +++ b/coreneuron/io/reports/report_handler.hpp @@ -46,7 +46,8 @@ class ReportHandler { const std::vector& nodes_to_gids) const; VarsToReport get_lfp_vars_to_report(const NrnThread& nt, ReportConfiguration& report, - double* report_variable) const; + double* report_variable, + const std::vector& nodes_to_gids) const; std::vector map_gids(const NrnThread& nt) const; #endif // defined(ENABLE_BIN_REPORTS) || defined(ENABLE_SONATA_REPORTS) protected: From 5a910b57635d76318a40a1c4ff078915b2217bbe Mon Sep 17 00:00:00 2001 From: Jorge Blanco Alonso Date: Wed, 6 Apr 2022 11:22:18 +0200 Subject: [PATCH 08/14] Clang format and other minor changes --- coreneuron/io/reports/report_event.cpp | 29 ++++++++++++------------ coreneuron/io/reports/report_handler.cpp | 3 ++- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/coreneuron/io/reports/report_event.cpp b/coreneuron/io/reports/report_event.cpp index 5a943bf02..6189c4526 100644 --- a/coreneuron/io/reports/report_event.cpp +++ b/coreneuron/io/reports/report_event.cpp @@ -89,19 +89,19 @@ void ReportEvent::lfp_calc(NrnThread* nt) { int count = 0; double sum = 0.0; for (const auto& kv: cell_mapping->lfp_factors) { - int segment_id = kv.first; - double factor = kv.second; - if(std::isnan(factor)) { - factor = 0.0; - } - double iclamp = 0.0; - for (const auto& value: summation_report.currents_[segment_id]) { - double current_value = *value.first; - int scale = value.second; - iclamp += current_value * scale; - } - sum += (fast_imem_rhs[segment_id] + iclamp) * factor; - count++; + int segment_id = kv.first; + double factor = kv.second; + if (std::isnan(factor)) { + factor = 0.0; + } + double iclamp = 0.0; + for (const auto& value: summation_report.currents_[segment_id]) { + double current_value = *value.first; + int scale = value.second; + iclamp += current_value * scale; + } + sum += (fast_imem_rhs[segment_id] + iclamp) * factor; + count++; } *(to_report.front().var_value) = sum; } @@ -115,8 +115,7 @@ void ReportEvent::deliver(double t, NetCvode* nc, NrnThread* nt) { { if (report_type == ReportType::SummationReport) { summation_alu(nt); - } - else if (report_type == ReportType::LFPReport) { + } else if (report_type == ReportType::LFPReport) { lfp_calc(nt); } // each thread needs to know its own step diff --git a/coreneuron/io/reports/report_handler.cpp b/coreneuron/io/reports/report_handler.cpp index 53efb137d..e720f331e 100644 --- a/coreneuron/io/reports/report_handler.cpp +++ b/coreneuron/io/reports/report_handler.cpp @@ -62,7 +62,8 @@ void ReportHandler::create_report(double dt, double tstop, double delay) { case LFPReport: // 1 lfp value per gid mapinfo->_lfp.resize(nt.ncell); - vars_to_report = get_lfp_vars_to_report(nt, m_report_config, mapinfo->_lfp.data(), nodes_to_gid); + vars_to_report = + get_lfp_vars_to_report(nt, m_report_config, mapinfo->_lfp.data(), nodes_to_gid); is_soma_target = m_report_config.section_type == SectionType::Soma || m_report_config.section_type == SectionType::Cell; register_section_report(nt, m_report_config, vars_to_report, is_soma_target); From 7705a2c54f246636444a6753941cc085e76c848e Mon Sep 17 00:00:00 2001 From: Jorge Blanco Alonso Date: Fri, 30 Sep 2022 17:07:06 +0200 Subject: [PATCH 09/14] Record online LFP from multiple electrodes --- coreneuron/io/nrn_filehandler.hpp | 18 +++++++++---- coreneuron/io/nrnsection_mapping.hpp | 26 +++++++++++++++--- coreneuron/io/reports/report_event.cpp | 34 +++++++++++++----------- coreneuron/io/reports/report_handler.cpp | 28 +++++++++++++++---- 4 files changed, 77 insertions(+), 29 deletions(-) diff --git a/coreneuron/io/nrn_filehandler.hpp b/coreneuron/io/nrn_filehandler.hpp index 9688f9575..a171db39f 100644 --- a/coreneuron/io/nrn_filehandler.hpp +++ b/coreneuron/io/nrn_filehandler.hpp @@ -113,30 +113,38 @@ class FileHandler { template int read_mapping_info(T* mapinfo, NrnThreadMappingInfo* ntmapping, CellMapping* cmap) { int nsec, nseg, n_scan; + size_t total_lfp_factors; char line_buf[max_line_length], name[max_line_length]; F.getline(line_buf, sizeof(line_buf)); - n_scan = sscanf(line_buf, "%s %d %d", name, &nsec, &nseg); + n_scan = sscanf(line_buf, "%s %d %d %zd", name, &nsec, &nseg, &total_lfp_factors); - nrn_assert(n_scan == 3); + nrn_assert(n_scan == 4); mapinfo->name = std::string(name); if (nseg) { std::vector sec, seg; std::vector lfp_factors; + sec.reserve(nseg); seg.reserve(nseg); - lfp_factors.reserve(nseg); + lfp_factors.reserve(total_lfp_factors); read_array(&sec[0], nseg); read_array(&seg[0], nseg); - read_array(&lfp_factors[0], nseg); + read_array(&lfp_factors[0], total_lfp_factors); + int num_electrodes = read_int(); + int factor_offset = 0; for (int i = 0; i < nseg; i++) { mapinfo->add_segment(sec[i], seg[i]); ntmapping->add_segment_id(seg[i]); - cmap->add_segment_lfp_factor(seg[i], lfp_factors[i]); + int factor_offset = i * num_electrodes; + if (total_lfp_factors > 0) { + std::vector segment_factors(lfp_factors.begin() + factor_offset, lfp_factors.begin() + factor_offset + num_electrodes); + cmap->add_segment_lfp_factor(seg[i], segment_factors); + } } } return nseg; diff --git a/coreneuron/io/nrnsection_mapping.hpp b/coreneuron/io/nrnsection_mapping.hpp index 5b9c7bd57..11e79d086 100644 --- a/coreneuron/io/nrnsection_mapping.hpp +++ b/coreneuron/io/nrnsection_mapping.hpp @@ -75,7 +75,7 @@ struct CellMapping { std::vector secmapvec; /** map containing segment ids an its respective lfp factors */ - std::unordered_map lfp_factors; + std::unordered_map> lfp_factors; CellMapping(int g) : gid(g) {} @@ -100,6 +100,15 @@ struct CellMapping { }); } + /** @brief return the number of electrodes in the lfp_factors map **/ + int num_electrodes() const { + int num_electrodes = 0; + if (!lfp_factors.empty()) { + num_electrodes = lfp_factors.begin()->second.size(); + } + return num_electrodes; + } + /** @brief number of section lists */ size_t size() const noexcept { return secmapvec.size(); @@ -141,9 +150,9 @@ struct CellMapping { return count; } - /** @brief add the lfp factor of a segment_id */ - void add_segment_lfp_factor(const int segment_id, double factor) { - lfp_factors.insert({segment_id, factor}); + /** @brief add the lfp electrode factors of a segment_id */ + void add_segment_lfp_factor(const int segment_id, std::vector factors) { + lfp_factors.insert({segment_id, factors}); } ~CellMapping() { @@ -200,5 +209,14 @@ struct NrnThreadMappingInfo { void add_segment_id(const int segment_id) { segment_ids.push_back(segment_id); } + + /** @brief Resize the lfp vector */ + void prepare_lfp() { + size_t lfp_size = 0; + for (const auto& mapping: mappingvec) { + lfp_size += mapping->num_electrodes(); + } + _lfp.resize(lfp_size); + } }; } // namespace coreneuron diff --git a/coreneuron/io/reports/report_event.cpp b/coreneuron/io/reports/report_event.cpp index 6189c4526..e649db1e2 100644 --- a/coreneuron/io/reports/report_event.cpp +++ b/coreneuron/io/reports/report_event.cpp @@ -85,25 +85,29 @@ void ReportEvent::lfp_calc(NrnThread* nt) { int gid = kv.first; const auto& to_report = kv.second; const auto& cell_mapping = mapinfo->get_cell_mapping(gid); - - int count = 0; - double sum = 0.0; + int num_electrodes = cell_mapping->num_electrodes(); + std::vector lfp_values (num_electrodes, 0.0); for (const auto& kv: cell_mapping->lfp_factors) { int segment_id = kv.first; - double factor = kv.second; - if (std::isnan(factor)) { - factor = 0.0; - } - double iclamp = 0.0; - for (const auto& value: summation_report.currents_[segment_id]) { - double current_value = *value.first; - int scale = value.second; - iclamp += current_value * scale; + std::vector factors = kv.second; + int electrode_id = 0; + for (auto& factor: factors) { + if (std::isnan(factor)) { + factor = 0.0; + } + double iclamp = 0.0; + for (const auto& value: summation_report.currents_[segment_id]) { + double current_value = *value.first; + int scale = value.second; + iclamp += current_value * scale; + } + lfp_values[electrode_id] += (fast_imem_rhs[segment_id] + iclamp) * factor; + electrode_id++; } - sum += (fast_imem_rhs[segment_id] + iclamp) * factor; - count++; } - *(to_report.front().var_value) = sum; + for(int i=0; i < to_report.size(); i++) { + *(to_report[i].var_value) = lfp_values[i]; + } } } } diff --git a/coreneuron/io/reports/report_handler.cpp b/coreneuron/io/reports/report_handler.cpp index e720f331e..94508ad19 100644 --- a/coreneuron/io/reports/report_handler.cpp +++ b/coreneuron/io/reports/report_handler.cpp @@ -60,8 +60,7 @@ void ReportHandler::create_report(double dt, double tstop, double delay) { register_custom_report(nt, m_report_config, vars_to_report); break; case LFPReport: - // 1 lfp value per gid - mapinfo->_lfp.resize(nt.ncell); + mapinfo->prepare_lfp(); vars_to_report = get_lfp_vars_to_report(nt, m_report_config, mapinfo->_lfp.data(), nodes_to_gid); is_soma_target = m_report_config.section_type == SectionType::Soma || @@ -356,8 +355,15 @@ VarsToReport ReportHandler::get_lfp_vars_to_report(const NrnThread& nt, ReportConfiguration& report, double* report_variable, const std::vector& nodes_to_gids) const { + const auto* mapinfo = static_cast(nt.mapping); + if (!mapinfo) { + std::cerr << "[LFP] Error : mapping information is missing for a Cell group " + << nt.ncell << '\n'; + nrn_abort(1); + } auto& summation_report = nt.summation_report_handler_->summation_reports_[report.output_path]; VarsToReport vars_to_report; + off_t offset_lfp = 0; for (int i = 0; i < nt.ncell; i++) { int gid = nt.presyns[i].gid_; if (report.target.find(gid) == report.target.end()) { @@ -373,10 +379,22 @@ VarsToReport ReportHandler::get_lfp_vars_to_report(const NrnThread& nt, summation_report.currents_[segment_id].push_back(std::make_pair(var_value, -1)); } } + 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 << '\n'; + nrn_abort(1); + } std::vector to_report; - double* variable = report_variable + i; - to_report.push_back(VarWithMapping(i, variable)); - vars_to_report[gid] = to_report; + int num_electrodes = cell_mapping->num_electrodes(); + for (int electrode_id = 0; electrode_id < num_electrodes; electrode_id++) { + to_report.emplace_back(VarWithMapping(electrode_id, report_variable + offset_lfp)); + offset_lfp++; + } + if (!to_report.empty()) { + vars_to_report[gid] = to_report; + } } return vars_to_report; } From e5b42505e38fac181676904a4899753ce9d85893 Mon Sep 17 00:00:00 2001 From: Jorge Blanco Alonso Date: Tue, 11 Oct 2022 17:14:13 +0200 Subject: [PATCH 10/14] Fix clang-format --- coreneuron/io/nrn_filehandler.hpp | 4 +++- coreneuron/io/reports/report_event.cpp | 4 ++-- coreneuron/io/reports/report_handler.cpp | 9 ++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/coreneuron/io/nrn_filehandler.hpp b/coreneuron/io/nrn_filehandler.hpp index a171db39f..a25e8140d 100644 --- a/coreneuron/io/nrn_filehandler.hpp +++ b/coreneuron/io/nrn_filehandler.hpp @@ -142,7 +142,9 @@ class FileHandler { ntmapping->add_segment_id(seg[i]); int factor_offset = i * num_electrodes; if (total_lfp_factors > 0) { - std::vector segment_factors(lfp_factors.begin() + factor_offset, lfp_factors.begin() + factor_offset + num_electrodes); + std::vector segment_factors(lfp_factors.begin() + factor_offset, + lfp_factors.begin() + factor_offset + + num_electrodes); cmap->add_segment_lfp_factor(seg[i], segment_factors); } } diff --git a/coreneuron/io/reports/report_event.cpp b/coreneuron/io/reports/report_event.cpp index e649db1e2..6182efd0c 100644 --- a/coreneuron/io/reports/report_event.cpp +++ b/coreneuron/io/reports/report_event.cpp @@ -86,7 +86,7 @@ void ReportEvent::lfp_calc(NrnThread* nt) { const auto& to_report = kv.second; const auto& cell_mapping = mapinfo->get_cell_mapping(gid); int num_electrodes = cell_mapping->num_electrodes(); - std::vector lfp_values (num_electrodes, 0.0); + std::vector lfp_values(num_electrodes, 0.0); for (const auto& kv: cell_mapping->lfp_factors) { int segment_id = kv.first; std::vector factors = kv.second; @@ -105,7 +105,7 @@ void ReportEvent::lfp_calc(NrnThread* nt) { electrode_id++; } } - for(int i=0; i < to_report.size(); i++) { + for (int i = 0; i < to_report.size(); i++) { *(to_report[i].var_value) = lfp_values[i]; } } diff --git a/coreneuron/io/reports/report_handler.cpp b/coreneuron/io/reports/report_handler.cpp index 94508ad19..376f51763 100644 --- a/coreneuron/io/reports/report_handler.cpp +++ b/coreneuron/io/reports/report_handler.cpp @@ -357,8 +357,8 @@ VarsToReport ReportHandler::get_lfp_vars_to_report(const NrnThread& nt, const std::vector& nodes_to_gids) const { const auto* mapinfo = static_cast(nt.mapping); if (!mapinfo) { - std::cerr << "[LFP] Error : mapping information is missing for a Cell group " - << nt.ncell << '\n'; + std::cerr << "[LFP] Error : mapping information is missing for a Cell group " << nt.ncell + << '\n'; nrn_abort(1); } auto& summation_report = nt.summation_report_handler_->summation_reports_[report.output_path]; @@ -381,9 +381,8 @@ VarsToReport ReportHandler::get_lfp_vars_to_report(const NrnThread& nt, } 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 << '\n'; + std::cerr << "[LFP] Error : Compartment mapping information is missing for gid " << gid + << '\n'; nrn_abort(1); } std::vector to_report; From 81d24a062dea9f03e845f25b3e2c1c6dc5883318 Mon Sep 17 00:00:00 2001 From: Jorge Blanco Alonso Date: Wed, 12 Oct 2022 16:33:05 +0200 Subject: [PATCH 11/14] Change data files to adapt to lfp changes --- coreneuron/io/nrn_filehandler.hpp | 10 ++++++---- tests/integration/ring/0_3.dat | Bin 9444 -> 9524 bytes tests/integration/ring/1_3.dat | Bin 9323 -> 9403 bytes 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/coreneuron/io/nrn_filehandler.hpp b/coreneuron/io/nrn_filehandler.hpp index a25e8140d..0b23679ee 100644 --- a/coreneuron/io/nrn_filehandler.hpp +++ b/coreneuron/io/nrn_filehandler.hpp @@ -114,12 +114,13 @@ class FileHandler { int read_mapping_info(T* mapinfo, NrnThreadMappingInfo* ntmapping, CellMapping* cmap) { int nsec, nseg, n_scan; size_t total_lfp_factors; + int num_electrodes; char line_buf[max_line_length], name[max_line_length]; F.getline(line_buf, sizeof(line_buf)); - n_scan = sscanf(line_buf, "%s %d %d %zd", name, &nsec, &nseg, &total_lfp_factors); + n_scan = sscanf(line_buf, "%s %d %d %zd %d", name, &nsec, &nseg, &total_lfp_factors, &num_electrodes); - nrn_assert(n_scan == 4); + nrn_assert(n_scan == 5); mapinfo->name = std::string(name); @@ -133,8 +134,9 @@ class FileHandler { read_array(&sec[0], nseg); read_array(&seg[0], nseg); - read_array(&lfp_factors[0], total_lfp_factors); - int num_electrodes = read_int(); + if (total_lfp_factors > 0) { + read_array(&lfp_factors[0], total_lfp_factors); + } int factor_offset = 0; for (int i = 0; i < nseg; i++) { diff --git a/tests/integration/ring/0_3.dat b/tests/integration/ring/0_3.dat index b79f96e2ea8163c5b3c949b01f6aca2c14e0371d..7e68f2cdb430cee9a32d6ea1a3e71752db70cd38 100644 GIT binary patch literal 9524 zcmeHNiB7{X4COuw;{Jeq0czSNZ9fMwBqYQ@g8vsUUERhsJCHn9M!H&Cqs@(-=NH?Z zzPE`^lT>B1Gx>OXeNY;&RHez|^UM46Q{_6@!9iD9b2WLIPL!_Q>3=m(cJb9c$Ufu% zatJws979eZrx2&%407InzQFq>?ftD)e;`0saM_9MO-JKq;TFhp7(R+%9>5MHKRz`D6N7q{!a@%x>b-^$#1bx z%)(D#Ax5dfs!Xf0?qjoHOPn(tI130NLyBln0<4uBC1$HpB8j*=&%HebjuJK_n-tg$ zduWP1m9`j;!Eyj&X8=Jt%-ICznyacKoZ-4vk_iXrHHC-a`;%MDc>JCRGy)Cr=5kny zH85US%?^uSL%pqqxF z_B)2`frK4)3`6P(tgDp(9if(Z^wB>jv9Y!2`dXXn#YhsEgf0mk>)L<_?~5y(P^84M z=z&dmK+k&WwU;rY?dP*^xTzkRE1`e&nyh2|itjG5`yLs;|J%Zt8DDa4ZTytWOV3dB L#j)stzwCi8eL44S delta 529 zcmdnu^~7_6VZB0>Vo)#eKQa5ea6Y}`64EJ z^W(7tst4}X%}IhzS&mkI}-pDnwBB} diff --git a/tests/integration/ring/1_3.dat b/tests/integration/ring/1_3.dat index ae6b27a253d2d518d0a1e1d5e3baebe6e001158a..a4579fd1afc65af62a1d79b5d0d52cbdaa5b91dd 100644 GIT binary patch literal 9403 zcmeHNiE6_z4BdTXWA_K-3q}+lNj_(+gTYug*#4g>ha8KzZ3bd^!D&QW(<-v`^dhN+ zN1H*BL0;3QF_%`%Xxd86Rw)|BvadE#MnfW^ zlpljTbf1y}!H8Bx)uNNFvW;WS5JVf3l1glhC%>(9CMhD4SS`S9CRWFTCuIndRz0CvnT zPW62~8`}R6IJ5bNN_hsr3ST2%_(}j#LI)KalDgX4hlD-}9Tf9vr4T|$T8qyE&~Szl(xRxV^b0bqL_;}T!-#E-M*lSquEC%&YQyn5J#3$zgO(%P~;0Nro{j7Lnh zU+Eh@-3U2@$Z2;e=?F?U>>A4-gGeW`guYmG5Q$4wT%>QnrQKX9htQnXk_YB^0J?b} zRLGw+@MENArvtx`S_0|3(%uoMW$mI(lfmEqW)lnfN!USzCrzLdwh_L!cP^pKNNdRh zf8hb>M%{o@X-DLIaAw29?vQPS_WAvlWAvI$#ci63Cr0o8T_C~2bcc}8C82}zWOvIL N%CfYUJn$bp@B{n)_89;G literal 9323 zcmeHN+fKtU4CQ_)_sa+L3((v&Y5O^dAt50K68yh#yB@dIvaLuK3MJG0u&8yNljBp{ zKo2gVSwd;H{3f68Z;vUZlsvt>ek{JytV(wH)BZBE=GXjrF;BA@e{q?iWS1}7W7}st zU^`?xVmoF#VLN53?>=KYXS-m#WV>R!X1ig#WxHd$XTu}2=8?Rh_A&KtO_gTYZ6@0= z@-RF;mlf>V6mq#$-?avc2;E8OYS1Y-vNig)hrSUwi$TEHMmbo;DOe}BRY9JD#z`U{ zS}5{m`Y9Yjur7+49VJT(ax=#<=QQ9!y#v6qDiL5wAuP$w%m_CNZwf~0zHA4%sJwYl( zIEGUTA2^Vh?Pa3~Q(lSx>5n(G6IjDvC_W(GS``-jwVZV8t70FM<61;u37Q#e{%^%^fcmt&}j>&Mr`2r<}SsT6>%*h@EZtF zGs32dJ8=kjHym^RA+|3rFnxS4B}!h(wA;mLcU1D_e+6i$FWw9qzBGIwN4B?zz6^_N J5rMyez&CF<>OKGf From 59f7ae7378b08bc2295981f9124416ec8e3a8322 Mon Sep 17 00:00:00 2001 From: Jorge Blanco Alonso Date: Wed, 12 Oct 2022 16:34:18 +0200 Subject: [PATCH 12/14] Fix clang format --- coreneuron/io/nrn_filehandler.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/coreneuron/io/nrn_filehandler.hpp b/coreneuron/io/nrn_filehandler.hpp index 0b23679ee..9476a6c53 100644 --- a/coreneuron/io/nrn_filehandler.hpp +++ b/coreneuron/io/nrn_filehandler.hpp @@ -118,7 +118,8 @@ class FileHandler { char line_buf[max_line_length], name[max_line_length]; F.getline(line_buf, sizeof(line_buf)); - n_scan = sscanf(line_buf, "%s %d %d %zd %d", name, &nsec, &nseg, &total_lfp_factors, &num_electrodes); + n_scan = sscanf( + line_buf, "%s %d %d %zd %d", name, &nsec, &nseg, &total_lfp_factors, &num_electrodes); nrn_assert(n_scan == 5); From 1ba5e64356655e0a1488e5f95def3d7c6952e7b1 Mon Sep 17 00:00:00 2001 From: Jorge Blanco Alonso Date: Wed, 7 Dec 2022 12:41:22 +0100 Subject: [PATCH 13/14] Check if memblist is not null when getting IClamp --- coreneuron/io/reports/report_handler.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/coreneuron/io/reports/report_handler.cpp b/coreneuron/io/reports/report_handler.cpp index 376f51763..7cc53166c 100644 --- a/coreneuron/io/reports/report_handler.cpp +++ b/coreneuron/io/reports/report_handler.cpp @@ -372,6 +372,9 @@ VarsToReport ReportHandler::get_lfp_vars_to_report(const NrnThread& nt, // IClamp is needed for the LFP calculation auto mech_id = nrn_get_mechtype("IClamp"); Memb_list* ml = nt._ml_list[mech_id]; + if (!ml) { + continue; + } for (int j = 0; j < ml->nodecount; j++) { auto segment_id = ml->nodeindices[j]; if ((nodes_to_gids[segment_id] == gid)) { From 8f27b92ff41054643c2d05571e9854847f1e3a46 Mon Sep 17 00:00:00 2001 From: Jorge Blanco Alonso Date: Wed, 7 Dec 2022 16:26:08 +0100 Subject: [PATCH 14/14] fixup! Check if memblist is not null when getting IClamp --- coreneuron/io/reports/report_handler.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/coreneuron/io/reports/report_handler.cpp b/coreneuron/io/reports/report_handler.cpp index 7cc53166c..760ed0749 100644 --- a/coreneuron/io/reports/report_handler.cpp +++ b/coreneuron/io/reports/report_handler.cpp @@ -372,14 +372,13 @@ VarsToReport ReportHandler::get_lfp_vars_to_report(const NrnThread& nt, // IClamp is needed for the LFP calculation auto mech_id = nrn_get_mechtype("IClamp"); Memb_list* ml = nt._ml_list[mech_id]; - if (!ml) { - continue; - } - 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)); + 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)); + } } } const auto& cell_mapping = mapinfo->get_cell_mapping(gid);