Re: strange behaviour of the results table
Posted by
Karel Jansseune-2 on
May 08, 2009; 1:42pm
URL: http://imagej.273.s1.nabble.com/strange-behaviour-of-the-results-table-tp3692588p3692591.html
This is the code that I use to set the
coordinates.
The 2 first functions add an extra column
to the result table, the third function combines all the ROI's that have
the same coordiantes.
I included an image of the plants that
we are analysing.
function addXcoordinates (binsX){
minX
= getResult('X',1);
maxX
= getResult('X',1);
for(i=0;i<nResults;i++){
if (getResult('X',i)<minX){
minX =
getResult('X',i);
}
if (getResult('X',i)>maxX){
maxX=
getResult('X',i);
}
}
Xcoord
= "Numeric X coordinate";
setResult(Xcoord,0,NaN);
binSizeX
= (maxX - minX) / (binsX-1);
for(i=0;i<nResults;i++){
for (j = 0;j<binsX;j++){
Xval = getResult('X',i);
if ((minX + (j-0.5) * binSizeX <= Xval
) && (Xval <= minX + (j + 0.5) * binSizeX)){
XCoordinate
= j+1;
}
//if (Xval == maxX){
//XCoordinate
= binsX;
//}
}
setResult(Xcoord,i,XCoordinate);
}
updateResults;
}
function addYcoordinates (binsY){
minY
= getResult('Y',1);
maxY
= getResult('Y',1);
for(i=0;i<nResults;i++){
if (getResult('Y',i)<minY){
minY =
getResult('Y',i);
}
if (getResult('Y',i)>maxY){
maxY=
getResult('Y',i);
}
}
Ycoord
= "Numeric Y coordinate";
setResult(Ycoord,0,NaN);
binSizeY
= (maxY - minY) / (binsY-1);
for(i=0;i<nResults;i++){
for (j = 0;j<binsY;j++){
Yval = getResult('Y',i);
if ((minY + (j-0.5) * binSizeY <=
Yval ) && (Yval <= minY + (j + 0.5) * binSizeY)){
YCoordinate
= j+1;
}
//if (Yval == maxY){
//YCoordinate
= binsY;
//}
}
setResult(Ycoord,i,YCoordinate);
}
updateResults;
}
function combineROI (){
scalefactor
= 380/4036.07;
addXcoordinates(6);
addYcoordinates(4);
amountResults
= nResults;
for
(i=0;i<amountResults;i++){
for (j=0;j<amountResults;j++){
if (i
!= j){
doublesfound = false;
x1=getResult('X',i);
y1=getResult('Y',i);
x2=getResult('X',j);
y2=getResult('Y',j);
X1=getResult('Numeric X coordinate',i)*scalefactor;
Y1=getResult('Numeric Y coordinate',i)*scalefactor;
X2=getResult('Numeric X coordinate',j)*scalefactor;
Y2=getResult('Numeric Y coordinate',j)*scalefactor;
if (X1 == X2 && Y1 == Y2) {
doublesfound
= true;
roiManager("Select",i);
setKeyDown("shift");
roiManager("Select",j);
setKeyDown("none");
roiManager("Add");
roiManager("Select",
i);
roiManager("Delete");
run("Select
None");
roiManager("Select",
j-1);
roiManager("Delete");
roiManager("deselect");
run("Select
None");
updateResults;
}
if(doublesfound){
doublesfound
= false;
j = -1;
run("Select
None");
run("Clear
Results");
roiManager
("Measure");
addXcoordinates(6);
addYcoordinates(4);
}
amountResults
= nResults;
}
if (i
>= amountResults){
j = amountResults;
}
}
}
updateResults;
run("Select
None");
run("Clear
Results");
roiManager
("Measure");
}
combineROI();
Best regards,
Karel Jansseune
On Friday 08 May 2009 12:43:56 Karel Jansseune wrote:
> Am I missing some setting here? Or could it be a mistake in my code?
Yes, you must be missing something, but without seeing the code is nearly
impossible to say what it is.
G.
The information contained in this e-mail is for
the exclusive use of the intended recipient(s) and may be confidential,
proprietary, and/or legally privileged. Inadvertent disclosure of this
message does not constitute a waiver of any privilege. If you receive this
message in error, please do not directly or indirectly use, print, copy,
forward, or disclose any part of this message. Please also delete this
e-mail and all copies and notify the sender. Thank you.
For alternate languages please go to
http://bayerdisclaimer.bayerweb.com