# freqstatistics with indepsamplesZcoh: incompatible dimensions?

Dahlia Sharon dahliash at STANFORD.EDU
Tue Jun 8 21:04:34 CEST 2010

```Hi,

I'm trying to run cluster statistics on coherence between a single channel (actually 2) and a set of 516 channels. My code crashes when ft_freqstatistics reaches clusterstat [Error using ==> reshape; To RESHAPE the number of elements must not change.
Error in ==> clusterstat at 182;      posclusobs = findcluster(reshape(postailobs,  [cfg.dim,1]),channeighbstructmat,cfg.minnbchan);     ]
At this point postailobs is much larger than multiplying the elements of cfg.dim.
But digging into it the problem starts earlier, and as far as I can see is a result of incompatibility between the output of freqanalysis and the way indepsamplesZcoh treats the data:
In freqanalysis I calculate csd between each of the two channels and all the rest, i.e. I have 2 * (516+1) = 1034 pairs. The dimension of the resulting freq.crssspctrm is 10 (trials) x 1034 (channel pairs) x 51 (frequencies) x 1 (times).
In indepsamplesZcoh using the freqanalysis output, for each frequency I have a 1034x10 matrix multiplied by its transpose to get a dimension of 1034x1034. This is of-course much higher than the dimension of the data which should be something like 517x2.

How should I transform the freqanalysis output so that it'll be used correctly by indepsamplesZcoh?

Thanks!
Dahlia.

PS - here is part of the code that might be helpful, please let me know if any further information would help.

+++++++++++++++++++++++++++++++++++++++++++++++++++++
% configuration for freqanalysis
cfgfa            = [];
cfgfa.output     = 'powandcsd';          % 'pow';
cfgfa.toi        = -.25:.025:1.25;
cfgfa.foi        = 6:2:80;             %%
cfgfa.method     = 'mtmfft';       % 'mtmconvol';
cfgfa.trials     = 'all';
cfgfa.keeptrials = 'yes';
cfgfa.channel    = {'all' };
cfgfa.channelcmb = { 'rh-Jz MT' 'all' ; 'lh-Jz MT' 'all' }; % compute csd between right MT and all

% configuration for freqstatistics
cfgfs =                    [];
cfgfs.numrandomization =   100;
cfgfs.method =             'montecarlo';
cfgfs.correctm =           'cluster';
cfgfs.clusteralpha =       0.05;       % significance level for sample-level statistic, i.e. for being considered candidate for clustering
cfgfs.clusterstatistic =   'maxsum';   % maxsize
cfgfs.clusterthreshold =   'parametric';   % uses T distribution to calculate the sample-level statistic threshold - appropriate for cfg.statistic=indepsamplesT
cfgfs.minnbchan =          0;          %
cfgfs.alpha =              0.05;       % significance level for cluster-level statistic, i.e. for final result of significant cluster.
cfgfs.tail =               0;          % 0 for two-sided testing
cfgfs.correcttail =        'alpha';
cfgfs.ivar =               1;
cfgfs.latency =            'all';
cfgfs.frequency =          'all';
cfgfs.neighbours =          [];

cfgfs_coh =                 cfgfs;
cfgfs_coh.statistic =       'indepsamplesZcoh';
cfgfs_coh.label =           { 'all' }; %{ 'rh-Jz MT' 'all' ; 'lh-Jz MT' 'all' };

for trig = 100:100:200
trigstr = num2str( trig); disp([subj '  trig' trigstr])
invtrigfile = strcat( invtrigfile_base{1} , trigstr , invtrigfile_base{2});

freq = ft_freqanalysis( cfgfa, data_ftrip);
ntrl = size( freq.powspctrm, 1 ); eval(['ntrl' trigstr '=ntrl;'])
end
design = ones(1, ntrl100 + ntrl200); design(ntrl200+1:end)=2;
ccfgfs_coh.design = design;
%     cfgfs_coh.label = freq.labelcmb;
cfgfs_coh.channelcmb = freq.labelcmb;
coh_stat = ft_freqstatistics( cfgfs_coh, freq200, freq100);

----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/neuroimaging/fieldtrip.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20100608/3dd69629/attachment-0001.html>
```