Commit eabc1ee5 authored by cornimueller's avatar cornimueller
Browse files

[ADD #89] Added first version of the channel info class to retrieve...

[ADD #89] Added first version of the channel info class to retrieve information like the label of an elektrode using the new pager classes.
parent 3f884c58
......@@ -30,17 +30,31 @@
#include <boost/shared_ptr.hpp>
#include "../common/exceptions/WOutOfBounds.h"
#include "exceptions/WDHException.h"
#include "io/WPagerEEG.h"
#include "WEEGChannelInfo.h"
#include "WEEG2Segment.h"
#include "WEEG2.h"
WEEG2::WEEG2( boost::shared_ptr< WPagerEEG > pager )
{
if( !pager )
{
throw WDHException( "Couldn't construct new EEG: pager invalid" );
}
m_segments.reserve( pager->getNumberOfSegments() );
for( std::size_t segmentID = 0; segmentID < pager->getNumberOfSegments(); ++segmentID )
{
m_segments.push_back( boost::shared_ptr< WEEG2Segment >( new WEEG2Segment( pager, segmentID ) ) );
}
m_channelInfos.reserve( pager->getNumberOfChannels() );
for( std::size_t channelID = 0; channelID < pager->getNumberOfChannels(); ++channelID )
{
m_channelInfos.push_back( boost::shared_ptr< WEEGChannelInfo >( new WEEGChannelInfo( pager, channelID ) ) );
}
}
std::size_t WEEG2::getNumberOfSegments() const
......@@ -48,6 +62,11 @@ std::size_t WEEG2::getNumberOfSegments() const
return m_segments.size();
}
std::size_t WEEG2::getNumberOfChannels() const
{
return m_channelInfos.size();
}
boost::shared_ptr< WEEG2Segment > WEEG2::getSegment( std::size_t segmentID ) const
{
if( segmentID >= m_segments.size() )
......@@ -59,3 +78,15 @@ boost::shared_ptr< WEEG2Segment > WEEG2::getSegment( std::size_t segmentID ) con
return m_segments[segmentID];
}
boost::shared_ptr< WEEGChannelInfo > WEEG2::getChannelInfo( std::size_t channelID ) const
{
if( channelID >= m_channelInfos.size() )
{
std::ostringstream stream;
stream << "The EEG has no channel number " << channelID;
throw WOutOfBounds( stream.str() );
}
return m_channelInfos[channelID];
}
......@@ -32,6 +32,7 @@
#include <boost/shared_ptr.hpp>
#include "io/WPagerEEG.h"
#include "WEEGChannelInfo.h"
#include "WEEG2Segment.h"
#include "WRecording.h"
......@@ -58,6 +59,13 @@ public:
*/
std::size_t getNumberOfSegments() const;
/**
* Get the number of channels this EEG has.
*
* \return number of channels
*/
std::size_t getNumberOfChannels() const;
/**
* Get one segment.
*
......@@ -66,9 +74,19 @@ public:
*/
boost::shared_ptr< WEEG2Segment > getSegment( std::size_t segmentID ) const;
/**
* Get one channel info object.
*
* \param channelID number of channel
* \return object containing information about the channel
*/
boost::shared_ptr< WEEGChannelInfo > getChannelInfo( std::size_t channelID ) const;
protected:
private:
std::vector< boost::shared_ptr< WEEG2Segment > > m_segments; //!< list of all segments this EEG consists of
std::vector< boost::shared_ptr< WEEGChannelInfo > > m_channelInfos; //!< list of the information about all channel infos this EEG has
};
#endif // WEEG2_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <cstddef>
#include <sstream>
#include <string>
#include <boost/shared_ptr.hpp>
#include "../common/exceptions/WOutOfBounds.h"
#include "exceptions/WDHException.h"
#include "io/WPagerEEG.h"
#include "WEEGChannelInfo.h"
WEEGChannelInfo::WEEGChannelInfo( boost::shared_ptr< WPagerEEG > pager, std::size_t channelID )
{
if( !pager )
{
throw WDHException( "Couldn't construct new EEG channel info: pager invalid" );
}
if( channelID >= pager->getNumberOfChannels() )
{
std::ostringstream stream;
stream << "The EEG has no channel number " << channelID;
throw WOutOfBounds( stream.str() );
}
m_label = pager->getChannelLabel( channelID );
}
std::string WEEGChannelInfo::getLabel() const
{
return m_label;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WEEGCHANNELINFO_H
#define WEEGCHANNELINFO_H
#include <cstddef>
#include <string>
#include <boost/shared_ptr.hpp>
#include "io/WPagerEEG.h"
/**
* Class which contains information about one channel of an EEG recording, read
* from a WPagerEEG.
* \ingroup dataHandler
*/
class WEEGChannelInfo
{
public:
/**
* Constructor
*
* \param pager pager class which contains the data, read from a file on
* demand
* \param channelID number of this channel
*/
WEEGChannelInfo( boost::shared_ptr< WPagerEEG > pager, std::size_t channelID );
/**
* Get the label of the channel.
*
* \return label as string
*/
std::string getLabel() const;
protected:
private:
std::string m_label; //!< label of the channel
};
#endif // WEEGCHANNELINFO_H
......@@ -31,6 +31,7 @@
/**
* Values of an EEG.
* Saved as vector of channels, and each channel is a vector of samples.
* \ingroup dataHandler
*/
typedef std::vector< std::vector< double > > WEEGValueMatrix;
......
......@@ -48,10 +48,18 @@ public:
/**
* Get the number of segments this EEG consists of.
*
* \return number of segments
*/
virtual std::size_t getNumberOfSegments() const = 0;
/**
* Get the number of channels this EEG has.
*
* \return number of channels
*/
virtual std::size_t getNumberOfChannels() const = 0;
/**
* Get the values of all channels for a given sample range.
*
......@@ -62,6 +70,14 @@ public:
*/
virtual boost::shared_ptr< WEEGValueMatrix > getValues( std::size_t segmentID, std::size_t start, std::size_t length ) const = 0;
/**
* Get the label of a given channel
*
* \param channelID channelnumber
* \return label as string
*/
virtual std::string getChannelLabel( std::size_t channelID ) const = 0;
protected:
/**
* Constructor
......
......@@ -93,6 +93,11 @@ std::size_t WPagerEEGLibeep::getNumberOfSegments() const
return 1;
}
std::size_t WPagerEEGLibeep::getNumberOfChannels() const
{
return m_nbChannels;
}
boost::shared_ptr< WEEGValueMatrix > WPagerEEGLibeep::getValues( std::size_t segmentID, std::size_t start, std::size_t length ) const
{
if( segmentID != 0 )
......@@ -139,3 +144,15 @@ boost::shared_ptr< WEEGValueMatrix > WPagerEEGLibeep::getValues( std::size_t seg
return values;
}
std::string WPagerEEGLibeep::getChannelLabel( std::size_t channelID ) const
{
if( channelID >= m_nbChannels )
{
std::ostringstream stream;
stream << m_fileName << " has no channel number " << channelID;
throw WOutOfBounds( stream.str() );
}
return eep_get_chan_label( m_eeg, channelID );
}
......@@ -60,8 +60,12 @@ public:
virtual std::size_t getNumberOfSegments() const;
virtual std::size_t getNumberOfChannels() const;
virtual boost::shared_ptr< WEEGValueMatrix > getValues( std::size_t segmentID, std::size_t start, std::size_t length ) const;
virtual std::string getChannelLabel( std::size_t channelID ) const;
protected:
private:
eeg_t* m_eeg; //!< handler for the cnt file opened by libeep
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment