stimulation based epoching

Making & changing box plugins and external apps
Post Reply
ntarrin
Posts: 18
Joined: Mon May 02, 2011 2:07 pm

stimulation based epoching

Post by ntarrin »

Hello,

While modifying the brain invaders, I found that the signal corresponding to the first flash was not epoched by its corresponding stimulation based epocher. Waited stimulation and signal are there, but debuging showed me that, in stimulation based epoching box, the offset sample count was not initialised the very first call to this box, thus "samples to skip" is high, and the box does not epoch the signal even if it has the right stimulation.

I managed to make it work by forcing samplesToSkip to 0 (see code below), but I'm not very happy with this solution as I'm not sure of the consequences (I don't get a whole understanding there...).

Could you lead me to a better solution ?
Thanks.
Nicolas.

Code: Select all

boolean CAlgorithmStimulationBasedEpoching::process(void)
{
	if (isInputTriggerActive(OVP_Algorithm_StimulationBasedEpoching_InputTriggerId_Reset))
	{
		m_ui64ReceivedSamples=0;
		m_ui64SamplesToSkip=0; // *** instead of : m_ui64OffsetSampleCount ***
	}

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: stimulation based epoching

Post by yrenard »

Dear Nicolas,

can you tell me how close to the start the first stimulation comes ?

Are you using an offset so that you select signal before the actual stimulation ?

Yann

ntarrin
Posts: 18
Joined: Mon May 02, 2011 2:07 pm

Re: stimulation based epoching

Post by ntarrin »

Hi Yann,

The first stimulation comes something like 30s after the scenario's start. At that time, the signal is available for the stimulation based epoching box. The boxes configurations are :

epoch duration : 0.600000
epoch offset : 0.000000
stimulation to epoch from : OVTK_StimulationId_Label_xx (with xx from 01 to 0C)

It looks like the epoching algo has not been initialised yet when the first stim arrives. I'm investigating this.

Nicolas.

ntarrin
Posts: 18
Joined: Mon May 02, 2011 2:07 pm

Re: stimulation based epoching

Post by ntarrin »

Just giving an update on my investigation :

Looking at log and stimulation listener, I get this :

[WARNING] At time 161195491328 (0x2588000000) <Box algorithm::stim based epoch input> For input 0 (0x0) with name Stimulation stream 1 got stimulation 32771 (0x8003)[OVTK_StimulationId_SegmentStart] at date 160674725992 (0x2568f5c068) and duration 0 (0x0)
[WARNING] At time 161195491328 (0x2588000000) <Box algorithm::stim based epoch input> For input 0 (0x0) with name Stimulation stream 1 got stimulation 33026 (0x8102)[OVTK_StimulationId_Label_02] at date 160674725992 (0x2568f5c068) and duration 0 (0x0)
[WARNING] At time 161195491328 (0x2588000000) <Box algorithm::stim based epoch input> For input 0 (0x0) with name Stimulation stream 1 got stimulation 32780 (0x800c)[OVTK_StimulationId_VisualStimulationStop] at date 160889474355 (0x2575c28d33) and duration 0 (0x0)
[ INF ] At time 161229045760 (0x258a000000) <Box algorithm::Stimulation based epoching> Created new epocher at time 160674725992 (0x2568f5c068):160674725992 (0x2568f5c068):163251706369 (0x26028f5a01)

It looks like the stim based epoching initialisation happens after the stimulation has been received.

I'm looking why, any help welcomed :D

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: stimulation based epoching

Post by yrenard »

Dear Nicolas,

one of your trace message comes from a stimulation listener box, the other one from a stimulation based epoching. It is not guaranteed how those two boxes are scheduled if you did not set their priorities manually (which I doubt as this functionality is not currently exposed to the Designer).

In order to get help, can you tell us what you are trying to achieve ? I actually don't catch the relation between this question and your initial problem.

Yann

ntarrin
Posts: 18
Joined: Mon May 02, 2011 2:07 pm

Re: stimulation based epoching

Post by ntarrin »

Hi Yann,

Sorry if this was confusing, I'm going to try to make it simple :)

Giving a summary of the code I'm focusing on may help :

Code: Select all

boolean CBoxAlgorithmStimulationBasedEpoching::process(void)
(...)
l_oEpocher.m_pEpocher->initialize();                                             // sets m_ui64OffsetSampleCount to 0.
(...)
l_oEpocher.m_pEpocher->process(OVP_Algorithm_StimulationBasedEpoching_InputTriggerId_Reset);    // when we enter this, I found m_ui64OffsetSampleCount having a crazy value
(...)
l_oEpocher.m_pEpocher->process(OVP_Algorithm_StimulationBasedEpoching_InputTriggerId_PerformEpoching);  // thus, when this is called, the epoching is not performed
This is true the very first time, for the first stim. After that, everything run smoothly.

There's something I'm missing at initialisation time... Could you give a hand ?

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: stimulation based epoching

Post by yrenard »

Dear Nicolas,

I suspect that you have an "early" stimulation and that l_ui64OffsetSampleCount would be less than zero (being unsigned, that results in so called crazy value :) ).

That may be a bug but can you confirm that this is happening in your case (see line 222 of ovpCBoxAlgorithmStimultionBasedEpoching.cpp) ?

Sorry for late reply btw,
Hope this helps,
Yann

ethomas
Posts: 1
Joined: Fri Oct 07, 2011 11:56 am

Re: stimulation based epoching

Post by ethomas »

Hello,

I am experiencing a bug with the stimulation based epoching script: When using negative offset values, the data is outputted with a delay. For example, 2s epoch with -2s offset, should return the data immediately after the stimulation occurs, however the output data does not appear on the stream until 2s later (the length of the epoch). Trying various numbers for duration and offset revealed that the delay is always the duration of the epoch, regardless of the offset value.

I have reproduced this bug with both the gdf_reader and keyboard stimulation inputs, and on multiple machines. I believe the epoched data is timed correctly, implying that the epoching procedure itself is correct, but that the output is handled incorrectly.

Any and all assistance would be welcome,
Eoin

lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: stimulation based epoching

Post by lbonnet »

Hi Eoin!

Sorry for the late reply!
Indeed the Stimulation based epoching is producing the epoch with a delay, equal to the epoch duration.
This behavior is constant, for positive or negative offsets. In the negative case it's obviously a problem.

I added a bug report on the bugtracker. Don't hesitate to add a note if you want to give more precisions.

We will try to correct this a.s.a.p.

Laurent-
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

Post Reply