<div dir="ltr">Dear Chao,<div><br></div><div>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.</div>
<div><br></div><div>Does that help? Maybe someone else with more experience in this section of code can comment as well?</div><div><br></div><div style>Or if you still find that it indeed is not randomizing, you can file a bug here (<a href="http://bugzilla.fcdonders.nl/">http://bugzilla.fcdonders.nl/</a>), ideally with a small test script.</div>
<div><br></div><div>Cheers,</div><div>Johanna</div><div><br></div><div><br></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/5/7 Chao Wang <span dir="ltr"><<a href="mailto:chaowang0704@gmail.com" target="_blank">chaowang0704@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">I'm sorry to make a mistake just now. The previous message sent didn't fullfill my meaning.</div><div class="gmail_default" style="font-family:tahoma,sans-serif">
<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><span style="font-size:13px">I carefully inspected the code in the function </span><i style="font-size:13px"><b>resampledesign</b></i><span style="font-size:13px"> 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], </span><span style="font-size:13px">design(2,1:N)=1 and </span><span style="font-size:13px">design(2,N+1:2*N)=2 and N is for example the subject number</span><span style="font-size:13px">; and cfg.uvar=2</span><span style="font-size:13px">):</span></div>
<div class="gmail_default"><div class="gmail_default"><font face="tahoma, sans-serif">91 Nvar = size(design,1); % number of factors or regressors</font></div><div class="gmail_default"><font face="tahoma, sans-serif">92 Nrepl = size(design,2); % number of replications</font></div>
<div class="gmail_default"><font face="tahoma, sans-serif">...</font></div><div class="gmail_default"><font face="tahoma, sans-serif">...</font></div></div><div class="gmail_default"><div class="gmail_default"><font face="tahoma, sans-serif">248 units = design(cfg.uvar,:);</font></div>
<div class="gmail_default"><font face="tahoma, sans-serif">249 for k = 1:length(unique(units))</font></div><div class="gmail_default"><font face="tahoma, sans-serif">250 sel = find(units==k);</font></div><div class="gmail_default">
<font face="tahoma, sans-serif">251 indx(:,k) = sel;</font></div><div class="gmail_default"><font face="tahoma, sans-serif">252 Nrep(k) = length(sel);</font></div><div class="gmail_default"><font face="tahoma, sans-serif">253 end</font></div>
<div class="gmail_default"><font face="tahoma, sans-serif">254 resample = zeros(cfg.numrandomization, Nrepl);</font></div></div><div class="gmail_default"><font face="tahoma, sans-serif">...</font></div><div class="gmail_default">
<font face="tahoma, sans-serif">...</font></div><div class="gmail_default"><font face="tahoma, sans-serif"><div class="gmail_default">274 tmp = zeros(cfg.numrandomization*10, Nrepl/Nrep(1));</div><div class="gmail_default">
275 for i=1:cfg.numrandomization*10</div><div class="gmail_default">276 tmp(i,:) = <b>sort</b>(randsample(1:Nrepl/Nrep(1), Nrepl/Nrep(1)));</div><div class="gmail_default">277 end</div><div class="gmail_default">
<br></div><div class="gmail_default"><div class="gmail_default">278 tmp = unique(tmp, 'rows');</div><div class="gmail_default">279 fprintf('found %d unique rows in bootstrap matrix of %d bootstraps', size(tmp,1), cfg.numrandomization*10);</div>
</div><div class="gmail_default">...</div><div class="gmail_default">...</div><div class="gmail_default"><div class="gmail_default">292 for i=1:cfg.numrandomization</div><div class="gmail_default">293 for k=1:size(indx,1)</div>
<div class="gmail_default">294 resample(i,indx(k,:)) = indx(k,tmp(i,:));</div><div class="gmail_default">295 end</div><div class="gmail_default">296 end</div><div class="gmail_default"><br></div><div class="gmail_default">
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 '<b>sort</b>' 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.</div>
<div class="gmail_default"><br></div></div></font></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, May 7, 2013 at 2:35 PM, Chao Wang <span dir="ltr"><<a href="mailto:chaowang0704@gmail.com" target="_blank">chaowang0704@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">I<div> have been using field-trip. Recently, I tried to use it for statistic test by non-parametric method, e.g. bootstrap and permutation. As usual, the two method involve resample original data with or without replacement. I carefully inspected the code in the function <i><b>resampledesign</b></i> but I was quite confused by the method in the bootstrap section:</div>
<div><div><br></div></div><div><div><font face="tahoma, sans-serif">254resample = zeros(cfg.numrandomization, Nrepl);</font><br>
</div></div></div>
</blockquote></div><br></div></div>
<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>