Home Image-Pro Automation (Macros, Apps, Reports)

Extract Location / Well information macro

Hi Forum,

I am trying to save individual images/movies from a plate, and add a suffix of their well location to the file name. So for example: "Image1_A1" ,  with A1 being the well/location information.

I tried:
Dim imset As McImageSet=ThisApplication.ActiveDocument.Data
Dim curLoc As McImageSetLocations=imset.GetCurrentLocation
which I found in an existing App, but McImageSet gives me an error: Type Identifier is invalid. 
Is there an easy way of retrieving the location info for a macro?

I know that ImageSetAnalyzer can do this, but I dont fully understand the code behind it. And I would like to be able to quickly add this feature to future apps and macros.

Thanks for your help,

Best Answer

  • Answer ✓
    Hi Henri,

    There is no documentation specifically for getting location suffix. You can check "Automation Reference" that contains descriptions for all low-level objects and functions, though it's a large help file with thousands of pages.
    You can just look at the LocationSuff function of ImageSetAnalyzer to see how it works.

    Here is a modified version of the macro that prints location suffix of the CurrentLocation of the active Image Set, you can just copy/paste it to your macro (assuming that you have all necessary references and Imports in your project):

        Public Sub PrintLocationSuffix
            Dim suff As String=LocationSuffix(ThisApplication.SelectedData.ImageSet)
        End Sub
        Private Function LocationSuffix(imSet As McImageSet) As String
            If imSet Is Nothing Then Return ""
            Dim lc As McImageSetLocations = imSet.GetCurrentLocation()
            Dim rgn As McImageSetRegion = imSet.ActiveRegion
            Dim s As String = ""
            If rgn.Sections(mcImageSetDimensions.mcisdTime).Extent <> 1 Then
                AddSuff(s, String.Format("t{0}", lc(mcImageSetDimensions.mcisdTime).Location + 1))
            End If
            If rgn.Sections(mcImageSetDimensions.mcisdZ).Extent <> 1 Then
                AddSuff(s, String.Format("z{0}", lc(mcImageSetDimensions.mcisdZ).Location + 1))
            End If
            If rgn.Sections(mcImageSetDimensions.mcisdSite).Extent <> 1 Then
                AddSuff(s, _imSet.Sites.Item(lc(mcImageSetDimensions.mcisdSite).Location).Name)
            End If
            If Not opt.AutoTile AndAlso rgn.Sections(mcImageSetDimensions.mcisdScan).Extent <> 1 Then
                AddSuff(s, String.Format("xy{0}", lc(mcImageSetDimensions.mcisdScan).Location + 1))
            End If
            'If s.Length = 0 Then Return "Comp"
            Return "_" & s
        End Function
        Private Sub AddSuff(ByRef s As String, suff As String)
            If s.Length > 0 Then s += "_"
            s += suff
        End Sub



  • Hi Henri,

    The error "Type identifier is invalid" means that the macro is missing reference and/or Imports. The type McImageSet is defined in MediaCy.IQL.Sets.dll, please check that it's exists in references and Imports.

    Another solution is to Export dependencies from the source project (ImageSetAnalyzer) in Project Workbench, Edit tab, and Import it to the new project (it will copy all references and imports).

  • Thanks Yuri! I'm not getting the error anymore (although it still isnt working as intended).

    Is there any documentation or instructions on how to implement these features in macros? 
  • Thanks a lot for your help, Yuri. I'll have a good look through the document.
Sign In or Register to comment.