Home Image-Pro General Discussions

Automatic Image Compression

Hi all,

I'm just learning to use Image Pro Premier Offline 9.1, & I'd like to learn how to write my own macros. My ultimate application is probably pretty advanced, so for now I'm just trying to break the process down into simpler individual steps.

 When I open up my image files (.lifs), a bunch of multi-channel z-stack images pour out. Before I can begin working on them, the first thing I need to do is to compress the images into single channel .tiffs. Each image needs to be broken into at least two daughter images - one brightfield image & at least one fluorescent image. Manually turning off the channels I don't want, hitting "Apply", then doing an EDF, twice, for each image gets pretty time-consuming, so I'm looking for a way to automate this part of the process. I've tried using the "Record macro" feature & doing the process manually to see if the software could learn how to do this by watching me, but this doesn't seem to work. I think it might be because the software has no way to determine which image to select & which channels to turn off, but I'm honestly just guessing. I completely fumbling around in the dark with this, so any advice will be much appreciated. Thanks.


  • Whoops. I just noticed that this is the wrong forum. I have reposted on the correct one. Please disregard this.
  • Hello Grant,

    It is a good idea to start your macros by recording manual steps, however the resulting macro often needs a little bit of editing!

    Here is a macro that loops on all channels of each loaded image set and produces an EDF image from each Z-stack. The macro is also attached as a project package. Of course, depending on the exact geometry of your images you might need to adjust some of the parameters.

        Public Sub ExtractMacro()
            Dim docList, doc, zstack, edf
            ' Load the image sets without displaying them
            With Application.DocumentCommands.Open(Nothing)
            End With
            For Each doc In docList
                ' Process each image set in the collection
                Dim imageSet As McImageSet = doc.Data
                ' How many channels?
                Dim locations As McImageSetLocations = imageSet.GetCurrentLocation()
                Dim numChannels As Integer = imageSet.GetDimensionLength(mcImageSetDimensions.mcisdChannel,locations)
                For channel As Integer = 0 To numChannels -1
                    ' Extract a Z-stack for each channel
                    locations.Item(mcImageSetDimensions.mcisdChannel).Location = channel
                    With Adjust.ImageSetCommands.ExtractDimension(Nothing)
                        .Dimension = MediaCy.IQL.Sets.mcImageSetDimensions.mcisdZ
                        .Run(imageSet, zstack)
                    End With
                    ' Run EDF on each Z-stack
                    With Process.EDF.WindowsCommands.Clear(Nothing)
                    End With
                    With Process.EDF.WindowsCommands.Add(Nothing)
                    End With
                    With Process.EDFCommands.Apply(Nothing)
                        .Run(edf, Nothing)
                    End With
                ' Remove the image set from its collection to release memory
        End Sub

  • I tried pasting that & hitting "Load", but every time I do I get an error message saying that there is unexpected text in line 3, character 1. I've tried doing all sorts of things to line 3, character 1, but the same error message shows up again & again.
  • You are probably missing assembly references and/or imports, which is why I also uploaded the project package which you can load as a new project, and which should have eveything needed.

  • Okay, I did that, & now when I try to Load I get a new error message:

    "Not an object reference.

    Module '*Module1.vb', line 29, character 62."

  • While you puzzle that, here's a simpler question to you or anybody. How exactly do you run your apps or macros anyway? I just designed a very simple workflow (btw, I have no clue what the difference between "workflow", "macro", & "app" is) to do an EDF on a stack, & it seems that, for once, there are no bugs, but I can't figure out how to make the thing actually go.
  • Nevermind. I finally figured that part out.
  • Well, apparently not entirely figured out. Could someone please explain to me how the "Batch Processing" side menu works? What is "Run Before" or "Run After"? What if I don't want to run anything before or after my macro? What if I just want to run one thing? And what on earth does "Loop On" mean?

    Next, "Select Images". Frustratingly enough, it seems that I can, in fact, only select images. This sucks, because I want to start by selecting multichannel z-stacks, & apparently that just blows Image Pro's mind. There's got to be a way around this, right?
  • edited April 2014
    Okay, nevermind on the first part of that question. Apparently if you just move your pointer over those terms, you get a pop-up explanation of them. I'm sorry for all the obvious questions, people, but it seems like I can spend hours trying to figure this stuff out on my own, then I'll post about it here, & five minutes later I stumble upon the answer. It's like magic.

    Still trying to figure out how to get around the image format restrictions, though.
  • edited April 2014
    Hi Grant,

    I would recommend you to check our tutorials, they may give you more info about Premier's functionalty:

    This one is about batch processing:

  • Hey Yuri,

    I had already watched the first & third videos. They were helpful in getting me as far as I am now. Thanks for the link.
  • Grant,  It turns out that the macro I originally posted was using a command which will only be available in Premier 9.1.2, so as a workaround here is another version that should work for LIF files in Premier 9.1.

Sign In or Register to comment.