[FieldTrip] TRF before defining trials

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Fri Nov 19 19:48:44 CET 2021


Hi Philip,

It is not possible to use ft_redefinetrial on time-frequency data, I am pretty sure that the function’s help is pretty clear on how it ought to be used.

I don’t know what you mean with ‘boundary effects’, but perhaps it brings you some peace of mind to know that ft_freqanalysis only returns an estimate of time-resolved power for those time points for which the shifting time-window if completely filled with data samples. Otherwise it will return a NaN.

Best wishes,
Jan-Mathijs


On 18 Nov 2021, at 21:41, philip Joadavi via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Dear all,

I have continuous EEG data and I would like to first compute the time-frequency analysis to avoid any boundary effects etc, and then define my trials.
so I want to do the following:
1- time frequency analysis
2- define trials
3- average over TRF trials
4- average over subjects

However, after defining the trials, my 3dimential data becomes 2 dimensional. I would like to know if there is any function in FieldTrip that I can use to keep the trial dimension as it is?
I would also like to know how can I get the average over my TRF over trials and subjects with the same dimension.

here is the code I'm using:
cfg           = [];
cfg.trials    = 'all';
cfg.channel   = 'EEG';
cfg.output    = 'pow';
cfg.method    = 'mtmconvol';
cfg.taper     = 'hanning';
cfg.pad       = 'nextpow2';
cfg.keeptrials = 'yes';
cfg.foi       = 10:.5:40;
cfg.toi       = data.time{1};

cfg.t_ftimwin = 0.5*ones(size(cfg.foi));


df{t}         = ft_freqanalysis(cfg,data);

--------

cfg                     = [];
cfg.fsample             = fsample;
cfg.trialdef.prestim    = preStim ;       % sec
cfg.trialdef.poststim   = postStim ;      % sec
cfg.trialdef.events     = data.trial{1}(e,:);
cfg.trialfun            = 'eegTrialFun';
cfg.trialdef.eventvalue = eventValue;
cfg.keeptrials          = 'yes';



cfg                     = ft_definetrial(cfg);
----------
cfg.trials              = 'all';
d                       = ft_redefinetrial(cfg,df{t});




Thanks a lot!
Philip
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!50nUOvdSkbOxHrYmv3dc-wRl08NnWvOp2dVISpmsJOi73PlIA2x8i2AtGIO3v5fggpzjFshrLVify-5T3U6PqqAB37YElXhaK9UtJw$

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20211119/7b578a51/attachment.htm>


More information about the fieldtrip mailing list