[FieldTrip] TFR with different trial lengths

Ioanna Zioga i.zioga at qmul.ac.uk
Wed Jun 26 14:49:22 CEST 2019


Dear Jan-Mathijs, Raphaël, and Stephen,


Thanks so much for your insightful replies!


I need to analyze the whole duration of the different trials, so I think the suggestion to run freqanalysis looping over trials is really suitable!


I'm using these parameters:

cfgft = [];
cfgft.method = 'wavelet';
cfgft.output = 'pow';
cfgft.foi = 2:1:40;
cfgft.width = 6;
cfgft.pad = 'nextpow2';
cfgft.keeptrials = 'yes';
cfgft.toi = data.time{1};

But I get this error at some point:
Error using  ./
Matrix dimensions must agree.

Error in ft_freqanalysis (line 435)
    fboi   = round(cfg.foi ./ (data.fsample ./ (cfg.pad*data.fsample))) + 1;

This trial is quite long (10267 timepoints divided by 500 sampling rate = 20 seconds), so I can't think of why I get this error?
I think there is a problem with the padding, anyone has any suggestion?
Also, does the cfgft.toi need to be exactly the time resolution of my data (0.0020 sec), or can I use a lower resolution by changing the cfgft.toi?

Thank you very very much for all your help!

Best,
Ioanna



________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of Stephen Whitmarsh <stephen.whitmarsh at gmail.com>
Sent: 26 June 2019 10:58:32
To: 'FieldTrip discussion list'
Subject: Re: [FieldTrip] TFR with different trial lengths


Dear Ionna,



First of all, in general FieldTrip works very well with different trial durations (that’s why there is a ‘time’ field for every trial in a ‘raw’ data structure), at least in those functions where it makes sense, although it’s definitely something to always check (never hurts).



Secondly, in my memory at least, ‘mtmfft’ returns NaNs where there is no data, but the implementation of ‘tfr’ might be different and I trust that you have 0s :) But it’s something to keep in mind as this suggests that you might have unexpected results if you change methods. It also emphasizes that you are asking freqanalysis to calculate power of data that doesn’t exist and although it seems handy, it might not be the most consistent way of scripting your analysis in the end. In particular when you will be averaging, calculating relative differences (baseline correction e.g.), etc., where you might not keep track of the fact that you are using 0s as if this was true data.



In such situations as you describe, I myself typically do two different analysis: first I preprocess and epoch the stimulus-locked timecourse data once using the full (different) trial lengths, and then split my time-frequency-analysis up into one stimulus-locked analysis, and one response-locked analysis  (after re-aligning stimulus-locked data to the end of the trial), both using the shortest time duration. This allows me to easily average the time-frequency-data over trials without having different time-points/windows that I would have gotten if I was trying to response-lock TFR data that was calculated on stimulus-locked data. This is especially the case when using sliding time-windows (method = ‘mtmfft’) where those time-windows won’t perfectly align in time. (and using sliding time-windows with mtmfft, using steps of e.g. 0.05s will be more memory-efficient than calculating a wavelet for every time-point). Also, it would mean that all my power-estimates over time will have the same amount of trials.



You can also ofcourse, if you really want to, loop over trials and append the trials (powspctrm and time) afterwards.



Although not a direct answer to your question perhaps, I hope this helps.



Cheers,

Stephen













From: fieldtrip <fieldtrip-bounces at science.ru.nl> On Behalf Of Ioanna Zioga
Sent: Wednesday, June 26, 2019 11:12 AM
To: fieldtrip at science.ru.nl
Subject: [FieldTrip] TFR with different trial lengths



Hello Fieldtrip community!



I want to do TFR analysis on datasets with trials with different lengths (as I'm analysing the time period from the onset of a stimulus until participant's response, which differs from trial to trial).



These are the parameters:

cfgft                   = [];

cfgft.method    = 'tfr';

cfgft.output      = 'pow';

cfgft.foi              = exp(linspace(log(2),log(45),50));

cfgft.toi              = [];

cfgft.width         = 6;

cfgft.keeptrials  = 'yes';



The result I get from the freqanalysis (powspctrm) is a trial x chan x freq x time matrix, in which the time is the time of the trial with the largest duration. The datapoints of the trials with smaller durations are filled with zeros.



I would prefer to get the powspctrm without the zeros at the end, but maybe I can just exclude them later on from the analysis?

Do you know if Fieldtrip works fine with trials of different durations? And if there is any other more efficient way to analyse trials with different durations?



Any help would be extremely appreciated, thanks so much in advance!



Best wishes,

Ioanna


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190626/2c50ddef/attachment-0002.html>
-------------- next part --------------
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202


More information about the fieldtrip mailing list