Running FFT on raw data

hello everyone iam asking about this error (All picks must be < n_channels (14), got 14), i want to filter it using FFT and when run code i got this error.
This is my code:
from pathlib import Path
import matplotlib.pyplot as plt
import mne
import numpy as np
from scipy.fftpack import fft, ifft

fname = “C:\Users\hp\Desktop\data\Emotiv 30s EDF\S021\S021E04.edf”
raw =,preload=True)
X = fft(raw)

Hello @zainab and welcome to the forum!

You must not run fft() on raw, which is an MNE Raw object. fft() cannot work with this. It expects a NumPy array. You can get the raw’s data represented as a NumPy array by using the get_data() method. Here’s a working example:

# %%
import mne
from scipy.fftpack import fft

# Load sample data
sample_dir = mne.datasets.sample.data_path()
sample_fname = sample_dir / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
raw =, preload=True)

# Run FFT
X = fft(raw.get_data())

Best wishes,

1 Like

emphasized text

I don’t know, why don’t you just use the built-in functionality for all of that in MNE?


I want to plot the difference between 2 edf signal (concetration and relax) ,pds does not show the difference , so i use fft then i want to plot the psd but it does not work.
Is there any other plots to show the difference?

Hello, I don’t know what exactly you want to do. Can you please open a new topic and provide detailed information on what you’re trying to achieve, what you’ve tried, and where problems arise?


1 Like