Commit 14519a5f authored by cornimueller's avatar cornimueller
Browse files

[ADD #89] Added more information acquirable via the WEEG2 related classes:...

[ADD #89] Added more information acquirable via the WEEG2 related classes: file name, sampling rate and channel unit
parent 96b7dadc
......@@ -66,6 +66,14 @@ WEEG2::WEEG2( boost::shared_ptr< WPagerEEG > pager, boost::shared_ptr< WEEGPosit
throw WDHException( "Couldn't construct new EEG: invalid number of channels" );
}
m_samplingRate = pager->getSamplingRate();
if( m_samplingRate <= 0.0 || wlimits::MAX_RECORDING_SAMPLING_FREQUENCY < m_samplingRate )
{
throw WDHException( "Couldn't construct new EEG: invalid sampling rate" );
}
setFileName( pager->getFileName() );
m_segments.reserve( nbSegments );
for( std::size_t segmentID = 0; segmentID < nbSegments; ++segmentID )
{
......@@ -93,6 +101,11 @@ std::size_t WEEG2::getNumberOfChannels() const
return m_channelInfos.size();
}
double WEEG2::getSamplingRate() const
{
return m_samplingRate;
}
boost::shared_ptr< WEEG2Segment > WEEG2::getSegment( std::size_t segmentID ) const
{
if( segmentID >= m_segments.size() )
......
......@@ -76,6 +76,13 @@ public:
*/
std::size_t getNumberOfChannels() const;
/**
* Get the sampling rate used by the recording.
*
* \return sampling rate
*/
double getSamplingRate() const;
/**
* Get one segment.
*
......@@ -102,6 +109,8 @@ protected:
static boost::shared_ptr< WPrototyped > m_prototype;
private:
double m_samplingRate; //!< sampling rate used by the recording
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
......
......@@ -58,10 +58,16 @@ WEEGChannelInfo::WEEGChannelInfo( std::size_t channelID,
throw WOutOfBounds( stream.str() );
}
m_unit = pager->getChannelUnit( channelID );
m_label = pager->getChannelLabel( channelID );
m_position = positionsLibrary->getPosition( m_label );
}
std::string WEEGChannelInfo::getUnit() const
{
return m_unit;
}
std::string WEEGChannelInfo::getLabel() const
{
return m_label;
......
......@@ -57,6 +57,13 @@ public:
boost::shared_ptr< WPagerEEG > pager,
boost::shared_ptr< WEEGPositionsLibrary > positionsLibrary );
/**
* Get the unit used by the recording of the channel.
*
* \return unit as string
*/
std::string getUnit() const;
/**
* Get the label of the channel.
*
......@@ -73,6 +80,7 @@ public:
protected:
private:
std::string m_unit; //!< unit used by the recording of the channel
std::string m_label; //!< label of the channel
wmath::WPosition m_position; //!< position of the electrode
};
......
......@@ -33,6 +33,11 @@ WPagerEEG::~WPagerEEG()
{
}
std::string WPagerEEG::getFileName() const
{
return m_fileName;
}
WPagerEEG::WPagerEEG( std::string fileName )
: m_fileName( fileName )
{
......
......@@ -46,6 +46,13 @@ public:
*/
virtual ~WPagerEEG();
/**
* Get the name of the loaded file.
*
* \return name of file
*/
std::string getFileName() const;
/**
* Get the number of segments this EEG consists of.
*
......@@ -79,9 +86,24 @@ 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
* Get the sampling rate used by the recording.
*
* \return sampling rate
*/
virtual double getSamplingRate() const = 0;
/**
* Get the unit used by the recording of a given channel.
*
* \param channelID channel number
* \return unit as string
*/
virtual std::string getChannelUnit( std::size_t channelID ) const = 0;
/**
* Get the label of a given channel.
*
* \param channelID channelnumber
* \param channelID channel number
* \return label as string
*/
virtual std::string getChannelLabel( std::size_t channelID ) const = 0;
......
......@@ -157,6 +157,23 @@ boost::shared_ptr< WEEGValueMatrix > WPagerEEGLibeep::getValues( std::size_t seg
return values;
}
double WPagerEEGLibeep::getSamplingRate() const
{
return eep_get_rate( m_eeg );
}
std::string WPagerEEGLibeep::getChannelUnit( 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_unit( m_eeg, channelID );
}
std::string WPagerEEGLibeep::getChannelLabel( std::size_t channelID ) const
{
if( channelID >= m_nbChannels )
......
......@@ -66,6 +66,10 @@ public:
virtual boost::shared_ptr< WEEGValueMatrix > getValues( std::size_t segmentID, std::size_t start, std::size_t length ) const;
virtual double getSamplingRate() const;
virtual std::string getChannelUnit( std::size_t channelID ) const;
virtual std::string getChannelLabel( std::size_t channelID ) const;
protected:
......
......@@ -348,6 +348,7 @@ void WMEEGView::redraw()
debugLog() << " Number of segments: " << m_eeg->getNumberOfSegments();
size_t nbChannels = m_eeg->getNumberOfChannels();
debugLog() << " Number of channels: " << nbChannels;
debugLog() << " Sampling Rate: " << m_eeg->getSamplingRate();
// draw 2D plot
for( size_t segmentID = 0; segmentID < m_eeg->getNumberOfSegments(); ++segmentID )
......@@ -368,6 +369,7 @@ void WMEEGView::redraw()
{
debugLog() << " Channel " << channelID;
boost::shared_ptr< WEEGChannelInfo > channelInfo = m_eeg->getChannelInfo( channelID );
debugLog() << " Channel unit: " << channelInfo->getUnit();
debugLog() << " Channel label: " << channelInfo->getLabel();
// create text geode for the channel label
......
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