freqanalysis_wltconvol.m question

Jan Mathijs Schoffelen Jan.Schoffelen at FCDONDERS.RU.NL
Tue Nov 21 08:02:00 CET 2006

Dear Brian et al,


From: Brian Roach [mailto:Brian.Roach at]
Sent: Monday, November 20, 2006 11:56 PM
To: Jan Mathijs Schoffelen
Subject: Re: [FIELDTRIP] freqanalysis_wltconvol.m question

Hi, I could not get this posted to the list, and figured since you gave most
of the feedback, I would see what you think.


Date: Mon, 13 Nov 2006 12:09:00 -0500
To: FieldTrip discussion list <FIELDTRIP at NIC.SURFNET.NL>
From: Brian Roach <Brian.Roach at>
Subject: Re: [FIELDTRIP] freqanalysis_wltconvol.m question
Bcc: Daniel Mathalon <daniel.mathalon at>

Thanks for the advice,  I am wondering if FT users would agree that this is
an acceptable way to estimate univariate phase coherence:

In freqanalysis_wltconvol.m, line 283:
                %         powdum = (2.* abs(autspctrmacttap)  ./
data.fsample) .^ 2;
                powdum = (2.*autspctrmacttap  ./ data.fsample);

1. I've commented out the power line and inserted basically the same thing
(but not squared)
2. As suggested, I change cfg.keeptrials = 'yes';
3. After running freqanalysis.m, in the command prompt:
        itc =

squeeze is used because freq.powspctrm is a 3 d matrix including sites,
times, and frequencies and in the above case I am just getting itc from 1
channel.  Does this method seem alright?  Regarding step #1 above, it seemed
to make no difference whether I left the 2.* in that equation or not, which
seems consistent with an earlier e-mail that mentioned this multiplication
being tied into power, so it does not influence phase angle.  Is that right?
Or, should it be taken out for my purposes?


This looks fine to me. Indeed the factor of 2 does not affect the outcome,
because it falls out in the division (normalization) step.



PS: you might have to think about whether or not to square the final itc, to
make it consistent with the way it is defined in the literature.

At 04:37 AM 11/9/2006, you wrote:

Dear Brian,

Freqanalysis_wltconvol does not support fourier as an output. However, since
wavelet-analysis and fft's in the end are about the same thingy, you could
use freqanalysis_mtmconvol to achieve your goal.
There is a tutorial on the fieldtrip-website which deals with this function,
and uses it in a way that it resembles a wavelet-analysis, in which the
time-frequency resolution is treated in the same way as with standard

Phase-locking-value is defined in fieldtrip as a bivariate-measure, so that
means that it quantifies how consistent the phase-relation between two
channels is across trials.
Inter-trial coherence is a bit an odd thingy, because the term coherence
suggests something bivariate, but the way you would like to use it, is
essentially univariate. You want to estimate how consistent the phase of the
oscillations at a particular channel is across trials.
However, both measures use similar math. In fact, when you create a
dummy-fourier-channel you can use the plv-option to obtain your 'itc'. This
is because in this situation, the mathematics become identical. I would
advise it like this:

Do your freqanalysis as Robert suggested in one of his previous mails (see
below (cfg.keeptapers = 'yes')).
Then create a dummy channel:

dim                             = size(freq.fourierspctrm;
freq.fourierspctrm(:,end+1,:,:) = ones(dim([1 3 4]));
freq.label = 'dummy';

cfg = [];
cfg.cohmethod = 'plv';
cfg.channelcmb = channelcombination({'dummy' 'all'}, freq.label); %should

itc = freqdescriptives(cfg, freq);

Your 'itc' now is contained in the field itc.cohspctrm;

The check whether this is correctly done is done outside fieldtrip:

itc2 = abs(mean(freq.fourierspctrm./abs(freq.fourierspctrm),1));



-----Original Message-----
From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf
Of Brian Roach
Sent: Wednesday, November 08, 2006 11:13 PM
Subject: Re: [FIELDTRIP] freqanalysis_wltconvol.m question

Thanks for your quick reply.  I did not realize that
freqanalysis_wltconvol.m allowed for 'fourier' output, but maybe I need to
download the latest version.  Or, do you mean I should use freqanalysis_mtm
instead?  Also, how does ITC differ from phase-locking value?  I thought
they were the same measure.
At 04:56 PM 11/8/2006, you wrote:
>Hi Brian
>On 8 Nov 2006, at 21:20, Brian Roach wrote:
>>eI would like to take this complex output and use it to calculate
>>phase-locking factor, but I am not sure what parts of the power
>>transformation need to be removed - just the abs() and the
>>squaring?  Clarification of this line of code would be extremely
>>helpful to me.
>You can use the existing code for that:
>For computing the phase-locking value I suggest that you use either
>   cfg.output='fourier'
>   cfg.keeptrials='yes'
>   cfg.keeptapers='yes'
>   cfg.output='fourier'
>   cfg.keeptrials='yes'
>   cfg.keeptapers='no' (not needed now)
>   cfg.channelcmb = something, see the help
>in freqanalysis.
>Subsequently, use the option
>   cfg.cohmethod='plv'
>in freqdescriptives. In case of fourier output in freqanalysis, you
>should specify the channel combinations here.
>Looking back at your previous mail, I see that you mean ITC and not
>PLV. The stuff above then does not apply. You can do output=fourier
>in freqanalysis and work manually on the output freq structure. I
>think that this should work
>magnitude = abs(freq.fourierspctrm);
>scaled    = freq.fourierspctrm ./ magnitude;
>freq.itcspctrm = mean(scaled, 1);
>freq = rmfield(freq, 'fourierspctrm');   % remove the single
>fourierspectrum, to avoid confusion
>freq.dimord = 'chan_freq_time';          % remove the rpt or rpttap
>best regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the fieldtrip mailing list