Contributions:SigfriedSigProc
From BCI2000 Wiki
Contents |
Synopsis
The SigfriedSigProc is a BCI2000 signal processing and visualization module using SIGFRIED (SIGnal modelling For Realtime Identification and Event Detection) to provide the following functionality to investigators:
- Passive Functional Brain Mapping
- Map active/passive brain function in real-time without the need of post-hoc analysis.
- Brain-Computer Interface Operation
- Establish a real-time 1-dimensional Brain-Computer Interface within minutes.
Location
http://www.bci2000.org/svn/tags/BCI2000.v2.1/src/contrib/SignalProcessing/SigfriedSigProc/
Versioning
Author
Peter Brunner
Source Code Revisions
- Initial development: --
- Tested under: --
- Known to compile under: --
- Broken since: --
Parameters
AutoScaleChannelList
Optional list of channels that define which channels will be used to autoscale the visualization results. This list is either empty (all channels will be used) or contains more than one channel. The AutoScaleChannelList can be used for example to exclude a set of EMG electrodes from a greater set of ECoG electrodes.
CircleRadius
Maximum pixel radius of the circles in a maximized visualization.
ElectrodeCondition
Table that with each column defines a conditions that will be visualized.
The table is defined by the following rules:
- The first column always defines the realtime condition.
- Each column can can contain multiple logical conditions (operators <,>,=) that are logical conjuncted.
- If the original expression is not in a pure conjuncted form it may be transformed to be so.
- All columns must have the same number of logically conjuncted conditions.
- Always true expressions such as "Running = 1" may be used to fill in and to achieve the same number of logically conjuncted conditions for all columns.
- Each row can be referenced to another row.
- -1 disables the reference feature which will enable the averaging instead of the statistics selected in StatisticDisplayType.
- Each column must define the min/max value of the visualization.
- Each column can use operators from the set of < (smaller), > (larger) and = (equal) operators.
- There is no limitation on the number of columns/rows of the ElectrodeCondition.
| Name | Reference | DispMin | DispMax | State | Operator | Value | State | Operator | Value | ... | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | realtime | -1 | 0 | 20 | StimulusCode | > | -1 | Feedback | = | 1 | ... |
| 2 | average | -1 | 0 | 20 | StimulusCode | 0 | 0 | Feedback | = | 0 | ... |
| 3 | tongue | 2 | 0 | 1 | StimulusCode | = | 11 | Feedback | = | 1 | ... |
| 4 | hand | 2 | 0 | 1 | StimulusCode | = | 12 | Feedback | = | 1 | ... |
| 5 | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
ElectrodeLocation
Table that contains a label and the relative position of each electrode used in the model:
- label
- String that is displayed when the user moves the mouse over this electrode.
- x
- Horizontal position (from left to right)
- y
- Vertical position (from bottom to top)
FeedbackType
Defines the input signal for the next application in the BCI2000 filter chain:
- log-score
- Uses the score defined in ScoreType.
- real-time display
- Uses the values of the real-time display.
LearningRateAutoScale
Controls the how quickly the auto-scale feature reacts to changes in the min/max of the data. Implemented using a 1st-order IIR filter with the filter coefficient LearningRateAutoScale. Filter is applied to the min and max of all channels defined by the channels listed in AutoScaleChannelList.
LearningRateAverage
Controls the how quickly the real-time display reacts to changes in the average of the data. Implemented using a 1st-order IIR filter with the filter coefficient LearningRateAverage. Filter is applied to the histogram of all data for each electrode.
LearningRateHist
Controls the how quickly the real-time display reacts to changes in the histogram of the data. Implemented using a 1st-order IIR filter with the filter coefficient LearningRateHist. Filter is applied to the histogram of all data for each electrode.
MemWindows
Number of blocks of the size SampleBlockSize (samples per channel per digitized block) that are used for the maximum entropy method to estimate the spectra. For the example settings bellow the spectra will be estimated 30 times per second (1200 / 40) for 600 samples (15 * 40) each. It is recommended that the number of samples to estimate the spectra are exactly the same in the SigfriedSigProc and the model (spectral_size).
Example:
- SamplingRate = 1200 Hz
- SampleBlockSize = 40
- MemWindows = 15
ModelFiles
Table that contains for each model file:
- filename
- Absolute or relative path to the model file.
- label
- String that is used as a title for all windows associated with this model.
- x-pos (optional)
- Horizontal origin for the window that visualizes this model.
- y-pos (optional)
- Vertical origin for the window that visualizes this model.
- width (optional)
- Width of the window that visualizes this model.
If the optional x-pos, y-pos and width are not provided then each window will be scaled to fill the full screen width.
ScoreType
Two choices are provided to determine to score the likelihood of the task-related data:
- Mahalanobis-Distance
- Simple score that provides smooth transition from task-related data to baseline data and vice versa.
- Negative-Log-Likelihood
- More complex measure that provides steep discrimination between task-related and baseline data.
StatisticDisplayType
Defines the statistic that is used to visualize the difference between two conditions define in the ElectrodeCondition table:
VisualizeSigfried
Checkbox that enables visualization of the SIGFRIED results in a seperate graph for each model.
States
None.
Methodology
Methodology Concept
The conceptional idea behind SIGFRIED is to detect task-related changes in brain signals. This for example can be the detection of changes in the sensorimotor rhythm associated with actual/imaged motor movement and thus the detection of actual/imaged hand movement. This is achieved in three steps:
- Baseline non-task related data is recorded.
- Features that capture the mainfestation of this changes in the frequency domain are extracted from the data using the Maximum Entropy Spectral Estimation Method. A multi-modal statistical model using Gaussian-Mixture Models and the CEM-algorithm is then build.
- The build model is used to calculate the likelihood of task-related data (see figure below).
Methodology Outline
The methodology can be outlined in three essential steps (see figure below):
- Record Baseline Data
- 5-10 minutes of non-task related data (e.g. while the subject is resting) is recorded.
- Build Model
- A model describing the baseline data is build.
- Apply Model
- The build model is applied to different active/passive task-related data (e.g. while the subject is performing multiple motor tasks).
Methodology Step By Step
Step 1: Record Baseline Data
The figure below illustrates the process of recording baseline data:
- For this recording the subject is instructed to relax and stay motionless for the period of 5-10 minutes while data is recorded.
- It is particularly important that the data is not poisoned by movement artifacts since this will affect the quality of the model and thus the detection sensitivity for task related changes in the brain-signals.
- Data is processed (amplified, bandpass filtered, digitized) and stored.
Step 2: Build Model
Feature Extraction
From both the task and the non-task related data the same features that capture the task-related changes are extracted using the Maximum Entropy Spectral Estimation Method. This method has the following parameters:
- start
- Minimum frequency in Hz.
- stop
- Maximum frequency in Hz.
- delta
- Up-sampling resolution in Hz for the intermediate spectral estimate.
- bandwidth
- Frequency resolution in Hz for the final spectral estimate.
- detrend
- Detrending the signal with : (0) no detrend, (1) linear detrend (2) second order detrend.
- modelorder
- Number of autoregressive (AR) coefficients.
- spectral_size
- Number of samples for each spectral estimation.
- spectral_stepping
- Number of samples between each spectral estimation.
- bins2use
- List of bins from 1 to [(stop-start) / bandwidth - 1] that shall be used for the final spectral estimate.
The concept of his method is outlined int the figure below were for data recorded at 160 Hz the parameters start = 10 Hz, stop = 40 Hz, delta = 0.5 Hz, detrend = 1, modelorder = 16, spectral_size = 64, spectral_stepping = 32 are used to extract a spectral estimate.
Model Estimation
The figure below illustrates the steps in building and applying a model for each channel:
- Generate Model
- Stored signals are loaded from a BCI2000 data file.
- Spatial filters e.g. Common Average Reference Filter are applied.
- Feature samples are extracted using the Maximum Entropy Spectral Estimation Method.
- Each feature is normalized between 0 and 1.
- The feature space is populated with the feature samples.
- The model, i.e. the parameters of a Gaussian-Mixture Model are estimated for each channel using the CEM-algorithm.
- The model is stored in a file.
Step 3: Apply Model
The figure below illustrates the process of applying a model to either perform Passive Functional Brain Mapping or Brain-Computer Interface Operation:
- The subject is exposed to different active (e.g. imagined and actual motor movement) and passive (e.g. auditory or tactile stimulation) tasks.
- Data is processed the same way as for the baseline data.
- Features are extracted the same way as for the baseline data.
- The likelihood of the data is determined using the baseline data model.
- The estimated likelihood is visualized and/or used to operate a 1-dimensional Brain-Computer Interface.
Tutorial
Step 0: Compile BCI2000 with SigfriedSigProc
As SigfriedSigProc is a contribution to BCI2000, a few manual steps are necessary to compile and install SigfriedSigProc:
- Make sure that you can access and download to the source code.
- Open a console window in the BCI2000 src/ directory, and execute make prepare.
- Locate the file /src/makefiles and navigate to the line ($PATHTOBCI2000$ will be the path of your BCI2000 installation)
#"$PATHTOBCI2000$\src\contrib\SignalProcessing\SigfriedSigProc\SigfriedSigProc.mak"
- remove the # character.
"$PATHTOBCI2000$\src\contrib\SignalProcessing\SigfriedSigProc\SigfriedSigProc.mak"
- build BCI2000
make all
- now you should have the following files in the /prog folder
- SigfriedSigProc.exe
- SIGFRIED.dll
- sigfried.ini
- create a batch file in the batch folder to use SigfriedSigProc (use your signal source to replace SignalGenerator.exe)
cd ..\prog\ start operat.exe start SignalGenerator.exe AUTOSTART 127.0.0.1 start SigfriedSigProc.exe AUTOSTART 127.0.0.1 start StimulusPresentation.exe AUTOSTART 127.0.0.1
- create a batch file in the batch folder to record baseline data (use your signal source to replace SignalGenerator.exe)
cd ..\prog\ start SignalGenerator.exe AUTOSTART 127.0.0.1 start DummySignalProcessing.exe AUTOSTART 127.0.0.1 start StimulusPresentation.exe AUTOSTART 127.0.0.1 start operat.exe
Step 1: Baseline Recording
- Start the batch file for baseline recording, setup the parameters for you signal source and data storage.
- Record 5-15 minutes of baseline data (e.g 5 minutes for 5 of bins in the bins2use and 10 minutes for 10 bins).
Step 2: Build Model
Locate the data2model GUI in \src\contrib\Tools\Sigfried\data2model_gui.exe and create a batch file in batch:
cd ..\src\contrib\Tools\Sigfried\ start data2model_gui.exe -inicfg data2model_gui.ini -inisig sigfried.ini -input ../$pathtobaseline$/baseline.dat -output /$pathtomodel$/baseline.mdl
Edit the data2model_gui.ini such that it suites your needs. The example below reflects settings for 16 channels recorded at 1000 Hz. Features are extracted from linearly detrended (detrend = 1) and common average referenced filtered (filter_car = 1) segments of 480 samples (spectral_size = 480)in steps of 480 samples from 8 to 40 Hz in 3 Hz steps using the bins 1 to 8. I.e. The frequency bins are 8-11 Hz, 11-14 Hz, 14-17 Hz, 17-20 Hz, 20-23 Hz, 23-26 Hz, 26-29 Hz, 29-32 Hz covering the mu and beta range of the EEG.
Detailed description of the parameters:
- SpectralSettings
- Explained in the methodology section.
- ModelSettings
- Explained in the methodology section.
- SpatialSettings
- Allows to not only use the frequency features them self but also use the same features with a spatial derivative i.e. the difference between one feature from different channels at each time. To enable that add further lines with spatial1, spatial2 a.s.o that define the difference relative to the spatial0 channels. Each parameter has to have the same length as spatial0. Each the channels of each parameter must be a subset of spatial0.
- SpatialSettings
- Allows to not only use the frequency features them self but also use the same features with a temporal derivative i.e. the difference between one feature from the same channel at different points in time. The lowest temporal derivative is 1.
- FilterSettings
- The parameter filter_car can be:
- 0 for no common average reference filtering.
- 1 for common average reference filtering using all channels.
- 2 for common average reference filtering using only the channels in channels
[SpectralSettings] start = 8 stop = 40 delta = 0.2 bandwidth = 3 detrend = 1 modelorder = 40 samplefreq = 1000 [ModelSettings] spectral_stepping = 480 spectral_size = 480 bins2use = 1 2 3 4 5 6 7 8 channels = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [SpatialSettings] spatial0 = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [TemporalSettings] temporal = [FilterSettings] filter_car = 1
Starting the data2model_gui using the created batch file and the custom data2model_gui will provide a visual interface that allows to review and verify the settings. For that reason the data2model_gui has a color coded scheme:
- settings ok : The setting and all dependencies are valid.
- settings mismatch : The settings may be valid but there is a mismatch with another parameter.
- settings error : The settings is invalid.
The model can be build by pressing the "Build Model" button, which becomes available when all settings are valid and green. The model building can take a few second to many minutes depending on the amount of data. The progress is indicated by progress bars and no changes can be made until the process is finished.
Step 3: Run SigfriedSigProc
To run SigfriedSigProc the following steps have to be performed:
- Use the batch file created in step 0 to start BCI2000 v2.0 with the SigfriedSigProc module.
- Configure the parameters as described in the parameters section to either perform Passive Functional Brain Mapping or Brain-Computer Interface Operation.
- Instruct the subject to perform the configured tasks (e.g. multiple cued motor movements or passive listening to a auditory task).
- Start the task.
The functionality of the visualization is illustrated in the following to figures. In general the visualization allows to:
- Turn a condition on or off.
- Set the display range, e.g. to only display significant activity.
- Use the auto range feature to set the display range.
- Display the active condition.









