Time based epoching Box

Working with OpenViBE signal processing scenarios and doing scenario/BCI design
Post Reply
illusion
Posts: 7
Joined: Tue Dec 27, 2022 11:24 am

Time based epoching Box

Post by illusion »

I am trying to understand how the "Time based epoching Box" works.
I use the classic MI-CSP Left vs. Right with Default parameters.

Number of trials in each class = 20
Device Sampling Frequency 125 Hz


Stimulation Based epoching
epoch duration = 4 sec
epoch offset = 0.5 sec

Time Based epoching
epoch 1 duration = 1 sec
epoch 1 intervals = 0.0625 sec

From what I understand the parameter epoch 1 intervals is the overlap?
I print the Signal output to a CSV file after each stage.

I notice that in the output of Stimulation Based epoching I get 10000 samples (4sec * 125Hz = 500 samples per trial).
500 samples * 20 = 10000 samples. So far so good.

In the output of Time Based epoching I get 135000 samples (125Hz * 1080 epochs =135000)
1080 epochs / 20 trials = 54 samples per trial
What I don't understand, however, is where this 54 comes from.

Since Stimulation epoch duration = 4 sec and epoch offset = 0.5 sec
So doesn't it mean that Time Based epoching segments each 4sec segment into 1sec chunks with an overlap of 0.0625 starting from 0.5sec to 4sec?

Start --------> End
0.5 ----------->1.5
0.5625 ------->1.5625
0.62 ---------->1.625
0.6875-------->1.6875
0.75----------->1.75
0.8125-------->1.8125
0.875---------->1.875
0.9375--------->1.9375
1---------------> 2
1.0625--------> 2.0625
1.125---------->2.125
1.1875--------> 2.1875
1.25 ---------> 2.25
1.3125--------> 2.3125
1.375----------> 2.375
1.4375---------> 2.4375
1.5 ------------> 2.5
1.5625----------> 2.5625
1.625----------> 2.625
1.6875 --------> 2.6875
1.75 -----------> 2.75
1.8125-----------> 2.8125
1.875-----------> 2.875
1.9375-----------> 2.9375
2-----------------> 3
2.0625----------->3.0625
2.125-----------> 3.125
2.1875-----------> 3.1875
2.25 -----------> 3.25
2.3125-----------> 3.3125
2.375-----------> 3.375
2.4375----------->3.4375
2.5 ----------->3.5
2.5625-----------> 3.5625
2.625----------->3.625
2.6875-----------> 3.6875
2.75 -----------> 3.75
2.812-----------> 3.8125
2.875-----------> 3.875
2.9375--------> 3.9375
3------------------> 4


This would give 41 samples per trial and not 54 but the console says 1080 epochs which means that it is indeed 54 samples (1080 epochs / 20 trials = 54 samples per trial)
Can someone explain to me how the 54 samples are obtained after Time based epoching?

Thomas
Posts: 211
Joined: Wed Mar 04, 2020 3:38 pm

Re: Time based epoching Box

Post by Thomas »

Hi illusion,

Thanks for the detailed message.

Indeed, numbers are not matching.

I just tried with the default data file provided with OpenViBE saving data in CSV files to count samples, and the counts are ok for me.
The Time Based Epoching is actually going from 0.5 to 4.5 seconds (starts at 0.5 and lasts 4), so it should give 49 samples. It's worth noting but it's still not matching the figures you have...

Could you share your data file, including the right/left stimulations so I can try to reproduce what you see ?

Thank you,
Thomas

illusion
Posts: 7
Joined: Tue Dec 27, 2022 11:24 am

Re: Time based epoching Box

Post by illusion »

Dear Thomas,

Thanks for the quick response.

Please, find the files in the following link: https://drive.google.com/file/d/1zGH1Nh ... sp=sharing

mi-csp-1-acquisition.xml is the scenario used to record EEG Data.
mi-csp-2-train-CSP.xml is the scenario used for CSP
mi-csp-3-classifier-trainer.xml is the scenario used for the classification
signals (folder) includes the EEG data from the acquisition (MI-csp-WET.ov), the CSP (csp-spatial-filter.cfg) and the classification model (motor-imagery-bci-config-classifier.cfg)
CSPfeatures (folder) includes the CSV files from the mi-csp-2-train-CSP.xml
ClassifierFeatures (folder) includes the CSV files from the mi-csp-3-classifier-trainer.xml scenario

Device used: OpenBCI + Daisy (16 channels)
125Hz sampling rate
32Sample count per sent block

If you want any further information please let me know.

Thanks in advance!

illusion
Posts: 7
Joined: Tue Dec 27, 2022 11:24 am

Re: Time based epoching Box

Post by illusion »

Dear Thomas,

Have you found out what is happening in my case?

Thomas
Posts: 211
Joined: Wed Mar 04, 2020 3:38 pm

Re: Time based epoching Box

Post by Thomas »

Hi illusion,

I looked at the data you sent me and understood what is going on.

Basically, there are more features than expected because the TimeBaseEpoching creates more epochs than excpected.
However this is not really a bug. This is due to the "epoching offset / sampling rate" ratio.

If I take the nice time list you made again:
Start --------> End
0.5 ----------->1.5
0.5625 ------->1.5625

This imply that there is a chunk of data starting at time 0.5625, however, it is not the case with a sampling rate of 128Hz (an epoch every 0.008s).
There is an epoch starting at 0.556s or 0.564s.

The TimeBasedEpoching decides to start the next epoch at 0.556s in order to have the 0.5625s into the epoch.
The epoch after will start 0.0625s after this, which would be 0.6185s (0.556+0.0625), and not at 0.062, and as it slides this way all the way to the end, we end up with more epochs than we would have thought.
The effective gap between the start of epochs is 0.056s and not 0.0625, so for 4s of signal from the StimBasedEpoching the TimeBasedEpoching produces 54 epochs ( 3/0.056 + 1), while in theory we were expecting 49 (3/0.0625 + 1).

However, if the box was to start the second epoch at 0.564s, then it would run out of data and get less epochs and less features than expected.

If you increase the sampling frequency, the ratio between the epoching offset and the sampling rate will reduce, and even though there is not necessarily a perfect alignment the gaps will be smaller and you will still get the expected amount of features.

I hope this makes sense, don't hesitate if something is not quite clear.

Cheers,
Thomas

Post Reply