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:
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,
Henri
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.GetCurrentLocationwhich 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,
Henri
0
Best 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) Debug.Print(suff) 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
Yuri0
Answers
-
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).
Yuri0 -
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?0 -
Thanks a lot for your help, Yuri. I'll have a good look through the document.0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions