requesting support - Power Spectra Interactive model

58 views
Skip to first unread message

Pragha

unread,
Aug 17, 2021, 9:33:45 AM8/17/21
to tvb-...@googlegroups.com
Dear TVB user,
I tried to calculate the power spectrum for the simulated data. Please find the attachment of my code.  I guess that I have defined all the required parameters but I do get errors while executing. Could some help where I went wrong?

Thank you,
Pragha
PowerSpectrum.pdf

Julie Courtiol

unread,
Aug 17, 2021, 12:14:35 PM8/17/21
to tvb-...@googlegroups.com
Dear Pragha,

The error informs you there is a shape problem with your data. Indeed, the TimeSerieRegion requires data in TVB format, i.e., 4D:

TAVG = TAVG[:, numpy.newaxis,:,numpy.newaxis]

Then, you can define

tsr.data = TAVG

Best,
Julie


Dr. Julie Courtiol
Scientific Lab Manager
Brain Simulation Section 
Charité Universitätsmedizin Berlin

Le 17 août 2021 à 15:33, Pragha <praa...@gmail.com> a écrit :


--
You received this message because you are subscribed to the Google Groups "TVB Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tvb-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tvb-users/CALEM43kE5fXVCpeJ9KMzTEYs%2Bjox2R%2BB9vS4FTxeUmWV2nyERw%40mail.gmail.com.
<PowerSpectrum.pdf>

Pragha

unread,
Aug 19, 2021, 8:43:45 AM8/19/21
to TVB Users

Thank you. But it is showing the same error after converting the data into 4d. Do I need to check something ?

Julie Courtiol

unread,
Aug 19, 2021, 10:30:12 AM8/19/21
to tvb-...@googlegroups.com
Hi Pragha,

Try with this:

psi = ps_int.PowerSpectraInteractive()
psi.time_series=tsr
psi.period=0.001 #s

Be careful, the tsr sampling period is in ms.

Also, I advise you to separate your code in several cells to debug it and see where the error is.

---
Best regards,

Julie Courtiol





Julie Courtiol

unread,
Aug 19, 2021, 4:04:40 PM8/19/21
to tvb-...@googlegroups.com
Dear Pragha,

I had a deeper look into the code and found why the function (psi.configure) returns an error. I will give you the correction below (and the file to replace in your tvb folder).

See also some comments on your code.

[4]: You don't need to define S, C and dS.
They were only defined for building the phase plane in the tutorial. Here, as you can see you are not using these variables.

[5] Úseless as you are already running the simulation in the previous cell (>> (time, data), = sim.run())

[14] The sampling period is wrong. It is also in ms!

#Create a tvb TimeSeries object
tsr = TimeSeriesRegion(connectivity=con,
                       data=tavg,
                       sample_period=sim.monitors[0].period)
tsr.configure()

Also, to identify the error easily, I advise you to separate your code lines in separated cells.

For psi, you need to define it as the TimeSeries above:

#Create and launch the interactive visualiser
psi = ps_int.PowerSpectraInteractive()
psi.time_series=tsr

For the psi.configure(), I have implemented some corrections in the code
line 159: convert the sampling period in second for further use 
lines 328 and 352: seg_tptsstarts and nfreq are float and need to be converted in integer

When you then run your notebook, you should obtain a similar figure

PS_Pragha.png

Best,
Julie
---
Best regards,

Julie Courtiol




power_spectra_interactive.py

Pragha

unread,
Aug 20, 2021, 8:43:11 AM8/20/21
to tvb-...@googlegroups.com

Dear Dr. Julie Courtiol,
Many thanks for the support. 

Best,
Pragha


You received this message because you are subscribed to a topic in the Google Groups "TVB Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tvb-users/3Phv80LLIb0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tvb-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tvb-users/CALsG46-TmRwL1KitdCv34Rq8bTXtWUBR%2BstmhPO7%3DcdAdpFF5g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages