Vous êtes sur la page 1sur 64

MASTER PROJECT

FINAL PREPARATION OF THE CEBIT DATA

Ignatius Sapto Condro Atmawan B.


Matrikel Nummer 2113914

Supervised by
Dr.-Ing. Ivan Volosyak

Examined by
Prof. Dr.-Ing. Axel Gräser

Information and Automation Engineering


Institute für Automatissierungstechnik
Universität Bremen
2009
DECLARATION

Ich versichere daß die vorliegende Arbeit – bis auf die offiziele Betreuung durch den
Lehrstuhl – ohne fremde Hilfe von mir durchgeführt wurde. Die verwendete Literatur ist im
Literaturverzeichnis vollständig angegeben.
Herewith I declare that I have conducted this work on my own without external
support and that I did not use other than quoted sources and auxiliary means. I hereby assure
that this thesis was made exclusively by me, with exception for official support from the
BrainRobot research group at the Institute für Automatissierungstechnik (IAT) of the
University of Bremen and especially my project supervisors: Dr.-Ing. Ivan Volosyak and Prof.
Dr.-Ing Axel Gräser

Bremen, 31st March 2009

Ignatius Sapto Condro Atmawan B.

ii
ABSTRACT

Brain-computer interface (BCI) has been studied in the Institute für


Automatissierungstechnik (IAT) of the University of Bremen since 2005. In the CeBit event
in Hannover, Germany, in March 2008, the BrainRobot research group from the IAT made a
study of the steady-state visual evoked potential (SSVEP) for BCI spelling application. Later
on, in October 2008, they conducted a similar SSVEP-based BCI experiment in the Rehacare
event in Düsseldorf, Germany.
There is a bug in the data storing part of the CeBit software. The bug made data from
one channel from 6 EEG electrodes not stored. This bug does not exist anymore in the
Rehacare software. This master project compares the data storing part between both IAT
software and explains the data storing bug in the CeBit one. It is found that the data could not
be retrieved. This report also describes EEG data formats used by IAT for both CeBit and
Rehacare event then compares them to other internationally standard data formats: GDF,
EDF, BDF and BKR. The standard EEG data format could be used for future works in the
IAT for flexible data exchange between institutes.

Keywords: brain-computer interface (BCI), electroencephalogram (EEG), steady-state visual


evoked potential (SSVEP), CeBit, Rehacare, data format.

iii
ACKNOWLEDGEMENT

This master project uses software developed in the Institute für


Automatissierungstechnik (IAT) of the University of Bremen. The CeBit software for this
master project was previously developed by Indar Sugiarto et al. The Rehacare software for
this master project was previously developed by Hubert Cecotti et al. Some tips using
Microsoft Visual C++ are given by my supervisor: Dr.-Ing Ivan Volosyak. I would like to
thank them for their help in this master project.

iv
Table of Contents

DECLARATION ................................................................................................................ ii
ABSTRACT....................................................................................................................... iii
ACKNOWLEDGEMENT ................................................................................................. iv
Table of Contents................................................................................................................ v
List of Figures ................................................................................................................... vii
List of Tables ................................................................................................................... viii

Chapter 1 Introduction....................................................................................................... 1
1.1. Project Background................................................................................................ 1
1.2. Objectives of the Project........................................................................................ 2
1.3. Project Outline ....................................................................................................... 2

Chapter 2 Bremen SSVEP BCI ......................................................................................... 4


2.1. Brain-Computer Interface (BCI)............................................................................ 4
2.2. EEG-based BCI...................................................................................................... 5
2.3. SSVEP-based BCI ................................................................................................. 5
2.4. Study of SSVEP-based BCI in the IAT of the University of Bremen ................... 6

Chapter 3 Data Format ...................................................................................................... 9


3.1. Introduction to EEG Data Format.......................................................................... 9
3.2. General Data Format (GDF) ................................................................................ 10
3.3. European Data Format (EDF).............................................................................. 13
3.4. Biosemi Data Format (BDF)................................................................................ 15
3.5. BKR-Format ........................................................................................................ 19
3.6. IAT CeBIT 2008 Data Format............................................................................. 22
3.7. IAT REHACARE 2008 Data Format ................................................................. 25

v
Table of Contents

Chapter 4 Data Storing in the IAT Spelling Software..................................................... 31


4.1. Differences between Software used in CeBIT 2008 and in REHACARE
2008.................................................................................................................... 31
4.2. Data Storing for the CeBIT 2008 Event .............................................................. 34
4.3. Data Storing for the REHACARE 2008 Event.................................................... 44
4.4. Software Bug in the CeBIT 2008 Software ......................................................... 48

Chapter 5 Conclusion and Discussion............................................................................. 54


5.1. Conclusion ........................................................................................................... 54
5.2. Discussion and Future Works .............................................................................. 54

BIBLIOGRAPHY ........................................................................................................... 55

vi
List of Figures

Figure 1.1 Spelling (and stimulator) software GUI, from the IAT BrainRobot
group of the University of Bremen ................................................................... 2
Figure 2.1 Spelling program GUI, from the IAT of the University of Bremen................. 6
Figure 2.2 Electrodes placement for SSVEP-based BCI used by the IAT in the
CeBIT 2008 event ............................................................................................. 7
Figure 4.1 Dialog Box in CeBit Software........................................................................ 33
Figure 4.2 Dialog Box in REHACARE Software............................................................ 33
Figure 4.3 Example of CeBit Data Storing Result........................................................... 49
Figure 4.4 The CeBit data checking result....................................................................... 51
Figure 4.5 The Rehacare EEG data checking result (only first 7 columns)..................... 53

vii
List of Tables

Table 3-1 Fixed Header of GDF ...................................................................................... 11


Table 3-2 Variable Header of GD .................................................................................... 12
Table 3-3 Optional Header of GDF (Header 3) ............................................................... 12
Table 3-4 Data Record in GDF ........................................................................................ 14
Table 3-5 Event Table in GDF......................................................................................... 14
Table 3-6 Fixed Header of EDF with example ................................................................ 15
Table 3-7 Variable Header of EDF with example............................................................ 15
Table 3-8 Data Record in EDF......................................................................................... 16
Table 3-9 Fixed Header of BDF and EDF ....................................................................... 17
Table 3-10 Variable Header of BDF and EDF................................................................. 17
Table 3-11 BDF Data Record........................................................................................... 18
Table 3-12 BKR Header................................................................................................... 20
Table 3-13 BKR Data block............................................................................................. 22
Table 3-14 CeBit Data Format ......................................................................................... 24
Table 3-15 Rehacare Data Format ................................................................................... 28
Table 4-1 Comparison between CeBit and Rehacare Software ....................................... 31
Table 4-2 Class Member of CSSVEP_gUSBampDlg in the CeBit Software.................. 34
Table 4-3 New Class Member of CSSVEP_gUSBampDlg in the Rehacare
Software .......................................................................................................... 44

viii
Chapter 1
Introduction

1.1. Project Background

Brain-Computer Interface (BCI) has been studied in the Institute für


Automatissierungstechnik (IAT) of the University of Bremen since 2005 [1]. The first
publication from IAT is in 2006 [2]. In the CeBIT event in Hannover, Germany, in
March 2008, the BrainRobot research group from IAT made a study of steady-state visual
evoked potential (SSVEP) for BCI application and 106 subjects participated in this study
[3]. Later on, in October 2008, IAT conducted another SSVEP-based BCI study in the
REHACARE event in Düsseldorf.
In the CeBIT 2008 and the REHACARE 2008, the IAT BrainRobot research
group conducted a study with SSVEP-based BCI spelling application. A subject should
spell some words with IAT system. The spelling (also stimulator) software for both
events can be seen in Figure 1.1. The hardware used is also the same [3]. The
experimental procedure did not have big differences. The main difference between these
events was the data acquisition software, resulting a different way of storing data. In both
events, 6 electrodes are put in certain sites on the scalp [3]. It was intended to store data
from 6 EEG channels, relating to the 6 electrodes. Unfortunately, in the CeBIT 2008,
only data from 5 channels was stored. There was software bug that makes the data from
the last channel was not properly stored. In the REHACARE 2008, this software bug was
fixed but it is important to study the problems of data acquisition and data storing of the
software used in the CeBIT 2008 .

1
1. Introduction

Figure 1.1 Spelling (and stimulator) software GUI, from the IAT BrainRobot group of
the University of Bremen, modified from [1],[3],[4]

1.2. Objectives of the Project

The main goal of this master project is to find problems and bugs of the software
used in the CeBIT 2008, especially the data acquisition and storing part. As a result, it is
intended to reconstruct the right original EEG data. Other purpose of this project is a
literature research about different ways of storing EEG data.

1.3. Project Outline

Chapter 1 introduces the background and the objectives of this project. Chapter 2
describes definition of BCI, SSVEP, EEG and so on. Chapter 2 also tells about the Study
of SSVEP BCI in the IAT of the University of Bremen.
Chapter 3 describes different kinds of EEG data format. In the last part of Chapter
3, the EEG data formats from the IAT BrainRobot research group from the University of
Bremen is explained, both used in CeBIT 2008 and in REHACARE 2008.

2
1. Introduction

Chapter 4 explains the software used by the IAT BrainRobot group for data
acquisition and storing. The software bug is described in this chapter. In the end, Chapter
5 concludes the master project.

3
Chapter 2
Bremen SSVEP BCI

2.1. Brain-Computer Interface (BCI)

Brain-Computer Interface (BCI) is a communication system in which messages or


commands that an individual sends to the external world do not pass through the brain’s
normal output pathways of peripheral nerves and muscles [5]. With BCI, people can
communicate without movement [3]. BCI system enable people to send messages or
commands to an electronic device, e.g. a computer, by means of brain activity [5],[6].
The communication channel connects the brain directly to a computer or a machine [7].
The channel does not go through normal muscle and nerves, i.e. in hands and fingers.
This happens because there are electrodes which are put on or in the head to measure the
neural activity in the brain [3],[8]. The communication between the brain and the
computer goes through this electrode as a channel, in stead of muscles and nerves.
There are dependent and independent BCI [5],[8]. BCI is called dependent if a
few muscular activities are needed. In SSVEP-based BCI, people have to look at certain
direction, for example the stimuli. In this system, extra ocular muscle and the cranial
nerve are needed. An independent BCI is a “pure” BCI because it does not need any
muscular activities, for example P300 BCI.
There are invasive and non-invasive BCI [8]. Invasive BCI needs surgery to
implant electrodes, whether on the surface of the brain or penetrating into the brain. Non-
invasive BCI is otherwise. Electrodes are put on the scalp for the non-invasive one.

4
2. Bremen SSVEP BCI

2.2. EEG-based BCI

The neurons of the human brain process information by changing the flow of
electrical currents across their membranes. These changing currents generate electric and
magnetic fields. By putting electrodes to the scalp, the change of electric field can be
measured and recorded. Electroencephalogram (EEG) is a record of the electrical
potentials between those different electrodes. EEG means the writing out of the electrical
activity of the brain [9].
EEG-based BCI is a kind of human computer interface which enables the direct
communication between human and computers by analyzing electroencephalographic
activities (EEG) that reflect the function of the brain [10]. EEG based BCI is mostly
invasive. EEG electrodes are put on the surface of the scalp.

2.3. SSVEP-based BCI

The evoked potential is the change in brain’s electrical activity that follows a
stimulus [9]. This potential is recorded by using EEG. Visually Evoked Potential (VEP)
is recorded from the scalp over virtual cortex [5]. The visual cortex is under the occipital
scalp [7]. Light stimuli, e.g. flickering light or image, are used to stimulate the visual
systems. These stimuli elicit response in the visual cortex. This response is called VEP
[11]. VEP reflects the attention (to the stimuli) and can determine the direction of the eye
gaze [5].
There is transient VEP and steady-state VEP. Transient VEP arise if the electrical
excitation of the visual system is able to abate before new stimuli are presented [11].
P300 is an example of the transient VEP. There is a resonance phenomenon arising in the
visual attention to a flickering light source and this resonance happens in the Steady-State
VEP [12].
Steady-State Visually Evoked Potential (SSVEP) is the electrophysiological
response of the visual cortex to a rapidly repeating (flickering) stimulus. This response
generally has a sinusoidal waveform with the same temporal frequency as the driving

5
2. Bremen SSVEP BCI

stimulus [13]. This means that SSVEP is periodic [14]. The periodic pattern of SSVEP
can be detected and correlated to the periodic pattern of the stimuli. SSVEP reflects the
attention to a rapidly oscillating stimulus [8].

2.4. Study of SSVEP-based BCI in the IAT of the University of Bremen

In the CeBIT 2008, the BrainRobot research group from the IAT of the University
of Bremen conducted a study of SSVEP-based BCI [3]. The BCI application used was
spelling software, which had a graphical user interface (GUI) on Figure 2.1. There were a
set of letter in the middle of the software display, five white boxes containing commands
and texts at the bottom of the display as spelling result. The five white boxes had
commands: left, right, up, down and select. Each box flickered with different frequency.
On the top right of the display, there was an application to show the Signal-to-Noise-
Ratio (SNR) of the desired EEG signal and the threshold. This application was not only
used for GUI but also for data acquisition and storing.

Figure 2.1 Spelling program GUI, from the IAT of the University of Bremen [1],[3]

6
2. Bremen SSVEP BCI

There were 106 subjects participated in the study [3]. Electrodes were put on the
subject’s scalp on the sites PO3, PO4, O9, O10, Oz and Pz aligned with the standard 10-20
system of electrode placement [3], as seen on Figure 2.2. The reference was the site Fz
and the ground was the site AFz [3]. The electrodes were connected to the gUSBamp
(Guger Technology), so that the EEG signal could be amplified, digitized, filtered and
collected. The gUSBamp sent EEG data to the computer through USB. The computer
enabled a lot of EEG or BCI applications and many ways of EEG data recording.

Figure 2.2 Electrodes placement for SSVEP-based BCI used by the IAT in the CeBIT
2008 event, modified from [1], [15]

Each white box in the display flickers with different frequency. A subject who
looks at a certain box could have SSVEP response. This SSVEP feature is extracted from
EEG signal from the subject’s brain. The SSVEP contains signal with the same frequency
as the flickering box, to which the subject put his attention. The SNR of the correlating

7
2. Bremen SSVEP BCI

frequency will get higher until it reaches a certain threshold. If two or more SNRs reach
the threshold, the highest is chosen. The user commands are based on the SNR. A
subject, who focuses on one flickering box, could choose a command that is assigned to
that box, e.g. left, right, up, down and select.
In the experiment, each subject should fill forms and then was prepared with the
electrodes. The subject should spell some given words and a free word. A subject spelled
by looking at one of the flickering boxes, in order to move the cursor to a desired letter
and to select that letter. A subject spelled letter by letter to form a word or more. The
spelling result was shown as text at the bottom of the display. A subject is considered
accurate if he could spell the complete desired words without a mistake.

8
Chapter 3
Data Format

3.1. Introduction to EEG Data Format

Biosignals are currently stored in a wide variety of different data formats [16]-
[18]. BioSig – an open source software library – supports approximately 50 different data
format [16],[18]-[20]. Many data formats have been developed by commercial
companies, research groups and standardization organisations. For EEG recording and
the Brain-Computer Interface research, there are some data formats that can be used for
flexible data exchange between organisations or institutes, e.g. GDF [16],[21], EDF
[15],[22]-[24], BDF [25], BKR [26] and so on.
EEG data usually contains signal from different electrodes from the scalp so it is
mostly multichannel data. The EEG signals are always stored based on channel and time.
The EEG signals are digitized with a certain sampling frequency and those digital signals
is then stored in timely samples.
EEG data can be stored as channel-based order or time-based order or
combination of both [16]. Channel-based order means that the data is stored channel by
channel and each channel contains data from sample 1 until sample Ns, with Ns is the
number of samples. Most EEG amplifiers basically provide channel-based order
recording but due to memory limitation, the signals cannot be all buffered so a
combination with time-based order is needed. Time-based order means that the data is
stored sample by sample timely and each sample contains data from channel 1 until
channel Nch, with Nch is the number of channels. Some examples of time-based order
recording are BKR format and IAT BrainRobot EEG data format.
EEG Data is recorded and buffered by an EEG amplifier before it is sent to a
computer to be stored. The buffer size is always a constraint. Although most EEG
amplifier record data in channel-based order, the limited buffer size make the data storing

9
3. Data Format

always timely. So there is a term “record”. Most data format use records. Each record
contains data, whether it is in channel-based order or in time-based order. EEG amplifier
sends data to the computer record by record. GDF, EDF and BDF keep data in these
records.
A record is not always purely in time-based order. In BKR format, a record is
based on experiment or trial [26]. One BKR file may contain data from different kinds of
experiments, for example in spelling experiments, first trial is spelling “BCI” then second
trial is spelling “CHUG” and so on. Each experiment is stored as one record and all
records are arranged in only one file.
There is also different perception of the number of channels and the number of
electrodes. EEG signals come from different electrodes. Due to many kinds of signal
processing, e.g. spatial filtering, the number of channels is not always the same as the
number of electrodes. For example, EEG signals from 6 electrodes can be only 1 channel
if averaging filter is used. Other examples of spatial filtering can be seen in [12].

3.2. General Data Format (GDF)

General Data Format (GDF) is a scientific data format to integrate and to combine
a lot of features in biomedical signals. GDF is not only used for storing EEG data, but
also ECG. GDF is a development of EDF [23], EDF+ [24] and BDF [25], which use only
integer to store data. GDF supports data recording not only in integer but also in floating
point: float32 (float in C++) and float64 (double in C++).
GDF contains header, data and event table. The header consists of fixed header
and variable header. The fixed header size is 256 bytes. The variable header depends on
the number of channels. So the size of the variable header is 256 bytes times number of
channels. There is also optional header in GDF version 2.0 with the size of 256 bytes.
The data contains records in time-based order and each record contains biomedical
signals in channel-based order. In the end, there is event table.
Below are some tables showing the GDF version 2.0 with “remark” column
indicating which fields have changed from version 1.25 to version 2.0, [16]. Table 3-1
presents the fixed header. Table 3-2 pictures the variable header. Table 3-3 shows the

10
3. Data Format

optional header. Table 3-4 gives an idea about the data record. Table 3-5 tells about the
event table.

Table 3-1 Fixed Header of GDF, from [16].


Fixed Header Remark Position
Bytes Type
(Header 1) v1.x Æ v2.0 Start:End [bytes]
Version identification (GDF 2.00) updated 0 8 Char[8]
Patient identification (P-id) smaller 8 66 Char[66]
reserved 74 10 Uint8
Smoking / Alcohol abuse / drug abuse / Added 84 1 Bit[4x2]
medication
Weight [in kg] Added 85 1 Uint8
Height [in cm] Added 86 1 Uint8
Gender [bits 0..1] Added 87 2/8 Bit[2]
Handedness [bits 2..3] Added 87 2/8 Bit[2]
Visual impairment [bits 4..5] Added 87 2/8 Bit[2]
Recording identification (study id + serial smaller 88 64 Char[64]
number)
Recording Location (Lat, Long, Alt) Added 152 16 Uint32[4]
Start date and –time of recording changed 168 8 Uint32[2]
Birthday Added 176 8 Uint32[2]
Header Length smaller 184 2 Uint16
(number of 256-byte blocks)
Patient classification according to ICD NEW 186 6 Byte[6]
Equipment Provider identification (EP-id) 192 8 Uint64
Technician ID removed 8
Lab ID removed 8
Reserved 200 6 Byte[6]
Head size [in mm] Added 206 6 Uint16[3]
Position Reference Electrode [X, Y, Z] Added 212 12 Float32[3]
Position Ground Electrode [X, Y, Z] Added 224 12 Float32[3]
reserved 236 20 byte
Number of data records (-1 if unknown) 236 8 Int64
Duration of a data record, as a rational 244 8 Uint32[2]
number in seconds

11
3. Data Format

(first the numerator, secondly the


denominator)
NS: number of signals (channels) 252 2 Uint16
reserved 254 2 Uint16

Table 3-2 Variable Header of GDF, friom [16]


Variable Header Remark Position
Bytes Type
(Header 2) v1.x Æ v2.0 Start:End [bytes]
Label 256 NS*16 Char[16]*NS
Transducer type 256+16*NS NS*80 Char[80]*NS
Physical dimension obsolete 256+96*NS NS*6 Char[6]*NS
Physical dimension code NEW 256+102*NS NS*2 Uint16*NS
(ISO/IEEE 11073-10101:2004)
Physical minimum 256+104*NS NS*8 Float64*NS
Physical maximum 256+112*NS NS*8 Float64*NS
Digital minimum changed 256+120*NS NS*8 Float64*NS
Digital maximum changed 256+128*NS NS*8 Float64*NS
Pre-filtering obsolete 256+136*NS NS*68 Char[68]*NS
Low pass Added 256+204*NS NS*4 Float32*NS
High pass Added 256+208*NS NS*4 Float32*NS
Notch Added 256+212*NS NS*4 Float32*NS
Samples per Record 256+216*NS NS*4 Uint32*NS
(0 indicates non-equidistant sampling)
Type of data (gdftyp) 256+220*NS NS*4 Uint32*NS
Electrode Positions XYZ Added 256+224*NS NS*12 Float32*NS*3
Electrode Impedance Added 256+236*NS NS*1 Uint8*NS
reserved smaller 256+237*NS NS*19 Char[32]*NS

Table 3-3 Optional Header of GDF (Header 3), from [16]


List of TLV elements Remark Position
Bytes Type
(Header 3) v1.x Æ v2.0 Start:End [bytes]
Tag NEW 256*(NS+1) 1 Uint8
Length NEW 3 Uint24
Value NEW Length (*) depends on
tag

12
3. Data Format

Table 3-4 Data Record in GDF, from [16],[21]


Remark Position
Data Record Bytes Type
v1.x Æ v2.0 Start:End [bytes]
nr samples from channel [1] of TYPE[1] Txpe[1]
nr samples from channel [2] of TYPE[2] Txpe[2]
nr samples from channel [3] of TYPE[3] Txpe[3]
… …
nr samples from channel [NS] of Txpe[NS]
TYPE[NS]

Table 3-5 Event Table in GDF, from [16],[21]


Remark Position
Event Table Bytes Type
v1.x Æ v2.0 Start:End [bytes]
Mode of event table NEW ETP+0 1 Uint8
(can be 1 or 3)
NEV: Number of Events changed ETP+1 3 Uint8[3]
Sample rate associated with Event changed ETP+4 4 Float32
positions
Position [in samples] ETP+8 NEV*4 Uint32
Type ETP+8+NEV*4 NEV*2 Uint16
Channel [optional] Only if ETP+8+NEV*6 NEV*2 Uint16
mode is 3
Duration [in samples, optional] Only if ETP+8+NEV*8 NEV*4 Uint32
Or value of non-equidistant sampling mode is 3 Float32(*)

3.3. European Data Format (EDF)

European Data Format (EDF) was defined by a European group of researchers


and mainly used for sleep analysis [18]. EDF was developed by Bob Kemp et al and
published in 1992 [23]. Later on they developed EDF+ and made a publication in 2003
[24].
EDF, like GDF, is not only used to record EEG. It can record ECG, PSG, body
temperature, and other biomedical signals. EDF supports only int16 (short integer in
C++). An EDF file consists of header followed by data records. The header has a fixed

13
3. Data Format

header and variable header. The fixed header size is 256 bytes. The variable one has a
size of NS times 256 bytes, with NS as a number of signals/channels. The data records
contain consecutive fixed-duration epochs of the polygraphic recording. They are in
channel-based order.
Table 3-6 below shows the fixed header of EDF. Table 3-7 presents the variable
header. The size of the header is in ASCII (char in C++), which is 1 byte each. Table 3-8
gives an idea about the data records in EDF.

Table 3-6 Fixed Header of EDF with example, modified from [22]-[24]
Type and size Fixed Header Example
8 ascii Version of this format (0) 0
80 ascii Local patient identification MCH-0234567 F 02-MAY-1951 Haagse_Harry
80 ascii Local recording identification Startdate 02-MAR-2002 EMG561 BK/JOP Sony.
MNC R Median Nerve.
8 ascii Start date of recording (dd.mm.yy) 17.04.01
8 ascii Start time of recording (hh.mm.ss) 11.25.00
8 ascii Number of bytes in header record 768
44 ascii reserved EDF+D
8 ascii Number of data records
2
(-1 if unknown)
8 ascii Duration of data record, in seconds 0.0050
4 ascii Number of signals/channels (NS)
2
in data record

Table 3-7 Variable Header of EDF with example, modified from [22]-[24]
Example
Type and size Variable Header st
1 signal/channel 2nd signal/channel
NS * 16 ascii Label
R APB EDF Annotations
(e.g. EEG Fpz-Cz or Body temp)
NS * 80 ascii Transducer type
AgAgCl electrodes
(e.g. AgAgCl electrode)
NS * 8 ascii Physical dimension
mV
(e.g. uV or degreeC)
NS * 8 ascii Physical minimum
-100 -1
(e.g. -500 or 34)

14
3. Data Format

NS * 8 ascii Physical maximum


100 1
(e.g. -500 or 40)
NS * 8 ascii Digital minimum (e.g. -2048) -2048 -32768
NS * 8 ascii Digital maximum (e.g. 2047) 2047 32767
NS * 80 ascii Prefiltering HP:3Hz
(e.g. HP:0.1Hz LP:75Hz) LP:20kHz
NS * 8 ascii Number of samples in each data
1000 60
record
NS * 32 ascii reserved

In Table 3-7, each data record contains 1000 times 2-byte integer of R APB
samples and 60 times 2-byte integer of EDF Annotations.

Table 3-8 Data Record in EDF, modified from [22]-[24]


Type Data Record
nr of samples in channels 1 Int16 First signal in the data record
nr of samples in channels 2 Int16 Second signal
.. .. ..
.. .. ..
nr of samples in channels NS Int16 Last signal

3.4. Biosemi Data Format (BDF)

Biosemi Data Format (BDF) is an alternative format of EDF. This format is


designed by BioSemi, which is a company in Amsterdam [27]. EDF supports 16 bit
integer but BDF supports 24 bit integer. EDF and BDF have the same header size. The
difference is only the data record because of the data size. Table 3-9 compares the fixed
header of EDF and BDF. Table 3-10 compares the variable one.

15
3. Data Format

Table 3-9 Fixed Header of BDF and EDF, modified from [25]
Length BDF Header EDF Header Description
Byte 1: “255” Byte 1: “0”
(non ascii) (ASCII)
8 bytes Identification code
Byte 2-8: “BIOSEMI” Byte 2-8: “ ”
(ASCII) (ASCII)
80 bytes User text input (ASCII) Local subject identification
80 bytes User text input (ASCII) Local recording identification
8 bytes dd.mm.yy (ASCII) Start date of recording
8 bytes hh.mm.ss (ASCII) Start time of recording
8 bytes (ASCII) Number of bytes in header record
44 bytes “24BIT” (ASCII) “BIOSEMI” (ASCII) Version of data format
Number of data records,
8 bytes (ASCII)
“-1” if unknown
Duration of data records, in
8 bytes e.g.: “1” (ASCII)
seconds
Number of channels (N) in data
4 bytes e.g.: “257” or “128” (ASCII)
record

Table 3-10 Variable Header of BDF and EDF, modified from [25]
Length BDF Header EDF Header Description
N x 16 bytes e.g.: “Fp1”, “Fpz”, “Fp2”, etc (ASCII) Labels of the channels
N x 80 bytes e.g.: “active electrode”, “respiration belt” (ASCII) Transducer type
N x 8 bytes e.g.: “uV”, “Ohm” (ASCII) Physical dimension of channels
Physical minimum in units of
N x 8 bytes e.g.: “-262144” (ASCII) e.g.: “-32768” (ASCII)
physical dimension
Physical maximum in units of
N x 8 bytes e.g.: “262143” (ASCII) e.g.: “32767” (ASCII)
physical dimension
e.g.: “-8388608”
N x 8 bytes e.g.: “-32768” (ASCII) Digital minimum
(ASCII)
e.g.: “8388607”
N x 8 bytes e.g.: “32767” (ASCII) Digital maximum
(ASCII)
N x 80 bytes e.g.: “HP:DC; LP:410” e.g.: “HP:0,16; LP:500” Prefiltering
N x 8 bytes For example: “2048” (ASCII) Number of samples in each data

16
3. Data Format

record
(Sample-rate if duration of data
record = “1”)
N x 32 bytes (ASCII) Reserved

The variable headers, as seen on Table 3-10, are defined for each channel
separately. Each channel can be different. The data record can be seen on Table 3-11. The
record is arranged in time-based order and inside a record, the data is arranged in
channel-based order. Below is an example of BDF Data Record from 16 channel system
with 2048 Hz sample-rate (duration of a data record has been set to “1” or 1 second).

Table 3-11 BDF Data Record, from [25]


Which part Which Which sample Which
Byte in file BDF Data
of 24 bit channel of data record data record
1 Byte 1
2 Byte 2 Channel 1 1
3 Byte 3
4 Byte 1
5 Byte 2 Channel 1 2
6 Byte 3
7 Byte 1
8 Byte 2 Channel 1 3 Duration of data set has
9 Byte 3 been set to “1”.
etc etc etc etc So this block will be filled 1
6136 Byte 1 with (1 x 2048) samples
6137 Byte 2 Channel 1 2046 from only “Channel 1”
6138 Byte 3
6139 Byte 1
6140 Byte 2 Channel 1 2047
6141 Byte 3
6142 Byte 1
6143 Byte 2 Channel 1 2048
6144 Byte 3

6145 Byte 1 Channel 2 1


6146 Byte 2

17
3. Data Format

6147 Byte 3
6148 Byte 1
6149 Byte 2 Channel 2 2
6150 Byte 3
6151 Byte 1
6152 Byte 2 Channel 2 3
6153 Byte 3
Duration of data set has
etc etc etc etc 1
been set to “1”.
12280 Byte 1
So this block will be filled
12281 Byte 2 Channel 2 2046
with (1 x 2048) samples
12282 Byte 3
from only “Channel 2”
12283 Byte 1
12284 Byte 2 Channel 2 2047
12285 Byte 3
12286 Byte 1
12287 Byte 2 Channel 2 2048
12288 Byte 3
etc etc etc etc etc
98302 Byte 1
98303 Byte 2 Channel 16 2048 etc
98304 Byte 3
98305 Byte 1
98306 Byte 2 Channel 1 2049
98307 Byte 3
etc 2
98308 Byte 1
98309 Byte 2 Channel 1 2050
98310 Byte 3
etc etc etc etc etc etc

18
3. Data Format

3.5. BKR-Format

The previous data formats use channel-based order. BKR format use time-based
order to store EEG data. BKR is developed by EEG Processing Software (EPS). So BKR
is intended only for EEG data storing. This format also consists of header and data. The
header size is 1024 byte. The size of the data block is given by the number of trials (ntr),
channels (nch), number of samples per trial (nsp) and the datasize of a sample value (2
Bytes for sshort).
The BKR header contains more information than GDF, EDF and BDF. In the
BKR header, there is information about the signal processing used, for example filtering,
windowing, artificial neural network, wavelet and so on. Table 3-12 shows the BKR
header.

Table 3-12 BKR Header, from [26]


Name Data type Size Offset Meaning
ver USHORT 2 Bytes 0 Version
nch USHORT 2 Bytes 2 Number of channels
nhz USHORT 2 Bytes 4 Sampling frequency
ntr ULONG 4 Bytes 6 Number of trials
nsp ULONG 4 Bytes 10 Number of samples per trial
cvlt USHORT 2 Bytes 14 Calibration voltage
cval USHORT 2 Bytes 16 Calibration value
code Char[4] 4 Bytes 18 Electrode code
lcf Float 4 Bytes 22 Lower cut-off frequency
ucf Float 4 Bytes 26 Upper cut-off frequency
sref ULONG 4 Bytes 30 Start of reference period in samples
eref ULONG 4 Bytes 34 End of reference period in samples
sact ULONG 4 Bytes 38 Start of action period in samples
eact ULONG 4 Bytes 42 End of action period in samples
trg BOOL 2 Bytes 46 Flag if file is triggered
pre ULONG 4 Bytes 48 Number of samples before trigger
pst ULONG 4 Bytes 52 Number of samples after trigger

19
3. Data Format

hav BOOL 2 Bytes 56 Flag if file is “horizontally” averaged


nah ULONG 4 Bytes 58 Number of averaged trials
vav BOOL 2 Bytes 62 Flag if file is “vertically averaged”
nav USHORT 2 Bytes 64 Number of averaged trials
cav BOOL 2 Bytes 66 Flag for data compression
nac ULONG 4 Bytes 68 Number of compressed samples
com BOOL 2 Bytes 72 Flag: Common Average Reference
loc BOOL 2 Bytes 74 Flag: Local Average Reference
lap BOOL 2 Bytes 76 Flag: Laplace
wgt BOOL 2 Bytes 78 Flag: Weighted Average Reference
pwr BOOL 2 Bytes 80 Flag: Power
avr BOOL 2 Bytes 82 Flag: Average
std BOOL 2 Bytes 84 Flag: Standard Deviation
bps BOOL 2 Bytes 86 Flag: Bandpass filtered
erd BOOL 2 Bytes 88 Flag: ERD
sig BOOL 2 Bytes 90 Flag: Significance
coh BOOL 2 Bytes 92 Flag: Coherence
spc BOOL 2 Bytes 94 Flag: Spectrum
conf float 4 Bytes 96 Confidence
csp BOOL 2 Bytes 100 Flag: Coherence Power Spectrum
erc BOOL 2 Bytes 102 Flag: ERC
ham BOOL 2 Bytes 104 Flag: Hanning smoothed
ann BOOL 2 Bytes 106 Flag: art. Neuronal. NW. Filter (ANN)
niu USHORT 2 Bytes 108 ANN: Number of input units
nhu USHORT 2 Bytes 110 ANN: Number of hidden units
nlc ULONG 4 Bytes 112 ANN: Number of learn cycles
reg float 4 Bytes 116 ANN: Regression
lco float 4 Bytes 120 ANN: Learn coefficient
epo USHORT 2 Bytes 124 ANN: Epoch
rel BOOL 2 Bytes 126 Flag: ERC in relative values
wnd USHORT 2 Bytes 128 Window type
kal BOOL 2 Bytes 130 Flag: Kalman filtered
cwt BOOL 2 Bytes 132 Flag: cont. Wavelet transformed
cwt_fmin float 4 Bytes 134 Lower frequency, wavelet
cwt_fmax float 4 Bytes 138 Upper frequency, wavelet
scales USHORT 2 Bytes 142 Number of frequency bands, wavelet

20
3. Data Format

(π ) 2 wavelet
1
cwt_fe float 4 Bytes 144 Freq. for Δt = Δf = 1
2
cwt_start ULONG 4 Bytes 148 Start sample for Wavelet
--NULL-- ---- ---- 152 --- Offset to 512 Byte ---
eletype[1] UCHAR 1 Byte 512 Electrode 1: Signal type (e.g. EEG)
elenum[1] UCHAR 1 Byte 513 Electrode 1: Channel number for the same signal
ref[1] float 4 Bytes 514 Reference value for Channel 1
… … … … etc
eletype[nch] UCHAR Electrode nch: Signal type (e.g. EEG)
elenum[nch] UCHAR Electrode nch: Channel number for the same signal
ref[nch] float Reference value for Channel nch

The data is divided into trials. Each trial contains data in channel based order.
Table 3-13 presents how the data is stored.

Table 3-13 BKR Data block , from [26]


Channel 1 Channel 2 Channel 3 … … Channel nch-1 Channel nch
Trial 1:
Sample 1 Sample 1 Sample 1 … … Sample 1 Sample 1
Channel 1 Channel 2 Channel 3 … … Channel nch-1 Channel nch
Sample 2 Sample 2 Sample 2 … … Sample 2 Sample 2
… … … … … … …
… … … … … … …
Channel 1 Channel 2 Channel 3 … … Channel nch-1 Channel nch
Sample nsp Sample nsp Sample nsp … … Sample nsp Sample nsp
Channel 1 Channel 2 Channel 3 … … Channel nch-1 Channel nch
Trial 2:
Sample 1 Sample 1 Sample 1 … … Sample 1 Sample 1
… … … … … … …
… … … … … … …
Channel 1 Channel 2 Channel 3 … … Channel nch-1 Channel nch
Sample nsp Sample nsp Sample nsp … … Sample nsp Sample nsp
… … … … … … …
Channel 1 Channel 2 Channel 3 … … Channel nch-1 Channel nch
Trial ntr:
Sample 1 Sample 1 Sample 1 … … Sample 1 Sample 1
… … … … … … …
… … … … … … …

21
3. Data Format

Channel 1 Channel 2 Channel 3 … … Channel nch-1 Channel nch


Sample nsp Sample nsp Sample nsp … … Sample nsp Sample nsp
EOF

3.6. IAT CeBIT 2008 Data Format

Unlike the data formats from the BioSig Project [19],[20], IAT BrainRobot group
does not use header to store EEG data. The data is stored in text or binary file. The
experiment date and subject number is stored as a directory or a folder name. The
experiment time is stored as a file name. Below are some examples of folder and file
names used for the experiments in CeBIT 2008 event.

C:\BCIData\3_2_2009\Subject_999\Experiment_at_14_35.txt
F:\RecordedCEBIT3\5_3_2008\Subject_31\ Experiment_at_11_12.bin

The first example means that the data is stored in folder C:\BCIData, the
experiment date is on 3rd of February 2009, the subject number is 999, the experiment
time began at 14.35 and the data is stored as a text file. The second means that the data is
stored in folder F:\RecordedCEBIT3, the experiment date is on 5th of March 2008, the
subject number is 31, the experiment time started at 11.12 and the data is stored as a
binary file. So the general format is below.

Folder_Name\d_m_yyyy\Subject_N\Experiment_at_hh_mm.txt (or .bin)


(The date may also dd_mm_yyyy dan the subject number can be NN or NNN).

The file contains 6 channels of EEG data and 1 command in time-based order.
Table 3-14 summarizes the columns in CeBit Data Format. The 6 channels of EEG data
is float32 type (float in C++) and the command is int32 type (int in C++). In text file, the
data is stored as a string representing number of float and integer. Below is an example of
the text file.

22
3. Data Format

4.58068 9.87616 0.676514 18.0576 11.7465 0 3


-8.72467 57.0976 -233.682 -179.563 -57.0293 79079 3
-100.928 124.535 -1029.09 -989.75 -389.663 1.71191e-030 3
-217.56 101.889 -1598.54 -1609.01 -680.271 0 3
-179.722 -52.9912 -633.289 -565.716 -295.813 0 3
-6.11695 -182.173 1031.37 1264.33 453.48 0 3
78.9396 -153.218 1355.57 1592.66 619.318 4.80701e-041 3
32.2359 -58.5553 520.087 602.787 234.805 0 3
3.17374 -27.0085 120.554 107.899 35.9006 0 3

Table 3-14 CeBit Data Format


Column Description Type Size Comment
st th
1 until 6 EEG Signals float 4 bytes 6 significant numbers
th
7 User Command int 4 bytes 0 until 5

The command enumeration from the 7th column is below.


0: no command
1: LEFT
2: RIGHT
3: UP
4: DOWN
5: Select

Beside the EEG data recording, there are other files providing information about
protocol and calibration in text files. These files are generated if the protocol sheet is
filled and the calibration procedure is conducted. The format is below.

Folder_Name\d_m_yyyy\Subject_N\ProtocolSheet.txt
e.g.
F:\RecordedCEBIT3\5_3_2008\Subject_31\ProtocolSheet.txt

23
3. Data Format

Folder_Name\d_m_yyyy\Subject_N\Calibration.txt
e.g.
F:\RecordedCEBIT3\5_3_2008\Subject_31\Calibration.txt

Protocol sheet contains information about the subject number, the name of people
who prepare and train the subject, the number of cap size, the amplifier number, subject
gender, whether subject is left-handed or right-handed, subject’s vision, whether the
electrodes impedance is good and the words that should be spelled. Below is an example
of the protocol sheet format.

Subject Number = 31
Prepper-1 = Aavo
Prepper-2 = Thorsten
Trainer = Aavo
Experimenter =
Cap Number = 60
Amplifier Number =
Gender = female
Subject is Left-handed
Vision condition =
Impedance condition =
Run 1: Subject spells BCI
Run 3: Subject speels SIREN
Run 5: Subject speels adamski

The calibration file contains information about SNR threshold to make certain
commands as described in Chapter 2. The example of calibration file format is below.

Here are the thresholds calculated during run-time


Threshold for channel 1 = 393.834
Threshold for channel 2 = 368.379
Threshold for channel 3 = 403.799
Threshold for channel 4 = 384.748

24
3. Data Format

Threshold for channel 5 = 393.653

3.7. IAT REHACARE 2008 Data Format

In the REHACARE 2008 event, there was improvement in EEG data recording.
There is still no header. The experiment date and the subject number are stored as a
folder name, with modification from the ones from the CeBIT 2008 event. The file name
contains not only information about experiment time but also the threshold used and the
word that should be spelled. The data can be stored as binary or text file. Below are
examples of folder and file names used in the REHACARE 2008.

E:\RecordedRehaCare\13102008\Subject_1\Experiment_at_16_19_Threshold_260_Word_BCI.tx
t
E:\RecordedRehaCare\10122008\Subject_919\Resume_Experiment_at_16_04_Threshold_200_
Word_BRAIN.txt

The first example means that the data is stored in folder E:\RecordedRehaCare,
the experiment date is on 13th of October 2008, the subject number is 1, the experiment
time started at 16.19, the SNR threshold is 260 and “BCI” is the word that should be
spelled. The second means that the data is stored in the same folder, the experiment date
is on 10th of December 2008, the subject number is 919, the experiment time began at
16.04, the SNR threshold is 200 and “BRAIN” is the word that should be spelled. These
examples used text file as data format. So the general data format is below.

Folder_Name\ddmmyyyy\Subject_N\Experiment_at_hh_mm_Threshold_TTT_W
ord_XXX.txt (or .bin)
(the subject number can be NN or NNN and XXX can be a longer word) .

The file contains 6 channels of EEG data, 1 command, 5 SNR data (related to 5
stimuli), command accuracy, 1 current cursor position, 1 selected letter and absolute time,
separated in different columns. All are arranged in time-based order. Table 3-15
summarizes the Rehacare data format. The 6 channels of EEG data and 5 SNR Data are

25
3. Data Format

float32 type (float in C++). The command and the command accuracy are int32 type (int
in C++). The current cursor position and the selected letter are char type. In text file, the
data is stored as not only a string of character, but also a string representing number of
float and integer. Below is an example of the text file.

-8.388292e+000 -6.413250e+000 -4.876347e+000 -9.389525e+000 -7.280463e+000 -


7.552543e+000 0 +7.723758e+001 +7.855746e+001 +8.348566e+001 +7.644870e+001
+1.601331e+002 # B # 12:21:00.234

-5.755557e+000 -3.027267e+000 -1.429671e+000 -6.063205e+000 -4.147856e+000 -


5.251766e+000 0 +7.723758e+001 +7.855746e+001 +8.348566e+001 +7.644870e+001
+1.601331e+002 # B # 12:21:00.242

-2.185323e+000 +1.324678e+000 +3.585089e+000 -1.641525e+000 -2.133119e+000 -


6.903646e+000 5 +8.646204e+001 +7.837384e+001 +9.561758e+001 +8.264581e+001
+1.883556e+002 1 B # 12:21:00.250

+5.614222e-001 +3.628772e+000 +5.917499e+000 +2.017163e+000 +2.760272e+000 -


4.174883e+000 5 +8.646204e+001 +7.837384e+001 +9.561758e+001 +8.264581e+001
+1.883556e+002 # B # 12:21:00.258

………
………

+6.260961e+000 +9.576910e+000 +1.029809e+001 +6.447649e+000 +1.171754e+001


+8.652941e+000 5 +8.646204e+001 +7.837384e+001 +9.561758e+001 +8.264581e+001
+1.883556e+002 # B # 12:21:00.336

+3.892870e+000 +7.326949e+000 +8.706282e+000 +5.067448e+000 +8.205467e+000


+1.194804e+001 5 +8.646204e+001 +7.837384e+001 +9.561758e+001 +8.264581e+001
+1.883556e+002 # B # 12:21:00.344

-1.261088e+000 +1.369993e-001 +8.276825e-002 -9.816767e-001 +1.980728e+000


+8.633536e+000 0 +8.335911e+001 +8.116586e+001 +7.700015e+001 +8.657768e+001
+8.061893e+001 # E B 12:21:00.352

26
3. Data Format

-3.713362e+000 -4.916427e+000 -5.338178e+000 -4.915452e+000 -6.626158e-001


+3.280909e+000 0 +8.335911e+001 +8.116586e+001 +7.700015e+001 +8.657768e+001
+8.061893e+001 # E B 12:21:00.359

Table 3-15 Rehacare Data Format


Column Description Type Size Comment
scientific format, with 7 significant
1st until 6th EEG Signals float 4 bytes
numbers
th
7 User Command Int 4 bytes Same as in CeBit Format
Scientific format, with 7 significant
8th until 12th SNR float 4 bytes
numbers
-1, 0, and 1
13th Command accuracy Int 4 bytes
-1 is ‘#’ in text file
th
14 Current cursor position char 1 byte
15th Selected letter char 1 byte ‘#’ if none is selected
th
16 Absolute time CString - hh:mm:ss.xxx format

In the Rehacare data format, the float format in text file is scientific, with 7
significant numbers. This improvement makes the EEG data better to read than the one in
the CeBit. The new parts are the SNRs, the command accuracy, the current cursor
position, the selected words and the absolute time. The first seven columns have the
same function as the ones in CeBit Data Format. The commands enumeration between
CeBit and Rehacare format are the same. In the Rehacare format, the 8th until 12th column
or the 5 SNR values correlates to 5 frequencies from the 5 white-boxed stimuli each:
Left, Right, Up, Down and Select.

The command accuracy enumeration from the 13th column is below


#: No command
1: Accurate Command
0: Bad or false Command

The selected letter from the 15th column is ‘#’ if none is selected.

27
3. Data Format

The absolute time from the 16th column is in hh:mm:ss.xxx format.


hh: hour (0-23)
mm: minute (0-59)
ss: second (0-59)
xxx: millisecond (0-999)

Beside the EEG data recording, there are other files containing user command
resume and whole experiment resume in text files. The user command resume is in time-
based order. These files are generated after one word is spelled. The format is below.

FolderName\ddmmyyyy\Subject_N\Command_Experiment_at_hh_mm_Threshol
d_TTT_Word_XXX.txt
e.g.
E:\RecordedRehaCare\17102008\Subject_24\Command_Experiment_at_13_01_Threshold_200_
Word_BCI.txt

FolderName\ddmmyyyy\Subject_N\Resume_Experiment_at_hh_mm_Threshold_
TTT_Word_XXX.txt
e.g.
E:\RecordedRehaCare\18102008\Subject_3\Resume_Experiment_at_13_03_Threshold_200_Wo
rd_GEHIRN.txt

The user command resume contains the user command, the current cursor
position, spelling time (in seconds, with the millisecond resolution), the current accuracy,
the current information transfer rate (ITR) and the current spelled word, separated in
columns. All are arranged in time-based order. Below is an example of the user command
resume.

28
3. Data Format

2 S 3.670 100.000 37.960 ""


4 B 7.327 100.000 38.030 ""
5 E 10.283 100.000 40.646 "B"
4 R 15.960 100.000 34.917 "B"
5 E 18.702 100.000 37.246 "BR"
1 N 22.968 100.000 36.394 "BR"
1 A 26.016 100.000 37.485 "BR"
5 E 28.656 100.000 38.893 "BRA"
5 E 30.697 88.889 28.084 "BRAE"
3 I 39.422 90.000 25.158 "BRAE"
3 T 41.454 90.909 27.076 "BRAE"
3 L 43.484 91.667 28.834 "BRAE"
2 1 46.227 92.308 29.981 "BRAE"
5 E 48.671 92.857 31.201 "BRA"
3 I 52.830 93.333 31.265 "BRA"
5 E 56.086 93.750 31.831 "BRAI"
1 N 60.348 94.118 31.801 "BRAI"
5 E 63.394 94.444 32.390 "BRAIN"
5 E 65.431 89.474 28.329 "BRAINE"
3 I 70.218 90.000 28.248 "BRAINE"
3 T 72.232 90.476 29.266 "BRAINE"
3 L 74.259 90.909 30.229 "BRAINE"
2 1 77.002 91.304 30.857 "BRAINE"
5 E 79.652 91.667 31.483 "BRAIN"

The resume consists of the main folder name, the experiment date, the subject
number, the desired word to spell, the spelled word, the whole ITR, the whole accuracy,
the spelling time, number of commands and number of correct commands, separated in
rows. The example of the resume is below.

PATH = C:\\RecordedRehaCare
DATE_INFO = \17102008
SUBJECT_INFO = \Subject_24
WORD TO SPELL = GEHIRN
WRITTEN WORD = "GEHIRN"

29
3. Data Format

ITR = 33.9456
Accuracy = 100 %
Time = 61.5614 seconds
Number of commands = 15
Number of correct commands = 15

30
Chapter 4
Data Storing in the IAT Spelling Software

4.1. Differences between Software used in CeBIT 2008 and in REHACARE 2008

The IAT data storing software are compiled using Microsoft Visual C++. The
software uses Microsoft Foundation Class (MFC), DirectX and driver for running EEG
amplifier from Guger Technology. Table 4-1 summarizes the software used by IAT and
the differences in CeBit and REHACARE software.

Table 4-1 Comparison between CeBit and Rehacare Software


CeBit REHACARE
Modules Comment
2008 2008
SSVEP_gUSBamp.cpp
same same The main application
SSVEP_gUSBamp.h
SSVEP_gUSBampDlg.cpp This module is for GUI and the
Old version New version
SSVEP_gUSBampDlg.h data storing
This module is for classification
BCIclassifier.cpp
Multi-threshold One threshold based on SNR threshold, in order to
BCIclassifier.h
decide the command.
This module is automatically
eeggraph.cpp
same same generated by Windows for
eeggraph.cpp
displaying EEG.
This module is used for creating
Perftimer.cpp
same same high-resolution timer in real time
Perftimer.h
process
Same function,
This module is used for signal
Same function, but the harmonic
SSVEPdetector.cpp processing: spatial filtering, band
with minor frequency is
SSVEPdetector.h pass filtering and multi-channel
difference limited:
error correction, like in [12]
Nh = 2

31
4. Data Storing in IAT Spelling Software

TCPIPConnection.cpp This module is used for managing


same same
TCPIPConnection.h TCP-IP Socket
This module is important for using
gUSBamp.h same same the driver of the Guger USB EEG
amplifier
stdafx.cpp This module is automatically
same same
stdafx.h generated by Windows
This module is automatically
resource.h Old version New version
generated by Windows
This module is automatically
_Font.h same same
generated by Windows
This module is automatically
_Picture.h same same
generated by Windows
This module is used for message
CalibrationInfo.cpp
Only in CeBit No longer used for user, how to calibrate the
CalibrationInfo.h
system
ProtocolSheet.cpp This module is used in GUI for
Only in CeBit No longer used
ProtocolSheet.h showing the protocol to the user
command_acc.cpp Used in This module is used to calculate the
Not ueed
command_acc.h Rehacare command accuracy
This module is used to calculate
speller.cpp Used in
Not used cursor position in the speller and
speller.h Rehacare
the spelled word

In CeBit 2008, the software allowed different threshold for each SNR. It was
intended to have a lot of subjects so there was protocol sheet to record the experimenter,
the EEG cap preparer, cap number and information about each subject. So there were
software modules: ProtocolSheet and CalibrationInfo, in Table 4-1.
In REHACARE 2008, only one threshold was used for all SNR. Protocol Sheet
was considered no longer important. In this event, calculating information transfer rate
(ITR) was more important. So there were modules: command_acc and speller, in Table 4-
1.
The change in the SNR threshold makes a different BCIclassifier module. In
REHACARE, there was research on the frequency selection so the SSVEPdetector
module changed. In REHACARE software, the harmonic frequency number is set to only

32
4. Data Storing in IAT Spelling Software

2. In CeBit software, the harmonic frequency number can be 1 until 3. If the harmonic
frequency number is 1, there is only fundamental frequency and no harmonics. The
REHACARE software uses only 2 frequencies: the fundamental and the first harmonic.
The most important change is the data storing software, in the
SSVEP_gUSBampDlg module. This module has an important role on GUI. So there is a
different Dialog Box between CeBit software (Figure 4.1) and REHACARE software
(Figure 4.2). From Fig. 4.1, the “Calibrate” and “Protocol Sheet” buttons can be seen.
These buttons are no longer used in the REHACARE software. But there are texts to
know the cursor position, the accuracy and the information transfer rate (ITR), in Fig.
4.2.

Figure 4.1 Dialog Box in CeBit Software

Figure 4.2 Dialog Box in REHACARE Software

Beside the change in the GUI, there is a change in the data acquisition and
storing, as mentioned in the previous chapter. This part is explained below in the next
subchapter.

33
4. Data Storing in IAT Spelling Software

4.2. Data Storing for the CeBIT 2008 Event

The module which is responsible for the data storing is SSVEP_gUSBampDlg.


Inside, there are the CSSVEP_gUSBampDlg class and the EEGBuffer structure.
EEGBuffer structure contains the variables for EEG signals and the command, which are
finally stored in text files. The class member of CSSVEP_gUSBampDlg can be seen in
Table 4-2.

Table 4-2 Class Member of CSSVEP_gUSBampDlg in the CeBit Software


(yellow marking means the class member is important for data storing and pink marking
means that it is used only in CeBit and no longer in Rehacare)
Member Type Description
CSSVEP_gUSBampDlg(CWnd*
Constructor
pParent = NULL)
Public argument for time
PerfTimer CPerfTimer
resolution
DoDataExchange(CDataExc Protected method for Data
virtual void
hange* pDX) Exchange
m_hIcon HICON Protected argument for icon
Protected method generated for
OnInitDialog() virtual bool
message map
OnSysCommand(UINT nID, Protected method generated for
afx_msg void
LPARAM lParam) message map
Protected method generated for
OnPaint() afx_msg void
message map
Protected method generated for
OnQueryDragIcon() afx_msg HCURSOR
message map
Protected method generated for
DECLARE_MESSAGE_MAP()
message map
m_SNRgraph CEeggraph Public argument for SNR display
Public argument for number of
m_NbrOfChannels int
channels
m_PortNbr int Public argument for TCP/IP port

34
4. Data Storing in IAT Spelling Software

number
Public argument for TCP format
m_TCPFormatCtrl CComboBox control (not used in the
implementation file)
Public argument for the
m_Frequencies CString
frequencies (of the stimuli)
Public argument for segment
length in seconds, important for
m_SegLenSeconds double
buffering in data acquisition and
storing
Public argument for idle length in
m_IdleLen double second, important for TCP/IP
connection
Public argument for SNR
m_Threshold double
threshold
m_StartButton CButton Public argument for Start Button
Public argument for Connect
m_ConnectButton CButton
Button
Public argument for sampling
m_Fs int frequency in hertz, important for
data acquisition (128 Hz is used)
Public argument for calculation
interval in seconds, important for
m_CalculationInterval double
buffering in data acquisition (0.1
seconds is used)
Public argument for length of
m_GraphLength int SNR plots in seconds (10 seconds
is used)
Public argument pointing to the
newest data obtained from the
m_pfDataBuffer float*
EEG amplifier, important in CeBit
data storing, but not in Rehacare
Public argument pointing to a
m_Detectors SSVEPdetector* SSVEP detection object, using
signal processing module in [12]
m_Detectors_created bool Public argument to know whether

35
4. Data Storing in IAT Spelling Software

a SSVEP detection object are


created
Public argument for simple
m_Classifier BCIclassifier classification object, using signal
processing module in [12]
Public argument for handling
m_TCPIPObject TCPIPConnection
TCP/IP connection
Public argument for the
m_vFrequencies vector<double> frequencies of the stimuli,
separated in a vector
Public argument for the EEG
m_vSignals vector<double> signal segment on which detection
is made, important in data storing
m_vSNRs vector<double> Public argument for SNR
Public argument for user
m_iCommand int command, sent over TCP/IP and
finally stored in files
Public argument for buffer size
per channel in amplifier,
m_BufferSizeScans USHORT
important in data acquisition and
storing
Public argument for number of x-
m_SNRgraph_NbrOfPoints int
axis points in SNR graph
Public argument for segment
length in samples, important for
m_SegLenSamples int
buffering in data acquisition and
storing
Public argument as a handle for
m_hdev HANDLE
amplifier
Public argument as a handle for
m_hAcquireThread HANDLE
the acquisition thread
Public argument as an event
m_hEvent_DataReady HANDLE handle indicating that a new data
is available in the amplifier
Public argument for knowing
_isrunning volatile bool
whether the acquisition is running

36
4. Data Storing in IAT Spelling Software

Public argument for knowing


_isconnected bool whether the TCP/IP connection is
established
Public argument for thread ID
_tid ULONG
(starting thread)
Public method generated for
OnStartbutton() afx_msg void
message map
Public method for EEG plot
InitEEGGraph(void) void initialisation, not used in CeBit
implementation
Public method for SNR plot
InitSNRGraph(void) void
initialisation
Public method to setup the
SetupAmplifier(void) int
amplifier
Public method for converting
GetFrequencies(void) int string to vector of number, to get
the frequencies as numbers
EnableControls(void) void Public method generated to enable
DisableControls(void) void or disable controls
Public method generated for
OnConnectbutton() afx_msg void
message map
Public argument for the
m_duration double
calibration duration for each trial
Public argument for the target file
m_FileName CString name, where the CeBit EEG data
is stored
Public argument to stop the data
m_SampledData unsigned int
acquisition automatically
Public argument for subject
m_iSubjectNumber int
number
OnCancel() virtual void Protected method generated for
OnOK() virtual void OK or Cancel
Private method to read the
readConfig(void) void
configuration file
Public argument to choose
m_BinaryOrAscii bool
whether the data is stored in

37
4. Data Storing in IAT Spelling Software

binary or text file


Public argument for path to the
m_RootDirectory CString root directory, important for data
storing
Public argument for buffering the
m_EEGBuffer std::vector<EEGBuffer> EEG data, important for data
storing
Public argument to choose
m_UseBPF bool
whether a band-pass filter is used
Public argument to choose
m_UseNotch bool
whether a notch filter is used
OnBnClickedProtocolShee
afx_msg void Public argument generated for
t()
message map
OnBnClickedCalibrate() afx_msg void
Public argument to determine
m_CalibrationState volatile bool whether the program is calibrating
or recording
Public argument for multiple
m_vThresholds std::vector<double>
threshold
Public argument generated for
m_CalibrateButton CButton
Calibrate button
Public argument generated for
m_ProtocolSheetButton CButton
Protocol Sheet button
m_Mutex CMutex Not used in CeBit implementation
Public argument for calibration
m_CalibrateTimerID UINT_PTR
time
m_ChannelIteratorForCal Public argument for each channel
int
ibrationID in calibration
m_ChannelIteratorTimerI Public argument for timer in
UINT_PTR
D calibration
OnTimer(UINT_PTR Public argument generated for
afx_msg void
nIDEvent) message map
Public argument for knowing
_isCalibrating bool
whether the program is calibrating
isSubjectHasProtocolShe Public method for asking whether
bool
et(void) the subject has filled the protocol

38
4. Data Storing in IAT Spelling Software

sheet, if not, the subject has to fill


it first
Public argument for assigning the
m_CalibratedSubjectList std::vector<int> calibration result to the right
subject
isSubjectHasBeenCalibra Public method for asking whether
bool
ted(void) the subject has been calibrated
Public argument for the starting
m_StartingFrequency double
frequency
Public argument for the SNR plot
m_SNRgraphRange double
range
m_SystemLog CString Public argument for system log
doSystemLogging(void) bool Public method for system logging
Public argument for numbers of
m_NbrOfElectrodes int
electrodes
Public argument for index of
m_IndexOfWordToSpell int
words to spell
m_WordsToSpell std::vector<CString> Public argument for words to spell
Public argument for displaying
m_DisplayedWordToSpell CString
word to spell on the Dialog Box

In the class member CSSVEP_gUSBampDlg::OnInitDialog(), the buffer size


for data storing is calculated. The code can be seen below.

// Fix calculation interval to 0.1 seconds


m_GraphLength = 10;
m_CalculationInterval = 0.1;
m_BufferSizeScans = (USHORT)ceil(m_Fs*m_CalculationInterval);

The sampling frequency (m_Fs) is set 128 Hz and the calculation interval is 0.1
seconds. The buffer size for each electrode will be 12,8 and it is rounded up to 13. The
software will store data blocks of 13 EEG signal times number of electrodes/channels.
The buffer size will be use in the signal processing, in [12]. The signal processing
uses SSVEPdetector module. The SSVEP detector has to be set up. As setting up the

39
4. Data Storing in IAT Spelling Software

detector, the segment length of EEG data blocks will be calculated. In the CeBit software,
this happens in the class members CSSVEP_gUSBampDlg::OnStartButton() and
CSSVEP_gUSBampDlg::OnBnClickedCalibrate(). The code can be seen below.

// Setup detectors
m_SegLenSamples =
(int)ceil(m_SegLenSeconds*m_Fs/m_BufferSizeScans)*m_BufferSizeScans;
int frequenciessize = (int)m_vFrequencies.size();
if (!m_Detectors_created)
{
m_Detectors = new SSVEPdetector[frequenciessize];
m_Detectors_created = true;
}

for(int i=0;i<frequenciessize;i++)
{
Status =
m_Detectors[i].Initialize(m_vFrequencies[i],m_Fs,m_NbrOfChannels,m_SegL
enSamples,0,0);
if(Status !=0)
{
MessageBox(SSVEPdetector::get_error(Status));
delete[] m_Detectors;
m_TCPIPObject.Send(LPCTSTR("11")); //11 = stop flickering
Sleep(25);
return;
}
}

In the class member CSSVEP_gUSBampDlg::OnBnClickedCalibrate(), the TCP/IP


does not send “11” but “13”. The code is below.

m_TCPIPObject.Send(LPCTSTR("13")); //13 = cancel calibration

40
4. Data Storing in IAT Spelling Software

After setting up the SSVEP detectors, the buffer size for signals and SNRs should
be allocated. In CeBit software, this allocation happens in
CSSVEP_gUSBampDlg::OnStartButton() and
CSSVEP_gUSBampDlg::OnBnClickedCalibrate(). The code can be seen below.

// Allocate size in m_vSignals vector and m_vSNRs vector


m_vSignals.clear();
m_vSignals.resize(m_SegLenSamples*m_NbrOfChannels);
m_vSNRs.clear();
m_vSNRs.resize(m_vFrequencies.size());

In CeBit software, after the buffer has been allocated, the thread is created. The
code can be seen below. This code is in the class member
CSSVEP_gUSBampDlg::OnStartButton().

// Reset all event handles


ResetEvent(m_hEvent_DataReady);

// Create thread
m_hAcquireThread = CreateThread(NULL,// pointer to security attributes
0,// initial thread stack size
AcquireProc,// pointer to thread function
this,// argument for new thread
CREATE_SUSPENDED,// creation flags
&_tid);// pointer to receive thread ID
SetThreadPriority(m_hAcquireThread, THREAD_PRIORITY_NORMAL );
//THREAD_PRIORITY_HIGHEST

_isrunning = TRUE;
m_pfDataBuffer = NULL;

41
4. Data Storing in IAT Spelling Software

After creating the thread, in the same class member, the acquisition can start. The
code for acquisition thread is below.

// Start acquisition thread


GT_Start(m_hdev);
Sleep(150);
ResumeThread(m_hAcquireThread);

The acquisition is done in the function AcquireProc(). The thread


m_hAcquireThread uses a pointer to the function AcquireProc() for data acquisition
and storing. Below is the acquisition thread function declaration.

ULONG WINAPI AcquireProc(void* pArg)

In the function, there are variables pDataBuffer and pByteBuffer, which are
important in the data storing and acquisition. Those variables are pointer in C++. In
CeBit software, they are just dummy variables. In Rehacare software, the variables are
class members. In CeBit software, the declaration of those two variables and related ones
can be seen below.

CSSVEP_gUSBampDlg *pthis = new CSSVEP_gUSBampDlg;


pthis = (CSSVEP_gUSBampDlg*) pArg;
DWORD dwResult;
float *pfl = NULL;
int iBytesperScan = pthis->m_NbrOfChannels*sizeof(float);
int BufferLengthBytes = pthis->m_BufferSizeScans*iBytesperScan;
int i,j;
float *pDataBuffer = new float[pthis->m_BufferSizeScans*pthis-
>m_NbrOfChannels];
BYTE *pByteBuffer = new BYTE[HEADER_SIZE + BufferLengthBytes];
pthis->m_pfDataBuffer = pDataBuffer;

42
4. Data Storing in IAT Spelling Software

The data acquisition and storing can be done after the declaration above. Below
is the important code for the data acquisition and storing in the CeBit software.

// Reshuffle data in m_vSignal. First shift out the oldest data


// to make place for the new data.
for(j=0; j<pthis->m_NbrOfChannels; j++)
for(i =0; i<pthis->m_SegLenSamples - pthis-
>m_BufferSizeScans;i++)
pthis->m_vSignals[i + j*pthis->m_SegLenSamples] = pthis-
>m_vSignals[i+pthis->m_BufferSizeScans+j*pthis->m_SegLenSamples];

// Wait for new data to be ready


GT_GetData(pthis->m_hdev, pByteBuffer,HEADER_SIZE +
BufferLengthBytes,&ov);
dwResult = WaitForSingleObject(pthis->m_hEvent_DataReady,1000);

// Convert 4 bytes into floats and store in the data buffer


for(j=0; j<pthis->m_NbrOfChannels; j++)
{
for(i=0; i<pthis->m_BufferSizeScans;i++)
{
pfl = (float*)(pByteBuffer + HEADER_SIZE +
(iBytesperScan)*i + j*sizeof(float));
pDataBuffer[i + j*pthis->m_BufferSizeScans] = *pfl;
pthis->m_vSignals[(j+1)*pthis->m_SegLenSamples-pthis-
>m_BufferSizeScans+i] = *pfl;
}
}

After the code above, there are codes to store EEG Data from pDataBuffer into a
file. The class member m_vSignals stores the EEG signal and processes the signals into
SNRs. SNRs will be used for classification, command decision and display.

43
4. Data Storing in IAT Spelling Software

4.3. Data Storing for the REHACARE 2008 Event

The Rehacare software also use SSVEP_gUSBampDlg module for data


acquisition and storing. The CSSVEP_gUSBampDlg class and the EEGBuffer structure
are modified. The modification of the class member of CSSVEP_gUSBampDlg can be
seen on Table 4-3.

Table 4-3 New Class Member of CSSVEP_gUSBampDlg in the Rehacare Software


(yellow marking means the class member is important for data storing)

Member Type Description


platz Cfont Public argument for Font
Public argument for the target file
m_FileNameEEG CString name, where the RehaCare EEG
data is stored
Public argument for the target file
m_FileNameResume CString name, where the resume of the
Rehacare experiment is stored
Public argument for the target file
name, where the command event
m_FileNameCommand CString
in the Rehacare experiment is
stored
Public argument for speller
SPELLER Speller
simulation
m_WORD1 CString
m_WORD2 CString
Public argument for the desired
m_WORD3 CString
words to be spelled
m_WORD4 CString
m_WORD5 Cstring
Public argument for index of the
current_word int
current word
Public argument to count the total
m_NbrCommands int number of commands, important
for calculating accuracy and ITR

44
4. Data Storing in IAT Spelling Software

Public argument to count the total


number of correct commands,
m_NbrCorrectCommands int
important for calculating accuracy
and ITR
Public argument for spelling
m_SpellCtrl CEdit control and displaying words on
GUI
OnBnClickedNext() afx_msg void Public method generated for
OnBnClickedOkay() afx_msg void message map
Public argument for number of
NbCommand float command (Left, Right, Up, Down,
Select)
Public argument to end the thread
end_thread int before creating a new one,
important in data acquisition
Public method to translate
PreTranslateMessage(MSG
BOOL command (Left, Right, Up, Down,
* pMsg)
and Select) into message
Public method to process
ProcessMessages() void
message
Public argument pointing to data
pDataBuffer float* buffer, important in data
acquisition and storing
Public argument pointing to a
pByteBuffer float* buffer in bytes, important in data
acquisition and storing

The Rehacare software also uses the sampling frequency of 128 Hz and the
calculation interval of 0.1 seconds. There are no different with the previous CeBit
version. The buffer size is also 13.

45
4. Data Storing in IAT Spelling Software

The SSVEP detector setup in the Rehacare software is modified. This part is no
longer in the class member CSSVEP_gUSBampDlg::OnStartButton(), but in the
CSSVEP_gUSBampDlg::OnInitDialog(). The modified code can be seen below.

Status =
m_Detectors[i].Initialize(m_vFrequencies[i],m_Fs,m_NbrOfElectrodes,m_Se
gLenSamples,0,0);

The buffer allocation for EEG signals and SNRs is modified in the Rehacare
version. The code is in the class member CSSVEP_gUSBampDlg::OnInitDialog(), no
longer in the CSSVEP_gUSBampDlg::OnStartButton(). Below is the modified code.

m_vSignals.resize(m_SegLenSamples*m_NbrOfElectrodes);

In CeBit version, m_NbrOfChannels is used but in Rehacare version,


m_NbrOfElectrodes is used. This modification is intended to help the next software
developers not confuse between the number of channels and the number of electrodes.
In Rehacare software, after the size of m_vSignals and m_vSNRs vectors has
been allocated, there is buffer allocation. Here, pDataBuffer and pByteBuffer, which are
important pointers in data acquisition and storing, are allocated. In Rehacare version,
those two variables are used not only in the function AcquireProc(), but also the class
member CSSVEP_gUSBampDlg::OnInitDialog(). The two pointers are not dummy
variables in Rehacare software, but they are class member of CSSVEP_gUSBampDlg.
Below is the code.

int iBytesperScan = m_NbrOfElectrodes*sizeof(float);


int BufferLengthBytes = m_BufferSizeScans*iBytesperScan;
pDataBuffer = new float[m_BufferSizeScans*m_NbrOfElectrodes];
pByteBuffer = new BYTE[HEADER_SIZE + BufferLengthBytes];

After all the buffers have been allocated in the initialisation part, which is the
class method CSSVEP_gUSBampDlg::OnInitDialog(), the thread is handled in the

46
4. Data Storing in IAT Spelling Software

class method CSSVEP_gUSBampDlg::OnStartButton(). The Rehacare software does


not change the thread handling. The process is the same as in CeBit version: resetting all
event handles, creating thread, setting thread priority and setting the pointer to data buffer
to NULL.
In the thread creation, the function AcquireProc() is still used in the Rehacare
software. Since the buffers pDataBuffer and pByteBuffer are no longer dummy variables
in the Rehacare version, but a class member, the declaration of the important variables for
data acquisition and storing is a bit different. The code in the acquisition thread function
can be seen below.

CSSVEP_gUSBampDlg *pthis = (CSSVEP_gUSBampDlg*) pArg;


DWORD dwResult;
int NbrFrequencies=(int)pthis->m_vFrequencies.size();
int NbrOfElectrodes=pthis->m_NbrOfElectrodes;
int BufferSizeScans=pthis->m_BufferSizeScans;
float *pfl = NULL;
int iBytesperScan = NbrOfElectrodes*sizeof(float);
int BufferLengthBytes = BufferSizeScans*iBytesperScan;
int i,j;

The data acquisition and storing can be done after the declaration above. Below is
the important code for the data acquisition and storing in the Rehacare software. Due to
some changes in the buffering (pDataBuffer and pByteBuffer) and the differentiation
between the number of electrodes and the number of channels, there is modification in
the data acquisition.

// Reshuffle data in m_vSignal. First shift out the oldest data to make
place for the new data.
for(j=0; j<NbrOfElectrodes; j++)
for(i =0; i<pthis->m_SegLenSamples - pthis-
>m_BufferSizeScans;i++)
pthis->m_vSignals[i + j*pthis->m_SegLenSamples] = pthis-
>m_vSignals[i+pthis->m_BufferSizeScans+j*pthis->m_SegLenSamples];

47
4. Data Storing in IAT Spelling Software

// Wait for new data to be ready


GT_GetData(pthis->m_hdev, pthis->pByteBuffer,HEADER_SIZE +
BufferLengthBytes,&ov);
dwResult = WaitForSingleObject(pthis->m_hEvent_DataReady,1000);

// Convert 4 bytes into floats and store in the data buffer


for(j=0; j<NbrOfElectrodes; j++)
{
for(i=0; i<pthis->m_BufferSizeScans;i++)
{
pfl = (float*)(pthis->pByteBuffer + HEADER_SIZE +
(iBytesperScan)*i + j*sizeof(float));
pthis->pDataBuffer[i + j*pthis->m_BufferSizeScans] = *pfl;
pthis->m_vSignals[(j+1)*pthis->m_SegLenSamples-pthis-
>m_BufferSizeScans+i] = *pfl;
}
}

The code above does not have many differences from the CeBit version. After
that, there are codes for saving the EEG data from the class member pDataBuffer to files.
In Rehacare software, SNRs, time information and other do not come from pDataBuffer.
The class member m_vSignals acquires the EEG signals and then there are signal
processing like in the CeBit version to get the SNRs. There are codes in the Rehacare
software to store commands, SNRs, ITRs and accuracies in the end.

4.4. Software Bug in the CeBIT 2008 Software

There are problem in the CeBit Software. It is intended to store data from 6 EEG
electrodes. Instead of getting a good result for every column in the EEG data file, there is
a different pattern in the sixth column, which comes from 1 electrode. Figure 4.3 gives an
idea of the different pattern.

48
4. Data Storing in IAT Spelling Software

Figure 4.3 Example of CeBit Data Storing Result

In this master project, the difference of the sixth column should be explained. A
change in the data acquisition code is done to check whether the different pattern is a bug
or not. The change happens in the function AcquireProc() and it can be seen below.

// Reshuffle data in m_vSignal. First shift out the oldest data


// to make place for the new data.
for(j=0; j<pthis->m_NbrOfChannels; j++)
for(i =0; i<pthis->m_SegLenSamples - pthis-
>m_BufferSizeScans;i++)
pthis->m_vSignals[i + j*pthis->m_SegLenSamples] = pthis-
>m_vSignals[i+pthis->m_BufferSizeScans+j*pthis->m_SegLenSamples];

// Wait for new data to be ready


GT_GetData(pthis->m_hdev, pByteBuffer,HEADER_SIZE +
BufferLengthBytes,&ov);
dwResult = WaitForSingleObject(pthis->m_hEvent_DataReady,1000);

49
4. Data Storing in IAT Spelling Software

// Convert 4 bytes into floats and store in the data buffer


static int iNumber = 0; // Condro's change
for(j=0; j<pthis->m_NbrOfChannels; j++)
{
for(i=0; i<pthis->m_BufferSizeScans;i++)
{
pfl = (float*)(pByteBuffer + HEADER_SIZE +
(iBytesperScan)*i + j*sizeof(float));
// Condro tries to change this into counter
pDataBuffer[i + j*pthis->m_BufferSizeScans] = 0.001 *
static_cast<float>(iNumber); // Condro's change
iNumber++; // Condro's change
pthis->m_vSignals[(j+1)*pthis->m_SegLenSamples-pthis-
>m_BufferSizeScans+i] = *pfl;
}
}

The memories pointed by the variable pDataBuffer do not store EEG Data from
the memories pointed by the variable pfl but store data from the variable iNumber. The
change of codes above acts as a counter. The checking result can be seen in Figure 4.4.

50
4. Data Storing in IAT Spelling Software

Figure 4.4 The CeBit data checking result

Figure 4.4 shows bugs in the sixth column as the counter does not change
anything there. This means that EEG data/signal from one electrode could not be
retrieved. The data is stored correctly every 13 samples based on the buffer size of each
electrode scanning, but wrongly for every number of electrodes. The CeBit software uses
a loop of number of channels. Although in the initialisation, the number of channels has
been set to 6, but in the acquisition part, the number of channels is only 5. There is a
problem using the number of channels and the number of electrodes in the CeBit version.
The signal processing module (SSVEPdetector) uses the relation between those two
variables. Inside the module there is a method which returns a number of channels. This
new number of channels, which is 5, replaces the initial number of channels, which is 6.
The Rehacare software revised many things from the CeBit version. The buffer
sizes for data acquisition and storing (pByteBuffer and pDataBuffer) in the Rehacare
software are no longer dummy variables but now a class member. The buffer sizes have
been initialised in the dialog box initialisation before clicking the Start Button. In the
CeBit version the buffer sizes are initialised after clicking the Start Button. The most
important changes in the Rehacare version for the data storing and acquisition is the

51
4. Data Storing in IAT Spelling Software

separation of the number of electrodes and the number of channels. The revision in the
Rehacare software is intended to fix the bugs in the CeBit version. In order to check
whether the bugs are fixed the same checking method as in the CeBit software is used in
the Rehacare one. The codes can be seen below.

// Reshuffle data in m_vSignal. First shift out the oldest data to make
place for the new data.
for(j=0; j<NbrOfElectrodes; j++)
for(i =0; i<pthis->m_SegLenSamples - pthis-
>m_BufferSizeScans;i++)
pthis->m_vSignals[i + j*pthis->m_SegLenSamples] = pthis-
>m_vSignals[i+pthis->m_BufferSizeScans+j*pthis->m_SegLenSamples];

// Wait for new data to be ready


GT_GetData(pthis->m_hdev, pthis->pByteBuffer,HEADER_SIZE +
BufferLengthBytes,&ov);
dwResult = WaitForSingleObject(pthis->m_hEvent_DataReady,1000);

// Convert 4 bytes into floats and store in the data buffer


static int iNumber = 0; // Condro's change
for(j=0; j<NbrOfElectrodes; j++)
{
for(i=0; i<pthis->m_BufferSizeScans;i++)
{
pfl = (float*)(pthis->pByteBuffer + HEADER_SIZE +
(iBytesperScan)*i + j*sizeof(float));
// Condro tries to change this into counter
pthis->pDataBuffer[i + j*pthis->m_BufferSizeScans] = 0.01 *
static_cast<float>(iNumber); // Condro's change
iNumber++; // Condro's change
pthis->m_vSignals[(j+1)*pthis->m_SegLenSamples-pthis-
>m_BufferSizeScans+i] = *pfl;
}
}

52
4. Data Storing in IAT Spelling Software

The result of Rehacare data checking can be seen in Figure 4.5. The data storing
bug is fixed. The buffer size for scanning each EEG electrode is 13, which is the same as
the size in the CeBit version. The number of electrodes is 6 and the result shows that the
sixth column successfully stored EEG signal from the last electrode.

Figure 4.5 The Rehacare EEG data checking result (only first 7 columns)

53
Chapter 5
Conclusion and Discussion

5.1. Conclusion

From this master project, some conclusions can be drawn. The conclusions can be
seen below.
¾ The data from one channel from 6 EEG electrodes cannot be retrieved, in the CeBit
software.
¾ The data storing bug in the CeBit software happened because of the inconsistency
between using the number of channels and using the number of electrodes
¾ In the Rehacare software, the data storing bug of the CeBit version has been fixed.
¾ Chapter 3 of this report gives an idea of different data formats: GDF, EDF, BDF,
BKR, CeBit data format and Rehacare data format.

5.2. Discussion and Future Works

It can be concluded from the chapter 3 of this report that some alternative data
formats can be used for flexible data exchange between institutes. CeBit and Rehacare
data format from the IAT of the University of Bremen provide a text file choice which
can be easily opened by other institutes. The disadvantage is that they need other
documentation because they have no header. The alternative data formats proposed here
are GDF, EDF, BDF and BKR. BKR can be used for the future if the time-based order
remains an IAT standard of EEG data storing. GDF can be a good choice for the future
because the IAT save EEG data in floating point format.

54
BIBLIOGRAPHY

[1] Indar Sugiarto. Display and Feedback Approaches for BCI Systems. 2008. Master Thesis,
Information and Automation Engineering, University of Bremen.
[2] T. Lüth. “Bremen Brain-Computer Interface Applications”. 28th Colloquium of
Automation. 2006. November, Salzhausen.
[3] B. Allison, I. Volosyak, T. Lüth, D. Valbuena, I. Sugiarto, M.A. Spiegel, A. Teymourian,
I.S. Condro, A. Brindusescu, K. Stenzel, H. Cecotti and A. Gräser. “BCI Demographics:
How many (and what kinds of) people can use an SSVEP BCI?”. Proc. 4th International
Brain-computer Interface Workshop and Training Course. 2008. Graz, Austria,
September 18-21, pp. 333-338.
[4] D Valbuena, I. Sugiarto and A. Gräser. “Spelling with the Bremen brain-computer
interface and the integrated SSVEP stimulator”, Proc. 4th International Brain-conputer
Interface Workshop and Training Course. 2008. Graz, Austria, September 18-21, pp.
291-296.
[5] Jonathan R. Wolpaw, Niels Birbaumer, Dennis J. McFarland, Gert Pfurtscheller and
Theresa M. Vaughan. “Brain-computer interfaces for communication and control”.
Clinical Neurophysiology. 2002. vol. 113, pp 767-791. Ireland: Elsevier. ISSN 1388-
2457.
[6] F. Lotte, M. Congedo, A. Lécuyer, F. Lamarche and B. Arnaldi. “A review of
classification algorithms for EEG-based brain-computer interfaces”. Journal of Neural
Engineering. 2007. pp R1-R13. UK: IOP Publishing. ISSN 1741-2560.
[7] Ming Cheng, Xiaorong Gao, Shangkai Gao and Dingfeng Xu, “Design and
Implementation of a Brain-Computer Interface With High Transfer Rates”. IEEE
Transactions on Biomedical Engineering. 2002. Vol. 49, No. 10, October, pp 1181-1186.
ISSN 0018-9294.
[8] Brendan Z. Allison, Elizabeth Winter Wolpaw and Jonathan R Wolpaw. “Brain-computer
interface systems: progress and prospects”. Expert Rev. Med. Devices. 2007. Vol.4, pp
463-474. Future Drugs Ltd. www.future-drugs.com. ISSN 1743-4440.
[9] Terence W. Picton. “What is an EEG (Electroencephalogram)?”. Rotman Research
Institute, Baycrest. www.rotman-baycrest.on.ca/index.php?section=402. Retrieved on
January 2009.
[10] Neng Xu, Xiaorong Gao, Bo Hong, Xiaobo Miao, Shangkai Gao and Fusheng Yang.
“BCI Competition 2003 – Data Set IIb: Enhancing P300 Wave Detection Using ICA-
Based Subspace Projections for BCI Applications”. IEEE Transcation on Biomedical
Engineering. 2004. Vol. 51, No. 6, June, pp 1067-1072. ISSN 0018-9294.
[11] Athanasios P. Liavas, George V. Moustakides, Günter Henning, Emmanuil Z. Psarakis
and Peter Husar. “A Periodogram-Based Method for the Detection of Steady-State
Visually Evoked Potentials”. IEEE Transactions on Biomedical Engineering. 1998. Vol.
45, No. 2, February, pp 242-248. ISSN 0018-9294.
[12] Ola Friman, Ivan Volosyak and Axel Gräser. “Multiple Channel Detection of Steady-
State Visual Evoked Potentials for Brain-Computer Interfaces”. IEEE Transactions on
Biomedical Engineering. 2007. Vol 54 No 4, April 2007, pp 742-751, ISSN 0018-9294.
[13] Peter Malinowski, Sandra Fuchs and Matthias M. Müller. “Sustained division of spatial
attention to multiple locations within one hemifield”. Neuroscience Letter. 2007. Vol.
414, pp 65-70. Ireland: Elsevier. ISSN 0304-3940.

55
Bibliography

[14] Zhonglin Lin, Changsui Zhang, Wei Wu and Xiaorong Gao. “Frequency Recognition
Based on Canonical Correlation Analysis for SSVEP-Based BCIs“. IEEE Transactions
on Biomedical Engineering. 2006. Vol. 53, No. 12, December, pp 2610-2614. ISSN
0018-9294.
[15] Bob Kemp, Alpo Värri, Thomas Penzel and Jesus Olivan. “European Data Format:
standard texts”. http://www.edfplus.info/specs/edftexts.html, retrieved in January 2009.
[16] Alois Schlögl. “GDF – A General Dataformat for Biosignals version 2.11”. Technical
Report. October 2008. ,
[17] Alois Schlögl. “Overview of data formats for biomedical signals”. Technical Report.
http://hci.tugraz.at/~schloegl/publications/Schloegl_Nov2008_OverviewBiosignalDatafor
mats.pdf, November 2008.
[18] _____. “Scientific Data Format”. http://hci.tugraz.at/schloegl/matlab/eeg/, retrieved in
February 2009.
[19] _____. “The BioSig Project”. http://biosig.sourceforge.net/, retrieved in February 2009.
[20] _____. “Dataformats supported by BioSig”. http://hci.tugraz.at/schloegl/biosig/TESTED,
retrieved in February 2009.
[21] Alois Schlögl, Oliver Filz, Herbert Ramoser and Gert Pfurtscheller. “GDF – A General
Dataformat for Biosignals version 1.25”. Technical Report. 1998-1999, revised on 29th
March 2005.
[22] _____. “European Data Format (EDF): technical specification”. http://www.dpmi.tu-
graz.ac.at/~schloegl/matlab/eeg/edf_spec.htm, retrieved in February 2009.
[23] Bob Kemp, Alpo Värri, Agostinho C. Rosa, Kim D. Nielsen and John Gade. “European
Data Format: Full specification of EDF”. http://www.edfplus.info/specs/edf.html,
retrieved in February 2009.
[24] Bob Kemp and Jesus Olivan. “European Data Format: Full specification of EDF+”.
http://www.edfplus.info/specs/edfplus.html, retrieved in February 2009.
[25] _____. “Which file format does BioSemi use?”.
http://www.biosemi.com/faq/file_format.htm, retrieved in February 2009.
[26] _____. “BKR-Format V2.07”. EPS (EEG Processing Software). http://www.dpmi.tu-
graz.ac.at/~schloegl/matlab/eeg/bkr.html, retrieved in February 2009.
[27] _____. “About BioSemi”. http://www.biosemi.com/company.htm, retrieved in February
2009.

56

Vous aimerez peut-être aussi