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

Creating Image Sets with Time and Z

Hello

In a previous question on creating Image Sets I got the code to recreate Z Sets. I've tried to modify the code to accept timepoint information but I'm not having much success. My best effort is the code below which produces an Image Set of 34Z and 41 Timepoints but the Timepoints are all just a repeat of the Z positions from the first timepoint. I can't figure out where I'm going wrong. Also, for extra fun when its finished it crashes Premier.

Regards


David

Public Function CreateSetFromFrames()
Dim aSet As McImageSet

If ThisApplication.ActiveImage Is Nothing Then
MsgBox "No Image"
Exit Function
End If

aSet = ThisApplication.Engine.ImageSets.Add("SampleSet")
Dim theLoc As New McImageSetLocations
Dim i As Integer, j As Integer
Dim theFrame As McFrame
Dim thetime As New McImageSetLocations

For j = 0 To 40
    For i = 0 To 33
        theLoc.RemoveAll            ' get ready for next location
        theLoc.Add mcImageSetDimensions.mcisdChannel, 0  ' adding Channel 0
        theLoc.Add mcImageSetDimensions.mcisdZ, i        ' and this Z position
        theLoc.Add mcImageSetDimensions.mcisdTime, j      'add timepoint
        theFrame = ThisApplication.ActiveImage.Frame(i)
        aSet.AddFrame theFrame, theLoc                  'merge time and z
    Next i
    theFrame = Nothing                              'Reset theFrame Variable
Next j
ThisApplication.Windows.Add(aSet)
End Function

Answers

  • Options
    David,

    It looks like you are using the same frames in all time points, it could be the problem. 
    Do you have a real sample?

    Thanks,

    Yuri
  • Options
    Hi David,

    I checked your source image with 1394 frames and found the problem in macro.
    Here is the fixed version, the changed line is underlined (source frame index problem):

    Public Function CreateSetFromFrames2()
        Dim aSet As McImageSet
    
        If ThisApplication.ActiveImage Is Nothing Then
            MsgBox "No Image"
            Exit Function
        End If
    
        aSet = ThisApplication.Engine.ImageSets.Add("SampleSet")
        Dim theLoc As New McImageSetLocations
        Dim i As Integer, j As Integer
        Dim theFrame As McFrame
        Dim thetime As New McImageSetLocations
    
        For j = 0 To 40
            For i = 0 To 33
                theLoc.RemoveAll            ' get ready for next location
                theLoc.Add mcImageSetDimensions.mcisdChannel, 0  ' adding Channel 0
                theLoc.Add mcImageSetDimensions.mcisdZ, i        ' and this Z position
                theLoc.Add mcImageSetDimensions.mcisdTime, j      'add timepoint
                theFrame = ThisApplication.ActiveImage.Frame(i+j*34)'set correct frame index of source image
                aSet.AddFrame theFrame, theLoc                  'merge time and z
            Next i
            theFrame = Nothing                              'Reset theFrame Variable
        Next j
        ThisApplication.Windows.Add(aSet)
    End Function
    

    Yuri
  • Options

    That works

    Thanks

    David

Sign In or Register to comment.