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

Channel extraction macro not working correctly after update to version 10.0.4

After updating Image-Pro from version 10.0.2 to 10.0.4 a procedure does not work anymore. I use a macro ExtractZStacksFromActiveImage published in this board to extract exactly one channel.

Public Sub ExtractZStacksFromActiveImage
    Dim imset As MediaCy.IQL.Sets.McImageSet=ThisApplication.ActiveDocument.Data
    If imset Is Nothing Then Exit Sub'this is not image set

    'get number of channels in stack
    'Dim nChannels As Long=imset.GetDimensionLength(mcImageSetDimensions.mcisdChannel,imset.GetCurrentLocation)
    'For chInd As Integer=0 To nChannels-1
    '    ExtractZStackFromChannel(imset,chInd)
    'Next

    ExtractZStackFromChannel(imset,2)

End Sub

Public Sub ExtractZStackFromChannel(imset As MediaCy.IQL.Sets.McImageSet,chInd As Long)
    Dim setLoc As New MediaCy.IQL.Sets.McImageSetLocations
    'select channel to location
    setLoc.Add(mcImageSetDimensions.mcisdChannel, chInd)
    'get number of frames in Z dimension
    Dim nZframes As Long=imset.GetDimensionLength(mcImageSetDimensions.mcisdZ,setLoc)

    'create region to extract
    Dim theRegion As MediaCy.IQL.Sets.McImageSetRegion=ThisApplication.CreateOperator("McImageSetLib.McImageSetRegion")
    Dim theSections As MediaCy.IQL.Sets.McImageSetSections = theRegion.Sections
    theSections.Add(mcImageSetDimensions.mcisdChannel,chInd,1)
    theSections.Add(mcImageSetDimensions.mcisdZ,0,nZframes)
    'create image of Z frames (invisible)
    Dim outIm As McImage=imset.ExtractImage(theRegion, mcImageCreateFlags.mcicfNotVisible Or mcImageCreateFlags.mcicfNoAddToCollection)
    'show image
    outIm.Visible=True
End Sub
Since version 10.0.4 now all channels are extracted and not only the specified channel anymore.

How can I fix this?

Thanks in advance
fsup


Comments

  • Hi fsup,

    Thanks for reporting this. I can reproduce the problem and we will fix it, but for now, please use a new version of the macro:

    Public Sub ExtractZStackFromChannel(imset As MediaCy.IQL.Sets.McImageSet,chInd As Long)
        Dim setLoc As New MediaCy.IQL.Sets.McImageSetLocations
        'select channel to location
        setLoc.Add(mcImageSetDimensions.mcisdChannel, chInd)
        'get number of frames in Z dimension
        Dim nZframes As Long=imset.GetDimensionLength(mcImageSetDimensions.mcisdZ,setLoc)
        Dim srcs As McImageSetSources=imset.GetSourcesAlongDimension(setLoc,mcImageSetDimensions.mcisdZ)
        'duplicate channel image
        Dim outIm As McImage=srcs.Item(0).Image.Duplicate(mcImageCreateFlags.mcicfNotVisible Or mcImageCreateFlags.mcicfNoAddToCollection)
        'show image
        outIm.Visible=True
    End Sub
    
    
    Let me know if it works for you.

    Yuri
  • Hi Yuri,

    the macro works fine now.
    Thank you for supporting me.

    fsup
Sign In or Register to comment.