24#include <OpenMEEG_Export.h>
63 void init_labels(
const Strings& labels) {
64 m_pointSensorIdx = std::vector<size_t>(labels.size());
65 for (std::size_t i=0; i<labels.size(); ++i)
66 m_pointSensorIdx[i] = getSensorIdx(m_names[i]);
81 Sensors(
const char* filename): geometry(nullptr) { load(filename,
't'); }
85 Sensors(
const char* filename,
const Geometry& g): geometry(&g) { load(filename,
't'); }
88 m_nb(positions.nlin()),m_positions(positions),m_radii(m_nb),geometry(&g)
91 findInjectionTriangles();
95 m_nb(labels.size()),m_names(labels),m_positions(positions),m_orientations(orientations),m_weights(weights),m_radii(radii)
101 m_nb(labels.size()),m_names(labels),m_positions(positions),m_orientations(orientations),m_weights(weights),m_radii(radii),geometry(&g)
104 findInjectionTriangles();
110 void load(
const char* filename,
const char filetype=
't');
111 void load(
const std::string& filename,
const char filetype=
't') {
load(filename.c_str(),filetype); }
117 void save(
const char* filename)
const;
118 void save(
const std::string& filename)
const {
save(filename.c_str()); }
145 bool hasNames()
const {
return m_names.size()==m_nb; }
158 om_assert(idx<m_names.size());
171 return std::find(m_names.begin(),m_names.end(),name)!=m_names.end();
175 const auto& it = std::find(m_names.begin(),m_names.end(),name);
176 if (it==m_names.end())
177 throw OpenMEEG::SensorError(
"Unknown sensor \"" + name +
"\"");
178 return std::distance(m_names.begin(),it);
184 om_assert(idx<m_triangles.size());
185 return m_triangles[idx];
192 SparseMatrix weight_matrix(getNumberOfSensors(),getNumberOfPositions());
193 for(
size_t i=0; i<getNumberOfPositions(); ++i)
194 weight_matrix(m_pointSensorIdx[i],i) = m_weights(i);
195 return weight_matrix;
208 void findInjectionTriangles();
216 std::vector<Triangles> m_triangles;
218 std::vector<size_t> m_pointSensorIdx;
Geometry contains the electrophysiological model Vertices, meshes and domains are stored in this geom...
Matrix class Matrix class.
Sensors class for EEG and MEG sensors.
size_t getSensorIdx(const std::string &name) const
bool hasRadii() const
Return true if contains radii.
Sensors(const Geometry &g)
Default constructor with a geometry. Number of sensors = 0.
Sensors(const Strings &labels, const Matrix &positions, const Matrix &orientations, const Vector &weights, const Vector &radii)
Matrix & getPositions()
Return sensors positions.
Vector getPosition(const size_t idx) const
Return the position (3D point) of the integration point idx.
void save(const char *filename) const
bool isEmpty()
Return if the sensors object is empty. The sensors object is empty if its number of sensors is null.
Sensors()
Default constructor. Number of sensors = 0.
Vector getWeights() const
const Matrix & getOrientations() const
std::string getName(const size_t idx) const
Return the name of the idx_th sensor.
bool hasNames() const
Return true if contains all sensors names.
size_t getNumberOfPositions() const
Return the number of integration points.
Sensors(const Strings &labels, const Matrix &positions, const Matrix &orientations, const Vector &weights, const Vector &radii, const Geometry &g)
Vector getOrientation(const size_t idx) const
Return the orientations (3D point) of the integration point idx.
SparseMatrix getWeightsMatrix() const
void load(std::istream &in)
Load description file of sensors from stream.
const Matrix & getPositions() const
void save(const std::string &filename) const
void info() const
get info about sensors.
size_t getNumberOfSensors() const
Return the number of sensors.
Sensors(const Matrix &positions, const Geometry &g)
Strings & getNames()
Return sensors names.
Triangles getInjectionTriangles(const size_t idx) const
For EIT, get triangles under the current injection electrode.
void load(const char *filename, const char filetype='t')
Load sensors from file. Filetype is 't' for text file or 'b' for binary file.
bool hasSensor(const std::string &name) const
void setOrientation(const size_t idx, const Vector &orient)
Set the orientation (3D point) of the integration point i.
bool hasOrientations() const
Return true if contains orientations.
Sensors(const char *filename, const Geometry &g)
Construct from file and geometry (for EIT).
void setPosition(const size_t idx, const Vector &pos)
Set the position (3D point) of the integration point i.
void load(const std::string &filename, const char filetype='t')
Sensors(const char *filename)
Construct from text file.
Matrix & getOrientations()
Return sensors orientations.
std::vector< Triangle > Triangles
std::vector< std::string > Strings