[FieldTrip] Using clusterstat.m straight giving her specific statobs and statrnd
Eelke Spaak
eelke.spaak at donders.ru.nl
Mon Sep 1 09:48:30 CEST 2014
Dear Constantino,
First, you need to specify cfg.dim as the size of the data matrix, in your
case probably just [102 500], the size(statobs) before reshaping. Note that
you need to put in statobs as a vector (statobs(:)) and statrnd as a
numel(statobs) X nRand matrix.
Second, I don't know why you are specifying a cfg.layout, this is not used
by the function. The same goes for cfg.neighbours, this is also not used.
The higher-level statistics functions convert the cfg.neighbours
struct-array into a logical connectivity array using the low-level private
function channelconnectivity. To use clusterstat (a low-level function)
directly, you need to do this beforehand.
So, do something like this:
cfg = [];
cfg.neighbours = neighbours;
cfg.channel = datachannels; % order is important here, must be the same as
the data
connectivity = channelconnectivity(cfg);
cfg = [];
...
cfg.dim = size(statobs); % assuming statobs is still a chan X time matrix
cfg.connectivity = connectivity;
% this assumes statrnd is a chan X time X nRand array
statrnd = reshape(statrnd, [numel(statobs), size(statrnd,3)]);
statobs = statobs(:);
stat = clusterstat(cfg, statrnd, statobs);
Best,
Eelke
On 29 August 2014 18:36, Constantino Méndez Bértolo <
constantino.mendezbertolo at ctb.upm.es> wrote:
> Dear Fieldtrippers
>
> We have a 3x3 design and MEG data, say only mag channels (n102) to
> simplify.
>
> We want to perform a cluster-based permutation approach but
> timelockstatistics (cfg.method = 'montecarlo', cfg.correctm = 'cluster',
> etc) cannot deal with interactions when you have more than three levels
> (true?)
>
> So we built our 'statobs' and 'statrnd' doing a GLM in -R Statistical
> Package- and feed 'clusterstat.m' with them
>
> We have done this with one channel over time with success. However, I am
> clueless now about how to solve the problem when dealing with the whole
> channel set.
>
> I wonder what is the nature of the cfg.dim that we need to feed
> 'clusterstat.m' with.
>
> Up to now, we use, (cioming out of -R-):
>
> size(statobs) = nchan*ntime % (102*500) % twin = [0 .5] % seconds
> size(statrnd) = nchan*ntime*nrandomizations % (102*500*1000)
>
>
> and the following presets:
>
> cfg=[];
> cfg.clustercritval = Fcritmain; % We genereate this before hand
> cfg.tail = 1; cfg.clustertail = 1; cfg.clusterthreshold = 'parametric';
> cfg.dim = [1 size(statobs,1) size(statobs,2) ] % <<< The key may be here
> load('neuromag306mag_neighb.mat');
> cfg.neighbours = neighbours;
> cfg.feedback = 'yes';
> cfg.numrandomization = 1000;
> cfg.clusterstatistic = 'maxsum';
> cfg.layout = 'neuromag306mag.lay';
> for i = 1:length(cfg.neighbours)
> cfg.channel{i} = cfg.neighbours(i).label;
> end
>
> stat = clusterstat(cfg,statrnd, statobs)
>
>
> Which lead us to an error within findcluster
>
> Error using findcluster (line 59)
> invalid dimension of spatdimneighbstructmat
>
> Error in clusterstat (line 197)
> posclusobs = findcluster(reshape(postailobs,
> [cfg.dim,1]),channeighbstructmat,cfg.minnbchan);
>
>
> If anybody has got some insigth it would be greatly appreciated. Or any
> hints. Are the size of my statobs and starnd correct? I can share more
> information and firstly apologize if I was not able to describe the
> problem accurately, I am confused regarding that 'reshape' and the addition
> of one dimension at "...reshape(postailobs,[cfg.dim,1])...", but the
> problem arises first when findcluster.m tries to calculate the size of
> spatdimneighbstructmat
>
> First line of findcluster.m calcualtes 'spatdimlength' by : "
> spatdimlength = size(onoff, 1);" which in our case is "1", which is
> obviously wrong?.
>
> manythanks&peace2all
>
> --
> Constantino Méndez-Bértolo
> Laboratorio de Neurociencia Clínica, Centro de Tecnología Biomédica (CTB)
>
> Parque Científico y Tecnológico de la UPM, Campus de Montegancedo
>
> 28223 Pozuelo de Alarcón, Madrid, SPAIN
>
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140901/2db58df1/attachment-0001.html>
More information about the fieldtrip
mailing list