Issues with ajustement setting not applying.
Hi,
I recorder this macro to switch from composite view, apply some adjustment to each channel and redisplay the composite view.
When I do It manually, the composite picture is displayed properly, but when I run the macro, the adjustment are applied to each channel in the non composite view but they are applied only to channel 3 in the composite display.
I tried to work directly on the composite view, but I have issues with referring the channels in the composite view.
Thanks
Public Function NewMacro() As SimpleScript
NewMacro = New SimpleScript
Dim doc1, image1, window1
With Application.RibbonCommands.SelectRibbonTab(NewMacro)
.TabName = "Process"
.Run()
End With
With Application.DocumentCommands.Active(NewMacro)
.Run(doc1)
End With
With Process.Filter.EnhancementCommands.Gauss(NewMacro)
.Passes = 1
.KernelSize = Filters.mcKernelSize2.mcks3x3
.Strength = 100
.Run(doc1, image1)
End With
With Application.WindowCommands.Define(NewMacro)
.Run(doc1, window1)
End With
With View.ImageSetViewCommands.Options(NewMacro)
.ColorCompositeView = False
.Run(window1)
End With
With Application.RibbonCommands.SelectRibbonTab(NewMacro)
.TabName = "Adjust"
.Run()
End With
With Adjust.LookupTableCommands.WhiteLevel(NewMacro)
.WhiteLevel = 1000R
.LUT = -1
.Run(doc1)
End With
With View.ImageSetViewCommands.Options(NewMacro)
.ViewLocation = New McImageSetLocations
.ViewLocation.Add(mcImageSetDimensions.mcisdChannel, 1)
.Run(window1)
End With
With Adjust.LookupTableCommands.WhiteLevel(NewMacro)
.WhiteLevel = 1000R
.LUT = -1
.Run(doc1)
End With
With View.ImageSetViewCommands.Options(NewMacro)
.ViewLocation = New McImageSetLocations
.ViewLocation.Add(mcImageSetDimensions.mcisdChannel, 2)
.Run(window1)
End With
With Adjust.LookupTableCommands.WhiteLevel(NewMacro)
.WhiteLevel = 1000R
.LUT = -1
.Run(doc1)
End With
With View.ImageSetViewCommands.Options(NewMacro)
.ColorCompositeView = True
.Run(window1)
End With
With Application.RibbonCommands.SelectRibbonTab(NewMacro)
.TabName = "Share"
.Run()
End With
With View.ImageViewCommands.Options(NewMacro)
.View.AutoZoomMode = MediaCy.IQL.Display.Viewer.mcAutoZoomMode.mazmNone
.Run(window1)
End With
With Application.WindowCommands.ExportToPowerPoint(NewMacro)
.Export = Window.ExportToPowerPoint.ExportOptions.DocumentView
.Run(New List({window1}))
End With
End Function
0
Answers
-
I checked your macro and can see the problem. The issue is that the composite view is updated after some delay (when all messages are processed), so in the macro the view is exported to the PowerPoint before it gets updated.
Adding some delay before exporting the view fixes the problem.
I've added CodeCommand with DoEvents function. Here is the complete macro:Public Function NewMacro() As SimpleScript NewMacro = New SimpleScript Dim doc1, image1, window1,image2,window2,doc2 With Application.RibbonCommands.SelectRibbonTab(NewMacro) .TabName = "Process" .Run() End With With Application.DocumentCommands.Active(NewMacro) .Run(doc1) End With With Process.Filter.EnhancementCommands.Gauss(NewMacro) .Passes = 1 .KernelSize = Filters.mcKernelSize2.mcks3x3 .Strength = 100 .Run(doc1, image1) End With With Application.WindowCommands.Define(NewMacro) .Run(doc1, window1) End With With View.ImageSetViewCommands.Options(NewMacro) .ColorCompositeView = False .Run(window1) End With With Application.RibbonCommands.SelectRibbonTab(NewMacro) .TabName = "Adjust" .Run() End With With Adjust.LookupTableCommands.WhiteLevel(NewMacro) .WhiteLevel = 1000R .LUT = -1 .Run(doc1) End With With View.ImageSetViewCommands.Options(NewMacro) .ViewLocation = New McImageSetLocations .ViewLocation.Add(mcImageSetDimensions.mcisdChannel, 1) .Run(window1) End With With Adjust.LookupTableCommands.WhiteLevel(NewMacro) .WhiteLevel = 1000R .LUT = -1 .Run(doc1) End With With View.ImageSetViewCommands.Options(NewMacro) .ViewLocation = New McImageSetLocations .ViewLocation.Add(mcImageSetDimensions.mcisdChannel, 2) .Run(window1) End With With Adjust.LookupTableCommands.WhiteLevel(NewMacro) .WhiteLevel = 1000R .LUT = -1 .Run(doc1) End With With View.ImageSetViewCommands.Options(NewMacro) .ColorCompositeView = True .Run(window1) End With With Automate.ScriptingCommands.CodeCommand(NewMacro) If .Run() Then 'wait until the composite view is updated System.Windows.Forms.Application.DoEvents End If End With With View.ImageViewCommands.Options(NewMacro) .View.AutoZoomMode = MediaCy.IQL.Display.Viewer.mcAutoZoomMode.mazmNone .Run(window1) End With With Application.WindowCommands.ExportToPowerPoint(NewMacro) .Export = Window.ExportToPowerPoint.ExportOptions.DocumentView .Run(New List({window1})) End With End Function
Yuri0 -
YuriG said:I checked your macro and can see the problem. The issue is that the composite view is updated after some delay (when all messages are processed), so in the macro the view is exported to the PowerPoint before it gets updated.
Adding some delay before exporting the view fixes the problem.
I've added CodeCommand with DoEvents function. Here is the complete macro:Public Function NewMacro() As SimpleScript NewMacro = New SimpleScript Dim doc1, image1, window1,image2,window2,doc2 With Application.RibbonCommands.SelectRibbonTab(NewMacro) .TabName = "Process" .Run() End With With Application.DocumentCommands.Active(NewMacro) .Run(doc1) End With With Process.Filter.EnhancementCommands.Gauss(NewMacro) .Passes = 1 .KernelSize = Filters.mcKernelSize2.mcks3x3 .Strength = 100 .Run(doc1, image1) End With With Application.WindowCommands.Define(NewMacro) .Run(doc1, window1) End With With View.ImageSetViewCommands.Options(NewMacro) .ColorCompositeView = False .Run(window1) End With With Application.RibbonCommands.SelectRibbonTab(NewMacro) .TabName = "Adjust" .Run() End With With Adjust.LookupTableCommands.WhiteLevel(NewMacro) .WhiteLevel = 1000R .LUT = -1 .Run(doc1) End With With View.ImageSetViewCommands.Options(NewMacro) .ViewLocation = New McImageSetLocations .ViewLocation.Add(mcImageSetDimensions.mcisdChannel, 1) .Run(window1) End With With Adjust.LookupTableCommands.WhiteLevel(NewMacro) .WhiteLevel = 1000R .LUT = -1 .Run(doc1) End With With View.ImageSetViewCommands.Options(NewMacro) .ViewLocation = New McImageSetLocations .ViewLocation.Add(mcImageSetDimensions.mcisdChannel, 2) .Run(window1) End With With Adjust.LookupTableCommands.WhiteLevel(NewMacro) .WhiteLevel = 1000R .LUT = -1 .Run(doc1) End With With View.ImageSetViewCommands.Options(NewMacro) .ColorCompositeView = True .Run(window1) End With With Automate.ScriptingCommands.CodeCommand(NewMacro) If .Run() Then 'wait until the composite view is updated System.Windows.Forms.Application.DoEvents End If End With With View.ImageViewCommands.Options(NewMacro) .View.AutoZoomMode = MediaCy.IQL.Display.Viewer.mcAutoZoomMode.mazmNone .Run(window1) End With With Application.WindowCommands.ExportToPowerPoint(NewMacro) .Export = Window.ExportToPowerPoint.ExportOptions.DocumentView .Run(New List({window1})) End With End Function
Yuri
0 -
Important point is to have always the same starting conditions, in your case the 1st channel should be active when ColorComposite gets switched off (otherwise you need to record activation of the first channel).
If it still doesn't work, try to reproduce the problem on one of the demo images (e.g. the one from Colocalization folder) and attach the complete macro project (packaged as IPX) to the post.
Yuri
0 -
Hi,
I tested the File in the colocalization folder and it's a hit and miss. Sometime it works sometime it does not. I wanted to upload the IPP file but I get the "File Format is no allowed" message
0 -
Do you mean that it's not always working for "15' HGF LAMP488 4.lsm" image (in Colocalization folder)? Or it's working for the demo image, but it's not working for your own image?
Yuri0 -
Here is a more complex macro that will apply new LUT to color composite view:
Public Function ApplyToCC() As SimpleScript ApplyToCC = New SimpleScript With Automate.ScriptingCommands.CodeCommand(ApplyToCC) If .Run() Then ' User Code Here If ThisApplication.ActiveWindowEx IsNot Nothing Then If TypeOf ThisApplication.ActiveWindowEx.DocumentView Is MediaCy.Viewers.Set.McSetLocationViewBase Then Dim sbv As MediaCy.Viewers.Set.McSetLocationViewBase = ThisApplication.ActiveWindowEx.DocumentView If TypeOf sbv.BaseDocumentView Is MediaCy.Viewers.Image.McSeqView Then Dim sv As MediaCy.Viewers.Image.McSeqView = sbv.BaseDocumentView Dim ccd As MediaCy.Viewers.Image.McColorCompositeDocument = sv.ColorCompositeDocument For Each im As McImage In ccd.Images.Keys Dim d As MediaCy.Viewers.Image.McDisplayInfo d = ccd.ImageDisplay(im) d.Reload = True 'restore image view display -> CC display sync d.Init(im) 'init display from channel ccd.ImageDisplay(im) = d 'apply display to CC view Next End If End If End If End If End With End Function
you can call this macro instead of System.Windows.Forms.Application.DoEvents , like this:With Automate.ScriptingCommands.CodeCommand(NewMacro) If .Run() Then 'wait until the composite view is updated 'System.Windows.Forms.Application.DoEvents ApplyToCC End If End With
Please test it and let us know if it fixes your problem.
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