OpenMEEG
sensors.h
Go to the documentation of this file.
1 /*
2 Project Name : OpenMEEG
3 
4 © INRIA and ENPC (contributors: Geoffray ADDE, Maureen CLERC, Alexandre
5 GRAMFORT, Renaud KERIVEN, Jan KYBIC, Perrine LANDREAU, Théodore PAPADOPOULO,
6 Emmanuel OLIVI
7 Maureen.Clerc.AT.inria.fr, keriven.AT.certis.enpc.fr,
8 kybic.AT.fel.cvut.cz, papadop.AT.inria.fr)
9 
10 The OpenMEEG software is a C++ package for solving the forward/inverse
11 problems of electroencephalography and magnetoencephalography.
12 
13 This software is governed by the CeCILL-B license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL-B
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided only
21 with a limited warranty and the software's authors, the holders of the
22 economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards their
32 requirements in conditions enabling the security of their systems and/or
33 data to be ensured and, more generally, to use and operate it in the
34 same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL-B license and that you accept its terms.
38 */
39 
40 #pragma once
41 
42 #include <fstream>
43 #include <sstream>
44 #include <stdlib.h>
45 #include <string>
46 #include <vector>
47 
48 #include <IOUtils.H>
49 #include <vector.h>
50 #include <matrix.h>
51 #include <geometry.h>
52 #include <om_common.h>
53 
54 #include <OpenMEEG_Export.h>
55 
56 namespace OpenMEEG {
57 
92  class OPENMEEG_EXPORT Sensors {
93 
94  public:
95  Sensors(): m_nb(0), m_geo(NULL) {}
96  Sensors(const Geometry& g): m_nb(0), m_geo(&g) {}
97  Sensors(const char* filename): m_geo(NULL) { this->load(filename,'t'); }
98  Sensors(const char* filename, const Geometry& g): m_geo(&g) { this->load(filename,'t'); };
100  void load(const char* filename, char filetype = 't' );
101  void load(std::istream &in);
102  void save(const char* filename);
103 
104  size_t getNumberOfSensors() const { return m_nb; }
105  size_t getNumberOfPositions() const { return m_positions.nlin(); }
107  Matrix& getPositions() { return m_positions ; }
108  Matrix getPositions() const { return m_positions ; }
110  Matrix& getOrientations() {return m_orientations ; }
111  Matrix getOrientations() const {return m_orientations ; }
113  Strings& getNames() {return m_names ; }
114  Strings getNames() const {return m_names ; }
116  bool hasRadii() const { return m_radii.nlin() > 0 ;}
117  bool hasOrientations() const { return m_orientations.nlin() > 0 ;}
118  bool hasNames() const { return m_names.size() == m_nb ;}
119  Vector getPosition(size_t idx) const;
120  Vector getOrientation(size_t idx) const;
121  std::string getName(size_t idx) const{ om_assert(idx < m_names.size()); return m_names[idx]; }
122  void setPosition(size_t idx, Vector& pos);
123  void setOrientation(size_t idx, Vector& orient);
125  bool hasSensor(std::string name);
126  size_t getSensorIdx(std::string name);
127  Triangles getInjectionTriangles(size_t idx) const { om_assert(idx < m_triangles.size()); return m_triangles[idx]; }
129  Vector getRadii() const { return m_radii; }
130  Vector getWeights() const { return m_weights; }
131 
132  SparseMatrix getWeightsMatrix() const;
133 
134  bool isEmpty() { if(m_nb == 0) return true; else return false; }
135  void info() const;
137  private:
138  size_t m_nb;
144  std::vector<Triangles> m_triangles;
145  const Geometry * m_geo;
146  std::vector<size_t> m_pointSensorIdx;
147  void findInjectionTriangles();
148  };
149 
150  inline Vector Sensors::getPosition(size_t idx) const {
151  return m_positions.getlin(idx);
152  }
153 
154  inline Vector Sensors::getOrientation(size_t idx) const {
155  return m_orientations.getlin(idx);
156  }
157 
158  inline void Sensors::setPosition(size_t idx, Vector& pos) {
159  return m_positions.setlin(idx,pos);
160  }
161 
162  inline void Sensors::setOrientation(size_t idx, Vector& orient) {
163  return m_orientations.setlin(idx,orient);
164  }
165 }
void setOrientation(size_t idx, Vector &orient)
Definition: sensors.h:162
size_t getNumberOfSensors() const
Definition: sensors.h:104
Matrix getOrientations() const
Definition: sensors.h:111
Geometry contains the electrophysiological model Here are stored the vertices, meshes and domains...
Definition: geometry.h:61
Triangles getInjectionTriangles(size_t idx) const
Definition: sensors.h:127
Vector getRadii() const
Definition: sensors.h:129
Strings getNames() const
Definition: sensors.h:114
std::vector< std::string > Strings
Definition: om_common.h:52
Matrix getPositions() const
Definition: sensors.h:108
std::vector< Triangle > Triangles
Definition: triangle.h:176
Matrix m_orientations
Definition: sensors.h:141
const Geometry * m_geo
Definition: sensors.h:145
void setPosition(size_t idx, Vector &pos)
Definition: sensors.h:158
std::vector< size_t > m_pointSensorIdx
Definition: sensors.h:146
Vector getlin(size_t i) const
Definition: matrix.h:256
Vector m_radii
Definition: sensors.h:143
Vector m_weights
Definition: sensors.h:142
bool hasOrientations() const
Definition: sensors.h:117
Vector getWeights() const
Definition: sensors.h:130
Sensors(const char *filename)
Definition: sensors.h:97
Vector getPosition(size_t idx) const
Definition: sensors.h:150
bool hasNames() const
Definition: sensors.h:118
Matrix & getOrientations()
Definition: sensors.h:110
Sensors(const char *filename, const Geometry &g)
Definition: sensors.h:98
bool hasRadii() const
Definition: sensors.h:116
Matrix & getPositions()
Definition: sensors.h:107
Matrix m_positions
Definition: sensors.h:140
Strings & getNames()
Definition: sensors.h:113
bool isEmpty()
Definition: sensors.h:134
Strings m_names
Definition: sensors.h:139
std::string getName(size_t idx) const
Definition: sensors.h:121
size_t getNumberOfPositions() const
Definition: sensors.h:105
Sensors(const Geometry &g)
Definition: sensors.h:96
Vector getOrientation(size_t idx) const
Definition: sensors.h:154
std::vector< Triangles > m_triangles
Definition: sensors.h:144
Matrix class.
Definition: matrix.h:61
void setlin(size_t i, const Vector &v)
Definition: matrix.h:276