Commit ae439bd5 authored by cornimueller's avatar cornimueller
Browse files

[ADD] Added libeep library to read and write *.cnt and *.avr files

parent e99f353d
......@@ -182,7 +182,7 @@ ADD_CUSTOM_TARGET( tags DEPENDS ctags DEPENDS cscope )
FILE( GLOB_RECURSE STYLE_CPP ${PROJECT_SOURCE_DIR}/*.cpp )
FILE( GLOB_RECURSE STYLE_H ${PROJECT_SOURCE_DIR}/*.h )
# Set dirs to exclude from stylecheck
SET( EXCLUDE_DIRS "/dataHandler/io/nifti/;/dataHandler/io/biosig/;/dataHandler/io/biosig/XMLParser/;/common/platformDependent/visualStudio/" )
SET( EXCLUDE_DIRS "/dataHandler/io/nifti/;/dataHandler/io/biosig/;/dataHandler/io/biosig/XMLParser/;/dataHandler/io/libeep/avr/;/dataHandler/io/libeep/cnt/;/dataHandler/io/libeep/eep/;/common/platformDependent/visualStudio/" )
FOREACH( dirname ${EXCLUDE_DIRS} )
FILE( GLOB EXCLUDE_H ${PROJECT_SOURCE_DIR}${dirname}*.h )
FILE( GLOB EXCLUDE_CPP ${PROJECT_SOURCE_DIR}${dirname}*.cpp )
......
......@@ -8,14 +8,14 @@ IF( CMAKE_HOST_SYSTEM MATCHES Windows )
LIST( REMOVE_ITEM DATAHANDLER_IO_SRC ${EXCLUDE_biosig} )
ADD_LIBRARY( dataHandler ${DATAHANDLER_SRC} ${DATAHANDLER_EXCEPTIONS_SRC} ${DATAHANDLER_IO_SRC} )
TARGET_LINK_LIBRARIES( dataHandler common math ${Boost_LIBRARIES} niftiio ${OPENSCENEGRAPH_LIBRARIES})
TARGET_LINK_LIBRARIES( dataHandler common math ${Boost_LIBRARIES} niftiio libeep ${OPENSCENEGRAPH_LIBRARIES})
ELSE()
FILE( GLOB DATAHANDLER_SRC "*.cpp" "*.h" )
FILE( GLOB DATAHANDLER_EXCEPTIONS_SRC "exceptions/*.cpp" "exceptions/*.h" )
FILE( GLOB DATAHANDLER_IO_SRC "io/*.cpp" "io/*.h" ) # former WLoader
ADD_LIBRARY( dataHandler SHARED ${DATAHANDLER_SRC} ${DATAHANDLER_EXCEPTIONS_SRC} ${DATAHANDLER_IO_SRC} )
TARGET_LINK_LIBRARIES( dataHandler common math ${Boost_LIBRARIES} niftiio biosig ${OPENSCENEGRAPH_LIBRARIES})
TARGET_LINK_LIBRARIES( dataHandler common math ${Boost_LIBRARIES} niftiio biosig libeep ${OPENSCENEGRAPH_LIBRARIES})
ENDIF()
# Unit tests
IF( OW_COMPILE_TESTS )
......
ADD_SUBDIRECTORY( nifti )
ADD_SUBDIRECTORY( biosig )
ADD_SUBDIRECTORY( libeep )
FILE( GLOB DATAHANDLER_IO_SRC "*.cpp" "*.h" )
# Unit tests
IF( OW_COMPILE_TESTS )
CXXTEST_ADD_TESTS_FROM_LIST( "${DATAHANDLER_IO_SRC}"
"dataHandler;niftiio;biosig"
"dataHandler;niftiio;biosig;libeep"
"WWriter.cpp" # too simple to test
"WReader.cpp" # too simple to test
"WWriterLookUpTableVTK.cpp" # there is only one member function which is not trivial, but its more an integration test
......
Max-Planck Institute of Cognitive Neuroscience, Germany
Maren Grigutsch
Rainer Nowagk
Erdmut Pfeifer
ANT Software BV, The Netherlands, www.ant-neuro.com
Maarten van de Velde
Robert Smies
Johan Wiskerke
Wilke Havinga
Tijmen Vroegop
Radboud University, Nijmegen, The Netherlands
Robert Oostenveld
# Adapted flags for this directory to inhibit all warnings.
# There is a good reason for this: We do not want to debug
# third party software!
IF( CMAKE_HOST_SYSTEM MATCHES Windows )
SET( CMAKE_CXX_FLAGS "/EHsc /DWIN32")
SET( CMAKE_C_FLAGS "/TC /DWIN32")
ELSE()
SET( CMAKE_CXX_FLAGS "-pedantic -Wno-write-strings -Wno-deprecated -Wformat=0")
SET( CMAKE_C_FLAGS "-w")
ENDIF()
INCLUDE_DIRECTORIES( . )
FILE( GLOB LIBEEP_SRC "avr/*.h" "cnt/*.h" "eep/*.h" "libavr/*.c" "libcnt/*.c" "libeep/*.c" )
ADD_LIBRARY( libeep SHARED ${LIBEEP_SRC} )
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
ADDENDUM TO LIBEEP LGPL LICENSE
Copyright (C) 2009 ANT www.ant-neuro.com
Everyone is permitted to copy and distribute verbatim copies of this
license addendum document, but changing it is not allowed.
LIBEEP License Addendum.
1. License. The LIBEEP Library (the "Library") is licensed under
GNU Lesser General Public License as published by the Free Software
Foundation, version 3 of the License.
2. Relinking Exemption. You may distribute a combined work using a
statically linked, unmodified copy of the Library under terms of your
choice, without the relinking requirement stipulated under the GNU Lesser
Public License, subject to the following conditions:
a) This static relinking exemption covers only the LIBEEP. Other libraries
which the LIBEEP may need are covered by their own respective licenses.
b) Modification of the configure scripts, makefiles, or installation tools
of the LIBEEP to support a specific platform does not constitute creating a
modified copy based on the Library.
c) Programs or binaries statically linked with the Library must be identified
as such by including, in the Documentation or by other means (for example in
the About Box or Online Help), the following statement:
"This software uses the LIBEEP Library (http://libeep.sourceforge.net)."
d) Subclassing from Objects or Widgets supplied by the Library involves no
modifications to the source code of the Library itself, and does not
constitute creating a modified copy based on the Library.
3. This LIBEEP License Addendum does not automatically apply to derivative
works. When making derivative works based on the LIBEEP Library, this license
addendum ceases to apply, and code will revert to the simple GNU Lesser
General Public License. The Relinking Exemption only applies to unmodified
versions of the Library.
4. If you do not accept or are unable to meet the conditions under (2), you
may continue to distribute the combined work under the original GNU Lesser
General Public License.
END OF ADDENDUM
How to submit changes:
*) create a patch of your changes to the latest trunk in the Subversion tree.
*) send the patch in an e-mail to rsmies@ant-neuro.com. don't forget to include a description of your change in the body of the e-mail.
How to enable the matlab importers:
*) run the configure script with the '--enable-matlab' option.
*) make sure the environment variable 'MATLAB' points to a working MATLAB installation
*) start MATLAB, make sure the (install dir)/share/matlab path is added to MATLAB
*) run [my_data] = read_eep_cnt('/path/to/my_data.cnt', 1, 1024) to read the first 1024 samples
/********************************************************************************
* *
* this file is part of: *
* libeep, the project for reading and writing avr/cnt eeg and related files *
* *
********************************************************************************
* *
* LICENSE:Copyright (c) 2003-2009, *
* Advanced Neuro Technology (ANT) B.V., Enschede, The Netherlands *
* Max-Planck Institute for Human Cognitive & Brain Sciences, Leipzig, Germany *
* *
********************************************************************************
* *
* This library 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. *
* *
* This library is distributed WITHOUT ANY WARRANTY; 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 this program. If not, see <http://www.gnu.org/licenses/> *
* *
*******************************************************************************/
#ifndef AVR_H
#define AVR_H
#define RCS_AVR_H "$RCSfile: avr.h,v $ $Revision: 2415 $"
#include <stdio.h>
#include <eep/eepmisc.h>
#define AVR_HEADER_SIZE 38
#define AVR_CHANNEL_HEADER_SIZE 16
typedef char chanlab_t[11];
typedef struct {
char lab[11]; /* channel label */
unsigned int filepos; /* offset of data in file */
} avrchan_t;
typedef struct {
char condlab[11]; /* condition label */
char condcol[9]; /* associated color code */
/* e.g. "color:23" */
unsigned short trialc; /* total number of trials */
unsigned short rejtrialc; /* number of rejected trials */
slen_t sample0; /* index (with respect to trigger) of first sample */
slen_t samplec; /* number of samples */
float period; /* sampling intervall in seconds */
float mtrialc; /* mean of trial numbers for grand_av */
/* not stored, initialized to trialc - rejtrialc during load */
unsigned short chanc; /* number of channels */
avrchan_t *chanv; /* channel info table */
unsigned short histc; /* number of entries in history */
char **histv; /* history table */
size_t hist_size; /* history length in bytes */
short header_size;
short channel_header_size;
} avr_t;
#define AVRERR_NONE 0
#define AVRERR_FILE 1
#define AVRERR_DATA 2
/*
fill the avr structure with file data
*/
int avropen (avr_t *avr, FILE *f);
int avrclose (avr_t *avr);
/* free dynam. alooc. memory, init history struct with safe values */
void free_avr_history(avr_t *avr);
/* append one entry to the history, (allocate history, if not yet present) */
int append_avr_history( avr_t *avr, const char *line);
/* copy history members */
void copy_avr_history( avr_t *src, avr_t *dst);
/* print avr history members to stdout, wrap lines after linelen chars */
void show_avr_history( avr_t *avr, int linelen );
/*
insert format specific contents into structure and
dump the complete structure contents to file
append the registry and cmdline strings to the file history
*/
int avrnew (avr_t *avr, FILE *f, const char *registry, const char *cmdline);
/*
duplicate avr structure,
retain / discard avr-history according to last parameter
*/
void avrcopy (avr_t *src, avr_t *dst, short retain_history);
#define AVRBAND_MEAN 0
#define AVRBAND_VAR 1
int avrseek (avr_t *avr, FILE *f, short chan, short band);
int avrread (FILE *f, float *v, slen_t c);
int avrwrite(FILE *f, float *v, slen_t c);
short get_avr_headerSize(avr_t *avr);
short get_avr_channelHeaderSize(avr_t *avr);
size_t get_avr_histSize(avr_t *avr);
size_t get_avr_totalHeaderSize(avr_t *avr);
char *get_avr_chan_lab(avr_t *avr, short indx);
unsigned short get_avr_chanc(avr_t *avr);
unsigned short get_avr_trialc(avr_t *avr);
unsigned short get_avr_rejectc(avr_t *avr);
slen_t get_avr_samplec(avr_t *avr);
float get_avr_period(avr_t *avr);
short avr_eep_get_chan_index(avr_t *avr, char *lab, short try_first);
/*
optionally, allocate a matrix
load avr file contents into it
avr is expected to contain all required data, no checks here!
chanc = 0 requests all channels in the original order
samplec = 0 requests all sample points
in every case, v must point to sufficient space or to NULL
return: v (if v is NULL on entry, it points to the newly allocated space)
*/
float **avr_load(avr_t *avr, FILE *f, float **v,
chanlab_t *chanv, short chanc, slen_t sample0, slen_t samplec,
int band);
/*
save average data matrix
v contents must match avr channel layout
*/
void avr_save(avr_t *avr, FILE *f, float **v, int band);
/*
load the specified time slice from the avr according to chanv
avr must contain all requested channels/samples, no checks here!
return: 0 on success, 1 on read error
*/
int avr_read_slice(avr_t *avr, FILE *Avr, slen_t start, slen_t length,
chanlab_t *chanv, short chanc, float *slice);
/*
return: 1 if the vector contains valid variance information
0 otherwise
*/
int avr_var_valid(float *v, int c);
#endif
/********************************************************************************
* *
* this file is part of: *
* libeep, the project for reading and writing avr/cnt eeg and related files *
* *
********************************************************************************
* *
* LICENSE:Copyright (c) 2003-2009, *
* Advanced Neuro Technology (ANT) B.V., Enschede, The Netherlands *
* Max-Planck Institute for Human Cognitive & Brain Sciences, Leipzig, Germany *
* *
********************************************************************************
* *
* This library 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. *
* *
* This library is distributed WITHOUT ANY WARRANTY; 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 this program. If not, see <http://www.gnu.org/licenses/> *
* *
*******************************************************************************/
/* source not (yet) available for native WIN32 */
#if ! defined(__CYGWIN__)
#ifndef AVRCFG_H
#define AVRCFG_H
#define RCS_AVRCFG_H "$RCSfile: avrcfg.h,v $ $Revision: 2415 $"
#include <cnt/cnt.h>
#define AVR_IGNORE_NOTHING 0x0000
#define AVR_IGNORE_REJECTION 0x0001
#define AVR_IGNORE_AVRWINDOW 0x0010
#define EEPCOLORC 33
extern char eepcolortbl[EEPCOLORC + 1][11];
int cfg_get_eepcolor(char colorstr[11]);
#define AVR_COLOR_NR_TO_INDEX(x) ((x) > 15 ? (x - 7) : (x - 8))
char *cfg_put_eepcolorstr(int color, char *colorstr);
char *get_x_colorstring(const char *avrcolor);
/* average -------------------------------------------------------- */
typedef struct {
short codec;
trgcode_t *codetbl; /* all triggers for this condition */
trgcode_t code; /* new condition shortcut */
char lab[16];
char col[10];
} avrcondition_t;
typedef struct {
short condc;
avrcondition_t *condtbl;
short chanc;
short *chantbl;
int iswindow;
swin_t window;
int isbaseline;
swin_t baseline;
short refdisp;
trgcode_t *reftrgv;
int isrejection;
swin_t rejection;
int isbslrejection;
swin_t bslrejection; /* added for use in case of reference displacement
- MG 07/03/2000 */
} AverageParameters;
int ReadAverageParameters(FILE *Cfg, eeg_t *EEG_p, AverageParameters *p);
void FreeAverageParameters(AverageParameters *p);
/* mode: AVR_IGNORE_(NOTHING|REJECTION|AVRWINDOW) */
void ShowAverageParameters(AverageParameters p, eeg_t *src, short mode);
int check_reject_window_settings(AverageParameters p);
/* retrieve information strings from the AverageParameters struct
(strGet.. functions) */
/* get whitespace-separated list of condition triggers */
char *strGetConditionTriggers( AverageParameters *cfg, short condI );
/* get reference trigger,
return NULL if no baseline used or undisplaced reference */
char *strGetReferenceTrigger( AverageParameters *cfg, short condI );
char *strGetAllReferenceTriggers( AverageParameters *cfg );
/* return window settings in ms (e.g. "-200..1500"),
return NULL if window not used */
char *strGetAverageWindow( eeg_t *eeg, AverageParameters *cfg );
char *strGetBaselineWindow( eeg_t *eeg, AverageParameters *cfg );
char *strGetRejectionWindow( eeg_t *eeg, AverageParameters *cfg );
char *strGetBslRejectionWindow( eeg_t *eeg, AverageParameters *cfg );
#endif
#endif /* ! defined(WIN32) || defined(__CYGWIN__) */
/********************************************************************************
* *
* this file is part of: *
* libeep, the project for reading and writing avr/cnt eeg and related files *
* *
********************************************************************************
* *
* LICENSE:Copyright (c) 2003-2009, *
* Advanced Neuro Technology (ANT) B.V., Enschede, The Netherlands *
* Max-Planck Institute for Human Cognitive & Brain Sciences, Leipzig, Germany *
* *
********************************************************************************
* *
* This library 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. *
* *
* This library is distributed WITHOUT ANY WARRANTY; 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 this program. If not, see <http://www.gnu.org/licenses/> *
* *
*******************************************************************************/
#ifndef CNT_H
#define CNT_H
#if defined(WIN32)
#include <TCHAR.H>
#else
#define TCHAR char
#endif
#define RCS_CNT_H "$RCSfile: cnt.h,v $ $Revision: 2415 $"