Brion  2.0.0
The Blue Brain C++ I/O library
brion/types.h
1 /* Copyright (c) 2013-2017, EPFL/Blue Brain Project
2  * Daniel Nachbaur <daniel.nachbaur@epfl.ch>
3  *
4  * This file is part of Brion <https://github.com/BlueBrain/Brion>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 3.0 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef BRION_TYPES
21 #define BRION_TYPES
22 
23 #include <brion/enums.h>
24 
25 #include <boost/multi_array.hpp>
26 #include <lunchbox/compiler.h>
27 #include <lunchbox/types.h>
28 #include <map>
29 #include <servus/uri.h>
30 #include <set>
31 
32 #pragma warning(push)
33 #pragma warning(disable : 4996)
34 #include <vmmlib/types.hpp>
35 #pragma warning(pop)
36 
38 namespace brion
39 {
40 using namespace enums;
41 class BlueConfig;
42 class Circuit;
43 class CompartmentReport;
44 class CompartmentReportPlugin;
45 class Mesh;
46 class Morphology;
47 class SpikeReport;
48 class SpikeReportPlugin;
49 class Synapse;
50 class SynapseSummary;
51 class Target;
52 
53 using vmml::Vector2i;
54 using vmml::Vector3f;
55 using vmml::Vector4f;
56 using vmml::Vector3d;
57 using vmml::Vector4d;
58 
59 typedef std::vector<size_t> size_ts;
60 typedef std::vector<int32_t> int32_ts;
61 typedef std::vector<uint16_t> uint16_ts;
62 typedef std::vector<uint32_t> uint32_ts;
63 typedef std::vector<uint64_t> uint64_ts;
64 typedef std::vector<float> floats;
65 typedef std::vector<double> doubles;
66 typedef std::vector<Vector2i> Vector2is;
67 typedef std::vector<Vector3f> Vector3fs;
68 typedef std::vector<Vector4f> Vector4fs;
69 typedef std::vector<Vector3d> Vector3ds;
70 typedef std::vector<Vector4d> Vector4ds;
71 typedef std::vector<SectionType> SectionTypes;
72 typedef std::vector<Target> Targets;
73 typedef std::shared_ptr<int32_ts> int32_tsPtr;
74 typedef std::shared_ptr<uint16_ts> uint16_tsPtr;
75 typedef std::shared_ptr<uint32_ts> uint32_tsPtr;
76 typedef std::shared_ptr<floats> floatsPtr;
77 typedef std::shared_ptr<doubles> doublesPtr;
78 typedef std::shared_ptr<Vector2is> Vector2isPtr;
79 typedef std::shared_ptr<Vector3fs> Vector3fsPtr;
80 typedef std::shared_ptr<Vector4fs> Vector4fsPtr;
81 typedef std::shared_ptr<Vector3ds> Vector3dsPtr;
82 typedef std::shared_ptr<Vector4ds> Vector4dsPtr;
83 typedef std::shared_ptr<SectionTypes> SectionTypesPtr;
84 
86 typedef std::set<uint32_t> GIDSet;
87 
88 typedef GIDSet::const_iterator GIDSetCIter;
89 typedef GIDSet::iterator GIDSetIter;
90 
94 typedef std::vector<uint64_ts> SectionOffsets;
95 
97 typedef std::vector<uint16_ts> CompartmentCounts;
98 
100 typedef boost::multi_array<std::string, 2> NeuronMatrix;
101 
103 typedef boost::multi_array<float, 2> SynapseMatrix;
104 
106 typedef boost::multi_array<uint32_t, 2> SynapseSummaryMatrix;
107 
109 typedef std::pair<float, uint32_t> Spike;
110 typedef std::vector<Spike> Spikes;
111 
113 typedef std::multimap<float, uint32_t> SpikeMap;
114 
115 struct Frame
116 {
117  double timestamp;
118  floatsPtr data;
119 };
120 
121 struct Frames
122 {
123  doublesPtr timeStamps;
128  floatsPtr data;
129 };
130 
133 const float UNDEFINED_TIMESTAMP LB_UNUSED = std::numeric_limits<float>::max();
134 const float RESTING_VOLTAGE LB_UNUSED = -67.;
135 
136 const float MINIMUM_VOLTAGE LB_UNUSED = -80.;
137 
138 using lunchbox::Strings;
139 
140 using servus::URI;
141 
142 typedef std::vector<URI> URIs;
143 }
144 
145 // if you have a type T in namespace N, the operator << for T needs to be in
146 // namespace N too
147 namespace boost
148 {
149 template <typename T>
150 inline std::ostream& operator<<(std::ostream& os,
151  const boost::multi_array<T, 2>& data)
152 {
153  for (size_t i = 0; i < data.shape()[0]; ++i)
154  {
155  for (size_t j = 0; j < data.shape()[1]; ++j)
156  os << data[i][j] << " ";
157  os << std::endl;
158  }
159  return os;
160 }
161 }
162 
163 namespace std
164 {
165 template <class T, class U>
166 inline std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& pair)
167 {
168  return os << "[ " << pair.first << ", " << pair.second << " ]";
169 }
170 }
171 
172 #endif
std::vector< uint64_ts > SectionOffsets
The offset for the voltage per section for each neuron, uin64_t max for sections with no compartments...
Definition: brion/types.h:94
STL namespace.
std::multimap< float, uint32_t > SpikeMap
A list of Spikes events per cell gid, indexed by spikes times.
Definition: brion/types.h:113
std::pair< float, uint32_t > Spike
A spike.
Definition: brion/types.h:109
std::set< uint32_t > GIDSet
Ordered set of GIDs of neurons.
Definition: brion/types.h:86
boost::multi_array< std::string, 2 > NeuronMatrix
Data matrix storing NeuronAttributes for each neuron.
Definition: brion/types.h:100
std::ostream & operator<<(std::ostream &, const BlueConfig &)
Stream out content of BlueConfig or CircuitConfig file.
boost::multi_array< uint32_t, 2 > SynapseSummaryMatrix
Data matrix storing GID, numEfferent, numAfferent for each neuron.
Definition: brion/types.h:106
const float RESTING_VOLTAGE
Resting voltage in mV.
Definition: brion/types.h:134
std::vector< uint16_ts > CompartmentCounts
The number of compartments per section for each neuron.
Definition: brion/types.h:97
Blue Brain File IO classes.
Definition: blueConfig.h:29
Enumerations used in Brion.
const float MINIMUM_VOLTAGE
Lowest voltage after hyperpolarisation.
Definition: brion/types.h:136
boost::multi_array< float, 2 > SynapseMatrix
Data matrix storing SynapseAttributes for each neuron.
Definition: brion/types.h:103
floatsPtr data
The data of multiple compartment frames in a flat array.
Definition: brion/types.h:128
const float UNDEFINED_TIMESTAMP
A value for undefined timestamps.
Definition: brion/types.h:133