Number of frames and McImageSetLocationsClass
Hello
I'm using the code below to perform an EDF on a 3D timelapse image. The code is not tested yet because although its basically the recorded code from the Record Macro option I get the following error "Type identifier is invalid referring to the line below.
.SetFrames = New System.Collections.Generic.List(Of MediaCy.IQL.Sets.McImageSetLocations)
Also which command do you use to get the number of z and number of timepoints in an image
Full code below
Public Function MergeRed() Dim x As Integer Dim doc1, image1, doc2, image2, doc3 With Application.DocumentCommands.Active(MergeRed) .Run(ThisApplication.ActiveImage) End With With Process.FramesCommands.Extract(MergeRed) .SetFrames = New System.Collections.Generic.List(Of MediaCy.IQL.Sets.McImageSetLocations) Dim locations As MediaCy.IQL.Sets.McImageSetLocationsClass For x = 0 To 5 locations = New MediaCy.IQL.Sets.McImageSetLocationsClass locations.Add(MediaCy.IQL.Sets.mcImageSetDimensions.mcisdChannel, 1) locations.Add(MediaCy.IQL.Sets.mcImageSetDimensions.mcisdZ, x) locations.Add(MediaCy.IQL.Sets.mcImageSetDimensions.mcisdScan, 0) locations.Add(MediaCy.IQL.Sets.mcImageSetDimensions.mcisdSite, 0) locations.Add(MediaCy.IQL.Sets.mcImageSetDimensions.mcisdTime, 0) locations.Add(MediaCy.IQL.Sets.mcImageSetDimensions.mcisdResolution, 0) locations.Add(MediaCy.IQL.Sets.mcImageSetDimensions.mcisdUser2, 0) .SetFrames.Add(locations) Next x .ViewClassName = "McGalleryView" .FrameByFrame = False .BestFocusPlane = False .NormalizeIllumination = False .BottomUp = False .Prefilter = MediaCy.IQL.Align.mcefPreFilterType.mcpftVarDilation3x3 .VarianceThreshold = 50 .Run(doc1, image1) End With
End Function
Best Answer
-
Hi David,Low level set operations are not covered by commands, so you have to use IQL functions to get all these parameters. Below is a sample macro that prints all dimensions of the active set from the active location:
Public Sub GetSetDimentions() If ThisApplication.ActiveDocument Is Nothing Then Exit Sub Dim imSet As McImageSet=ThisApplication.ActiveDocument.GetData(GetType(McImageSet),Nothing) If imSet IsNot Nothing Then Dim lc As McImageSetLocations=imSet.GetCurrentLocation For Each ilc As McImageSetLocation In lc Dim length As Integer=imSet.GetDimensionLength(ilc.Dimension,lc) If length>1 Then Debug.Print (ilc.Dimension.ToString() & " = " & length) End If Next End If End Sub
For other set operations you have to check IQL functions in MediaCy.IQL.Sets namespace of the automation help.Yuri0
Answers
-
Hi David,It looks like the references to MediaCy.IQL.Sets.dll and MediaCy.IQL.Align.dll are not added automatically.Please try to add them manually (Project workbench - References).Yuri0
-
Hello Yuri
The references worked, but which commands would you use to find how many timepoints and how many z are in an image.
Regards
David
0 -
David,I've created an example macro that extracts maximum Projection image from every time point stack and merges it to a sequence.
Imports MediaCy.IQL.Sets ... Public Sub CreateMIPSequenceOfActiveChannel() If ThisApplication.ActiveDocument Is Nothing Then Exit Sub Dim imSet As McImageSet=ThisApplication.ActiveDocument.GetData(GetType(McImageSet),Nothing) If imSet Is Nothing Then Exit Sub 'not a set Dim seqOp As New MediaCy.IQL.Operations.McOperations Dim lc As McImageSetLocations=imSet.GetCurrentLocation 'get number of time points Dim timeLength As Integer=imSet.GetDimensionLength(mcImageSetDimensions.mcisdTime,lc) Dim outIm As McImage Dim pm As McBusyState =ThisApplication.SetBusyState(,True) pm.SetProgressInfo("Creating MIP sequence",Interop.mcProgressAllowCancel.mcpacTopLevelCancelOnly,0,timeLength-1) For i As Integer =0 To timeLength-1 If pm.SetProgress(i) Then Exit Sub'user cancel 'get Z planes for every time point lc.Item(mcImageSetDimensions.mcisdTime).Location=i Dim src As McImageSetSources=imSet.GetSourcesAlongDimension(lc,mcImageSetDimensions.mcisdZ) 'create maximum intensity projection image, as invisible Dim im As mcimage=seqOp.MaxFrames(src,mcImageCreateFlags.mcicfNotVisible Or mcImageCreateFlags.mcicfNoAddToCollection) If outIm Is Nothing Then outIm=im Else 'append frame im.MoveFrames(0,1,outIm,outIm.FrameCount) End If Next 'make image visible outIm.Visible=True End Sub
You can use this macro as a reference for your processing.Yuri0 -
Hello Yuri
Thanks for code to extract the max projections over time it works well. I'm now trying to extend it to work on 2 or 3 colour images but using the debugger its very difficult to figure out what the various variables contain and therefore what they are doing so that I can modify the correct bit. In the debugger each variable seems to hold a hex memory location rather than readable values. I've been using the .DisplayName you suggested in a previous post but this doesn't work on most of the variables is there another way to figure out what the variables are doing. I've searched the help files for the commands but I'm struggling a bit with them
Regards
David
0 -
Hello Yuri
Got it, you select the channel then run your code
Regards
David
0 -
Yes, the macro uses CurrentLocation of the set, which defines what channel is currently selected.If you want to specify channel programmatically you can set it to the msisdChannel dimension of the location:
Dim lc As McImageSetLocations=imSet.GetCurrentLocation Dim ChannelIndex As Integer=0 'process my channel lc.Item(mcImageSetDimensions.mcisdChannel).Location=ChannelIndex
Yuri0
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