OpenWalnut  1.5.0dev
WEEGPositionsLibrary.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <map>
26 #include <string>
27 
28 #include "../common/WStringUtils.h"
29 #include "../common/exceptions/WOutOfBounds.h"
30 #include "../common/math/linearAlgebra/WPosition.h"
31 #include "WEEGPositionsLibrary.h"
32 
33 
34 WEEGPositionsLibrary::WEEGPositionsLibrary( const std::map< std::string, WPosition >& positions )
35 {
36  // put all the elements from positions in m_posititions, but convert the labels to uppercase
37  for( std::map< std::string, WPosition >::const_iterator iter = positions.begin(); iter != positions.end(); ++iter )
38  {
39  m_positions[string_utils::toUpper( iter->first )] = iter->second;
40  }
41 }
42 
43 WPosition WEEGPositionsLibrary::getPosition( std::string label ) const
44 {
45  std::map< std::string, WPosition >::const_iterator iter = m_positions.find( string_utils::toUpper( label ) );
46 
47  if( iter == m_positions.end() )
48  {
49  throw WOutOfBounds( std::string( "EEG Positions Library doesn't contain a position for electrode " + label ) );
50  }
51 
52  return iter->second;
53 }
std::map< std::string, WPosition > m_positions
mapping from labels to positions
WEEGPositionsLibrary(const std::map< std::string, WPosition > &positions)
Constructor.
WPosition getPosition(std::string label) const
Get the position of an electrode with the given label.
Indicates invalid element access of a container.
Definition: WOutOfBounds.h:37
This only is a 3d double vector.
std::string toUpper(const std::string &source)
Transforms all characters in the given string into upper case characters.