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