<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0"></p>
<div>Dear Fieldtrip community!</div>
<div><br>
</div>
<div>I would like to ask for your advice on zero padding when doing TFR analysis.</div>
<div><br>
</div>
<div>I'm analysing trials of different lengths, so I loop over the trials to run ft_freqanalysis.</div>
<div>I read in the tutorials that the padding length should be >= to the length of the trial.</div>
<div><br>
</div>
<div>Therefore, I prepared these parameters:</div>
<div><br>
</div>
<div>cfg = [];</div>
<div>cfg.method = 'wavelet';</div>
<div>cfg.output = 'pow';</div>
<div>cfg.foi = [2:1:40];</div>
<div>cfg.width = 6;</div>
<div>cfg.keeptrials = 'yes';</div>
<div>cfg.toi = data.time{1};</div>
<div><b>cfg.pad = round(length(data.time{1}(1,:))/500)+5; % duration of trial plus 5 seconds</b></div>
<div><b>% my sampling rate is 500</b></div>
<div>res = ft_freqanalysis(cfg,data);</div>
<div><br>
</div>
<div>Even if I add 5 seconds more to the length of the cfg.pad, SOMETIMES (and I </div>
<div>cannot figure out a pattern..), I get this error:</div>
<div>
<div><span style="color: rgb(255, 0, 0);">Error using ft_specest_wavelet (line 60)</span></div>
<div><span style="color: rgb(255, 0, 0);">the padding that you specified is shorter than the data</span></div>
<div><br>
</div>
<div><span style="color: rgb(255, 0, 0);">Error in ft_freqanalysis (line 505)</span></div>
<div><span style="color: rgb(255, 0, 0);">        [spectrum,foi,toi] = ft_specest_wavelet(dat, time, 'timeoi', cfg.toi, 'width', cfg.width, 'gwidth', cfg.gwidth,options{:},</span></div>
<div><span style="color: rgb(255, 0, 0);">        'feedback', fbopt);</span></div>
</div>
<div><br>
</div>
<div>The length of the above trial was 20 seconds (+5 secs padding).</div>
<div>Do you have any idea what is the problem?</div>
<div><br>
</div>
<div>Freqanalysis runs smoothly in trials with other trials with smaller or longer duration, and I can't find a pattern of when this error comes up..</div>
<div><br>
</div>
<div>Any idea would be extremely helpful, thanks so so much in advance!</div>
<div><br>
</div>
<div>Best,</div>
<div>Ioanna</div>
<br>
<p></p>
</div>
</body>
</html>