# Extract values from the 'plot\_psd' method

**URL:** <https://mne.discourse.group/t/extract-values-from-the-plot-psd-method/4408>\
**Category:** Support & Discussions\
**Created:** [February 14, 2022, 12:13pm UTC](https://mne.discourse.group/t/extract-values-from-the-plot-psd-method/4408 "2022-02-14T12:13:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![manfred1201](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@manfred1201](https://mne.discourse.group/u/manfred1201)\
**Post date:** [February 14, 2022, 12:13pm UTC](https://mne.discourse.group/t/extract-values-from-the-plot-psd-method/4408/1 "2022-02-14T12:13:47Z")

</div>

- MNE version: 0.24.1
- operating system: Windows 10

Hello!  
How can I extract the values from the raw.plot\_psd figure? I’ve seen others rasing the similar question and the answer is to use the psd\_welch method to calculate it manually.  
However I am really poor at the basic knowledges so I cannot fully understand the parameters of the method. Here is the code I tried my best with:

```python
raw.plot_psd(fmin=0,fmax=100)
psds,freqs=mne.time_frequency.psd_welch(raw,fmin=0,fmax=100)
plt.plot(psds[0], linewidth=0.25)
plt.show()

```

The output of the two figures are completely different, and I don’t know how to get the data as ndarray from plot\_psd figure. Can anyone help me to correct the code? Thanks very much!

fig1:plot\_psd

 ![fig1](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/c/cf756e6ba282889f9cb8b336f36dc6b8335e6985.png)

fig2:psd\_welch  
 ![fig2](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/6/656030469e19d767e5aba7b05abbc2476174a8d6.png)

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [February 16, 2022, 11:27am UTC](https://mne.discourse.group/t/extract-values-from-the-plot-psd-method/4408/2 "2022-02-16T11:27:49Z")

</div>

I might be mistaken, but I believe the difference comes from the Y-axis units. When using `.plot_psd()`, one of the arguments is `dB` to plot in `(amplitude**2/Hz (dB))`, while `mne.time_frequency.psd_welch` returns data in plain `(amplitude**2/Hz)` (I think, I actually never paid attention to this).

A second difference is in the argument `n_fft` which does not have the same default in both functions.
