29 #include "core/common/WStringUtils.h"
30 #include "core/common/WAssert.h"
31 #include "core/common/WLogger.h"
33 #include "WReaderEEG.h"
44 std::string elcFileName =
m_fname;
45 elcFileName.resize( elcFileName.size() - 3 );
49 ifs.open( elcFileName.c_str(), std::ifstream::in );
50 if( !ifs || ifs.bad() )
53 throw std::runtime_error(
"Problem during reading file. Probably file not found." );
56 std::string line =
"";
58 while( ifs.good() && line.substr( 0, 16 ) !=
"NumberPositions=" )
60 std::getline( ifs, line );
66 std::vector< std::string > tokens = su::tokenize( line );
67 size_t numPositions = string_utils::fromString< size_t >( tokens.at( 1 ) );
69 while( ifs.good() && line.substr( 0, 9 ) !=
"Positions" )
71 std::getline( ifs, line );
78 size_t posCounter = 0;
79 WEEGElectrodeLibrary elecPos;
80 while( posCounter != numPositions && ifs.good() && line.substr( 0, 9 ) !=
"Labels" )
82 std::getline( ifs, line );
90 std::vector< std::string > lineTokens = su::tokenize( line,
":" );
91 std::string label = lineTokens.at( 0 );
92 label = su::rTrim( label );
94 std::vector< std::string > posTokens = su::tokenize( lineTokens.at( 1 ) );
95 double posX = string_utils::fromString< double >( posTokens.at( 1 ) );
96 double posY = string_utils::fromString< double >( posTokens.at( 2 ) );
97 double posZ = string_utils::fromString< double >( posTokens.at( 3 ) );
104 std::getline( ifs, line );
105 WAssert( elecPos.size() == numPositions,
"Incompatible number of positions and electrodes found." );
106 WAssert( line.substr( 0, 6 ) ==
"Labels",
"Wrong string in file header found." );
An incomplete implementation to store information about electrodes of EEG data.
void addLogMessage(std::string message, std::string source="", LogLevel level=LL_DEBUG)
Appends a log message to the logging queue.
static WLogger * getLogger()
Returns pointer to the currently running logger instance.
This only is a 3d double vector.
WReaderEEG(std::string fileName)
Constructs basic eeg Reader with a file name.
WEEGElectrodeLibrary extractElectrodePositions()
Load electrode positions from ELC file with same name.
Read some data from a given file.
std::string m_fname
Absolute path of the file to read from.
Some utilities for string manipulation and output operations.