how to run Box processing on saved EEG to test and refine pipeline

Concerning processing components: filters, file load/save, visualizations, communication ...
KJeffrey
Posts: 74
Joined: Wed Jul 20, 2022 6:47 pm

how to run Box processing on saved EEG to test and refine pipeline

Post by KJeffrey »

So far, in learning OPenViBE, I have not seen how to run Box processes on previously recorded EEG files in anything but "real time", by which I mean you have to wait for the EEG to flow through a scenario at the same speed it was recorded. I would like to test the computational steps in a scenario in "computer time", that is, as fast as the computer can calculate. This is how one would develop any processing pipeline using a procedural language. I have developed our pipeline using Matlab, for instance, and have tried to port it to OpenViBE, but in order to test it and play around with it I really need to have it run as fast as it does under Matlab.

I am hoping this is possible, and probably just need to find the right documentation, or an example to follow.

-Jeff

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

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by Thomas »

Hi Jeff,

Luckily you are indeed not the only one wanting to do this and it is therefore possible in OpenViBE.

When you want to run a scenario reading a file for offline processing, instead of pressing the play button you can click on the double-arrow on the right side of the play button. This will execute the scenario as fast as possible.

Kind regards,
Thomas

KJeffrey
Posts: 74
Joined: Wed Jul 20, 2022 6:47 pm

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by KJeffrey »

Outstanding! I will try this right away.
Thanks,
-Jeff

KJeffrey
Posts: 74
Joined: Wed Jul 20, 2022 6:47 pm

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by KJeffrey »

I tried to run the attached scenario and it ran overnight and was still running in the morning.
smoke_1.xml
(25.84 KiB) Downloaded 571 times
I wish to have an output that gives me the classification results after training.

I do not understand the function of the "Play Controller" box.

I went back and hovered over the double-arrow icon and it states: run the scenario in a loop, un-check to stop loop". This is not what I want.

Please advise how to achieve my goal.

-Jeff
Attachments
smoke_1 scenario 2023-08-01_21-10-01.png
smoke_1 scenario 2023-08-01_21-10-01.png (31.27 KiB) Viewed 21501 times

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

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by Thomas »

I Jeff,

Sorry my previous reply may have been ambiguous. By "double-arrow" button, I was referring to the button in between the "play" and the "double blue arrows" button. If you hover over it, it will say "executes the scenario as fast as possible".

The player Controller box, is configurable to do an action upon receiving a specific stimulation. For exemple, STOP the scenario when receiving the stimulation "OVTK_StimulationId_TrainCompleted".

The Classifier trainer box happens to output "OVTK_StimulationId_TrainCompleted" when the data training is complete, so if the Player Controller is configured as specified in the previous sentence, it should stop the scenario automatically.

Hope this helps,
Thomas

KJeffrey
Posts: 74
Joined: Wed Jul 20, 2022 6:47 pm

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by KJeffrey »

Thomas,
I cannot figure out how to set the [Player Controlle]r to "STOP". Its Box documentation is no help.

Also, how do I verify that the [Classifier Trainer] is truly set to output what you say it will?

-Jeff

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

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by Thomas »

Yes indeed that box documentation is quite light.

If you double click on the box, you will see its two settings:
  • The first one is the stimulation it is expecting in order to perform an action, here you want to write "OVTK_StimulationId_TrainCompleted"
  • The second one is the action to perform, you want to select "Stop"
The Classifier Trainer box is hard coded to send "OVTK_StimulationId_TrainCompleted" upon training completion. If you want to verify it, you can connect the box "StimulationListener" on its output. The StimulationListener box will simply print a log entry for each stimulation it receives, allowing you do some debugging.

Note that the Classifier Trainer will only send that Training completion stimulation once it has finished the training. For this to happen, the box needs to be told to train on the received data. The training is trigger by sending the box the following stimulation: OVTK_StimulationId_Train.
This trigger stimulation is set as the first parameter of the box in you scenario. Is that stimulation present at the end of the file you are reading ?

Let met know how you get on with this.

Thomas

KJeffrey
Posts: 74
Joined: Wed Jul 20, 2022 6:47 pm

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by KJeffrey »

Thomas,

I did what you suggested. No, the EEG file does not have the OVTK_StimulationId_Train stimulation at the end. We ahd no clue about the need for it.

Is there a way to add it to the end of the file we already have?
Or any way to simulate it in the scenario?

How do we make sure it is there going forward?

Thanks,
-Jeff

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

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by Thomas »

Jeff,

There are two options,
  • First the easiest, is there a stimulation at the end of your EEG data ? It doesn't matter which stimulation it is, but it is important that it is unique in the stream and marking the end of the stream.
    If there is such a stim at the end of the file, then you can use it as the trigger for the Classifier Trainer. To do so, double-click on the Classifier-Trainer box and change the first parameter "Train Trigger" to the corresponding stimulation.
  • The second option consists in generating the OVTK_SimulationId_Train stimulation when the EEG signal finishes.
    To do so, you can add to your scenario the "Timeout" box. This box can generate a stimulation when it stops receiving signal.
    You want to connect its input to the signal output of the generic stream reader, and its output to the stimulation input of the Classifier Trainer Box.
    Then modify its settings (double-click on the box) to:
    • Timeout Delay: 1
    • Output Stimuation: OVTK_StimulationId_Train
Version 1 is a bit less work, but version two might be more robust if you are not sure to have an end stimulation.

Hope this helps,
Thomas

KJeffrey
Posts: 74
Joined: Wed Jul 20, 2022 6:47 pm

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by KJeffrey »

Thomas,

I will try to absorb all of this and apply it today.

Thanks for the detailed suggestions.

-Jeff

KJeffrey
Posts: 74
Joined: Wed Jul 20, 2022 6:47 pm

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by KJeffrey »

Thomas,

I mentioned before that there is nothing at the end of the EEG data file as we had not knowledge that it was needed.
I tried the second suggestion, here is the result:
smoke_1 2023-08-07_21-41-56.png
smoke_1 2023-08-07_21-41-56.png (58.59 KiB) Viewed 21422 times
Thanks for your continuing patience with me.

-Jeff

KJeffrey
Posts: 74
Joined: Wed Jul 20, 2022 6:47 pm

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by KJeffrey »

Here is the scenario,
-Jeff
Attachments
smoke_1.xml
(27.8 KiB) Downloaded 556 times

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

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by Thomas »

Jeff,

I don't see well the whole error messages, but from what I can see, the Classifier box has tried to train on the received data and failed.

It is complaining of not having received enough data. The time of the log is at 3 seconds of running the scenario, with the Timeout box set at 1 second, it would appear that there is only 2 seconds of signal in the file you are reading.

Can you double check that there is more than 2 seconds of data in your OV file ?
Feel free to share the file so I can reproduce the issue on my machine if you want.

Thanks
Thomas

KJeffrey
Posts: 74
Joined: Wed Jul 20, 2022 6:47 pm

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by KJeffrey »

Thomas,

Please try the test file I made today, link to it in other thread.
Good luck,

-Jeff

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

Re: how to run Box processing on saved EEG to test and refine pipeline

Post by Thomas »

Hi Jeff,

The problem you are encountering here is due to the fact that the data you are playing is already epcohed and contains gaps of around a second, which trigger the Timeout box to send the Train stimulation.

I tried to set the timeout to 2 seconds, but it triggered again a bit later in the file since there must have been a bigger gap then.

Finally, with 3 seconds it went through.

As I mentioned in your other post, I think it would be better practice to play data which is raw (no filter/epoching) and reapply it in the scenarios so you have the best control on the data and its filtering.

Note that when I tried, that amount of data made the training pretty long and OpenViBE hang.

Kind regards,
Thomas

Post Reply