[FieldTrip] Using clusterstat.m straight giving her specific statobs and statrnd

Constantino Méndez Bértolo constantino.mendezbertolo at ctb.upm.es
Fri Sep 5 17:30:26 CEST 2014


Dear Eelke,

Many thank yous - just a follow-up after your response on how to call
clusterstat with proper dimensions (days later because it took sometime to
compute the statobs and the statrnd)

Yes it works! :)

ps: To make this message less spammy, I will add the things we finally need
to consider in case it helps anyone. This assumes you have computed the
statobs and the statrnd structure (using whatever statistic you are into,
in this case, the interaction effect of two factors within a manova was
tested for each time point and channel in -R-).

Statobs should be Nchan*Ntime and statrnd Nchan*Ntime*Nrand (randomizations
performed)
Statobs should be converted int oa single vector and statrnd a matrix as
long * Nrand
Cfg.dim will have the same dimensions and statobs.
Use cfg.connectivity by calling ft_channelconnectivity
Of course you need to provide clusterstat with the specific critvalue
calculated beforehand.
You will encounter that you need to reshape back fields prob and
clusterlabelmat (eg: reshape(stat.posclusterslabelmat,[Nchan Ntime]) to
make it readable for humans
Last advice: you may be asking yourself why matlab says there is no
channelconnectivity functions or clusterstat.m --- they are inside
fieldtrip##\private and you may need to includes them in the path/alter the
name of the folder

Thanks a lot again Eelke,
Tino

















2014-09-01 9:48 GMT+02:00 Eelke Spaak <eelke.spaak at donders.ru.nl>:

> 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
>>
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>



-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140905/d234348d/attachment-0002.html>


More information about the fieldtrip mailing list