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

Image Selection

Hello

I'm writing an automation which requires me to loop through a time series of images 1 time point at a time however when I try to select the original image I get the error in the attached image. I can't figure out what is wrong as you can see in the watch window that the variable OriginalImage has a value. Any help appreciated

Regards

David




Best Answer

  • Answer ✓
    Hello David,

    We are working on the color composite playback issue, as I mentioned earlier. 
    As a workaround you can save and then reload the set, it will fix color composite playback issue, but it may not be acceptable for you as sets are very big.

    It will be fixed in the next patch.

    Yuri

Answers

  • David,

    If OriginalImage is a part of an image set it may exist (image set may contain multiple images, but still be in one Window), but not be a part of Windows (OriginalImage is used as a key to find the window in that collection). So you should't use this command to activate this window.
    As I see you already have "window1" variable, which looks like an image set window, so you can use that. (window1.Activate).

    Yuri
  • Hello Yuri

    Doesn't work, I also tried imageset1, I get the same ActiveX Automation: Object var is 'Nothing'

    I looked in the Watch window and imageset1 is set to Object@Nothing and window1 = Empty.

    I set the OriginalImage variable right at the beginning of the automation and made it a public variable and it always has a value whereas window1 and imageset1 don't seem to. Should I set imageset1 to the name of the function so in this case it would Object@GreenChannel

    Regards

    David

  • David,

    If window1 = Empty, then it will not work. It looks like you have some problems in the code above, that defines window1.
    It's hard to tell what variables you should use without knowing how they are assigned.

    It looks like you are trying to write a macro that goes beyond simple recording.
    If you can tell me what you want to accomplish (inputs/outputs), I can make a sample macro for that.

    Yuri
  • Hello Yuri

    This isn't really a macro that can be recorded.  I start with a 2 channel, multi-timepoint, multi Z position image from a deltavision. On each channel I threshold for small fluorescent spots in the Z positions at each timepoint, once thresholded I make a mask of the thresholded point and save the mask image, this is repeated for each timepoint in both channels. The idea is to then recombine the masks as pure green and pure red in a 3D timelapse image which can be played so that as the green and red (now blobs) will go yellow as they interact and back to red and green as they separate. I'll add some measurement functions later if the experiment has worked properly.

    I have to work by recording bits and then customizing them as best I can because I cannot figure out the IQL commands.

    Regards

    David

  • Hello David,

    Complex image set processing should be done on IQL level, as it produces best performance and provides flexibility. Below is the macro, which thresholds all Z-stacks extracted from time points and channels of the current image set. User gets a prompt to define threshold value.

        Public Sub BuildThresholdedSet
            Dim imset As McImageSet=ThisApplication.ActiveDocument.Data
            If imset Is Nothing Then Exit Sub 'active image is not an image set
            Dim outset As McImageSet=ThisApplication.CreateOperator("McImageSet")'create new set
            outset.Name="ThresholdedSet"
            'define threshold value
            Dim MyThreshold As Double=Val(InputBox("Please enter the threshold value","Threshold"))
            'create helper operator for sequience operations
            Dim trans As MediaCy.IQL.Operations.McTransform=ThisApplication.CreateOperator("McTransform")
            Dim curLoc As McImageSetLocations=imset.GetCurrentLocation
            Dim timeLength As Integer=imset.GetDimensionLength(mcImageSetDimensions.mcisdTime,curLoc)
            Dim pm As McBusyState =ThisApplication.SetBusyState(,True)
            pm.SetProgressInfo("Creating Thresholded set",Interop.mcProgressAllowCancel.mcpacTopLevelCancelOnly,0,timeLength-1)
            'go through all dimensions
            For iTime As Integer=0 To timeLength-1
                If pm.SetProgress(iTime) Then Exit Sub'user cancel
                curLoc(mcImageSetDimensions.mcisdTime).Location=iTime
                For ch As Integer=0 To imset.GetDimensionLength(mcImageSetDimensions.mcisdChannel,curLoc)-1
                    Dim newLoc As New McImageSetLocations
                    'set location from which we get Z stack
                    newLoc(mcImageSetDimensions.mcisdTime).Location=iTime
                    newLoc(mcImageSetDimensions.mcisdChannel).Location=ch
                    'get Z-stack for the givel location
                    Dim zSrcs As McImageSetSources=imset.GetSourcesAlongDimension(newLoc,mcImageSetDimensions.mcisdZ)
                    'copy all frames to a new image (invisible)
                    Dim outZseq As McImage=trans.SubSample(1,zSrcs,mcImageCreateFlags.mcicfNotVisible Or mcImageCreateFlags.mcicfNoAddToCollection)
    
                    'do processing of outZseq (threshold it)
                    outZseq.Filter3D.Binarize3D(MyThreshold)
    
                    'put it into a new set
                    Dim ext As New McImageSetExtents
                    ext.Add(mcImageSetDimensions.mcisdZ, outZseq.FrameCount)
                    outset.AddImage(outZseq, ext, newLoc)
                Next
            Next
            'make new set visible in a new window
            ThisApplication.WindowsEx.Add(outset)
        End Sub
    

    I've also attached the complete project, please use it for tests as it contains all the necessary references.

    Let me know if you need more details,

    Regards,

    Yuri
     
  • Thanks Yuri,

    I'll give it a go

    Regards

    David

  • Hello Yuri

    It didn't work, it seems to make a mask in Z of the first timepoint but just appends that mask to all the other timepoints giving 61 identical masks.

    I've tried to step through the automation and it appears that the variable curLoc never changes which I think should change everytime the timepoint increments. Its quite hard to debug because the Watch window only gives the Hex memory location. Is there a way to get it to show exactly what the variable holds, which debugger do you use as yours must show the actual variable contents.

    Regards

    David

  • Hello David,

    I just tested the macro with one of your sets (01.nd) and it worked correctly, though I found a problem with color composite view update when you change time points on the output set. You can switch off the "Color Composite" mode (in the bottom-right corner of the navigation panel) and the time points are updated correctly for each channel playing through time. We will look at the issue in details.

    Regarding the Watch window: if  the variable is a class, the watch window will show the pointer. To see the parameters of the class variable you have to add the complete parameter definition to the Watch window, as "curLoc(mcImageSetDimensions.mcisdTime).Location". I've attached the screenshot with the view.

    Regards,

    Yuri
  • Hello Yuri

    That worked, however when you play through the time dimension I get the following error.

    Not a legal OleAut date

    The file I'm using is a deltavision file rather than the metamorph one you tested it with. I've put the file onto my server and I'll send you the link outside of the forum.

    Regards

    David

  • Hello David,

    I checked you image and can confirm that this is a bug in reading DV files, frame dates are not loaded properly. This bug will be fixed in the next patch. Meanwhile I have added a macro to the attached project that can fix this. Please run FixDVFileDates macro after loading a DV file. After that there will be no Ole Date errors.

    Regards,

    Yuri
  • Hello Yuri

    Fixed the oleaut date problem and makes the separate red/green mask images but when I put the red/green masks back together in composite view Premier will only show the frame it was showing when composite was clicked. When you cycle through time it just shows the same image.

    Regards

    David  

  • That works

    Thanks

    David

Sign In or Register to comment.