Login  Register

Re: Threading problem? Montage with Overlay?

Posted by Nathaniel Ryckman on Jun 01, 2011; 3:09pm
URL: http://imagej.273.s1.nabble.com/Threading-problem-Montage-with-Overlay-tp3684401p3684402.html

I probably should investigate the cause further, but, instead, I'll just say that IJ.makeRectangle() was causing the error. When I replaced IJ.makeRectangle() with custom code that should do the same thing, the program worked liked normal:

// Select window
imp = WindowManager.getImage("DAPI");
imp.setActivated();
iw = imp.getWindow();
WindowManager.setCurrentWindow(iw);
               
// Run IJ command
//IJ.makeRectangle(xC - maxDim/2, yC - maxDim/2, maxDim, maxDim);
               
// Create rectangle selection
Rectangle tempRect = new Rectangle(xC - maxDim/2, yC - maxDim/2, maxDim, maxDim);
iw.getImagePlus().setRoi(tempRect);
                                       
// Select window
imp = WindowManager.getImage("DAPI");
imp.setActivated();
iw = imp.getWindow();
WindowManager.setCurrentWindow(iw);
               
// Run IJ command
IJ.run("Duplicate...", "title=DAPI_" + yfpIndex);

Nathaniel Ryckman wrote
Here are the goals that I have:

1) I have many stained cells that I would like to cut out and then montage. I have the cells' Rois.
2) After I have a montage, I would like to create an overlay using the Rois from step 1.

Any ideas would be appreciated.

---------------------------------------

I used the following to obtain square images of the cells to montage:

IJ.makeRectangle();
IJ.run("Duplicate...", "title");
IJ.run("Canvas Size...", "width= height= position=");

// Select window
iw = WindowManager.getImage("title").getWindow();
WindowManager.setCurrentWindow(iw);


The problem that I am having is that there seems to be some threading going on that I am not fully aware of or am not handling correctly when I call the IJ commands.....

I suspect that there is a threading problem because, when I run the program normally, I end up with cells that have been duplicated several times (total squares duplicated stays the same though), but, when I run the program in debug mode, I do not get this error.

Thanks again!