# How interpret the time\_frequence.EpochsSpectrum().get\_data() output

**URL:** <https://mne.discourse.group/t/how-interpret-the-time-frequence-epochsspectrum-get-data-output/6660>\
**Category:** Support & Discussions\
**Created:** [April 4, 2023, 6:28am UTC](https://mne.discourse.group/t/how-interpret-the-time-frequence-epochsspectrum-get-data-output/6660 "2023-04-04T06:28:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hugues1273](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/hugues1273/32/2423_2.png) [@Hugues1273](https://mne.discourse.group/u/Hugues1273)\
**Post date:** [April 4, 2023, 6:28am UTC](https://mne.discourse.group/t/how-interpret-the-time-frequence-epochsspectrum-get-data-output/6660/1 "2023-04-04T06:28:45Z")

</div>

Dear all,

I am currently making some tests with MNE on 3 random channels. I wanted to compute PSD of two populations and compare these two populations.  
I thought to use the following line code to do that:  
`psds, freqs = mne.time_frequency.EpochsSpectrum(Epochs, "welch", fmin = 2, fmax = 100, tmin = 0, tmax = 30, picks = "eeg", proj = False, n_jobs = 1).get_data(return_freqs = True)`

However, it returns a list of 5 times 3 lists looking like that:

```python
[
[[1 2 3 4...] [1 2 3 4...] [1 2 3 4...]] 
[[1 2 3 4...] [1 2 3 4...] [1 2 3 4...]] 
[[1 2 3 4...] [1 2 3 4...] [1 2 3 4...]]
[[1 2 3 4...] [1 2 3 4...] [1 2 3 4...]]
[[1 2 3 4...] [1 2 3 4...] [1 2 3 4...]]
]
[2 4 6... 98 100]

```

Each individual list contains 50 elements.  
How can interpret this? Why there is 5 lists of lists? why there 50 elements in each lists (I guess it is for the frequencies)? What represent the values in each list? Does each individual list correspond to one channel, but why 5 times?  
Based on these data, on could I compare my different populations according to the different frequency bands (delta, alpha…)? I guess the very last list (from 2 to 100) is for the different frequencies?

Sorry for these questions,

Best regards,

Hugues

PS: of course the values insides the lists are not the real ones, just for the illustration

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [April 7, 2023, 10:36pm UTC](https://mne.discourse.group/t/how-interpret-the-time-frequence-epochsspectrum-get-data-output/6660/2 "2023-04-07T22:36:23Z")

</div>

At the top of [the docstring of the EpochsSpectrum class](https://mne.tools/stable/generated/mne.time_frequency.EpochsSpectrum.html) it says:

> **Warning** The preferred means of creating Spectrum objects from Epochs is via the instance method [`mne.Epochs.compute_psd()`](https://mne.tools/stable/generated/mne.Epochs.html#mne.Epochs.compute_psd). Direct class instantiation is not supported.

Please use that API instead. As for the output of the `EpochsSpectrum.get_data()` method: It will return an array of shape `(n_epochs, n_channels, n_frequency_bins)`, and optionally also an array giving the center frequencies (in Hz) of the frequency bins. Your pasted output looks reasonable; it suggests you have `n_epochs=5`, `n_channels=3`, and `n_frequency_bins=50`. The data values are “Spectral power in that epoch in that channel in that frequency bin”

---

<div class="post-metadata">

**Author:** ![Hugues1273](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/hugues1273/32/2423_2.png) [@Hugues1273](https://mne.discourse.group/u/Hugues1273)\
**Post date:** [April 10, 2023, 2:48pm UTC](https://mne.discourse.group/t/how-interpret-the-time-frequence-epochsspectrum-get-data-output/6660/3 "2023-04-10T14:48:10Z")

</div>

So cool!!  
Than you so much!!  
It is so clear for me now!

Thank you again, it helps a lot!

Hugues
