<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Jasper, <div><br></div><div>I think this is indeed a bug in fieldtrip. The reason being that the cumtapcnt field for timefrequency data is not well-defined/well-designed/well-handled (the latter by ft_selectdata, which is doing the trial selection).</div><div>Probably you can work around this by updating the cumtapcnt field prior to calling ft_freqdescriptives.</div><div><br></div><div>I suspect that it will work if you define it to be a vector (nx1) where n is the number of trials, and each entry has the value of the number of tapers applied (per trial).</div><div><br></div><div>Would it be possible for you to create a bug on our bugzilla site (<a href="http://bugzilla.fcdonders.nl">bugzilla.fcdonders.nl</a>) with a description of the problem, a little test script and some (small) data for reproduction? The team will then take it from there.</div><div><br></div><div>Best,</div><div><br></div><div>Jan-Mathijs</div><div><br></div><div><br></div><div><br><div><div>On Aug 23, 2012, at 12:34 PM, Jasper Poort wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote"><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:10.0pt;font-family:"Courier New"">Dear Fieldtrip users, <br></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:10.0pt;font-family:"Courier New""><br></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left">


<span style="font-size:10.0pt;font-family:"Courier New"">I have a problem with using a trial selection to do freqdescriptives on a subset of trials:<br></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left">


<br><span style="font-size:10.0pt;font-family:"Courier New""></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:10.0pt;font-family:"Courier New"">I first do ft_freqanalysis with these setttings, which results in freq:</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:10.0pt;font-family:"Courier New""><br></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left">


<span style="font-size:10.0pt;font-family:"Courier New"">cfg.output<span>      </span>= </span><span style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'fourier'</span><span style="font-size:10.0pt;font-family:"Courier New"">;</span><span style="font-size:12.0pt;font-family:"Courier New""></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:10.0pt;font-family:"Courier New"">cfg.method<span>      </span>= </span><span style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'mtmconvol'</span><span style="font-size:10.0pt;font-family:"Courier New"">;</span><span style="font-size:12.0pt;font-family:"Courier New""></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:10.0pt;font-family:"Courier New"">cfg.keeptrials<span>  </span>= </span><span style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'yes'</span><span style="font-size:10.0pt;font-family:"Courier New"">;</span><span style="font-size:12.0pt;font-family:"Courier New""></span></p><div style="text-align: left; text-indent: 0cm; line-height: normal; "><span style="font-size:12.0pt;font-family:"Courier New""> </span><br class="webkit-block-placeholder"></div><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New"">freq = </span></p><div style="text-align: left; text-indent: 0cm; line-height: normal; "><span style="font-size:12.0pt;font-family:"Courier New""> </span><br class="webkit-block-placeholder"></div><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New""><span>            </span>label: {1x64 cell}</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New""><span>           </span>dimord: 'rpttap_chan_freq_time'</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New""><span>             </span>freq: [30 35 40 45 50 55 60 65 70
75 80 85 90 95 100]</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New""><span>             </span>time: [1x36 double]</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New""><span>    </span>fourierspctrm: [4-D double]</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New""><span>        </span>cumtapcnt: [857x15 double]</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New""><span>              </span>cfg: [1x1 struct]</span></p><div style="text-align: left; text-indent: 0cm; line-height: normal; "><span style="font-size:12.0pt;font-family:"Courier New""> </span><br class="webkit-block-placeholder"></div><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New"">size(freq.fourierspctrm)</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left">


<span style="font-size:12.0pt;font-family:"Courier New"">ans =</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New""><span>        </span>2571<span>          </span>64<span>          </span>15<span>          </span>36</span></p><div style="text-align: left; text-indent: 0cm; line-height: normal; "><span style="font-size:12.0pt;font-family:"Courier New""> </span><br class="webkit-block-placeholder"></div><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left">


<span style="font-size:12.0pt;font-family:"Courier New"">then i try running ft_freqdescriptives with these settings<br></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:10.0pt;font-family:"Courier New"">tmpcfg = [];</span><span style="font-size:12.0pt;font-family:"Courier New""></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:10.0pt;font-family:"Courier New""><span>        </span>tmpcfg.jackknife = </span><span style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'no'</span><span style="font-size:10.0pt;font-family:"Courier New"">;</span><span style="font-size:12.0pt;font-family:"Courier New""></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:10.0pt;font-family:"Courier New""><span>        </span>tmpcfg.keeptrials = </span><span style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'no'</span><span style="font-size:10.0pt;font-family:"Courier New"">;</span><span style="font-size:12.0pt;font-family:"Courier New""></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:10.0pt;font-family:"Courier New""><span>        </span>tmpcfg.channel<span>    </span>= freq.label([chnix1,chnix2])</span><span style="font-size:12.0pt;font-family:"Courier New""></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:10.0pt;font-family:"Courier New""><span>        </span>tmpcfg.trials<span>     </span>= [1:10:100];</span><span style="font-size:12.0pt;font-family:"Courier New""></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:10.0pt;font-family:"Courier New""><span>        </span>tmp = ft_freqdescriptives(tmpcfg,freq);</span><span style="font-size:12.0pt;font-family:"Courier New""></span></p><div style="text-align: left; text-indent: 0cm; line-height: normal; "><span style="font-size:12.0pt;font-family:"Courier New""> </span><br class="webkit-block-placeholder"></div><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New"">Error using<span>  </span>+ </span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New"">Array dimensions must match
for binary array op.</span></p><div style="text-align: left; text-indent: 0cm; line-height: normal; "><span style="font-size:12.0pt;font-family:"Courier New""> </span><br class="webkit-block-placeholder"></div><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New"">Error in
ft_checkdata>fixcsd (line 740)</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New""><span>      </span>powspctrm = powspctrm +
abs(data.fourierspctrm(p:ntap:end,:,:,:,:)).^2;</span></p><div style="text-align: left; text-indent: 0cm; line-height: normal; "><span style="font-size:12.0pt;font-family:"Courier New""> </span><br class="webkit-block-placeholder"></div><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New"">Error in ft_checkdata (line
646)</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New""><span>    </span>data = fixcsd(data, cmbrepresentation,
channelcmb);</span></p><div style="text-align: left; text-indent: 0cm; line-height: normal; "><span style="font-size:12.0pt;font-family:"Courier New""> </span><br class="webkit-block-placeholder"></div><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New"">Error in ft_freqdescriptives
(line 131)</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New"">freq = ft_checkdata(freq,
'cmbrepresentation', 'sparsewithpow', 'channelcmb', {});</span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><br><span style="font-size:12.0pt;font-family:"Courier New""></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left">the error seems to happen because the <span style="font-size:12.0pt;font-family:"Courier New"">cumtapcnt seems to be updated </span>after calling ft_selectdata in ft_freqdescriptives such that it no longer contains a row for every trial which causes nrpt = size(data.cumtapcnt,1); in ft_checkdata to return 1 instead of the number of trials. <br>


</p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><br></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left">


            label: {2x1 cell}<br>           dimord: 'rpttap_chan_freq_time'<br>             freq: [30 35 40 45 50 55 60 65 70 75 80 85 90 95 100]<br>             time: [1x36 double]<br>    fourierspctrm: [4-D double]<br>


        cumtapcnt: [3 3 3 3 3 3 3 3 3 3]<br>              cfg: [1x1 struct]<br></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><br></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left">


I was wondering if this is a bug or am I somehow specifying the input incorrectly?</p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><br></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left">


Thanks! best, Jasper<br></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><br><span style="font-size:12.0pt;font-family:"Courier New""></span></p><p class="MsoNormal" style="text-align:left;text-indent:0cm;line-height:normal;text-autospace:none" align="left"><span style="font-size:12.0pt;font-family:"Courier New""><br></span></p>

</div><br>
_______________________________________________<br>fieldtrip mailing list<br><a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Jan-Mathijs Schoffelen, MD PhD </div><div><br></div><div>Donders Institute for Brain, Cognition and Behaviour, <br>Centre for Cognitive Neuroimaging,<br>Radboud University Nijmegen, The Netherlands</div><div><br></div><div>Max Planck Institute for Psycholinguistics,</div><div>Nijmegen, The Netherlands</div><div><br></div><div><a href="mailto:J.Schoffelen@donders.ru.nl">J.Schoffelen@donders.ru.nl</a></div><div>Telephone: +31-24-3614793</div></div></span></div></span></div></span></div></span></div></span></span>
</div>
<br></div></body></html>