Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
9 posts
|
Hello,
after a long Time I am now able to reproduce the error with a simple code. I create two Stacks "A" & "B" with 3 Slices. Then I draw a diffrent object in each Slice of "A". At the next step I select each Object in "A" with doWand and add it to the roiManager. At last I select every ROI and draw it in "B". So Image "A" and "B" should be exact copys of each other. So far no Problem. But if I duplicate "A", make a selection in "A-1" and do something with it, like fill or enlarge, before I add the selections of "A" to the roiManager and then Enlarge the selections in the roi manager, the wrong Selections are drawn to "B". This error only occurs if I Enlarge the selections from the ROI Manager and do something with a selection in a third Image before. If I do just one of this two things, or the batchmode is turned off, nothing happens. Here the code: macro "batchmodetest" { setBatchMode(true); //The macro works fine if BatchMode is turned off newImage("A", "8-bit Black", 400, 400, 3); newImage("B", "8-bit Black", 400, 400, 3); selectWindow("A"); makeRectangle(121, 132, 49, 43); run("Fill", "slice"); setSlice(2); run("Select All"); run("Fill", "slice"); setSlice(3); makeOval(121, 132, 127, 113); run("Fill", "slice"); run("Select None"); run("Duplicate...", "title=A-1 duplicate range=1-3"); makeRectangle(5, 5, 49, 43); run("Fill", "slice"); //If this and Enlarge in Line 40 is called the Error occurs. //If one of them is turned off it works roiManager("reset"); selectWindow("A"); setSlice(1); doWand(121,132) roiManager("Add"); setSlice(2); doWand(121,132) roiManager("Add"); setSlice(3); doWand(121,132) roiManager("Add"); selectWindow("B"); m=(roiManager("count")-1); for(r=0;r<=m;r++) { roiManager("deselect"); roiManager("select",r); run("Enlarge...", "enlarge=10"); // This is the enlarge that makes the error run("Fill", "slice"); } setBatchMode("exit and display"); } -----Ursprüngliche Nachricht----- Von: "Rasband, Wayne (NIH/NIMH) [E]" <[hidden email]> Gesendet: 02.11.2011 18:46:04 An: [hidden email] Betreff: Re: Problem with ROI Manager in BatchMode >On Nov 1, 2011, at 3:28 PM, Peter Haub wrote: > >> Hi Winfried, >> Hi Wayne, >> >> sorry, my description was not precise enough. >> >> The problem has - as far as I can see in the IJ code - to do with the IJ >> internal management of the RoiManager. >> In the BatchMode there is a special handling of the RoiManager. >> So the behaviour of your macro depends on the sequence of activation the >> BatchMode and first time calling the RoiManager. >> You solved the problem by changing that sequence. >> >> The idea of my code was to attract someones attention who can solve this. > >The open() macro function is unable to open ROI sets if the macro is running in batch mode and the ROI Manager is not open. I did not see an easy fix for this problem so the ImageJ 1.46a4 daily build displays an error message in this situation. You can easily work around this problem by using > > roiManager("Open", path_to_ROI_set); > >to open ROI sets. > >-wayne > >> The problem can be visualized more clearly by changing my code and to >> open the RoiManager before activating the BatchMode. >> This code works fine: >> >> **************** Here is my 'changed' code ********************** >> open("C:\\RoiSet.zip"); >> >> setBatchMode(true); >> >> open("C:\\test.tif"); >> >> // It's working if this call is previous to the batch mode activation >> !!!!!!!! >> //open("C:\\RoiSet.zip"); >> >> selectWindow("test.tif"); >> run("Select None"); >> m=(roiManager("count")-1); >> for(r=0;r<=m;r++) >> { >> roiManager("deselect"); >> roiManager("select",r); >> arg="enlarge="+2; >> run("Fill", "slice"); >> } >> setBatchMode("exit and display"); >> ***************************************************** >> >> Peter >> >> On 01.11.2011 17:44, Winfried Wurm wrote: >>> Thank you Peter for trying to solve my Problem. >>> But my Problems seems to have another reason. Actually I solved my Problem today, but I have to admit that I don´t know why the Macro is working now.... >>> >>> It seems to me now that the Problem was another Function that I run before the Foci counting part that I posted yesterday. That function is measuring the Area of Chromocenters. When I turned it off or behind the Foci measuring today everything worked fine. But I don’t know why! The function measures in a completely different Image and shares no variable with the Foci measuring function. And when I call that function AFTER the Foci Funtion there is no Problem. >>> >>> So why is that working? >>> CountMeasureFoci("cell.tif","foci.tif",px[con],mpx[con],msl[con]); >>> cellarea=Cellar("cellar.tif"); >>> chromarea=Cellar("chrom.tif"); >>> >>> And this not? >>> cellarea=Cellar("cellar.tif"); >>> chromarea=Cellar("chrom.tif"); >>> CountMeasureFoci("cell.tif","foci.tif",px[con],mpx[con],msl[con]); >>> >>> And why did the Problem only occur in BatchMode? I have no Idea what has happend. Maybe someone can tell what went wrong? Because even if it works now. I would like to understand why. >>> >>> Here is the function that seems to make the Problem: >>> >>> function Cellar(window) >>> { >>> selectWindow(window); >>> area=0; >>> for(z=1;z<=nSlices;z++) >>> { >>> setSlice(z); >>> run("Select None"); >>> run("Measure"); >>> if (getResult("Max")==255) >>> { >>> for(x=1;x<getWidth;x++) >>> { >>> makeRectangle(x, 0, 1, getHeight); >>> run("Measure"); >>> if (getResult("Max")==255) >>> { >>> for(y=1;y<getHeight;y++) >>> { >>> if(getPixel(x,y)==255) >>> { >>> doWand(x-1,y); >>> run("Measure"); >>> m=getResult("Area"); >>> area+=m; >>> run("Fill", "slice"); >>> makeRectangle(x, 0, (getWidth-x), getHeight); >>> run("Measure"); >>> if (getResult("Max")==255) >>> { >>> makeRectangle(x, 0, 1, getHeight); >>> run("Measure"); >>> if (getResult("Max")<255) >>> y=getHeight; >>> } >>> else >>> { >>> x=getWidth; >>> y=getHeight; >>> } >>> } >>> } >>> >>> >>> } >>> } >>> } >>> } >>> return area; >>> } >>> ... [show rest of quote] ___________________________________________________________ SMS schreiben mit WEB.DE FreeMail - einfach, schnell und kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192 |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
1064 posts
|
On Nov 28, 2011, at 8:15 AM, Winfried Wurm wrote:
> Hello, > after a long Time I am now able to reproduce the error with a simple code. I create two Stacks "A" & "B" with 3 Slices. Then I draw a diffrent object in each Slice of "A". At the next step I select each Object in "A" with doWand and add it to the roiManager. At last I select every ROI and draw it in "B". So Image "A" and "B" should be exact copys of each other. > > So far no Problem. But if I duplicate "A", make a selection in "A-1" and do something with it, like fill or enlarge, before I add the selections of "A" to the roiManager and then Enlarge the selections in the roi manager, the wrong Selections are drawn to "B". > This error only occurs if I Enlarge the selections from the ROI Manager and do something with a selection in a third Image before. If I do just one of this two things, or the batchmode is turned off, nothing happens. The 1.46b daily build fixes a batch mode macro bug that could cause run("Restore Selection") to fail. Your macro was failing because it uses the Enlarge command, which is implemented by a macro that uses run("Restore Selection"). -wayne > Here the code: > > macro "batchmodetest" > { > setBatchMode(true); //The macro works fine if BatchMode is turned off > newImage("A", "8-bit Black", 400, 400, 3); > newImage("B", "8-bit Black", 400, 400, 3); > selectWindow("A"); > makeRectangle(121, 132, 49, 43); > run("Fill", "slice"); > setSlice(2); > run("Select All"); > run("Fill", "slice"); > setSlice(3); > makeOval(121, 132, 127, 113); > run("Fill", "slice"); > run("Select None"); > > run("Duplicate...", "title=A-1 duplicate range=1-3"); > makeRectangle(5, 5, 49, 43); > run("Fill", "slice"); //If this and Enlarge in Line 40 is called the Error occurs. > //If one of them is turned off it works > > roiManager("reset"); > selectWindow("A"); > setSlice(1); > doWand(121,132) > roiManager("Add"); > setSlice(2); > doWand(121,132) > roiManager("Add"); > setSlice(3); > doWand(121,132) > roiManager("Add"); > > selectWindow("B"); > m=(roiManager("count")-1); > > for(r=0;r<=m;r++) > { > roiManager("deselect"); > roiManager("select",r); > > run("Enlarge...", "enlarge=10"); // This is the enlarge that makes the error > > run("Fill", "slice"); > } > setBatchMode("exit and display"); > } ... [show rest of quote]
|
Free forum by Nabble | Disable Popup Ads | Edit this page |