CoreNEURON
sonata_report_handler.cpp
Go to the documentation of this file.
1 /*
2 # =============================================================================
3 # Copyright (c) 2016 - 2021 Blue Brain Project/EPFL
4 #
5 # See top-level LICENSE file for details.
6 # =============================================================================
7 */
8 
14 #ifdef ENABLE_SONATA_REPORTS
15 #include "bbp/sonata/reports.h"
16 #endif // ENABLE_SONATA_REPORTS
17 
18 namespace coreneuron {
19 
21  double dt,
22  double tstop,
23  double delay) {
24 #ifdef ENABLE_SONATA_REPORTS
25  sonata_set_atomic_step(dt);
26 #endif // ENABLE_SONATA_REPORTS
27  ReportHandler::create_report(config, dt, tstop, delay);
28 }
29 
30 #ifdef ENABLE_SONATA_REPORTS
31 void SonataReportHandler::register_section_report(const NrnThread& nt,
32  const ReportConfiguration& config,
33  const VarsToReport& vars_to_report,
34  bool is_soma_target) {
35  register_report(nt, config, vars_to_report);
36 }
37 
38 void SonataReportHandler::register_custom_report(const NrnThread& nt,
39  const ReportConfiguration& config,
40  const VarsToReport& vars_to_report) {
41  register_report(nt, config, vars_to_report);
42 }
43 
44 std::pair<std::string, int> SonataReportHandler::get_population_info(int gid) {
45  if (m_spikes_info.population_info.empty()) {
46  return std::make_pair("All", 0);
47  }
48  std::pair<std::string, int> prev = m_spikes_info.population_info.front();
49  for (const auto& name_offset: m_spikes_info.population_info) {
50  std::string pop_name = name_offset.first;
51  int pop_offset = name_offset.second;
52  if (pop_offset > gid) {
53  break;
54  }
55  prev = name_offset;
56  }
57  return prev;
58 }
59 
60 void SonataReportHandler::register_report(const NrnThread& nt,
61  const ReportConfiguration& config,
62  const VarsToReport& vars_to_report) {
63  sonata_create_report(config.output_path.data(),
64  config.start,
65  config.stop,
66  config.report_dt,
67  config.unit.data(),
68  config.type_str.data());
69  sonata_set_report_max_buffer_size_hint(config.output_path.data(), config.buffer_size);
70 
71  for (const auto& kv: vars_to_report) {
72  uint64_t gid = kv.first;
73  const std::vector<VarWithMapping>& vars = kv.second;
74  if (!vars.size())
75  continue;
76 
77  const auto& pop_info = get_population_info(gid);
78  std::string population_name = pop_info.first;
79  int population_offset = pop_info.second;
80  sonata_add_node(config.output_path.data(), population_name.data(), population_offset, gid);
81  sonata_set_report_max_buffer_size_hint(config.output_path.data(), config.buffer_size);
82  for (const auto& variable: vars) {
83  sonata_add_element(config.output_path.data(),
84  population_name.data(),
85  gid,
86  variable.id,
87  variable.var_value);
88  }
89  }
90 }
91 #endif // ENABLE_SONATA_REPORTS
92 } // Namespace coreneuron
coreneuron::SonataReportHandler::m_spikes_info
SpikesInfo m_spikes_info
Definition: sonata_report_handler.hpp:41
netcvode.hpp
coreneuron::SpikesInfo::population_info
std::vector< std::pair< std::string, int > > population_info
Definition: nrnreport.hpp:44
coreneuron
THIS FILE IS AUTO GENERATED DONT MODIFY IT.
Definition: corenrn_parameters.cpp:12
coreneuron::SonataReportHandler::create_report
void create_report(ReportConfiguration &config, double dt, double tstop, double delay) override
Definition: sonata_report_handler.cpp:20
coreneuron::ReportConfiguration
Definition: nrnreport.hpp:85
coreneuron::dt
double dt
Definition: register_mech.cpp:22
mech_mapping.hpp
nrnsection_mapping.hpp
coreneuron::NrnThread
Definition: multicore.hpp:75
netcon.hpp
coreneuron::ReportHandler::create_report
virtual void create_report(ReportConfiguration &config, double dt, double tstop, double delay)
Definition: report_handler.cpp:36
sonata_report_handler.hpp