Back to the main page.

Bug 3443 - coherence

Status CLOSED FIXED
Reported 2018-08-25 12:59:00 +0200
Modified 2018-10-09 12:36:00 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P5 normal
Assigned to: Jan-Mathijs Schoffelen
URL:
Tags:
Depends on:
Blocks:
See also:

Ash - 2018-08-25 12:59:21 +0200

Created attachment 869 please see demo for partial coherence When computing coherence of A and B with B as a partial channel the solution should be 0/0 - NaN according the paper where the formula is described. This however does not seem to be the case with the field trip version. Please see the attached simulation of partial coherence. I have also attached a modified version of the function spm_eeg_ft_multitaper_coherence_mod which does get to the right solution - 0 You may want to investigate this. Hope it helps Ash


Ash - 2018-08-25 13:00:36 +0200

Created attachment 870 partial coherence function


Jan-Mathijs Schoffelen - 2018-08-28 15:43:17 +0200

The example is comparing apples with oranges. I haven't looked at the SPM-based section of code (partly because I don't have the file that is used), but the FT-implementation is using 'mtmfft', i.e. time-non resolved spectral estimation on only 2 trials, whereas the SPM implementation likely uses some kind of TFR


Jan-Mathijs Schoffelen - 2018-08-29 17:58:18 +0200

Ash replied: Thanks for looking at the partial coherence script I sent. Actually the issue wasn’t about time resolution. The issue was about the fact that if I simulate 2 time series A and B and compute partial coherence of A and B with B (or A) as a partial channel, I get a timeseries with field trip whereas EQ 38 of the Halliday paper (reference for partial coherence) suggests that the value in his instance should be 0/0 or NaN. The code I sent to bugzilla should have this example, but unfortunately maybe I didn’t have space to make it clear. I can send you a more detailed email later with code if you wish to explore further. The amp implementation is my own version for partial coherence which does give Nan output in the described instance


Jan-Mathijs Schoffelen - 2018-08-29 18:01:03 +0200

Thanks for the feedback, and apologies for being a bit rash with my response. If you are using the Halliday method, I can imagine that this by definition yields NaN, but I should look at the mathematics to be sure. For 'traditional' partial coherence, though, I think it will rarely really go to a 0/0 scenario, due to noise etc. I was a bit confused by your example code, but looking at it a bit better, I think I now understand it better. I will try to get back to this once time permits.


Jan-Mathijs Schoffelen - 2018-08-29 18:18:00 +0200

Hi, could you check out the following chunk of code, and let me know what you think? ntrials = 100; nsample = 1000; fband = [15 20]; for k = 1:ntrials tmp = ft_preproc_bandpassfilter(randn(3,nsample+20),1000,fband,[],'firws','onepass'); trial{k} = tmp(:,1:1000) + [tmp(1,1:1000);tmp(1,11:1010);tmp(1,21:1020)]; trial{k} = trial{k}+randn(size(trial{k}))./5; time{k} = (0:nsample-1)./1000; end data.trial = trial; data.time = time; data.label = {'chan01';'chan02';'chan03'}; cfg = []; cfg.method = 'mtmfft'; cfg.taper = 'hanning'; cfg.output = 'fourier'; cfg.foilim = [0 60]; freq = ft_freqanalysis(cfg, data); cfg = []; cfg.method = 'coh'; coh1 = ft_connectivityanalysis(cfg, freq); cfg.partchannel = {'chan01'}; coh2 = ft_connectivityanalysis(cfg, freq); coh2.label = freq.label(2:3); % needed for plotting cfg = []; cfg.parameter = 'cohspctrm'; cfg.channel = freq.label(2:3); ft_connectivityplot(cfg,coh1,coh2);


Jan-Mathijs Schoffelen - 2018-09-01 15:59:31 +0200

Hi Ash, For completeness, could you refer me to the specific paper by David that you mention (for the notorious equation '38')? For the fieldtrip implementation I used Rosenberg et al. 98 (j neurosci meth). If I recall well, I think that David was an author on that paper, too?


Jan-Mathijs Schoffelen - 2018-09-01 16:04:36 +0200

Also, would it be possible to communicate about this through the bugzilla website, instead of directly e-mailing back and forth? Thanks in advance.


Ash - 2018-09-01 22:47:06 +0200

Hi Jan-mathijis Yes you're right about the paper, it's the one from rosenberg https://ac.els-cdn.com/S0165027098000612/1-s2.0-S0165027098000612-main.pdf?_tid=7ef0a3e1-bf51-4d2b-aae3-face6a79608a&acdnat=1535834597_6da8a09e51711ef11057e21274929ce9 Eq 38 defines what the partial coherence matrix looks like, but also of note are EQs 40 and 41 from which we should see that F(12/1 or F12/2) should be 0/0 or NaN in Matlab terms


Ash - 2018-09-01 22:47:54 +0200

Regards Ash


Jan-Mathijs Schoffelen - 2018-09-24 21:04:46 +0200

Hi Ash, sorry this slipped off my radar to follow up. I think that it doesn't generally follow from the equations that the partial coherence goes to nan, only once one of the channels is an exact (possibly time-shifted) copy of the other one, this might be the case.


Jan-Mathijs Schoffelen - 2018-10-09 12:35:53 +0200

.