this demo show the conherence of MEG and EMG,  the data was recored when a tips on screen for anticipants lift the left or right hand.

there are 151 channels of MEG and EMGlft  EMGrgt, we are going to test kind of conditation for conherence and see what kind of factor effect the performence of conherence caculation .

of coures , this demo use automatic artifact reject method to remove the EOG jump and muscle. which is kind of confusion on how to set up the parameter.

anyway  we follow the tutorial to see what the  idea of this coherence.


to study the oscillatory synchrony between two signals , on can computer the coherence, this is computed in the frequency domain by normalizaing the magnitude of summed cross spectral density between two singals by their respective power, for each frequency bin the conherence value is a number between 0 and 1 , the coherence values reflect the consistency of the phase difference between two signals at a given frequency.

Coherence 是个 0到1之间的数字,反应的是两个信号之间特定频率上的相位差的一致性。

计算的时候 是归一化交叉频谱密度。


% find the interesting epochs of data
cfg = [];
cfg.trialfun                  = 'trialfun_left';
cfg.dataset                   = 'SubjectCMC.ds';
cfg = ft_definetrial(cfg);

% detect EOG artifacts in the MEG data  处理EOG杂讯
cfg.continuous                = 'yes';
cfg.artfctdef.eog.padding     = 0;
cfg.artfctdef.eog.bpfilter    = 'no';
cfg.artfctdef.eog.detrend     = 'yes';
cfg.artfctdef.eog.hilbert     = 'no';
cfg.artfctdef.eog.rectify     = 'yes';
cfg.artfctdef.eog.cutoff      = 2.5;
cfg.artfctdef.eog.interactive = 'no';
cfg = ft_artifact_eog(cfg);

% detect jump artifacts in the MEG data
cfg.artfctdef.jump.interactive = 'no';
cfg.padding                    = 5;
cfg = ft_artifact_jump(cfg);

% detect muscle artifacts in the MEG data
cfg.artfctdef.muscle.cutoff      = 8;
cfg.artfctdef.muscle.interactive = 'no';
cfg = ft_artifact_muscle(cfg);

% reject the epochs that contain artifacts
cfg.artfctdef.reject          = 'complete';
cfg = ft_rejectartifact(cfg);

% preprocess the MEG data
cfg.demean                    = 'yes';
cfg.dftfilter                 = 'yes';                   = {'MEG'};
cfg.continuous                = 'yes';
meg = ft_preprocessing(cfg);