Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
86659703
Commit
86659703
authored
Feb 19, 2010
by
cornimueller
Browse files
[ADD] Added loader for the CNT format based on the libeep library
parent
1a362cfe
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
221 additions
and
5 deletions
+221
-5
src/dataHandler/CMakeLists.txt
src/dataHandler/CMakeLists.txt
+3
-0
src/dataHandler/io/WLoaderLibeep.cpp
src/dataHandler/io/WLoaderLibeep.cpp
+102
-0
src/dataHandler/io/WLoaderLibeep.h
src/dataHandler/io/WLoaderLibeep.h
+53
-0
src/dataHandler/io/libeep/CMakeLists.txt
src/dataHandler/io/libeep/CMakeLists.txt
+6
-3
src/dataHandler/io/test/WLoaderLibeep_test.h
src/dataHandler/io/test/WLoaderLibeep_test.h
+48
-0
src/gui/qt4/WMainWindow.cpp
src/gui/qt4/WMainWindow.cpp
+2
-2
src/modules/data/WMData.cpp
src/modules/data/WMData.cpp
+7
-0
No files found.
src/dataHandler/CMakeLists.txt
View file @
86659703
# Needed because libeep has includes of form #include <cnt/cnt.h>
INCLUDE_DIRECTORIES
(
io/libeep
)
ADD_SUBDIRECTORY
(
io
)
IF
(
CMAKE_HOST_SYSTEM MATCHES Windows
)
...
...
src/dataHandler/io/WLoaderLibeep.cpp
0 → 100644
View file @
86659703
//---------------------------------------------------------------------------
//
// 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 <string>
extern
"C"
{
#include "libeep/cnt/cnt.h"
}
#include "../../common/WLogger.h"
#include "../exceptions/WDHNoSuchFile.h"
#include "WLoaderLibeep.h"
#include "../WEEG.h"
WLoaderLibeep
::
WLoaderLibeep
(
std
::
string
fileName
)
:
WLoader
(
fileName
)
{
}
boost
::
shared_ptr
<
WDataSet
>
WLoaderLibeep
::
load
()
{
WLogger
::
getLogger
()
->
addLogMessage
(
"Opening "
+
m_fileName
,
"Libeep Loader"
);
// initialize
FILE
*
file
=
fopen
(
m_fileName
.
c_str
(),
"rb"
);
if
(
!
file
)
{
throw
WDHNoSuchFile
(
m_fileName
+
" could not be opened"
);
}
int
status
;
eeg_t
*
eeg
=
eep_init_from_file
(
m_fileName
.
c_str
(),
file
,
&
status
);
if
(
status
!=
CNTERR_NONE
||
!
eeg
)
{
throw
WDHIOFailure
(
m_fileName
+
" could not be initialized"
);
}
// read data
int
numberOfChannels
=
eep_get_chanc
(
eeg
);
slen_t
numberOfSamples
=
eep_get_samplec
(
eeg
);
if
(
numberOfSamples
>
32768
)
{
// limit maximum size of the dataset
// TODO(cornimueller): Don't load EEG data as a whole, use blocks instead
// TODO(wiebel): Don't load EEG data as a whole, use blocks instead
numberOfSamples
=
32768
;
}
sraw_t
*
buffer
=
new
sraw_t
[
CNTBUF_ARRAYSIZE
(
eeg
,
numberOfSamples
)];
eep_read_sraw
(
eeg
,
DATATYPE_EEG
,
buffer
,
numberOfSamples
);
WEEGChannelLabels
channelLabels
(
numberOfChannels
);
WEEGSegment
segment
(
numberOfChannels
);
for
(
int
channel
=
0
;
channel
<
numberOfChannels
;
++
channel
)
{
channelLabels
[
channel
].
first
=
eep_get_chan_label
(
eeg
,
channel
);
double
scale
=
eep_get_chan_scale
(
eeg
,
channel
);
WEEGElectrode
electrode
(
numberOfSamples
);
for
(
slen_t
sample
=
0
;
sample
<
numberOfSamples
;
++
sample
)
{
electrode
[
sample
]
=
buffer
[
sample
*
numberOfChannels
+
channel
]
*
scale
;
}
segment
[
channel
]
=
electrode
;
}
// cleanup
delete
[]
buffer
;
eep_fclose
(
eeg
);
// construct WEEG object and return it
boost
::
shared_ptr
<
WEEG
>
out
(
new
WEEG
(
WEEGSegmentArray
(
1
,
segment
),
WEEGElectrodeLibrary
(
numberOfChannels
,
WEEGElectrodeObject
(
wmath
::
WPosition
()
)
),
channelLabels
)
);
out
->
setFileName
(
m_fileName
);
return
out
;
}
src/dataHandler/io/WLoaderLibeep.h
0 → 100644
View file @
86659703
//---------------------------------------------------------------------------
//
// 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 WLOADERLIBEEP_H
#define WLOADERLIBEEP_H
#include <string>
#include "../WLoader.h"
/**
* Loader for the CNT format supported by the libeep library.
* \ingroup dataHandler
*/
class
WLoaderLibeep
:
public
WLoader
{
public:
/**
* Constructs a loader to be executed in its own thread and sets the data
* needed for the loader when executed in its own thread.
*
* \param fileName this file will be loaded
*/
explicit
WLoaderLibeep
(
std
::
string
fileName
);
virtual
boost
::
shared_ptr
<
WDataSet
>
load
();
protected:
private:
};
#endif // WLOADERLIBEEP_H
src/dataHandler/io/libeep/CMakeLists.txt
View file @
86659703
...
...
@@ -10,7 +10,10 @@ ELSE()
SET
(
CMAKE_C_FLAGS
"-w"
)
ENDIF
()
INCLUDE_DIRECTORIES
(
.
)
FILE
(
GLOB LIBEEP_SRC
"libavr/*.c"
"libcnt/*.c"
"libeep/*.c"
)
FILE
(
GLOB LIBEEP_SRC
"avr/*.h"
"cnt/*.h"
"eep/*.h"
"libavr/*.c"
"libcnt/*.c"
"libeep/*.c"
)
ADD_LIBRARY
(
libeep SHARED
${
LIBEEP_SRC
}
)
IF
(
CMAKE_HOST_SYSTEM MATCHES Windows
)
ADD_LIBRARY
(
libeep
${
LIBEEP_SRC
}
)
ELSE
()
ADD_LIBRARY
(
libeep SHARED
${
LIBEEP_SRC
}
)
ENDIF
()
src/dataHandler/io/test/WLoaderLibeep_test.h
0 → 100644
View file @
86659703
//---------------------------------------------------------------------------
//
// 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 WLOADERLIBEEP_TEST_H
#define WLOADERLIBEEP_TEST_H
#include <cxxtest/TestSuite.h>
#include "../WLoaderLibeep.h"
/**
* Tests for the loader for the CNT format supported by the libeep library.
*/
class
WLoaderLibeepTest
:
public
CxxTest
::
TestSuite
{
public:
/**
* Test loading a CNT file
*/
void
testLoading
(
void
)
{
// Need a fixture to test anything ...
}
};
#endif // WLOADERLIBEEP_TEST_H
src/gui/qt4/WMainWindow.cpp
View file @
86659703
...
...
@@ -272,8 +272,8 @@ void WMainWindow::openLoadDialog()
fd
.
setFileMode
(
QFileDialog
::
ExistingFiles
);
QStringList
filters
;
filters
<<
"Known file types (*.edf *.asc *.nii *.nii.gz *.fib)"
<<
"EEG files (*.
asc
*.edf)"
filters
<<
"Known file types (
*.cnt
*.edf *.asc *.nii *.nii.gz *.fib)"
<<
"EEG files (*.
cnt
*.edf
*.asc
)"
<<
"NIfTI (*.nii *.nii.gz)"
<<
"Fibers (*.fib)"
<<
"Any files (*)"
;
...
...
src/modules/data/WMData.cpp
View file @
86659703
...
...
@@ -36,6 +36,7 @@
#include "../../dataHandler/io/WLoaderBiosig.h"
#endif
#include "../../dataHandler/io/WLoaderEEGASCII.h"
#include "../../dataHandler/io/WLoaderLibeep.h"
#include "../../dataHandler/io/WLoaderNIfTI.h"
#include "../../dataHandler/io/WReaderFiberVTK.h"
#include "WMData.h"
...
...
@@ -178,6 +179,11 @@ void WMData::moduleMain()
WLoaderEEGASCII
eegAsciiLoader
(
fileName
);
m_dataSet
=
eegAsciiLoader
.
load
();
}
else
if
(
suffix
==
".cnt"
)
{
WLoaderLibeep
libeepLoader
(
fileName
);
m_dataSet
=
libeepLoader
.
load
();
}
else
if
(
suffix
==
".fib"
)
{
WReaderFiberVTK
fibReader
(
fileName
);
...
...
@@ -189,6 +195,7 @@ void WMData::moduleMain()
}
if
(
suffix
==
".fib"
||
suffix
==
".cnt"
||
suffix
==
".asc"
||
suffix
==
".edf"
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment