Error when Acquiring and saving images with OAD macro

Discuss macros to control the hardware functions of your ZEISS microscope
Post Reply
Aliaksandr Halavatyi
Posts: 2
Joined: Wed Aug 05, 2020 2:12 pm

Error when Acquiring and saving images with OAD macro

Post by Aliaksandr Halavatyi »

We run long multiposition timelapse acquisitions controlled by OAD Macro in ZenBlue. The experiment lasts more then 72 hours.

Most of the times experiments work fine, but sometimes "Invalid Argument" error window occurs. The example screenshot is here

https://oc.embl.de/index.php/s/oOYu3nZdS5To4dg

The acquisitions are then stopped until someone presses OK button in this window. After pressing OK acquisition protocol continues normally.

Current guess is that error appears somewhere between acquiring and saving the image.

Code: Select all

    job = Zen.Acquisition.Experiments.GetByName(jobName)
    job.SetActive()
    job.ClearTileRegionsAndPositions(0)
    job.AddSinglePosition(0,Zen.Devices.Stage.ActualPositionX+dx,Zen.Devices.Stage.ActualPositionY+dy,Zen.Devices.Focus.ActualPosition+dz)
    print Zen.Devices.Focus.ActualPosition, dz
    acquiredImage=Zen.Acquisition.Execute(job)
    job.ClearTileRegionsAndPositions(0)
Zen.Application.Save(acquiredImage,savePath)
Error happens at random times and can not be easily reproduced.
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: Error when Acquiring and saving images with OAD macro

Post by CarlZeissMicroscopy3 »

Hello Aliaksandr Halavatyi,

first of all thank you for the reported error. The screenshot of the exception should be enough information to locate the error but as it happens at random times and can not be easily reproduced the fix might be tricky. In case of any progress I will inform you.

Please let me know which version/hotfix of Zen blue is used?

Just some thoughts on your ‘code snippet’:

acquiredImage=Zen.Acquisition.Execute(job)

Saving the file is also possible with
acquiredImage.Save(…)

After working with acquiredImage:

If the acquired image is visible in the GUI of ZEN blue use e.g.
Zen.Application.Documents.RemoveAll(False)

In most cases image.Close() should be called if the image is no loger needed.

Pease note that this subject is a bit complicated, because:

In older Versions of Zen
Zen.Application.Documents.RemoveAll(False)
just removed the image in the GUI
and you had to call
image.Close()
to free memory

In new Versions of Zen
Zen.Application.Documents.RemoveAll(False)
removes the image in the GUI AND closes the image, to free memory!
But if an image is used in code after RemoveAll, the image is opened automatically again
and you have to call
image.Close()
to free memory.


Maybe this can contribute to a stable solution.
Sohan Seenulal
Posts: 1
Joined: Fri Apr 14, 2023 5:36 am

Re: Error when Acquiring and saving images with OAD macro

Post by Sohan Seenulal »

Thanks for great answer. It works. Welcome to Papa's Pizzeria
Post Reply