[FieldTrip] Spacing of Frequency Axis, output from ft_freqanalysis

"Jörn M. Horschig" jm.horschig at donders.ru.nl
Thu Jun 5 11:29:08 CEST 2014


Hi Tyler,

> How bad would it be if [...]

it's wrong, don't do that.

Best,
Jörn


On 6/5/2014 11:16 AM, Tyler Grummett wrote:
> Hello everyone,
>
> For the interest of using the output in granger causality.
>
> How bad would it be if you did run the code:
>
>>              % compute spectral transfer function
>>              cfg = [];
>>              cfg.output = 'fourier';
>>              cfg.method = 'mtmfft';
>>              cfg.tapsmofrq = 5;
>>              cfg.foi = 5:1:7;
>>              freq = ft_freqanalysis(cfg, data);
> Then just rounded off the output frequencies.
>
>> freq =
>>
>>              label: {1x116 cell}
>>             dimord: 'rpttap_chan_freq'
>>               freq: [5.2000 6 7.2000]
>>      fourierspctrm: [336x116x3 double]
>>          cumsumcnt: [14x1 double]
>>          cumtapcnt: [14x1 double]
>>                cfg: [1x1 struct]
> freq.freq = round( freq.freq)
>
>   I just ran it through ft_connectivityanalysis and it didnt crash.
>
> I know this isnt the correct thing to do, but you otherwise unable to calculate granger causality.
>
> Tyler
>
> *************************
>
> Tyler Grummett ( BBSc, BSc(Hons I))
> PhD Candidate
> Brain Signals Laboratory
> Flinders University
> Rm 5A301
> Ext 66124
>
> ________________________________________
> From: fieldtrip-bounces at science.ru.nl <fieldtrip-bounces at science.ru.nl> on behalf of Eelke Spaak <eelke.spaak at donders.ru.nl>
> Sent: Thursday, 5 June 2014 6:22 PM
> To: FieldTrip discussion list
> Subject: Re: [FieldTrip] Spacing of Frequency Axis,     output from ft_freqanalysis
>
> See http://fieldtrip.fcdonders.nl/faq/why_does_my_output.freq_not_match_my_cfg.foi_when_using_mtmconvol_in_ft_freqanalyis
> and
> http://fieldtrip.fcdonders.nl/faq/what_does_padding_not_sufficient_for_requested_frequency_resolution_mean
>
> Also, 1250 samples == 2.5s > 1s. So the padding is too small indeed.
>
> Best,
> Eelke
>
> On 5 June 2014 10:45, Tyler Grummett <tyler.grummett at flinders.edu.au> wrote:
>> Hey jorn and clara,
>>
>> I am having the same issue, I use the following code:
>>
>>              % compute spectral transfer function
>>              cfg = [];
>>              cfg.output = 'fourier';
>>              cfg.method = 'mtmfft';
>>              cfg.tapsmofrq = 5;
>>              cfg.foi = 5:1:7;
>>              freq = ft_freqanalysis(cfg, data);
>>
>> and I get:
>>
>> freq =
>>
>>              label: {1x116 cell}
>>             dimord: 'rpttap_chan_freq'
>>               freq: [5.2000 6 7.2000]
>>      fourierspctrm: [336x116x3 double]
>>          cumsumcnt: [14x1 double]
>>          cumtapcnt: [14x1 double]
>>                cfg: [1x1 struct]
>>
>> I had a look at your links and it isnt clear as to what should be changed in the code.
>>
>> It seems to rely on padding, ie if cfg.pad = 1, then it should theoretically work.
>> However, there are lines in the code that do the following:
>>
>> padding = cfg.pad*data.fsample;
>>    if padding<max(trllength)
>>      error('the specified padding is too short');
>>    end
>>
>> As my fsample is 500 and my trllength is 1250 (sample points), then it regards my padding to be too small.
>>
>> Tyler
>>
>> *************************
>>
>> Tyler Grummett ( BBSc, BSc(Hons I))
>> PhD Candidate
>> Brain Signals Laboratory
>> Flinders University
>> Rm 5A301
>> Ext 66124
>>
>> ________________________________________
>> From: fieldtrip-bounces at science.ru.nl <fieldtrip-bounces at science.ru.nl> on behalf of "Jörn M. Horschig" <jm.horschig at donders.ru.nl>
>> Sent: Thursday, 5 June 2014 5:25 PM
>> To: FieldTrip discussion list
>> Subject: Re: [FieldTrip] Spacing of Frequency Axis,     output from ft_freqanalysis
>>
>> Hi Clara,
>>
>> regarding the frequency resolution, you can best read this:
>> http://fieldtrip.fcdonders.nl/tutorial/timefrequencyanalysis?s[]=frequency&s[]=resolution#time-frequency_analysis_i
>> If you still have trouble understanding, you can check out this:
>> http://www.youtube.com/watch?v=6EIBh5lHNSc
>>
>> So to get an equally spaced frequency axis, you space the frequency in
>> cfg.foi in steps of your frequency resolution. I hope above links help
>> you to find out what this means and how to do that ;)
>>
>> Best,
>> Jörn
>>
>> On 6/4/2014 5:51 PM, Clara A. Scholl wrote:
>>> Dear FieldTrip Community,
>>>
>>> I have a question regarding the frequency axis of a fourier spectrum
>>> calculated using ft_freqanalysis.  How do I specify the input for
>>> ft_freqanalysis to generate an evenly spaced frequency axis?
>>>
>>> I would like to calculate the fourier spectrum between 2 and 30 Hz in
>>> steps of 2 Hz (foi=2:2:30), full code here:
>>>
>>>>>>> ft_freqanalysis input specification<<<<<
>>> subj=598;
>>>
>>> load(['../subj'num2str(subj)
>>> 'FT_sameDiff_correctTrials_continuous_1secBlinkInt500hz0.1hz-30hz_fromContinuous_start-0.4end1.2.mat']);
>>>
>>> cfg=[];
>>>
>>> cfg.channel={'E59' 'E19'};
>>>
>>> data=ft_selectdata(cfg, dataSame);
>>>
>>> %data=dataSame;
>>>
>>> cfg = [];
>>>
>>> cfg.keeptrials = 'yes';
>>>
>>> cfg.keepindividual = 'yes';
>>>
>>> cfg.channel = {'all'};
>>>
>>> cfg.method       = 'mtmconvol';
>>>
>>> cfg.output       ='fourier';
>>>
>>> cfg.toi = -0.2:0.01:1.0;
>>>
>>> cfg.foi = 2:2:30; %frequency steps of 2Hz
>>>
>>> cfg.taper = 'hanning';
>>>
>>> cfg.t_ftimwin=ones(1,15).*.2;
>>>
>>> %cfg.t_ftimwin=1./[2:2:30];
>>>
>>> TFR = ft_freqanalysis(cfg, data);
>>>
>>>>>>> end input specification<<<<<
>>>>>>> output<<<<<
>>> TFR =
>>>
>>>              label: {2x1 cell}
>>>             dimord: 'rpttap_chan_freq_time'
>>>               freq: [1.8750 3.7500 6.2500 8.1250 10 11.8750 13.7500
>>> 16.2500 18.1250 20 21.8750 23.7500 26.2500 28.1250 30]
>>>               time: [1x121 double]
>>>      fourierspctrm: [4-D double]
>>>          cumtapcnt: [452x15 double]
>>>               elec: [1x1 struct]
>>>                cfg: [1x1 struct]
>>>
>>>>>>> end output<<<<<
>>> The output from this code has uneven spacing on the frequency axis.
>>>   Some frequency intervals are 1.875 Hz and some intervals are 2.5 Hz,
>>> see TFR.freq above.  TFR.freq is the same (uneven) for different
>>> output choices (fourier, powandcsd) and whether the length of time
>>> windows are the same at each frequency or vary by frequency.
>>>
>>> How can I run ft_freqanalysis to generate an evenly spaced frequency
>>> axis?  Downstream functions (ft_connectivityanalysis with method
>>> granger) check for an evenly spaced frequency axis.  I am using
>>> fieldtrip version 20140603.
>>>
>>> Thanks immensely,
>>> Clara
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> fieldtrip mailing list
>>> fieldtrip at donders.ru.nl
>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>> --
>> Jörn M. Horschig
>> PhD Student
>> Donders Institute for Brain, Cognition and Behaviour
>> Centre for Cognitive Neuroimaging
>> Radboud University Nijmegen
>> Neuronal Oscillations Group
>> FieldTrip Development Team
>>
>> P.O. Box 9101
>> NL-6500 HB Nijmegen
>> The Netherlands
>>
>> Contact:
>> E-Mail: jm.horschig at donders.ru.nl
>> Tel:    +31-(0)24-36-68493
>> Web: http://www.ru.nl/donders
>>
>> Visiting address:
>> Trigon, room 2.30
>> Kapittelweg 29
>> NL-6525 EN Nijmegen
>> The Netherlands
>>
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip


-- 
Jörn M. Horschig
PhD Student
Donders Institute for Brain, Cognition and Behaviour
Centre for Cognitive Neuroimaging
Radboud University Nijmegen
Neuronal Oscillations Group
FieldTrip Development Team

P.O. Box 9101
NL-6500 HB Nijmegen
The Netherlands

Contact:
E-Mail: jm.horschig at donders.ru.nl
Tel:    +31-(0)24-36-68493
Web: http://www.ru.nl/donders

Visiting address:
Trigon, room 2.30
Kapittelweg 29
NL-6525 EN Nijmegen
The Netherlands




More information about the fieldtrip mailing list