scenario lifecycle

Come here to discuss about OpenViBE in general!
Post Reply
joseph
Posts: 20
Joined: Wed Jun 12, 2013 1:33 pm

scenario lifecycle

Post by joseph »

Hi forum,

I'm trying to record a signal stream together with some stimulations into a Generic stream writer, and automatically append a specific stimulation at the end of the file when I stop the scenario, to be able to trigger the training of a Matrix classifier when reading the recorded file in a second scenario.

I'm receiving my stimulations from a python box, so I've been trying to append my specific stimulation from the box's uninitialize method, just before I send the OVStimulationEnd, but it doesn't seem to be written into the file.
The online doc for initialize, process, and uninitialize methods says "dummy method", which doesn't help much to understand when they are exactly called in the scenario lifecycle, but I was guessing that it should work because of the OVStimulationEnd being sent from there.

The Player Controller Box doesn't seem to be a useful alternative to address this case.
Is there some other box I've been missing, or is there no way to achieve this ?
It is not a big problem because I could send the specific ending stimulation from the same place I send the other ones, but it would help me in the process of iteratively testing my setup.

Thanks in advance,
Joseph

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

Re: scenario lifecycle

Post by Thomas »

Hi Joseph,

When pressing the Stop button, all boxes get uninitialized "at the same time", and there is no cascading.
Therefore when the python box uninitializes, the stim it sends to the Generic Stream Writer box is not received as the latter is also uninitializing.

And indeed using the Player controller box may not be of help as it will stop instantly the scenario and may not let the Writer Box insert the stimulation in the file.

However, you could use the Timeout box, that will trigger a stimulation when the signal is over to automate the stop procedure.
The python box could receive this stim, and then send the last stimulation that you want to append at the end of the file.
Shortly after the python box could send another stim of you choice to the Player controller in order to stop the scenario.

Hope I understood well what you wanted to do and that my message helps,

Let us know how you get on.

Cheers,
Thomas

joseph
Posts: 20
Joined: Wed Jun 12, 2013 1:33 pm

Re: scenario lifecycle

Post by joseph »

Hi Thomas,

Thanks for the clarification, you perfectly understood what I'm trying to achieve.
Indeed, the Timeout box (and the Keyboard Stimulator box, too) look like good solutions and should work in most cases.
And using a python box input to forward these stimulations is a very good idea.

However, I didn't expose the whole setup I'm trying to get to work here, which might enlighten some other issues I've run into :
This setup is a little unusual, I'm bypassing the OpenVibe acquisition server by using a python websocket client to receive concatenated signals from 10 headsets (hardware "forks" of OpenBCI developed by a company named Mentalista), and some stimulations from a UDP socket, to achieve "hyperscanning" of 10 users (the timing of stimulations is not critical so UDP is OK here).
Actually this is working pretty well, at least the recording of 10 x 16 electrodes at a 512 Hz rate + sparse stimulations for now, sent from a custom nodejs sinusoidal signals and stimulations generator I've written for tests purpose.
I'm not sure how far I will manage to go with 10 trained models trying to analyze the streams in real-time, though (soon to be tested).

Meanwhile, I tried to use a Keyboard Stimulator box and a Timeout box.
I tried to combine the stimulations with a Stimulation Multiplexer box, but I noticed some delay in the stimulations from the rightmost inlet, probably because I'm not dealing with dates in a perfect way in the python script, which has a 1 second buffer for smooth signal reconstruction.
So I tried to add a Stimulations input to the python box to pass stimulations from Timeout or Keyboard Stimulator boxes through.
The problem with this approach is that sooner or later I get "could not reach real-time" messages, and the specified delay value keeps growing, and I'm not sure what is causing this issue yet.
I just hope it's not that I'm already scratching the CPU limit ...OpenVibe reports about 90% system load while windows says 20% CPU usage.
Maybe I could address it by forcing several calls of the process function to catch up when needed ... I need to perform more tests to sort this out.
I will probably end up adding a timeout directly in my nodejs test program to send the ending stimulation for now.

Anyway, all these python based hyperscanning considerations will likely be a subject for another thread, because using Timeout / Keyboard Stimulator boxes and forwarding stimulations from the python box's input perfectly address my original question :)

Thanks a lot for answering,
Joseph

joseph
Posts: 20
Joined: Wed Jun 12, 2013 1:33 pm

Re: scenario lifecycle

Post by joseph »

Hi again,

I finally coded the timeout system in my python box and added a setting for it, so if it has a value <= 0 no timeout is performed, otherwise the value in seconds defines when the ending stimulation is sent out.

Concerning the "could not reach real-time" issue, I set the python box's clock frequency so 32 Hz instead of 64 Hz and all my problems disappeared.
I didn't give another try with the Timeout or Keyboard Stimulator boxes going through an input though, but I suspect that would also work fine now.

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

Re: scenario lifecycle

Post by Thomas »

Hi Joseph,

Thanks for the details and solutions you came up with.
I take note of CPU load display that indeed is not correlated with what windows sees, even though OpenViBE starts reporting time issues when this load reaches 80% and more.
Note that if you have a lot of console logs in the python script, it can quickly impact the performance too.

Your project sounds really interesting. Looking forward to hearing more about it.

Cheers,
Thomas

joseph
Posts: 20
Joined: Wed Jun 12, 2013 1:33 pm

Re: scenario lifecycle

Post by joseph »

Hi Thomas,

Thanks for the compliment !
I'll post here soon about the hyperscanning setup we are working on.
So far 10 riemannian classifiers fed with 48 channels each (16 electrode signals passing through 3 differents bandpass filters for alpha, beta and gamma, following Fabien Lotte's advice) are running smoothly :)
Right now I have a time based epoching of 2s with an interval of 1s just before processing for training and analysis, I'm about to check if I can get a higher processing rate without degrading the performances too much.

The displayed system load seems to deviate from what windows is reporting when the python script has difficulties to execute within one execution frame.
But I just checked again and now that the script has some room to run, the values look coherent (about 35% reported by OpenVibe vs 30% reported by task manager)
I do some logging, but not at a high rate (mostly logging stimulations), so I don't think the problem comes from there.

Cheers,
Joseph

Post Reply