dongqunxi / mne-python

MNE : Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
http://martinos.org/mne/
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

The issue 'Data and noise CSDs should be calculated at identical frequencies' #1

Closed dongqunxi closed 10 years ago

dongqunxi commented 10 years ago

Dear All, @dengemann When I try to run the plot_dics_source_power.py

fwd = mne.make_forward_solution(epochs.info, mri=mri, src=src, bem=bem,
fname=None, meg=True, eeg=False, mindist=5.0,
n_jobs=2, overwrite=True)
fwd = mne.convert_forward_solution(fwd, surf_ori=True)
data_csds = compute_epochs_csd(epochs, mode='multitaper', tmin=0.06, tmax=0.17,
fmin=15, fmax=30, fsum=False)
noise_csds = compute_epochs_csd(epochs, mode='multitaper', tmin=-0.11, tmax=-0.001, fmin=15, fmax=30, fsum=False)
#Compute DICS spatial filter and estimate source power
stc = dics_source_power(epochs.info, fwd, noise_csds, data_csds)

I met one issue as following:

/home/imenb101/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mne-0.8.git-py2.7.egg/mne/beamformer/_dics.pyc in dics_source_power(info, forward, noise_csds, data_csds, reg, label, pick_ori, verbose)
    325     for data_csd, noise_csd in zip(data_csds, noise_csds):
    326         if not np.allclose(data_csd.frequencies, noise_csd.frequencies):
--> 327             raise ValueError('Data and noise CSDs should be calculated at '
    328                              'identical frequencies')
    329

ValueError: Data and noise CSDs should be calculated at identical frequencies

dengemann commented 10 years ago

@dongqunxi make sure the time parameters amoubt to the same window lenght for noise and data csd. Or specify n_fft to make sure the same number of tapers is used. Let me know if that helps.

dongqunxi commented 10 years ago
data_csds = compute_epochs_csd(epochs, mode='multitaper', tmin=0.06, tmax=0.17,
                               n_fft=200, fmin=15, fmax=30, fsum=False)
noise_csds = compute_epochs_csd(epochs, mode='multitaper', tmin=-0.11, tmax=-0.00,
                                n_fft=200, fmin=15, fmax=30, fsum=False)
#Compute DICS spatial filter and estimate source power
stc = dics_source_power(epochs.info, fwd, noise_csds, data_csds)

@dengemann Yes, it did work. I have tried to use the same time window, it did not work. After I set the same 'n_fft', it worked. But I have another question: how large is appropriate for 'n_fft'?

dengemann commented 10 years ago

I have tried to use the same time window, it did not work.

that sounds weird to me ... should not be

After I set the same 'n_fft', it worked. But I have another question: how large is appropriate for 'n_fft'?

if you have more samples you can set higher n_fft, the higher your n_fft the better your frequency resolution. you should play with it. Keep in mind to increase this value to the power of 2.

dengemann commented 10 years ago

I have tried to use the same time window, it did not work.

the same time window length, I hope. The time window must not be the same but the number of samples should be identical. E.g. -1, 0.8 for noise and 0.8, 1.0 for data

dongqunxi commented 10 years ago

@dengemann I have checked, when I set the same time window, I got

len(data_csds)=2
len(noise_csds)=2
data_csds[0].frequencies=18.16
noise_csds[0].frequencies=18.49

It is not identical. If I want to control the frequencies changing, how to?

dengemann commented 10 years ago

Does this still result in an error?

dongqunxi commented 10 years ago

@dengemann After I adjust the epochs parameters as following, there is no errors in computing stc.

epochs = mne.Epochs(raw, events, 1, tmin, tmax, proj=True,
                    picks=picks, baseline=(None, 0), preload=True,
                    reject=dict(mag=4e-12))

But I met errors at:

/home/imenb/MEG-MRI_Scipts/Forward and Inverse Problem/temp.py in <module>()
     69     message = 'DICS source power at %0.1f Hz' %csd.frequencies[0]
     70     brain =stc.plot(surface='inflated', hemi='both', subjects_dir=subjects_dir,
---> 71                     time_label=message, figure=i)
/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_windows.pyc in __init__(self, *args, **kwargs)
    495             long style=DEFAULT_FRAME_STYLE, String name=FrameNameStr) -> Frame
    496         """
--> 497         _windows_.Frame_swiginit(self,_windows_.new_Frame(*args, **kwargs))
    498         self._setOORInfo(self)
    499 

PyNoAppError: The wx.App object must be created first!
dengemann commented 10 years ago

@dongqunxi that's another issue. You should not use the WX backend. Make sure to start ipython with the --qt flag. Can we close this?

dongqunxi commented 10 years ago

Ok, thanks! I will close it.

dengemann commented 10 years ago

ahhhsorry--- realized it was your repo :-)

dongqunxi commented 10 years ago

Haha, until now, I still don't familiar with the github environment. Sorry about my irregularities.

Best wishes, Qunxi Dong

2014-02-12 12:04 GMT+01:00 Denis A. Engemann notifications@github.com:

ahhhsorry--- realized it was your repo :-)

Reply to this email directly or view it on GitHubhttps://github.com/dongqunxi/mne-python/issues/1#issuecomment-34858688 .