OpenWalnut 1.2.5

WEEG.h

00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WEEG_H
00026 #define WEEG_H
00027 
00028 #include <map>
00029 #include <string>
00030 #include <vector>
00031 #include "WRecording.h"
00032 #include "../common/WPrototyped.h"
00033 #include "../common/math/linearAlgebra/WLinearAlgebra.h"
00034 #include "WExportDataHandler.h"
00035 
00036 /**
00037  * An incomplete implementation to store information about electrodes of EEG data
00038  */
00039 class OWDATAHANDLER_EXPORT WEEGElectrodeObject // NOLINT
00040 {
00041 public:
00042     /**
00043      * Contructor taking the position of the elctrode.
00044      * \param position The position of the electrode in world space.
00045      */
00046     explicit WEEGElectrodeObject( WPosition position );
00047 
00048     /**
00049      * Returns the position of the electrode.
00050      * \return The position of the electrode.
00051      */
00052     WPosition getPosition() const;
00053 protected:
00054 private:
00055     WPosition m_position; //!< Position of the electrode in space
00056 };
00057 
00058 typedef std::vector< double > WEEGElectrode;
00059 typedef std::vector< WEEGElectrode > WEEGSegment;
00060 typedef std::vector< WEEGSegment > WEEGSegmentArray;
00061 
00062 typedef std::vector< WEEGElectrodeObject > WEEGElectrodeLibrary;
00063 typedef std::vector< std::pair< std::string, std::string > > WEEGChannelLabels;
00064 /**
00065  * Contains EEG recording data.
00066  * \ingroup dataHandler
00067  */
00068 class OWDATAHANDLER_EXPORT WEEG : public WRecording // NOLINT
00069 {
00070 public:
00071 
00072 
00073     /**
00074      * Constructs a WEEG object from the give infos.
00075      * \param data Array of segments
00076      * \param electrodeLib Information about the electrodes
00077      * \param channelLabels The names of the channels.
00078      */
00079     explicit WEEG( const WEEGSegmentArray& data,
00080                    const WEEGElectrodeLibrary& electrodeLib,
00081                    const WEEGChannelLabels& channelLabels );
00082 
00083     /**
00084      * Constructor creating a quite unusable instance. Useful for prototype mechanism.
00085      */
00086     WEEG();
00087 
00088     /**
00089      * Access operator for single samples.
00090      * \param segment id of segment to access
00091      * \param signal id of signal to access
00092      * \param sample id of sample to access
00093      * \return The data sample at the given location
00094      */
00095     const double& operator()( size_t segment, size_t signal, size_t sample ) const;
00096 
00097     /**
00098      * Returns number of samples of a given segment.
00099      * \param segmentId id of segment beeing inspected.
00100      * \return Number of samples of segment with segmentId.
00101      */
00102     size_t getNumberOfSamples( size_t segmentId ) const;
00103 
00104     /**
00105      * Return the number of channels this EEG has.
00106      * \return Number of channels.
00107      */
00108     size_t getNumberOfChannels() const;
00109 
00110     /**
00111      * Return the number of segments this EEG consists of.
00112      * \return Number of segments.
00113      */
00114     size_t getNumberOfSegments() const;
00115 
00116     /**
00117      * Return the label of a certain channel.
00118      * \param channelId id of channel beeing inspected.
00119      * \return Name of channel with channelId
00120      */
00121     std::string getChannelLabel( size_t channelId ) const;
00122 
00123     /**
00124      * Return the position of the sensor for a certain channel.
00125      * \param channelId id of channel beeing inspected.
00126      * \return Position of sensor of channel channelId
00127      */
00128     WPosition getChannelPosition( size_t channelId ) const;
00129 
00130     /**
00131      * Determines whether this dataset can be used as a texture.
00132      *
00133      * \return true if usable as texture.
00134      */
00135     virtual bool isTexture() const;
00136 
00137     /**
00138      * Gets the name of this prototype.
00139      *
00140      * \return the name.
00141      */
00142     virtual const std::string getName() const;
00143 
00144     /**
00145      * Gets the description for this prototype.
00146      *
00147      * \return the description
00148      */
00149     virtual const std::string getDescription() const;
00150 
00151     /**
00152      * Returns a prototype instantiated with the true type of the deriving class.
00153      *
00154      * \return the prototype.
00155      */
00156     static boost::shared_ptr< WPrototyped > getPrototype();
00157 
00158 protected:
00159 
00160     /**
00161      * The prototype as singleton.
00162      */
00163     static boost::shared_ptr< WPrototyped > m_prototype;
00164 
00165 private:
00166     /**
00167      * We have only on sampling rate for all channels.
00168      */
00169     double m_samplingRate;
00170     /**
00171      * Description of electrodes
00172      */
00173     std::map< std::string, size_t > m_electrodeDescriptions;
00174 
00175     /**
00176      * Information about the electrodes.
00177      */
00178     WEEGElectrodeLibrary m_electrodeLibrary;
00179 
00180     /**
00181      * Contains the EEG data as an arry of segements
00182      * of data which consist of an array of electrodes
00183      * which again consist of an array of samples over time.
00184      */
00185     WEEGSegmentArray m_segments;
00186 
00187     /**
00188      * Label for each channel.
00189      */
00190     WEEGChannelLabels m_channelLabels;
00191 
00192     /**
00193      * Is the channel enabled?
00194      */
00195     std::vector< bool > m_channelEnabled;
00196 };
00197 
00198 inline const double& WEEG::operator()( size_t segment, size_t signal, size_t sample ) const
00199 {
00200     return m_segments[segment][signal][sample];
00201 }
00202 
00203 inline size_t WEEG::getNumberOfSamples( size_t segmentId ) const
00204 {
00205     return m_segments[segmentId][0].size();
00206 }
00207 
00208 inline size_t WEEG::getNumberOfChannels() const
00209 {
00210     return m_segments[0].size();
00211 }
00212 
00213 inline size_t WEEG::getNumberOfSegments() const
00214 {
00215     return m_segments.size();
00216 }
00217 
00218 inline std::string WEEG::getChannelLabel( size_t channelId ) const
00219 {
00220     // TODO(wiebel): what is done with the second string of the label?
00221     return  m_channelLabels[channelId].first;
00222 }
00223 
00224 inline WPosition WEEG::getChannelPosition( size_t channelId ) const
00225 {
00226     return  m_electrodeLibrary[channelId].getPosition();
00227 }
00228 
00229 #endif  // WEEG_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends