Jump to content

Contributions:CCEPFilter: Difference between revisions

From BCI2000 Wiki
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Image:CCEP gif.gif |500px|right|thumb|frame| An example video showing one channel of the CCEP filter.]]
 
[[Image:CCEP gif.gif|thumb|800px| An demo video of the CCEP Filter with VisualizeBCI2000. ]]
 
==Introduction==
==Introduction==
Cortico-cortical evoked potentials (CCEPs) are generated as a response to stimulation within the cortical zone. To best view this response, the CCEP filter time locks the signal to the stimulation and allows the user to view the CCEPS from every recording electrode. There are many adaptable parameters to include flexibility for a variety of experiments.
Cortico-cortical evoked potentials (CCEPs) are generated as a response to stimulation within the cortical zone. To best view this response, the CCEP filter time locks the signal to the stimulation and allows the user to view the CCEPS from every recording electrode. There are many adaptable parameters to include flexibility for a variety of experiments.
Line 19: Line 21:
*Broken since: --
*Broken since: --


==Integration into BCI2000==
==Installation==
Confirm your BCI2000 svn is up to date and you have built the most recent version.
See [[Python Visualizations#Installation|the Installation section on the Python Visualization page]] to see how to install the necessary packages and how to run demo files! Once that is all set up, you can return to this page to understand the specific parameters for the CCEPs.
Insert <code>Start executable CCEPFilter --local</code> as the SignalProcessing filter into the batch file that you want to run.  
 
==Processing Details==
The CCEP filter has two parts - a C++ filter in the Signal Processing pipeline, and the Python filter outside of the BCI2000 chain.  
# BCI2000 filter
#* The filter receives the raw data from the Source module, then time-locks the data based on the user-defined CCEP parameters.
#* When all the data is collected, the state CCEPTriggered will pulse to let the Python filter know data is ready to be visualized.
# Python filter
#* Data is received through the [[User Reference:SignalSharing|SignalSharing]] feature. Specifically, the parameter ShareCCEPFilter is set to a valid port to share the data.
#* When CCEPTriggered is true, the incoming data is further processed and plotted. The only processing this filter does is to calculate the area under the curve (AUC), then determine which channels have a significant response based on the threshold standard deviation set by the user. The raw values are given in the table, and the top most significant channels are visually shown.
#* If ''Sort Channels'' is enabled, all the significant channels will be at the top. They are then organized based on their original order, to maintain electrode grouping. If they were sorted purely on highest to lowest AUC, it would be very difficult to tell which general areas are responding.


==Parameters==
==Python Settings==
===<u>''General Configuration''</u>===
===Threshold (STD)===
====ChannelThreshold====
This defines the threshold to determine a CCEP response. This value should be adjusted to maximize the number of significant channels shown, while not going over. If the value is too low, there will be more significant channels than visualized windows. This would only show you the electrodes which were originally at the top of the list, which might lead you to disregard the bottom electrodes.
Magnitude threshold which defines a CCEP. Specify the units, such as uV or mV. The surpassing of this threshold is calculated with the CCEPEpochLength data (after the specified TriggerLatencyLength) after being subtracted from the average baseline value (the data during the BaselineEpochLength). If the threshold is surpassed, the channel is yellow. A horizontal bar is also displayed to show where the signal surpasses the threshold. If both the high and low thresholds are surpassed, both bars are displayed. If the signal stays below the threshold, it stays white.
===Max Windows===
The maximum amount of windows displayed. If you desire all the transmitted channels to be shown, set this max value to the number of channels or greater.
===x<sub>0</sub>===
The minimum shown value of the x-axis for all windows, in milliseconds. You can set this to a negative value to show baseline data before the CCEP.
===Hold Plots===
The number of plots to keep on a window. Set to 0 to hold all plots, until manually cleared with "Clear Figures".
===Average CCEPs===
Enable to display the average of the plots in addition to the single trials.
===Sort Channels===
Disable to keep the order of the channels unchanged. If there are more transmitted channels than windows shown, the shown windows will simply be the first in the list.
===Save figures on refresh===
''Currently broken''. Enable to make sure the visualizations are never lost, as every time the plots are cleared they would first be saved. This can get cumbersome with many saved files.


====OnsetExpression====
==BCI2000 Parameters==
Expression that defines the stimulus onset. See the [[User Reference:Expression Syntax | Expression syntax page]] for more information. This expression should be true when the stimulation is triggered.
===OnsetExpression===
====Stimulator====
Expression that defines the stimulus onset. Ideally, this should be a hardware trigger to have the most precise time-locking. This expression should be true when the stimulation is triggered. See the [[User Reference:Expression Syntax | Expression syntax page]] for more information.  
An optional setting that configures parameters for a certain device. Currently, only the NeuroOmega is implemented. This setting helps fills in other settings that are "auto" (such as TriggerLatencyLength, and configures the visualization to show which channels are stimulating in light blue.  


===<u>''Duration settings''</u>===
===Duration settings===
These parameters all should have units of time (e.g. milliseconds), or auto.
These parameters all should have units of time (e.g. milliseconds), or auto.
<gallery mode="packed" widths=250px heights=450px>
 
File:CCEPTimingVisualization.png|The three timing sections of the CCEP filter visualization.
====''BaselineEpochLength''====
</gallery>
====BaselineEpochLength====
The duration of desired baseline data. This baseline data is helpful for visualizing the data before the stimulation, and is also used to calculate the average signal value from which the threshold is calculated.
The duration of desired baseline data. This baseline data is helpful for visualizing the data before the stimulation, and is also used to calculate the average signal value from which the threshold is calculated.
====TriggerLatencyLength====
====''CCEPEpochLength''====
Approximate latency of the hardware stimulation from the OnsetExpression. The timing should surpass the stimulation artifact of the signal, so the CCEP is accurately calculated. If the length is too small, then the scaling of the visualization will be off, and the calculation of detecting CCEPs will also be inaccurate.
====CCEPEpochLength====
Duration of time after the baseline and latency. Essentially the amount of time that is needed to view the CCEP.
Duration of time after the baseline and latency. Essentially the amount of time that is needed to view the CCEP.


===<u>''Counting settings''</u>===
===Trigger settings===
<gallery mode="packed" widths=250px heights=450px>
These settings are best used for stimulation trains, however they can be used to specify a software trigger for the stimulation onset as well. If this used for a train, PreStimLength and PostStimLength should specify the length of the train. If it is used for software trigger, they should be the same as the Baseline and CCEP EpochLength.
File:CCEPCountingVisualization.png|The three counting parameters of the CCEP filter visualization. The yellow circles represent counting every third OnsetExpression, then the pink arrows display averaging every 5th number. The original plot is then held because HoldPlots is greater than 1.
====''SoftwareTrigger''====
</gallery>
If enabled, the filter will use the PreStim and PostStim Length parameters to define the shape of the output. This is helpful if the provided trigger is an estimate of the stimulation onset, because then the filter and save all the needed data to the output, where the python visualization can auto-detect the precise stimulation onset.
These parameters must be integers, they specify a quantity to count.  
====''PreStimLength''====
====EpochsToAverage====
If SoftwareTrigger is enabled, this will be the length of the saved baseline data.
Number of times the OnsetExpression is met to average together. The resulting average will then be displayed once the number is met. This is helpful if the OnsetExpression is frequently true within a short period of time.
====''PostStimLength''====
====OnsetPeriod====
If SoftwareTrigger is enabled, this will be the length of the post-baseline data. This should be the length of the train if you are visualizing a high frequency stimulation train.
Count every number of times the OnsetExpression is evaluated true. In other words, skip every OnsetPeriod - 1. This is helpful if you want to visualize a time range in which the OnsetExpression is met multiple times. If you are also averaging the plots, it will only average the signals specified by this period.
 
====HoldPlots====
===Counting settings===
The number of plots to hold. If it is 0 or 1, only the most recent signal will be shown. Any number higher, and that amount of signals will be shown. The most recent signal will always be white/yellow, while the others will be darker grey, with the oldest as the darkest.
These parameters must be integers as they specify a quantity to count.  
====''TriggerPeriodEnd''====
Enable this flag to pulse CCEPTriggered at the end of the period instead of the beginning. This can be used in combination with ''OnsetPeriod''.
====''EpochsToAverage''====
Average this number of CCEPs before sending it to Python to visualize. This is helpful if the OnsetExpression is frequently true within a short period of time, to lower the load on Python updating.  
====''OnsetPeriod''====
The period in which you expect the CCEPs to occur. This can be specified in time units or without units.
 
# Time units: The minimum time between detection of CCEPs. For example, if this is 2s, OnsetExpression will not be true for 2s after a sample that is is triggered. After 2 seconds, it will start being evaluated again.
# Without units: Skip one less than this number of CCEPs. For example, for high-frequency stimulation, the OnsetExpression might be true 50 times in 1 second. Therefore, you would want to set this number to 50. If you are also averaging the plots, it will only average the signals specified by this period.


===<u>''Visualization''</u>===
This is helpful if you want to visualize a time range in which the OnsetExpression is met multiple times.
<gallery mode="packed" widths=250px heights=450px>
File:CCEPVisualizationImg.png|A demonstration of the three visualization parameters of the CCEP filter. The specific channels are chosen through the Source parameter Online Processing.
</gallery>
====VisImageWidth====
The total width in pixels that the CCEP visualization will fill. Each sub-window will be adjusted accordingly.
====VisImageHeight====
The total height in pixels that the CCEP visualization will fill. Each sub-window will fill a portion.
====VisMaxWindows====
The maximum amount of windows that are desired to be visualized. To choose which windows are visualized, use the parameter in the Source tab, in the ''Online Processing'' section, '''TransmitChList'''. This lists the channels that are sent to the SignalProcessing filter and on. If VisMaxWindows is less than the number of channels in this list (and non-zero), the first number of windows will be shown.


==See also==
==See also==
[[User Reference:Filters]], [[Contributions:SignalProcessing]]
[[User Reference:Filters]], [[Contributions:SignalProcessing]], [[Python Visualizations]], [[Contributions:PAC]]


[[Category:Contributions]]
[[Category:Contributions]]

Latest revision as of 18:40, 30 July 2025

An demo video of the CCEP Filter with VisualizeBCI2000.

Introduction

Cortico-cortical evoked potentials (CCEPs) are generated as a response to stimulation within the cortical zone. To best view this response, the CCEP filter time locks the signal to the stimulation and allows the user to view the CCEPS from every recording electrode. There are many adaptable parameters to include flexibility for a variety of experiments.

Location

http://www.bci2000.org/svn/trunk/src/contrib/SignalProcessing/CCEPFilter

Versioning

Authors

  • Will Engelhardt (engelhardt@neurotechcenter.org)

Version History

  • 05/17/2023 - First working version

Source Code Revisions

  • Initial development: 7199
  • Tested under: 7303
  • Known to compile under: 7364
  • Broken since: --

Installation

See the Installation section on the Python Visualization page to see how to install the necessary packages and how to run demo files! Once that is all set up, you can return to this page to understand the specific parameters for the CCEPs.

Processing Details

The CCEP filter has two parts - a C++ filter in the Signal Processing pipeline, and the Python filter outside of the BCI2000 chain.

  1. BCI2000 filter
    • The filter receives the raw data from the Source module, then time-locks the data based on the user-defined CCEP parameters.
    • When all the data is collected, the state CCEPTriggered will pulse to let the Python filter know data is ready to be visualized.
  2. Python filter
    • Data is received through the SignalSharing feature. Specifically, the parameter ShareCCEPFilter is set to a valid port to share the data.
    • When CCEPTriggered is true, the incoming data is further processed and plotted. The only processing this filter does is to calculate the area under the curve (AUC), then determine which channels have a significant response based on the threshold standard deviation set by the user. The raw values are given in the table, and the top most significant channels are visually shown.
    • If Sort Channels is enabled, all the significant channels will be at the top. They are then organized based on their original order, to maintain electrode grouping. If they were sorted purely on highest to lowest AUC, it would be very difficult to tell which general areas are responding.

Python Settings

Threshold (STD)

This defines the threshold to determine a CCEP response. This value should be adjusted to maximize the number of significant channels shown, while not going over. If the value is too low, there will be more significant channels than visualized windows. This would only show you the electrodes which were originally at the top of the list, which might lead you to disregard the bottom electrodes.

Max Windows

The maximum amount of windows displayed. If you desire all the transmitted channels to be shown, set this max value to the number of channels or greater.

x0

The minimum shown value of the x-axis for all windows, in milliseconds. You can set this to a negative value to show baseline data before the CCEP.

Hold Plots

The number of plots to keep on a window. Set to 0 to hold all plots, until manually cleared with "Clear Figures".

Average CCEPs

Enable to display the average of the plots in addition to the single trials.

Sort Channels

Disable to keep the order of the channels unchanged. If there are more transmitted channels than windows shown, the shown windows will simply be the first in the list.

Save figures on refresh

Currently broken. Enable to make sure the visualizations are never lost, as every time the plots are cleared they would first be saved. This can get cumbersome with many saved files.

BCI2000 Parameters

OnsetExpression

Expression that defines the stimulus onset. Ideally, this should be a hardware trigger to have the most precise time-locking. This expression should be true when the stimulation is triggered. See the Expression syntax page for more information.

Duration settings

These parameters all should have units of time (e.g. milliseconds), or auto.

BaselineEpochLength

The duration of desired baseline data. This baseline data is helpful for visualizing the data before the stimulation, and is also used to calculate the average signal value from which the threshold is calculated.

CCEPEpochLength

Duration of time after the baseline and latency. Essentially the amount of time that is needed to view the CCEP.

Trigger settings

These settings are best used for stimulation trains, however they can be used to specify a software trigger for the stimulation onset as well. If this used for a train, PreStimLength and PostStimLength should specify the length of the train. If it is used for software trigger, they should be the same as the Baseline and CCEP EpochLength.

SoftwareTrigger

If enabled, the filter will use the PreStim and PostStim Length parameters to define the shape of the output. This is helpful if the provided trigger is an estimate of the stimulation onset, because then the filter and save all the needed data to the output, where the python visualization can auto-detect the precise stimulation onset.

PreStimLength

If SoftwareTrigger is enabled, this will be the length of the saved baseline data.

PostStimLength

If SoftwareTrigger is enabled, this will be the length of the post-baseline data. This should be the length of the train if you are visualizing a high frequency stimulation train.

Counting settings

These parameters must be integers as they specify a quantity to count.

TriggerPeriodEnd

Enable this flag to pulse CCEPTriggered at the end of the period instead of the beginning. This can be used in combination with OnsetPeriod.

EpochsToAverage

Average this number of CCEPs before sending it to Python to visualize. This is helpful if the OnsetExpression is frequently true within a short period of time, to lower the load on Python updating.

OnsetPeriod

The period in which you expect the CCEPs to occur. This can be specified in time units or without units.

  1. Time units: The minimum time between detection of CCEPs. For example, if this is 2s, OnsetExpression will not be true for 2s after a sample that is is triggered. After 2 seconds, it will start being evaluated again.
  2. Without units: Skip one less than this number of CCEPs. For example, for high-frequency stimulation, the OnsetExpression might be true 50 times in 1 second. Therefore, you would want to set this number to 50. If you are also averaging the plots, it will only average the signals specified by this period.

This is helpful if you want to visualize a time range in which the OnsetExpression is met multiple times.

See also

User Reference:Filters, Contributions:SignalProcessing, Python Visualizations, Contributions:PAC