[FieldTrip] Some Questions on the resample design (Johanna Zumer)
Chao Wang
chaowang0704 at gmail.com
Thu May 9 10:51:37 CEST 2013
Dear
Johanna,
Thank you! I understand your meaning and that's right
that
this part of code is only reached if
max(design(cfg.uvar,:)) < 20, but what I do not understand is that for what
reason,
the '20' is set to test the
max(design(cfg.uvar,:)). And besides, by using 'sort', each row of tmp will
be the same, in ascending order, which will lead the 278 line using
'unique' to have tmp only one row. That is size(tmp,1)=1; this will
lead to cfg.numrandomization=1
in 284 line.
> 274 tmp = zeros(cfg.numrandomization*10, Nrepl/Nrep(1));
> 275 for i=1:cfg.numrandomization*10
> 276 tmp(i,:) = *sort*(randsample(1:Nrepl/Nrep(1), Nrepl/Nrep(1)));
> 277 end
>
> 278 tmp = unique(tmp, 'rows');
Best regards!
Chao
Message: 4
> Date: Tue, 7 May 2013 14:53:40 +0200
> From: Johanna Zumer <johanna.zumer at donders.ru.nl>
> To: FieldTrip discussion list <fieldtrip at science.ru.nl>
> Subject: Re: [FieldTrip] Some Questions on the resample design
> Message-ID:
> <
> CAL4kA6d-WLuip_tUvBRbQr2JiYQ9vr0rb_FnOe18aK8tqEmadA at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Dear Chao,
>
> I'm not familiar with this piece of code, but I had a quick look. Line
> 276, with the 'sort' command, is testing for the number of unique 'rows'
> (line 278). It then uses this information to modify the value of
> cfg.numrandomization (line 283 which you have not displayed), which is
> reduced if not enough unique information to do the requested number of
> randomizations. Then (I think) the actual randomization should be
> occuring in subsequent lines of code (292-296). Note also that
>
> this part
> of code is only reached if
>
> max(design(cfg.uvar,:)) < 20.
>
> Does that help? Maybe someone else with more experience in this section
> of code can comment as well?
>
> Or if you still find that it indeed is not randomizing, you can file a bug
> here (http://bugzilla.fcdonders.nl/), ideally with a small test script.
>
> Cheers,
>
> Johanna
>
>
>
>
> 2013/5/7 Chao Wang <chaowang0704 at gmail.com>
>
> > I'm sorry to make a mistake just now. The previous message sent didn't
> > fullfill my meaning.
> >
> > I carefully inspected the code in the function *resampledesign* but I was
> > quite confused by the codes in the bootstrap section (For paired design,
> > the design matrix should be like this, design(1,:)=[1:N 1:N],
> design(2,1:N)=1
> > and design(2,N+1:2*N)=2 and N is for example the subject number; and
> > cfg.uvar=2):
> > 91 Nvar = size(design,1); % number of factors or regressors
> > 92 Nrepl = size(design,2); % number of replications
> > ...
> > ...
> > 248 units = design(cfg.uvar,:);
> > 249 for k = 1:length(unique(units))
> > 250 sel = find(units==k);
> > 251 indx(:,k) = sel;
> > 252 Nrep(k) = length(sel);
> > 253 end
> > 254 resample = zeros(cfg.numrandomization, Nrepl);
> > ...
> > ...
> > 274 tmp = zeros(cfg.numrandomization*10, Nrepl/Nrep(1));
> > 275 for i=1:cfg.numrandomization*10
> > 276 tmp(i,:) = *sort*(randsample(1:Nrepl/Nrep(1), Nrepl/Nrep(1)));
> > 277 end
> >
> > 278 tmp = unique(tmp, 'rows');
> > 279 fprintf('found %d unique rows in bootstrap matrix of %d
> bootstraps',
> > size(tmp,1), cfg.numrandomization*10);
> > ...
> > ...
> > 292 for i=1:cfg.numrandomization
> > 293 for k=1:size(indx,1)
> > 294 resample(i,indx(k,:)) = indx(k,tmp(i,:));
> > 295 end
> > 296 end
> >
> > My question was on the code in 276 line. These code was to generate a
> > number of rand numbers (about cfg.numrandomization lines) in the range
> of 1
> > to Nrepl/Nrep(1), in which Nrepl is the number of replications in the
> > design and Nrep is the number of repetition (Nrep(:)=2 for paired
> design).
> > If the function '*sort*' is used, then every row of matrix tmp is the
> > same, which will be 1,2,..., Nrepl/Nrep(1). And this will lead the 278
> line
> > to the result: temp=1:Nrepl/Nrep(1) (because of the function unique).
> This
> > result is by no means what we want, I think. What we do want is several
> > rows numbers with same range but with distinct orders. Only in this way,
> > can we guarantee that each resample is not the same.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20130509/b80c52bd/attachment-0001.html>
More information about the fieldtrip
mailing list