@@ -154,10 +154,9 @@ static void sort_spikes(std::vector<double>& spikevec_time, std::vector<int>& sp
154154/* * Split spikevec_time and spikevec_gid by populations
155155 * Add spike data with population name and gid offset tolibsonatareport API
156156 */
157- static void output_spike_populations (
158- const std::vector<std::pair<std::string, int >>& population_name_offset) {
157+ void output_spike_populations (const SpikesInfo& spikes_info) {
159158 // Write spikes with default population name and offset
160- if (population_name_offset .empty ()) {
159+ if (spikes_info. population_info .empty ()) {
161160 sonata_add_spikes_population (" All" ,
162161 0 ,
163162 spikevec_time.data (),
@@ -166,15 +165,15 @@ static void output_spike_populations(
166165 spikevec_gid.size ());
167166 return ;
168167 }
169- int n_populations = population_name_offset .size ();
168+ int n_populations = spikes_info. population_info .size ();
170169 for (int idx = 0 ; idx < n_populations; idx++) {
171- auto cur_pop = population_name_offset [idx];
172- std::string population_name = cur_pop .first ;
173- int population_offset = cur_pop .second ;
170+ const auto & curr_pop = spikes_info. population_info [idx];
171+ std::string population_name = curr_pop .first ;
172+ int population_offset = curr_pop .second ;
174173 int gid_lower = population_offset;
175174 int gid_upper = std::numeric_limits<int >::max ();
176175 if (idx != n_populations - 1 ) {
177- gid_upper = population_name_offset [idx + 1 ].second - 1 ;
176+ gid_upper = spikes_info. population_info [idx + 1 ].second - 1 ;
178177 }
179178 std::vector<double > pop_spikevec_time;
180179 std::vector<int > pop_spikevec_gid;
@@ -198,10 +197,7 @@ static void output_spike_populations(
198197 * \todo : MPI related code should be factored into nrnmpi.c
199198 * Check spike record length which is set to 64 chars
200199 */
201- static void output_spikes_parallel (
202- const char * outpath,
203- const char * filename,
204- const std::vector<std::pair<std::string, int >>& population_name_offset) {
200+ static void output_spikes_parallel (const char * outpath, const SpikesInfo& spikes_info) {
205201 std::stringstream ss;
206202 ss << outpath << " /out.dat" ;
207203 std::string fname = ss.str ();
@@ -211,8 +207,8 @@ static void output_spikes_parallel(
211207 remove (fname.c_str ());
212208 }
213209#ifdef ENABLE_SONATA_REPORTS
214- sonata_create_spikefile (outpath, filename );
215- output_spike_populations (population_name_offset );
210+ sonata_create_spikefile (outpath, spikes_info. file_name . data () );
211+ output_spike_populations (spikes_info );
216212 sonata_write_spike_populations ();
217213 sonata_close_spikefile ();
218214#endif // ENABLE_SONATA_REPORTS
@@ -280,16 +276,15 @@ static void output_spikes_serial(const char* outpath) {
280276 fclose (f);
281277}
282278
283- void output_spikes (const char * outpath,
284- const std::vector<std::pair<std::string, int >>& population_name_offset) {
279+ void output_spikes (const char * outpath, const SpikesInfo& spikes_info) {
285280 // try to transfer spikes to NEURON. If successfull, don't write out.dat
286281 if (all_spikes_return (spikevec_time, spikevec_gid)) {
287282 clear_spike_vectors ();
288283 return ;
289284 }
290285#if NRNMPI
291286 if (corenrn_param.mpi_enable && nrnmpi_initialized ()) {
292- output_spikes_parallel (outpath, " out " , population_name_offset );
287+ output_spikes_parallel (outpath, spikes_info );
293288 } else
294289#endif
295290 {
0 commit comments