Skip to content

Commit 568c0ba

Browse files
authored
BRAYNS 557 - Fix sonata synapses (#354)
Also * Updates libsonata & morphio dependencies * Removes usage of <boost/progress.hpp> for deprecation
1 parent 60e2f7b commit 568c0ba

8 files changed

+533
-832
lines changed

.clang-format

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ BreakBeforeBinaryOperators: false
1616
BreakBeforeBraces: Allman # brace on new line
1717
BreakBeforeTernaryOperators: true
1818
BreakConstructorInitializersBeforeComma: true
19+
ColumnLimit: 120
1920
ConstructorInitializerAllOnOneLineOrOnePerLine: false
2021
ConstructorInitializerIndentWidth: 4
2122
ContinuationIndentWidth: 4
@@ -24,7 +25,7 @@ DerivePointerBinding: true
2425
ExperimentalAutoDetectBinPacking: false
2526
IndentCaseLabels: false
2627
IndentFunctionDeclarationAfterType: true
27-
IndentWidth: 4
28+
IndentWidth: 4
2829
KeepEmptyLinesAtTheStartOfBlocks: false
2930
Language: Cpp
3031
MaxEmptyLinesToKeep: 1
@@ -46,6 +47,5 @@ SpacesInAngles: false # '< ' style
4647
SpacesInCStyleCastParentheses: false
4748
SpacesInParentheses: false # '(' style
4849
Standard: Cpp11
49-
TabWidth: 4
50-
UseTab: Never
51-
...
50+
TabWidth: 4
51+
UseTab: Never

apps/compartmentConverter.cpp

+35-62
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
#include <boost/filesystem.hpp>
2828
#include <boost/program_options.hpp>
29-
#include <boost/progress.hpp>
3029

3130
#include <chrono>
3231

@@ -62,7 +61,7 @@ void requireEqualCollections(const T& a, const T& b)
6261
REQUIRE_EQUAL(i, a.end());
6362
REQUIRE_EQUAL(j, b.end());
6463
}
65-
}
64+
} // namespace
6665

6766
/**
6867
* Convert a compartment report to an HDF5 report.
@@ -108,25 +107,21 @@ int main(const int argc, char** argv)
108107

109108
if (vm.count("help") || vm.count("input") == 0)
110109
{
111-
std::cout << "Usage: " << argv[0]
112-
<< " input-uri [output-uri=dummy://] [options]" << std::endl
110+
std::cout << "Usage: " << argv[0] << " input-uri [output-uri=dummy://] [options]" << std::endl
113111
<< std::endl
114112
<< "Supported input and output URIs:" << std::endl
115-
<< brion::CompartmentReport::getDescriptions()
116-
<< std::endl
113+
<< brion::CompartmentReport::getDescriptions() << std::endl
117114
#ifdef BRION_USE_BBPTESTDATA
118115
<< std::endl
119-
<< " Test data set (only for input):\n test:"
120-
<< std::endl
116+
<< " Test data set (only for input):\n test:" << std::endl
121117
#endif
122118
<< std::endl
123119
<< options << std::endl;
124120
return EXIT_SUCCESS;
125121
}
126122
if (vm.count("version"))
127123
{
128-
std::cout << "Brion compartment report converter "
129-
<< brion::Version::getString() << std::endl;
124+
std::cout << "Brion compartment report converter " << brion::Version::getString() << std::endl;
130125
return EXIT_SUCCESS;
131126
}
132127

@@ -136,8 +131,7 @@ int main(const int argc, char** argv)
136131
}
137132
catch (const po::error& e)
138133
{
139-
std::cerr << "Command line parse error: " << e.what() << std::endl
140-
<< options << std::endl;
134+
std::cerr << "Command line parse error: " << e.what() << std::endl << options << std::endl;
141135
return EXIT_FAILURE;
142136
}
143137

@@ -151,29 +145,25 @@ int main(const int argc, char** argv)
151145
return EXIT_FAILURE;
152146
}
153147

154-
const size_t maxFrames = vm.count("maxFrames") == 1
155-
? vm["maxFrames"].as<size_t>()
156-
: std::numeric_limits<size_t>::max();
148+
const size_t maxFrames =
149+
vm.count("maxFrames") == 1 ? vm["maxFrames"].as<size_t>() : std::numeric_limits<size_t>::max();
157150

158151
std::string input = vm["input"].as<std::string>();
159152
#ifdef BRION_USE_BBPTESTDATA
160153
if (input == "test:")
161154
{
162-
input = std::string(BBP_TESTDATA) +
163-
"/circuitBuilding_1000neurons/Neurodamus_output/voltages.bbp";
155+
input = std::string(BBP_TESTDATA) + "/circuitBuilding_1000neurons/Neurodamus_output/voltages.bbp";
164156
}
165157
#endif
166158
if (input == vm["output"].as<std::string>())
167159
{
168-
std::cerr << "Cowardly refusing to convert " << input << " onto itself"
169-
<< std::endl;
160+
std::cerr << "Cowardly refusing to convert " << input << " onto itself" << std::endl;
170161
return EXIT_FAILURE;
171162
}
172163

173164
brion::URI inURI(input);
174165
brion::CompartmentReport in(inURI, brion::MODE_READ);
175-
const std::chrono::high_resolution_clock::time_point loadTime1
176-
= std::chrono::high_resolution_clock::now();
166+
const std::chrono::high_resolution_clock::time_point loadTime1 = std::chrono::high_resolution_clock::now();
177167

178168
const double start = in.getStartTime();
179169
const double step = in.getTimestep();
@@ -182,9 +172,8 @@ int main(const int argc, char** argv)
182172
if (vm.count("dump"))
183173
{
184174
std::cout << "Compartment report " << inURI << ":" << std::endl
185-
<< " " << (end - start) / step << " frames: " << start
186-
<< ".." << end << " / " << step << " " << in.getTimeUnit()
187-
<< std::endl
175+
<< " " << (end - start) / step << " frames: " << start << ".." << end << " / " << step << " "
176+
<< in.getTimeUnit() << std::endl
188177
<< " " << in.getGIDs().size() << " neurons" << std::endl
189178
<< " " << in.getFrameSize() << " compartments" << std::endl;
190179
return EXIT_SUCCESS;
@@ -209,8 +198,7 @@ int main(const int argc, char** argv)
209198
{
210199
try
211200
{
212-
outURI.setPath(
213-
boost::filesystem::canonical(inURI.getPath()).generic_string());
201+
outURI.setPath(boost::filesystem::canonical(inURI.getPath()).generic_string());
214202
}
215203
catch (const boost::filesystem::filesystem_error&)
216204
{
@@ -219,14 +207,12 @@ int main(const int argc, char** argv)
219207
}
220208
}
221209

222-
const std::chrono::high_resolution_clock::time_point loadTime2
223-
= std::chrono::high_resolution_clock::now();
224-
const std::chrono::duration<float> loadTimeSpan
225-
= std::chrono::duration_cast<std::chrono::duration<float>>(loadTime2 - loadTime1);
210+
const std::chrono::high_resolution_clock::time_point loadTime2 = std::chrono::high_resolution_clock::now();
211+
const std::chrono::duration<float> loadTimeSpan =
212+
std::chrono::duration_cast<std::chrono::duration<float>>(loadTime2 - loadTime1);
226213
float loadTime = loadTimeSpan.count();
227214

228-
const std::chrono::high_resolution_clock::time_point writeTime1
229-
= std::chrono::high_resolution_clock::now();
215+
const std::chrono::high_resolution_clock::time_point writeTime1 = std::chrono::high_resolution_clock::now();
230216

231217
brion::CompartmentReport to(outURI, brion::MODE_OVERWRITE);
232218
to.writeHeader(start, end, step, in.getDataUnit(), in.getTimeUnit());
@@ -257,23 +243,20 @@ int main(const int argc, char** argv)
257243
}
258244
}
259245

260-
const std::chrono::high_resolution_clock::time_point writeTime2
261-
= std::chrono::high_resolution_clock::now();
246+
const std::chrono::high_resolution_clock::time_point writeTime2 = std::chrono::high_resolution_clock::now();
262247

263-
const std::chrono::duration<float> writeTimeSpan
264-
= std::chrono::duration_cast<std::chrono::duration<float>>(writeTime2 - writeTime1);
248+
const std::chrono::duration<float> writeTimeSpan =
249+
std::chrono::duration_cast<std::chrono::duration<float>>(writeTime2 - writeTime1);
265250
float writeTime = writeTimeSpan.count();
266251
// Adding step / 2 to the window to avoid off by 1 errors during truncation
267252
const size_t nFrames = (end - start + step * 0.5) / step;
268-
boost::progress_display progress(nFrames);
269253

270254
for (size_t frameIndex = 0; frameIndex < nFrames; ++frameIndex)
271255
{
272256
// Making the timestamp fall in the middle of the frame
273257
const double timestamp = start + frameIndex * step + step * 0.5;
274258

275-
const std::chrono::high_resolution_clock::time_point loadPivot1
276-
= std::chrono::high_resolution_clock::now();
259+
const std::chrono::high_resolution_clock::time_point loadPivot1 = std::chrono::high_resolution_clock::now();
277260

278261
brion::floatsPtr data;
279262
try
@@ -286,10 +269,9 @@ int main(const int argc, char** argv)
286269
::exit(EXIT_FAILURE);
287270
}
288271

289-
const std::chrono::high_resolution_clock::time_point loadPivot2
290-
= std::chrono::high_resolution_clock::now();
291-
const std::chrono::duration<float> loadPivotSpan
292-
= std::chrono::duration_cast<std::chrono::duration<float>>(loadPivot2 - loadPivot1);
272+
const std::chrono::high_resolution_clock::time_point loadPivot2 = std::chrono::high_resolution_clock::now();
273+
const std::chrono::duration<float> loadPivotSpan =
274+
std::chrono::duration_cast<std::chrono::duration<float>>(loadPivot2 - loadPivot1);
293275
loadTime += loadPivotSpan.count();
294276

295277
if (!data)
@@ -300,8 +282,7 @@ int main(const int argc, char** argv)
300282

301283
const brion::floats& values = *data.get();
302284

303-
const std::chrono::high_resolution_clock::time_point witePivot1
304-
= std::chrono::high_resolution_clock::now();
285+
const std::chrono::high_resolution_clock::time_point witePivot1 = std::chrono::high_resolution_clock::now();
305286

306287
if (isFrameSorted)
307288
{
@@ -329,31 +310,24 @@ int main(const int argc, char** argv)
329310
return EXIT_FAILURE;
330311
}
331312

332-
const std::chrono::high_resolution_clock::time_point witePivot2
333-
= std::chrono::high_resolution_clock::now();
334-
const std::chrono::duration<float> writePivotSpan
335-
= std::chrono::duration_cast<std::chrono::duration<float>>(witePivot2 - witePivot1);
313+
const std::chrono::high_resolution_clock::time_point witePivot2 = std::chrono::high_resolution_clock::now();
314+
const std::chrono::duration<float> writePivotSpan =
315+
std::chrono::duration_cast<std::chrono::duration<float>>(witePivot2 - witePivot1);
336316
writeTime += writePivotSpan.count();
337-
++progress;
338317
}
339318

340-
const std::chrono::high_resolution_clock::time_point flushPivot1
341-
= std::chrono::high_resolution_clock::now();
319+
const std::chrono::high_resolution_clock::time_point flushPivot1 = std::chrono::high_resolution_clock::now();
342320
to.flush();
343-
const std::chrono::high_resolution_clock::time_point flushPivot2
344-
= std::chrono::high_resolution_clock::now();
345-
const std::chrono::duration<float> flushPivotSpan
346-
= std::chrono::duration_cast<std::chrono::duration<float>>(flushPivot2 - flushPivot1);
321+
const std::chrono::high_resolution_clock::time_point flushPivot2 = std::chrono::high_resolution_clock::now();
322+
const std::chrono::duration<float> flushPivotSpan =
323+
std::chrono::duration_cast<std::chrono::duration<float>>(flushPivot2 - flushPivot1);
347324
writeTime += flushPivotSpan.count();
348325

349-
std::cout << "Converted " << inURI << " to " << outURI << " (in "
350-
<< size_t(loadTime) << " out " << size_t(writeTime) << " ms, "
351-
<< gids.size() << " cells X " << nFrames << " frames)"
352-
<< std::endl;
326+
std::cout << "Converted " << inURI << " to " << outURI << " (in " << size_t(loadTime) << " out "
327+
<< size_t(writeTime) << " ms, " << gids.size() << " cells X " << nFrames << " frames)" << std::endl;
353328

354329
if (vm.count("compare"))
355330
{
356-
progress.restart(nFrames);
357331
brion::CompartmentReport result(outURI, brion::MODE_READ);
358332

359333
REQUIRE_EQUAL(in.getStartTime(), result.getStartTime());
@@ -396,7 +370,6 @@ int main(const int argc, char** argv)
396370
REQUIRE_EQUAL((*frame1)[o1], (*frame2)[o2]);
397371
}
398372
}
399-
++progress;
400373
}
401374
}
402375

apps/spikeConverter.cpp

+28-47
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#define STREAM_FRAME_LENGTH_MS 10
3434

3535
#include <boost/program_options.hpp>
36-
#include <boost/progress.hpp>
3736

3837
namespace po = boost::program_options;
3938

@@ -66,25 +65,21 @@ int main(int argc, char* argv[])
6665

6766
if (vm.count("help") || vm.count("input") == 0)
6867
{
69-
std::cout
70-
<< "Usage: " << std::string(argv[0])
71-
<< " input-uri [output-uri=spikes.out] [options]" << std::endl
72-
<< std::endl
73-
<< "Supported input and output URIs:" << std::endl
74-
<< brion::SpikeReport::getDescriptions()
75-
<< std::endl
68+
std::cout << "Usage: " << std::string(argv[0]) << " input-uri [output-uri=spikes.out] [options]" << std::endl
69+
<< std::endl
70+
<< "Supported input and output URIs:" << std::endl
71+
<< brion::SpikeReport::getDescriptions() << std::endl
7672
#ifdef BRION_USE_BBPTESTDATA
77-
<< std::endl
78-
<< " Test data set (only for input):\n test:" << std::endl
73+
<< std::endl
74+
<< " Test data set (only for input):\n test:" << std::endl
7975
#endif
80-
<< std::endl
81-
<< options << std::endl;
76+
<< std::endl
77+
<< options << std::endl;
8278
return EXIT_SUCCESS;
8379
}
8480
if (vm.count("version"))
8581
{
86-
std::cout << "Brion spike report converter "
87-
<< brion::Version::getString() << std::endl;
82+
std::cout << "Brion spike report converter " << brion::Version::getString() << std::endl;
8883
return EXIT_SUCCESS;
8984
}
9085

@@ -94,76 +89,62 @@ int main(int argc, char* argv[])
9489
}
9590
catch (const po::error& e)
9691
{
97-
std::cerr << "Command line parse error: " << e.what() << std::endl
98-
<< options << std::endl;
92+
std::cerr << "Command line parse error: " << e.what() << std::endl << options << std::endl;
9993
return EXIT_FAILURE;
10094
}
10195

10296
std::string input = vm["input"].as<std::string>();
10397
#ifdef BRION_USE_BBPTESTDATA
10498
if (input == "test:")
10599
{
106-
input = std::string(BBP_TESTDATA) +
107-
"/circuitBuilding_1000neurons/Neurodamus_output/out.dat";
100+
input = std::string(BBP_TESTDATA) + "/circuitBuilding_1000neurons/Neurodamus_output/out.dat";
108101
}
109102
#endif
110103
if (input == vm["output"].as<std::string>())
111104
{
112-
std::cerr << "Cowardly refusing to convert " << input << " onto itself"
113-
<< std::endl;
105+
std::cerr << "Cowardly refusing to convert " << input << " onto itself" << std::endl;
114106
return EXIT_FAILURE;
115107
}
116108

117109
try
118110
{
119111
float readTime = 0.f, writeTime = 0.f;
120-
const std::chrono::high_resolution_clock::time_point p1
121-
= std::chrono::high_resolution_clock::now();
112+
const std::chrono::high_resolution_clock::time_point p1 = std::chrono::high_resolution_clock::now();
122113

123114
brion::SpikeReport in(brion::URI(input), brion::MODE_READ);
124115

125-
const std::chrono::high_resolution_clock::time_point p2
126-
= std::chrono::high_resolution_clock::now();
116+
const std::chrono::high_resolution_clock::time_point p2 = std::chrono::high_resolution_clock::now();
127117

128-
const std::chrono::duration<float> p1p2
129-
= std::chrono::duration_cast<std::chrono::duration<float>>(p2 - p1);
118+
const std::chrono::duration<float> p1p2 = std::chrono::duration_cast<std::chrono::duration<float>>(p2 - p1);
130119
readTime += p1p2.count();
131120

132-
brion::SpikeReport out(brion::URI(vm["output"].as<std::string>()),
133-
brion::MODE_WRITE);
121+
brion::SpikeReport out(brion::URI(vm["output"].as<std::string>()), brion::MODE_WRITE);
134122

135-
const std::chrono::high_resolution_clock::time_point p3
136-
= std::chrono::high_resolution_clock::now();
123+
const std::chrono::high_resolution_clock::time_point p3 = std::chrono::high_resolution_clock::now();
137124

138-
const std::chrono::duration<float> p2p3
139-
= std::chrono::duration_cast<std::chrono::duration<float>>(p3 - p2);
125+
const std::chrono::duration<float> p2p3 = std::chrono::duration_cast<std::chrono::duration<float>>(p3 - p2);
140126
writeTime += p2p3.count();
141127

142128
const float step = 10.f; // ms, arbitrary value
143129
while (in.getState() == brion::SpikeReport::State::ok)
144130
{
145-
const std::chrono::high_resolution_clock::time_point rl1
146-
= std::chrono::high_resolution_clock::now();
131+
const std::chrono::high_resolution_clock::time_point rl1 = std::chrono::high_resolution_clock::now();
147132
const auto spikes = in.readUntil(in.getCurrentTime() + step).get();
148-
const std::chrono::high_resolution_clock::time_point rl2
149-
= std::chrono::high_resolution_clock::now();
150-
const std::chrono::duration<float> rlspan
151-
= std::chrono::duration_cast<std::chrono::duration<float>>(rl2 - rl1);
133+
const std::chrono::high_resolution_clock::time_point rl2 = std::chrono::high_resolution_clock::now();
134+
const std::chrono::duration<float> rlspan =
135+
std::chrono::duration_cast<std::chrono::duration<float>>(rl2 - rl1);
152136
readTime += rlspan.count();
153137

154-
const std::chrono::high_resolution_clock::time_point wl1
155-
= std::chrono::high_resolution_clock::now();
138+
const std::chrono::high_resolution_clock::time_point wl1 = std::chrono::high_resolution_clock::now();
156139
out.write(spikes);
157-
const std::chrono::high_resolution_clock::time_point wl2
158-
= std::chrono::high_resolution_clock::now();
159-
const std::chrono::duration<float> wlspan
160-
= std::chrono::duration_cast<std::chrono::duration<float>>(wl2 - wl1);
140+
const std::chrono::high_resolution_clock::time_point wl2 = std::chrono::high_resolution_clock::now();
141+
const std::chrono::duration<float> wlspan =
142+
std::chrono::duration_cast<std::chrono::duration<float>>(wl2 - wl1);
161143
writeTime += wlspan.count();
162144
}
163145

164-
std::cout << "Converted " << input << " => "
165-
<< vm["output"].as<std::string>() << " in " << readTime
166-
<< " + " << writeTime << " ms" << std::endl;
146+
std::cout << "Converted " << input << " => " << vm["output"].as<std::string>() << " in " << readTime << " + "
147+
<< writeTime << " ms" << std::endl;
167148
}
168149
catch (const std::exception& exception)
169150
{

0 commit comments

Comments
 (0)