Dear,
I run a macro that makes calculation in the results table inorder to combine ROI's. (A long story short: calculations are made to create coordinates for the ROI's,and ROI's with similar coordinates are than combined) so far, the macro runs fine, but each time at startup, I get an error saying that the results table is empty. The second time the macro is run, everything works as it should. I have already included a step to show the resultstable and to update it, but this error persists. Am I missing some setting here? Or could it be a mistake in my code? Kind regards, Karel |
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. |
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
Result of IMG_0386.jpg (1M) Download Attachment |
On Friday 08 May 2009 14:42:51 Karel Jansseune wrote:
> 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. Well, your results table is empy. Unless you fill it with some data, there is no "X" that you can get (1st line). You need to run the Analyze>Analyze Particle... command before running your macro. G. |
In reply to this post by Karel Jansseune-2
The macro I posted is part of a bigger macro, which includes a "Analyse
particles" step It turns out now, that the macro moves to fast, so the resultstable wasn't filled when the combineROI started, I added an "wait(200)" step and I didn't got the problem anymore. thank you anyhow for the help |
Free forum by Nabble | Edit this page |