OpenWalnut  1.5.0dev
WMReadDipoles.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WMREADDIPOLES_H
26 #define WMREADDIPOLES_H
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include <osg/Geode>
33 
34 #include "core/kernel/WModule.h"
35 #include "core/kernel/WModuleInputData.h"
36 #include "core/kernel/WModuleOutputData.h"
37 
38 class WDataSetDipoles;
39 
40 /**
41  * Someone should add some documentation here.
42  * Probably the best person would be the module's
43  * creator, i.e. "wiebel".
44  *
45  * This is only an empty template for a new module. For
46  * an example module containing many interesting concepts
47  * and extensive documentation have a look at "src/modules/template"
48  *
49  * \ingroup modules
50  */
51 class WMReadDipoles: public WModule
52 {
53 public:
54  /**
55  * Simple constructor
56  */
57  WMReadDipoles();
58 
59  /**
60  * Destructs the reader.
61  */
62  virtual ~WMReadDipoles();
63 
64  /**
65  * Gives back the name of this module.
66  * \return the module's name.
67  */
68  virtual const std::string getName() const;
69 
70  /**
71  * Gives back a description of this module.
72  * \return description to module.
73  */
74  virtual const std::string getDescription() const;
75 
76  /**
77  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
78  * should never be initialized or modified in some other way. A simple new instance is required.
79  *
80  * \return the prototype used to create every module in OpenWalnut.
81  */
82  virtual std::shared_ptr< WModule > factory() const;
83 
84  /**
85  * Get the icon for this module in XPM format.
86  *
87  * \return The icon.
88  */
89  virtual const char** getXPMIcon() const;
90 
91 protected:
92  /**
93  * Entry point after loading the module. Runs in separate thread.
94  */
95  virtual void moduleMain();
96 
97  /**
98  * Initialize the connectors this module is using.
99  */
100  virtual void connectors();
101 
102  /**
103  * Initialize the properties for this module.
104  */
105  virtual void properties();
106 
107  /**
108  * Initialize requirements for this module.
109  */
110  virtual void requirements();
111 
112 private:
113  /**
114  * Function that composes the data read by readFile() from the different files to one WDataSetDipoles
115  *
116  * \param filenames Names and locations of files to read.
117  * \return A pointer to the loaded dataset
118  */
119  std::shared_ptr< WDataSetDipoles > readFiles( std::vector< std::string > filenames );
120 
121  /**
122  * Function doing the actual reading from one file
123  *
124  * \param filename Name and locations of file to read.
125  * \param pos position of the dipole
126  * \param times time values of the time steps
127  * \param magnitudes magnitudes of the dipole at the different time steps.
128  * \param firstTimeStep First time where the magnitude is not 0
129  * \param lastTimeStep Last time where the magnitude is not 0
130  */
131  void readFile( std::string filename,
132  WPosition* pos,
133  std::vector< float >* times,
134  std::vector< float >* magnitudes,
135  size_t* firstTimeStep,
136  size_t* lastTimeStep );
137 
138  /**
139  * Function reading meta file with filenames of dipole files
140  *
141  * \param filename Name and location of meta file to read.
142  * \return A pointer to the loaded dataset
143  */
144  std::shared_ptr< WDataSetDipoles > readMetaData( std::string filename );
145 
146  /**
147  * Output connector for dipoles of EEG data
148  */
149  std::shared_ptr< WModuleOutputData< WDataSetDipoles > > m_dipoles;
150 
151  /**
152  * Pointer to the loaded dataset
153  */
154  std::shared_ptr< WDataSetDipoles > m_dataSet;
155 
156  std::shared_ptr< WCondition > m_propCondition; //!< A condition used to notify about changes in several properties.
157  WPropFilename m_dataFile; //!< The data will be read from this file.
158  WPropBool m_metaFile; //!< Use meta file containing fileNames.
159 };
160 
161 #endif // WMREADDIPOLES_H
Represents a dipole dataset.
Someone should add some documentation here.
Definition: WMReadDipoles.h:52
virtual ~WMReadDipoles()
Destructs the reader.
WPropFilename m_dataFile
The data will be read from this file.
void readFile(std::string filename, WPosition *pos, std::vector< float > *times, std::vector< float > *magnitudes, size_t *firstTimeStep, size_t *lastTimeStep)
Function doing the actual reading from one file.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
virtual const std::string getName() const
Gives back the name of this module.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
std::shared_ptr< WModuleOutputData< WDataSetDipoles > > m_dipoles
Output connector for dipoles of EEG data.
std::shared_ptr< WDataSetDipoles > m_dataSet
Pointer to the loaded dataset.
WPropBool m_metaFile
Use meta file containing fileNames.
virtual const std::string getDescription() const
Gives back a description of this module.
virtual void moduleMain()
Entry point after loading the module.
virtual void connectors()
Initialize the connectors this module is using.
virtual void requirements()
Initialize requirements for this module.
virtual void properties()
Initialize the properties for this module.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
WMReadDipoles()
Simple constructor.
std::shared_ptr< WDataSetDipoles > readFiles(std::vector< std::string > filenames)
Function that composes the data read by readFile() from the different files to one WDataSetDipoles.
std::shared_ptr< WDataSetDipoles > readMetaData(std::string filename)
Function reading meta file with filenames of dipole files.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72
This only is a 3d double vector.