<div dir="ltr">Hi Anne,<div><br></div><div>I think this happens because your design matrix uses the trials of the different conditions, but the parameter you give timelockstats in 'avg' (i.e. the ERP).</div><div><br></div><div>May I  ask why you are using independent samples t-stats? I would expect that the participant participating in each condition is the same?</div><div><br></div><div>Best,</div><div>Tara</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 29, 2019 at 1:03 PM Anne Koopman <<a href="mailto:koopman.anne@gmail.com">koopman.anne@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear Fieldtrip community,</div><div><br></div><div>My name is Anne Koopman and I'm doing a PhD in Penny Lewis's lab in Cardiff. I focus on targeted memory reactivation during sleep, which is a fancy way of saying I play memory-related sounds to people while they sleep in our lab and I hope their brain responds in some way. During the experiment I'm trying to analyse here I played two types of sounds to people: experimental (i.e. memory-related) and control. I'm trying to find out whether there is a difference in the ERP response to these two different types of sounds. I've already successfully done this on a group level, but now I'm trying to look at each participant separately on a between-trial level.</div><div><br></div><div>I've followed the example code for between-trials experiments in the tutorial "Cluster-based permutation tests on event related fields" (link: <a href="http://www.fieldtriptoolbox.org/tutorial/cluster_permutation_timelock/" target="_blank">http://www.fieldtriptoolbox.org/tutorial/cluster_permutation_timelock/</a>). I'm following the tutorial exactly, including the specification of the design matrix (though substituting my own variable names, of course). I get the following error message:</div><div><br></div><div>Error using ft_timelockstatistics (line 168)<br>the length of the design matrix (1) does not match the number of observations in the data (2)</div><div><br></div><div>It looks like during that step in ft_timelockstatistics the data consists of two columns (one for each sound type?), whereas the design matrix only has one. I can see where it goes wrong, but I don't have enough insight into Fieldtrip to understand why and how to fix it. I tried adding a second column in the design matrix with the trial numbers as a uvar, but predictably this gave me an error saying:</div><div>Error using ft_statfun_indepsamplesT (line 74)<br>cfg.uvar should not exist for an independent samples statistic</div><div><br></div><div>The cfg and data I use are as follows: (note that there is also a corresponding data struct called ERP_ctrl which looks exactly the same as ERP_exp except for the fact that it has 204 trials instead of 215).<br></div><div><br></div><div>>> display(cfg)<br><br>cfg = <br><br>  struct with fields:<br><br>             channel: {'F4'  'Fz'  'F3'}<br>          neighbours: [1×13 struct]<br>             latency: [0 2]<br>         avgovertime: 'no'<br>           parameter: 'avg'<br>              method: 'montecarlo'<br>           statistic: 'ft_statfun_indepsamplesT'<br>               alpha: 0.0500<br>            correctm: 'cluster'<br>         correcttail: 'alpha'<br>                tail: 0<br>         clustertail: 0<br>    numrandomization: 200<br>           minnbchan: 0<br>              design: [1×419 double]<br>                ivar: 1</div><div><br></div><div>>> display(ERP_exp)<br><br>ERP_exp = <br><br>  struct with fields:<br><br>          avg: [18×2500 double]<br>          var: [18×2500 double]<br>         time: [1×2500 double]<br>          dof: [18×2500 double]<br>        label: {18×1 cell}<br>        trial: [215×18×2500 double]<br>       dimord: 'rpt_chan_time'<br>         elec: [1×1 struct]<br>    trialinfo: [215×1 double]<br>          cfg: [1×1 struct]</div><div><br></div><div>I've uploaded my data and the script that I use here: <a href="https://we.tl/t-aOiKBh6fO7" target="_blank">https://we.tl/t-aOiKBh6fO7</a></div><div><br></div><div>Sorry for the long email! I hope I've described everything clearly and I really appreciate any insight that you could give. I should note, I'm using Matlab R2016b with Fieldtrip version 03/04/2017.</div><div><br></div><div>Thanks in advance for your help,</div><div>Anne</div><div><br></div><div><span style="font-size:11pt;line-height:150%;font-family:Calibri,sans-serif" lang="EN-GB"></span></div></div>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</blockquote></div>