Roi Manager Problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Roi Manager Problem

Peter Haub
Dear IJDevTeam,

there seems to be a problem with Roi Manager / Edit Mode when selecting
rois in an image stacks (seen in ImageJ 1.44d).

If the images in the stack contain a high density of rois, the selection
of a particular roi in an image will result in the selection of a
different roi in an image with a lower image number.

The reason for this behavior seems to be the comparison of only the x
and y mouse positions with the roi label but not the image number z.

My work around is a modification in
ImageCanvas.java
..
boolean roiManagerSelect(int x, int y) {
..
..
for (int i=0; i<n; i++) {
     if (labelRects[i]!=null&&   labelRects[i].contains(x,y)) {
       ..
       ..
       // Check slice number
       slice = getSliceNumber(list.getItem(i));
       if (slice != imp.getCurrentSlice()) continue;
       ..
       ..
      }
}

Maybe there is a better solution.

If somebody is interested I can provide some test data.
(Please let me know where to upload a small example stack and roi collection.)


ps: I could not understand why it is sometimes not possible to reproduce
this behavior directly after loading stack and rois, and why it will
appear after selecting a roi in image 1 first.


Peter
Reply | Threaded
Open this post in threaded view
|

Re: Roi Manager Problem

Bill Mohler
Peter-

I just came upon the same problem (by chance) just after reading your
post.  Thanks for the simple solution!

Bill

On 5/4/11 12:42 AM, Peter Haub wrote:
>         // Check slice number
>         slice = getSliceNumber(list.getItem(i));
>         if (slice != imp.getCurrentSlice()) continue;
Reply | Threaded
Open this post in threaded view
|

Re: Roi Manager Problem

Bill Mohler
...  Actually, I just looked over my own ImageCanvas.java modifications,
and I found that I must have previously encountered the problem because
I had implemented a solution in my copy.  It also seems to solve the
problem by modifying a different method to limit accessible ROIs to
those in the current slice:


     void drawAllROIs(Graphics g) {

...
//        if (labelRects==null || labelRects.length!=n)
         labelRects = new Rectangle[n];

...
             if (Prefs.showAllSliceOnly && imp.getStackSize()>1) {
                 if (hyperstack) {

                     int c = roi.getCPosition();
                     int z = roi.getZPosition();
                     int t = roi.getTPosition();
                     if ((c==0||c==channel) && (z==0||z==slice) &&
(t==0||t==frame))
                         drawRoi(g, roi, drawLabels?i:-1);

                         labelRects[i] = new Rectangle(roi.getBounds());
                     }
                 } else {
                     int position = roi.getPosition();
                     if (position==0)
                         position = getSliceNumber(roi.getName());
                     if (position==0 || position==currentImage)
                         drawRoi(g, roi, -1);
                         drawRoi(g, roi, drawLabels?i:-1);

                         labelRects[i] = new Rectangle(roi.getBounds());

                }
             }
         }
         ((Graphics2D)g).setStroke(Roi.onePixelWide);
     }


I also found one error in mousePressed(e) that can mess up the clicking
of ROIs in edit mode when the image is zoomed in or out:

the line
                 if (!(roi!=null && (roi.contains(ox,
oy)||roi.isHandle(x, y)>=0)) && roiManagerSelect(x, y))


  should read
                if (!(roi!=null && (roi.contains(ox,
oy)||roi.isHandle(x, y)>=0)) && roiManagerSelect(ox, oy))


Best,
Bill



On 5/4/11 1:56 PM, Bill Mohler wrote:

> Peter-
>
> I just came upon the same problem (by chance) just after reading your
> post.  Thanks for the simple solution!
>
> Bill
>
> On 5/4/11 12:42 AM, Peter Haub wrote:
>>          // Check slice number
>>          slice = getSliceNumber(list.getItem(i));
>>          if (slice != imp.getCurrentSlice()) continue;

--

William A. Mohler

Associate Professor
Dept. of Genetics and Developmental Biology
University of Connecticut Health Center

*Physical Address:***

Room R1159

Cell and Genome Sciences Building

400 Farmington Ave.

Farmington, CT

*Mail Address:*

MC-6403

263 Farmington Ave.

Farmington, CT06030-6403

[hidden email] <mailto:[hidden email]>
*Mobile: (860) 985-2719*

skype: wmohler
Office: (860) 679-1833, room R1159
Lab: (860) 679-1834, room R1265
Fax: (314) 689-1833

http://genetics.uchc.edu/Faculty/assoc_professors/mohler.html
PThink before you print