Commit 61515568 authored by wiebel's avatar wiebel
Browse files

[ADD] added first drafts of classes for EEG handling. The have to be improved. See #89

parent 77ae7f0d
......@@ -4,10 +4,11 @@ ADD_SUBDIRECTORY( exceptions )
FILE( GLOB DATAHANDLER_SRC "*.cpp" "*.hpp" )
FILE( GLOB DATAHANDLER_EXCEPTIONS_SRC "exceptions/*.cpp" )
FILE( GLOB DATAHANDLER_LOADERS_SRC "io/WLoader*.cpp" )
ADD_LIBRARY( dataHandler SHARED ${DATAHANDLER_SRC} ${DATAHANDLER_EXCEPTIONS_SRC} ${DATAHANDLER_LOADERS_SRC})
ADD_LIBRARY( dataHandler SHARED ${DATAHANDLER_SRC} ${DATAHANDLER_EXCEPTIONS_SRC} ${DATAHANDLER_LOADERS_SRC} )
TARGET_LINK_LIBRARIES( dataHandler common math ${Boost_LIBRARIES} niftiio biosig)
# Unit tests
IF( CXXTEST_FOUND )
CXXTEST_ADD_TESTS_FROM_LIST( "${DATAHANDLER_SRC}" "dataHandler" "common" )
CXXTEST_ADD_TESTS_FROM_LIST( "${DATAHANDLER_SRC}" "dataHandler" )
ENDIF( CXXTEST_FOUND )
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 "WEEG.h"
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 WEEG_H
#define WEEG_H
#include <map>
#include <string>
#include <vector>
#include "WRecording.h"
///======================================
#include "../math/WPosition.h"
typedef double dummyType;
class WEEGElectrodeObject
{
public:
protected:
private:
wmath::WPosition m_position;
// WColor color;
};
class WEEGSegementInfo
{
public:
protected:
private:
dummyType m_startSample;
dummyType m_endSample;
dummyType m_segmentStartDate;
};
//================================================
/**
* TODO(wiebel): Document this!
*/
class WEEG : public WRecording
{
public:
typedef std::vector< double > WEEGElectrode;
typedef std::vector< WEEGElectrode > WEEGSegment;
typedef std::vector< WEEGSegment > WEEGSegmentArray;
/**
* TODO(wiebel): Document this!
*/
explicit WEEG( boost::shared_ptr< WMetaInfo > metaInfo, const WEEGSegmentArray& data )
: WRecording( metaInfo ), m_segments( data )
{
}
const double& operator()( size_t segment, size_t signal, size_t sample ) const
{
return m_segments[segment][signal][sample];
}
protected:
private:
/**
* We have only on sampling rate for all channels.
*/
double m_samplingRate;
/**
* Information about segments. An array of WEEGSegmentInfo objects.
*/
std::vector< WEEGSegementInfo > m_segmentInfo;
/**
* Description of electrodes
*/
std::map< std::string, size_t > m_electrodeDescriptions;
std::vector< WEEGElectrodeObject > m_electrodeLibrary;
/**
* Contains the EEG data as an arry of segements
* of data which consist of an array of electrodes
* which again consist of an array of samples over time.
*/
WEEGSegmentArray m_segments;
};
#endif // WEEG_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 "WRecording.h"
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 WRECORDING_H
#define WRECORDING_H
#include "WDataSet.h"
/**
* TODO(wiebel): Document this!
*/
class WRecording : public WDataSet
{
public:
/**
* TODO(wiebel): Document this!
*/
explicit WRecording( boost::shared_ptr< WMetaInfo > metaInfo )
: WDataSet( metaInfo )
{
}
protected:
private:
};
#endif // WRECORDING_H
......@@ -3,7 +3,9 @@ ADD_SUBDIRECTORY( test )
ADD_SUBDIRECTORY( nifti )
ADD_SUBDIRECTORY( biosig )
FILE( GLOB DATAHANDLER_LOADERS_SRC "WLoader*.cpp" )
# Unit tests
IF( CXXTEST_FOUND )
CXXTEST_ADD_TESTS_FROM_LIST( "${DATAHANDLER_IO_SRC}" "niftiio" )
CXXTEST_ADD_TESTS_FROM_LIST( "${DATAHANDLER_LOADERS_SRC}" "dataHandler;niftiio;biosig" )
ENDIF( CXXTEST_FOUND )
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>
#include "WLoaderBiosig.h"
#include "biosig/biosig.h"
#include "../WDataHandler.h"
#include "../WMetaInfo.h"
#include "../WEEG.h"
WLoaderBiosig::WLoaderBiosig( std::string fileName, boost::shared_ptr< WDataHandler > dataHandler )
: m_fileName( fileName ),
m_dataHandler( dataHandler )
{
}
void fillSegment( std::vector<std::vector<double> > segment, biosig_data_type* data, size_t nbSamples )
{
// for
}
void WLoaderBiosig::biosigLoader()
{
std::cout << "BIOSIGLOADER" << std::endl;
HDRTYPE* hd;
hd = sopen( m_fileName.c_str(), "r", 0 );
#warning check if format is supported here
std::cout << "BIOSIG ERRNUM : " << B4C_ERRNUM << std::endl;
std::cout << "BIOSIG Filename : " << hd->FileName << std::endl;
std::cout << "BIOSIG Type : " << hd->TYPE << " " << EEProbe << std::endl;
std::cout << "BIOSIG HeaderLength : " << hd->HeadLen << std::endl;
std::cout << "BIOSIG NbChannels : " << hd->NS << std::endl;
std::cout << "BIOSIG SamsPerBlock : " << hd->SPR << std::endl;
std::cout << "BIOSIG NbBlocks : " << hd->NRec << std::endl;
if( hd->FLAG.ROW_BASED_CHANNELS )
std::cout << "BIOSIG channels stored as rows." << std::endl;
else
std::cout << "BIOSIG channels stored as cols." << std::endl;
biosig_data_type* DATA = 0;
size_t LEN = 1;
#warning LOOK TO Notizen.txt on the Desktop.
#warning provides start and length parameters ...
#warning these should be used as EEG might not fit or at
#warning least is not intended to be completely in the main memory.
size_t alex = sread( DATA, 0, LEN, hd );
size_t nbSamples = LEN*hd->SPR*hd->NS;
size_t columns = hd->data.size[0];
size_t rows = hd->data.size[1];
std::cout << "BIOSIG data.size[0] : " << columns << std::endl;
std::cout << "BIOSIG data.size[1] : " << rows << std::endl;
std::cout << "BIOSIG data.block[0]: " << hd->data.block[0] << std::endl;
std::cout << "BIOSIG DataSize : " << alex << std::endl;
std::cout << alex << std::endl;
std::cout << "BIOSIGLOADER_some_data" << std::endl;
for( unsigned int i = 0; i < rows; ++i )
{
std::cout << hd->CHANNEL[i].Label << std::endl;
for( unsigned int j = 0; j < columns; ++j )
{
std::cout << hd->data.block[i*columns+j] << std::endl;
}
}
typedef std::vector< double > WEEGElectrode;
typedef std::vector< WEEGElectrode > WEEGSegment;
typedef std::vector< WEEGSegment > WEEGSegmentArray; // kann ich das auch irgendwie aus WEEG.h bekommen?
// WEEGSegmentArray segments;
std::vector<std::vector<double> > segment;
fillSegment( segment, hd->data.block, nbSamples );
std::vector<std::vector<std::vector<double> > > segments( 0 );
segments.push_back( segment );
boost::shared_ptr< WMetaInfo > metaInfo = boost::shared_ptr<WMetaInfo>( new WMetaInfo() );
boost::shared_ptr< WEEG > eeg = boost::shared_ptr< WEEG >( new WEEG( metaInfo, segments ) );
}
void WLoaderBiosig::operator()()
{
biosigLoader();
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 WLOADERBIOSIG_H
#define WLOADERBIOSIG_H
#include <string>
#include <boost/shared_ptr.hpp>
#include "../WLoader.h"
class WDataHandler;
/**
* Loader for several formats for biological signal.
* Uses BiosigC++ 4.
*/
class WLoaderBiosig : public WLoader
{
public:
/**
* Constructs a loader to be executed in its own thread and ets the data needed
* for the loader when executed in its own thread.
*/
WLoaderBiosig( std::string fileName, boost::shared_ptr< WDataHandler > dataHandler );
/**
* This function is automatically called when creating a new thread for the
* loader with boost::thread.
*/
void operator()();
protected:
private:
void biosigLoader();
std::string m_fileName;
boost::shared_ptr< WDataHandler > m_dataHandler;
};
#endif // WLOADERBIOSIG_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 WEEG_TEST_H
#define WEEG_TEST_H
#include <boost/shared_ptr.hpp>
#include <cxxtest/TestSuite.h>
#include "../WEEG.h"
#include "../WMetaInfo.h"
class WEEGTest : public CxxTest::TestSuite
{
public:
/**
* Test something
*/
void testSomething( void )
{
}
};
#endif // WEEG_TEST_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 WRECORDING_TEST_H
#define WRECORDING_TEST_H
#include <cxxtest/TestSuite.h>
#include "../WRecording.h"
class WRecordingTest : public CxxTest::TestSuite
{
public:
/**
* Test something.
*/
void testSomething( void )
{
}
};
#endif // WRECORDING_TEST_H
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