Home Image-Pro General Discussions

Cannot save XO ROI

Hi!

I have a few images that have some part in the ROI that I want to exclude. I have used the XO ROI to do this, but when closing the image and reopening it, it stops working and shows up as separate ROI's instead. How can I go about to save the setting so therse areas are excluded?

Thanks!

Best Regards Josephine

Best Answers

  • Josephine --

    I attempted to duplicate the problem that I thought you were describing.

    In doing so, I did the following:

    ** Acquired a JPG IMAGE FILE from the INTERNET
    ** Opened the JPG IMAGE FILE using PREMIER 9.2
    ** Saved the IMAGE as a TIF IMAGE (Stripes01.tif) using PREMIER
    ** Created nested XOR ROIS using PREMIER
    ** Performed and AUTO DARK COUNT using PREMIER
    ** Saved the IMAGE as a TIF IMAGE (Stripes02.tif) using PREMIER
    ** Copied the TIF IMAGE (Stripes02 - Copy.tif) using WINDOWS
    ** Opened the COPY of the TIF IMAGE using PREMIER
    ** Observed that the ROIS and the COUNTED OBJECTS were displayed in PREMIER
        (see 1st screen capture below for these steps)
    ** Performed and AUTO DARK COUNT using PREMIER and found that the XOR ROI OPTION was now OFF for the COPY IMAGE
        (see 2nd screen capture below for this steps)

    I tried to save the XOR ROI OPTION = ON in an IQO file using

        COUNT SIZE + MEASUREMENTS + SAVE OPTIONS

    and

        FEATURE MANAGER

    but neither was successful.

    The best solution that I can offer is a MACRO that will set the XOR ROI OPTION = ON with the following code

        Public Function Macro_XOR_ROI() As SimpleScript
            Macro_XOR_ROI = New SimpleScript
            Dim doc1
    
            With Application.DocumentCommands.Active(Macro_XOR_ROI)
                .Run(doc1)
            End With
    
            With [Select].RoiCommands.XORROIs(Macro_XOR_ROI)
                .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
                .Run(doc1)
            End With
    
        End Function
    Please see the 3rd screen capture below for the full PROJECT.

    You can use the PROJECT EXPLORER and the PROPERTIES of this MACRO to put this macro on the QUICK ACCESS TOOLBAR as shown in the 4th screen capture below.  This will make it to where you can turn this feature on with a single mouse click.  You can also use the PROPERTIES of this MACRO to create a KEYBOARD SHORTCUT for this MACRO.

    If you get fancy, you can put an IMAGE FILE OPEN into the MACRO so that you trigger the MACRO, the MACRO queries for the FILE NAME, the MACRO opens the IMAGE, and then the MACRO turns on the XOR ROI OPTION.

    Perhaps someone at MEDIA with a more intimate knowledge of PREMIER can suggest a better solution.

    I hope this information is helpful.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-








  • Josephine --

    I'm glad that the FEATURES and FUNCTIONS of PREMIER, the SUPPORT of the FORUM, and your ANALYSIS MACRO combined into a successful solution for your imaging challenge.

    -- Matt

Answers

  • Hi Josephine,

    You can also use Merge ROIs function  (it's in the same dropdown as XOR ROI). This function creates new ROIs using XOR rule, these ROIs are properly saved and restored with the image. Internal ROI is not visible after Merge, but it's processed properly by all operations including Count.

    Yuri
  • edited September 2016
    Hi,

    Thanks for helping!

    I started withe Yuris suggestions, since they were easiest.

    Unfortunately I cannot make it work by merging the ROIs...

    I attached some screen captures of what I want it to look like and what it looks like.
    Here is what I did:

    - I opened my image
    - chose XOR ROI and then merge ROI
    - Counted the area by manual threashold
    - By doing this I managed to exclude one of the two ROIs



    So I tried:

    - I opened my image
    - chose merge ROI
    - Counted the area by manual threashold
    - By doing this, none of the internal ROIs was excluded from the count



    Only thing that gives me my desired result is by only using XOR ROI, but then it wont save. 



    I am doing batch process with a macro for a set of images, thats why I need it to be saved.

    I will try Matthews suggestions next, I just need to read it a few more times to understand it ;) 

    Worst case scenario I batch process the images with only one ROI and do the ones with multiple ones manually.

    Any chance this will be mended in 9.3?

    Thanks for trying tho!

    Josephine

  • Hi Josephine,

    Here are the steps you should use:
    1. Draw 2 ROIs
    2. Activate XOR option
    3. Merge ROIs (internal ROI will disappear, but still be active)
    4. Save image 
    5. Load image (In the batch processing)
    6. Do count - correct areas should be measured.

    Also, if you do batch processing, you can just use Matt's suggeation, add XOR ROI command in your macro before the first Count.

    Yuri 
  • Hi, 

    I did a new macro, adding the XOR before smart segmentation and it so far seems to work fine in my small batch testing! I am running a larger batch at the moment where the image closes after analyzing, I'm curious to see if the settings have held up for when I run the data collector macro I have set up! I will get back as soon as I know!

    I tried it the way you explained Yuri, but it only seems to exclude one ROI, I have several internal ROIs in some images (excluding debris, holes in the section and such). Also, the ROI it actually excluded still showed on the image, while the other ROIs simply disappeared and were then included in the count while batch processing, both in analyzing the cells and in the total ROI area.

    Thanks for helping and have a nice weekend!

    Best Regards Josephine
  • This problem will be fixed in the next release of Premier.  Note that neither the "XOR ROI" nor the "Invert ROI" options are currently saved.  In the mean time, I see no workaround other than the one suggested by Matt, namely setting the options once the image has been opened.  Here are some simple macros that show low-level code that will do the job.

        Public Sub SetXorROI()
            ThisApplication.ActiveImage.Aoi.OptionFlags(MediaCy.IQL.Features.mcOptionFlags.mcofDefaultXorOnMerge) = _
                MediaCy.IQL.Features.mcOptionFlags.mcofDefaultXorOnMerge
        End Sub
    
        Public Sub SetInvertROI()
            ThisApplication.ActiveImage.Aoi.OptionFlags(MediaCy.IQL.Features.mcOptionFlags.mcofInvertFeatureMask) = _
                MediaCy.IQL.Features.mcOptionFlags.mcofInvertFeatureMask
        End Sub
    
        Public Sub SetBothXorAndInvertROI()
            ThisApplication.ActiveImage.Aoi.OptionFlags(MediaCy.IQL.Features.mcOptionFlags.mcofInvertFeatureMask + MediaCy.IQL.Features.mcOptionFlags.mcofDefaultXorOnMerge) = _
                MediaCy.IQL.Features.mcOptionFlags.mcofInvertFeatureMask + MediaCy.IQL.Features.mcOptionFlags.mcofDefaultXorOnMerge
        End Sub
    
    


  • Hi!

    I ran the batch over the weekend, adding the XOR ROI before smart segmentation in my macro did the trick! It worked very well! 

    Good to hear that it will be fixed for 9.3 though! 

    Thanks for helping!

    Best Regards Josephine
Sign In or Register to comment.