<div dir="ltr"><div>Hi Tara,</div><div><br></div><div>Thank you, removing that line solved everything and the code ran smoothly afterwards!</div><div><br></div><div>I used an independent samples t-test because I was following the tutorial and that's what was used there, but now that you mention it a dependent may be more appropriate. It's indeed the same participant doing each condition. In the end I don't think it matters much in this case. I was trying to see if each participant individually had a significant ERP, and exclude the participants that didn't have this. However, in the end only 1 out of 25 people had it, so I will not be using it for this purpose after all.<br></div><div><br></div><div>Thanks for all your help,</div><div>Anne<br></div><div><br></div><div>On Mon, Jul 29, 2019 at 1:31 PM Tara van Viegen <<a href="mailto:taravanviegen@gmail.com">taravanviegen@gmail.com</a>> wrote:<br>
</div><div><br></div><div>Hi Anne,</div>
<br>
I think this happens because your design matrix uses the trials of the<br>
different conditions, but the parameter you give timelockstats in 'avg'<br>
(i.e. the ERP).<br>
<br>
May I ask why you are using independent samples t-stats? I would expect<br>
that the participant participating in each condition is the same?<br>
<br>
Best,<br>
Tara<br>
<br>
On Mon, Jul 29, 2019 at 1:03 PM Anne Koopman <<a href="mailto:koopman.anne@gmail.com" target="_blank">koopman.anne@gmail.com</a>> wrote:<br>
<br>
> Dear Fieldtrip community,<br>
><br>
> My name is Anne Koopman and I'm doing a PhD in Penny Lewis's lab in<br>
> Cardiff. I focus on targeted memory reactivation during sleep, which is a<br>
> fancy way of saying I play memory-related sounds to people while they sleep<br>
> in our lab and I hope their brain responds in some way. During the<br>
> experiment I'm trying to analyse here I played two types of sounds to<br>
> people: experimental (i.e. memory-related) and control. I'm trying to find<br>
> out whether there is a difference in the ERP response to these two<br>
> different types of sounds. I've already successfully done this on a group<br>
> level, but now I'm trying to look at each participant separately on a<br>
> between-trial level.<br>
><br>
> I've followed the example code for between-trials experiments in the<br>
> tutorial "Cluster-based permutation tests on event related fields" (link:<br>
> <a href="http://www.fieldtriptoolbox.org/tutorial/cluster_permutation_timelock/" rel="noreferrer" target="_blank">http://www.fieldtriptoolbox.org/tutorial/cluster_permutation_timelock/</a>).<br>
> I'm following the tutorial exactly, including the specification of the<br>
> design matrix (though substituting my own variable names, of course). I get<br>
> the following error message:<br>
><br>
> Error using ft_timelockstatistics (line 168)<br>
> the length of the design matrix (1) does not match the number of<br>
> observations in the data (2)<br>
><br>
> It looks like during that step in ft_timelockstatistics the data consists<br>
> of two columns (one for each sound type?), whereas the design matrix only<br>
> has one. I can see where it goes wrong, but I don't have enough insight<br>
> into Fieldtrip to understand why and how to fix it. I tried adding a second<br>
> column in the design matrix with the trial numbers as a uvar, but<br>
> predictably this gave me an error saying:<br>
> Error using ft_statfun_indepsamplesT (line 74)<br>
> cfg.uvar should not exist for an independent samples statistic<br>
><br>
> The cfg and data I use are as follows: (note that there is also a<br>
> corresponding data struct called ERP_ctrl which looks exactly the same as<br>
> ERP_exp except for the fact that it has 204 trials instead of 215).<br>
><br>
> >> 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<br>
><br>
> >> 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]<br>
><br>
> I've uploaded my data and the script that I use here:<br>
> <a href="https://we.tl/t-aOiKBh6fO7" rel="noreferrer" target="_blank">https://we.tl/t-aOiKBh6fO7</a><br>
><br>
> Sorry for the long email! I hope I've described everything clearly and I<br>
> really appreciate any insight that you could give. I should note, I'm using<br>
> Matlab R2016b with Fieldtrip version 03/04/2017.<br>
><br>
> Thanks in advance for your help,<br>
> Anne
</div>