[FieldTrip] Issue with independent samples design matrix in ft_timelockstatistics

Anne Koopman koopman.anne at gmail.com
Mon Jul 29 19:00:58 CEST 2019

Dear Fieldtrip community,

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.

I've followed the example code for between-trials experiments in the
tutorial "Cluster-based permutation tests on event related fields" (link:
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:

Error using ft_timelockstatistics (line 168)
the length of the design matrix (1) does not match the number of
observations in the data (2)

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:
Error using ft_statfun_indepsamplesT (line 74)
cfg.uvar should not exist for an independent samples statistic

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).

>> display(cfg)

cfg =

  struct with fields:

             channel: {'F4'  'Fz'  'F3'}
          neighbours: [1×13 struct]
             latency: [0 2]
         avgovertime: 'no'
           parameter: 'avg'
              method: 'montecarlo'
           statistic: 'ft_statfun_indepsamplesT'
               alpha: 0.0500
            correctm: 'cluster'
         correcttail: 'alpha'
                tail: 0
         clustertail: 0
    numrandomization: 200
           minnbchan: 0
              design: [1×419 double]
                ivar: 1

>> display(ERP_exp)

ERP_exp =

  struct with fields:

          avg: [18×2500 double]
          var: [18×2500 double]
         time: [1×2500 double]
          dof: [18×2500 double]
        label: {18×1 cell}
        trial: [215×18×2500 double]
       dimord: 'rpt_chan_time'
         elec: [1×1 struct]
    trialinfo: [215×1 double]
          cfg: [1×1 struct]

I've uploaded my data and the script that I use here:

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.

Thanks in advance for your help,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190729/5af7ba09/attachment.html>

More information about the fieldtrip mailing list