time-frequency analysis

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

time-frequency analysis

Post by KJeffrey »

I wish to replicate a time-frequency analysis using a continuous wavelet transform (CWT) which produces a running estimate of the spectrum at each time sample. Is there an existing Box or combination of Boxes that could do something similar?

Thanks,
-Jeff

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

Re: time-frequency analysis

Post by KJeffrey »

I have had no replies yet. Does no one use continuous time-frequency analysis?

-Jeff

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

Re: time-frequency analysis

Post by Thomas »

Hi Jeff,

I don't know if you've seen it already, but there is a Continuous Wavelet Analysis box in OpenViBE.

Here its documentation page: http://openvibe.inria.fr//documentation ... lysis.html

Hope this helps,
Thomas

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

Re: time-frequency analysis

Post by KJeffrey »

Perfect, I had not found this before.

I mocked up a test scenario, but do not know how to display or save the results to a file for review.

-Jeff

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

Re: time-frequency analysis

Post by Thomas »

The output of the CWT analysis is compatible with the StreamedMatrix stream type.

Therefore you can write each of the outputs of the Continuous Wavelet Analysis box by connecting it to a CSV File Writer box (for a human readable output), or any other file writer box.

The thing is that the file writer boxes are set to receive Signal on their input by default (pink arrow). You can modify this by right clicking on the file writer box, and navigating to: inputs->1: InputStream->configure. In the configure box that pops up, you can change the stream type to StreamedMatrix.
Once the change is applied, the color of the input should change to green, and it can be connected to the Continuous Wavelet Analysis box outputs.

Hope this helps,
Thomas

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

Re: time-frequency analysis

Post by KJeffrey »

Thomas,

This all worked as you described. Here is the current scenario:
test_CWT 2023-08-03_16-37-17.png
test_CWT 2023-08-03_16-37-17.png (18.96 KiB) Viewed 47235 times
For this iteration I just selected the "smoking pic" epochs. I ran it but of course it used all the epochs and created huge CSV files that I could not open. How would I go about just selecting one epoch?

I used the default settings of Morlet wavelets and changed the highest frequency to 80 Hz, and the frequency spacing to 1.0. That was not acceptable, so I put the freq-spac back to 12.6 and got no complaint. I need to compare these parameters to the Matlab version I was using.Do you happen to know what the definition of the frequency spacing parameter is?

I see that I can use Doc_BoxAlgorithm_InstantBitmap3DStream to visualize the results, so I will try that.

-Jeff
Attachments
test_CWT.xml
(29.75 KiB) Downloaded 1328 times

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

Re: time-frequency analysis

Post by KJeffrey »

Addendum - where do I find documentation on the Doc_BoxAlgorithm_InstantBitmap3DStream?
-Jeff

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

Re: time-frequency analysis

Post by Thomas »

Hi Jeff,

I see the epochs are generated on the OVTK_StimulationId_Number_03 stimulation. I guess there are quite a few in the data file.
If you want the CWT to be calculated on the first epoch only, you could put in place a mecanism to stop the scenario when reaching the second epoch.

To do so, you can add the "Stimulation Validator" box and a "Player Controller" box, with the following connections and settings:
  • Stimulation Validator:
    • input: connected to the stimulation output of the generic stream reader
    • output: connected to the input of the Player Controller box
    • setting Stimulation to count:OVTK_StimulationId_Number_03
    • setting Number for validation: 2
  • Player Controller box:
    • input: connected to Stimulation Validator output
    • setting Stimulation Name: OVTK_StimulationId_Number_03
    • setting Action to perform: Stop
This mecanism will stop the scenario on the before the second epoch could be processed.

Here is Instant Bitmap 3D Stream box documentation, but this one is really not helpful unfortunately.

And for the frequency spacing parameter of the CWT, I honestly do not know. Have you looked at the paper cited at the very end of the documenation page ?

Hope this helps,
Thomas

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

Re: time-frequency analysis

Post by KJeffrey »

Hi Thomas,

I think I did the steps correctly, and here is what happened:
test_CWT 2023-08-07_21-41-12.png
test_CWT 2023-08-07_21-41-12.png (43.77 KiB) Viewed 47215 times
-Jeff

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

Re: time-frequency analysis

Post by KJeffrey »

Forgot the scenario XML.
-Jeff
Attachments
test_CWT.xml
(26.26 KiB) Downloaded 1277 times

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

Re: time-frequency analysis

Post by Thomas »

Hi Jeff,

What I can see from your screenshot is that the pipeline was too demanding and the real-time was not managed.

I tested the scenario on some data I have here, with 96 channels, but could not reproduce the latency issue.
What sampling frequency are you using in your data acquisition ?

Would you be able to share the EEG file you used to run the scenario ?

Thanks,
Thomas

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

Re: time-frequency analysis

Post by KJeffrey »

Hi Thomas,

Thanks for responding last Friday. I was travelling so was not able to respond until now. I created a test file that is shorter than the one I tried before. Two versions were created - OpenViBE and BrainVIsion. Here is a DropBox download link for the OV version. I examined the BV version in EEGlab, and it has 15 trials and lasts about 147 seconds. Sample rate of 500 frames/sec.

https://www.dropbox.com/scl/fo/iuxmy5qg ... 93tai&dl=0

-Jeff

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

Re: time-frequency analysis

Post by Thomas »

Hi Jeff,

Despite the time delay, the process went through and the csv file was created.

However, the CSV file seems to be corrupted and I could not open it.

There reason it is happening is the because the file you are playing is already epoched and there are gaps between the epochs, and re-epoched again the scenario... I didn't have time to dig more, but I wouldn't be sure of the result of such epoching mechanisms.

It would be better to play a continuous data file, and apply the epoching needed in the scenario only.

Kind regards,
Thomas

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

Re: time-frequency analysis

Post by KJeffrey »

see my reply to the other thread

Post Reply