> I've searched through the archives, and I haven't find a clue about this:
> Is there an easy/elegant way to random select x ROIs for measurement? Eg. I
> have around 230 ROIs, but I need only 200 results for the statistical
> analysis.
> Regards
>
> Ákos
Dear Ákos,
this issue has already been discussed here. Have a look at:
<
https://list.nih.gov/cgi-bin/wa?A2=ind0902&L=IMAGEJ&P=R27945&I=-3>
As Curtis suggested probably the best way to do it is to use Fisher Yates
shuffle: <
http://en.wikipedia.org/wiki/Fisher-Yates_shuffle>.
It could be something like the lines below but have a look at Curtis suggestion
// ---
k=0; n=roiManager("count"); rois=newArray(n);
for(i=0;i<n;i++)
rois[i]=k++;
myFisherYates(rois);
sample = getNumber("Size of Sample?", n);
count=1;
for(i=0;i<sample;i++) {
roiManager("select", rois[i]);
roiManager("measure");
print(count++ +"/"+sample+" : Measured ROI: "+rois[i]);
}
function myFisherYates(array) {
if(array.length!=0) {
for (i=0;i<array.length ;i++) {
j = floor(random()*(i+1));
temp1 = array[i]; temp2 = array[j];
array[i] = temp2; array[j] = temp1;
}
}
}