<p><span style="padding: 3px 10px; border-radius: 5px; color: #ffffff; font-weight: bold; display: inline-block; background-color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;External Email - Use Caution&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p><p></p><div dir="ltr"><div dir="ltr"><div><div><div>Hi everybody!<br></div>I&#39;ve just started using MNE and I would like to do a time frequency analysis (mne.time_frequency.psd_welch) for all frequency bands with EEG and MEG data: delta 1-4 Hz, theta 4-7 Hz, lower and upper alpha in 7-13 Hz range and lower and faster beta in 13-30Hz range.<br></div>Using the script here below I can compute the psd for each frequency needed changing the fmin and the fmax, <b>except for the theta</b>. The script allows to analyse one recorded  Run on EEG and MEG channels with open eyes (YO) and closed eyes (YF). More precisely, this script runs well and I don&#39;t have any error message, but in the end the final file .mat is empty. I tried to change the n_fft, using 128 or 64, but nothing has changed. So I couldn&#39;t find out where I&#39;m going wrong and I can&#39;t understand where is the difference between the theta band script and the other ones.<br></div><div>Any suggestion or comments are really welcome!<br></div><div>Thank you very much!<br></div><div>Best,<br>Jasmina<br></div><br>This is the script that I used :<br>***************<br>dirs_f=[&#39;brain_rf01_s01&#39;]<br>suj_count = len(dirs_f)<br>i=0<br>while i&lt;suj_count:<br>    n=dirs_f[i]<br>    path1, dirs1, files1 = next(os.walk(data_path_BRF+n))<br>   <br>    for ch in dirs1:<br>        if ch.startswith(&quot;171&quot;): # faire attention a changer le date     <br>           path2, dirs2, files2 = next(os.walk(path1+&#39;/&#39;+ch))<br>           <br>           for file in files2:<br>               if file.endswith(&#39;corrected_mne.fif&#39;) and (file.startswith(&#39;run01&#39;)):<br>                   fname=path2+&#39;/&#39;+file<br>                   raw = mne.io.read_raw_fif(fname, preload=True)<br>                   info = mne.io.read_info(fname)<br>                   ev=mne.find_events(raw, output=&#39;step&#39;)<br>                 <br>                   tmin, tmax = 8, 180  # use the first 120s of data<br>                   <b>fmin, fmax = 4, 7  # look at frequencies band</b><br>                   n_fft = 2048  # the FFT size (n_fft). Ideally a power of 2<br>              <br>                   psd_picks = mne.pick_types(<a href="http://raw.info">raw.info</a>, meg=True, eeg=True, stim=False, eog=False, exclude=&#39;bads&#39;)<br>                   tmin=(ev[0][0]+20-raw.first_samp)/info[&#39;sfreq&#39;]<br>                   tmax=(ev[3][0]-20-raw.first_samp) /info[&#39;sfreq&#39;]<br>                   psd, freqs= psd_welch(raw, fmin, fmax, tmin, tmax, n_fft=256, n_overlap=0, n_per_seg=None, picks=psd_picks, proj=False, n_jobs=1, reject_by_annotation=True, verbose=None)<br>                   <br>                   filename, file_extension = os.path.splitext(fname)<br>                   filename_psd, file_extension_psd = os.path.splitext(file)<br>                 <br>                   psds = 20 * np.log10(psd) <br>                   ch_names=info[&#39;ch_names&#39;]<br>                   ch_names_meeg = [ch_names[ii] for ii in np.array(psd_picks)]<br>                   chan_types = [mne.io.pick.channel_type(info, ch) for ch in psd_picks ]<br>                   psd_name_04_07=path2+&#39;/&#39;+filename_psd+&#39;_YO_meg_04hz_07hz.mat&#39;<br>                   scipy.io.savemat(psd_name_04_07,{&#39;freq_04_07&#39;:psds[74:380]}) <br>                   psd_name_04_07=path2+&#39;/&#39;+filename_psd+&#39;_YO_eeg_04hz_07hz.mat&#39;<br>                   scipy.io.savemat(psd_name_04_07,{&#39;freq_04_07&#39;:psds[0:74]})<br>                  <br>                   <br>                   tmin=(ev[3][0]+20-raw.first_samp)/info[&#39;sfreq&#39;]<br>                   tmax=(raw.last_samp-raw.first_samp) /info[&#39;sfreq&#39;]<br>                   <br>                   psd, freqs= psd_welch(raw, fmin, fmax, tmin, tmax, n_fft=256, n_overlap=0, n_per_seg=None, picks=psd_picks, proj=False, n_jobs=1, reject_by_annotation=True, verbose=None)<br>                   <br>                   psds = 20 * np.log10(psd) <br>                   ch_names=info[&#39;ch_names&#39;]<br>                   ch_names_meeg = [ch_names[ii] for ii in np.array(psd_picks)]<br>                   chan_types = [mne.io.pick.channel_type(info, ch) for ch in psd_picks ]<br>                   psd_name_04_07=path2+&#39;/&#39;+filename_psd+&#39;_YF_meg_04hz_07hz.mat&#39;<br>                   scipy.io.savemat(psd_name_04_07,{&#39;freq_04_07&#39;:psds[74:380]})<br>                   <br>                   psd_name_04_07=path2+&#39;/&#39;+filename_psd+&#39;_YF_eeg_04hz_07hz.mat&#39;<br>                   scipy.io.savemat(psd_name_04_07,{&#39;freq_04_07&#39;:psds[0:74]} <br>    i=i+1<br>************************<br></div></div>