Definite focus for tiled images in Macro

Post your acquisition-related questions and macros here
Yohsuke Fukai
Posts: 7
Joined: Thu Mar 17, 2022 10:54 am

Definite focus for tiled images in Macro

Post by Yohsuke Fukai »

We are trying to acquire tiled images with the focus strategy: "definite focus" from the macro but could not get it to succeed.
When we activate and start the experiment as

Code: Select all

output2 = Zen.Acquisition.Execute(exp2)
output2.Save( "/path/to/file.czi")
there appears the "Prepare Definite Focus Initialization" dialog box and the macro stops saying that `output2` is `None`.

Are there any workarounds to skip this dialog to use "definite focus" strategy in a macro?
We are using Zen 2.6 (blue edition).
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: Definite focus for tiled images in Macro

Post by CarlZeissMicroscopy3 »

Hello Yohsuke Fukai,

before we go into details please start Zen blue and have a look at

Menu bar / Help / About Zen / Show Zen Information / Tab 'Service Packs'

The 'last number' of the first column (Name) shows the number of the Hotfix.

Please be aware that the latest Hotfix is 12 for Zen blue 2.6!

You can have a look at the various hotfixes and download Hotfix 12 at

https://portal.zeiss.com/download-cente ... blue%202.6

You just need the latest hotfix (12) as the other hotfixes are included.

Please come back on me if you have an updated system and your problem persists.
Yohsuke Fukai
Posts: 7
Joined: Thu Mar 17, 2022 10:54 am

Re: Definite focus for tiled images in Macro

Post by Yohsuke Fukai »

Thank you @CarlZeissMicroscopy3 for your reply! I checked the Service Packs tab and it is displayed as
2.6.76.00012 (9/8/2021 3:40:12 PM) .
So I believe the software is already updated to the latest version.
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: Definite focus for tiled images in Macro

Post by CarlZeissMicroscopy3 »

Hello Yohsuke Fukai,

yes, HF12 is installed on your system!

with
output2 = Zen.Acquisition.Execute(zenExperiment)
you get `output2` is `None`.

My guess is, that you already tried to manually choose the zenExperiment on the acquisition tab (by its name), then click 'Start Experiment' and finally got an image.

If the experimant works manually and you get `output2` is `None`, this might mean your experiment is a 'special experiment' that has to be executed with a different call, like

output2 = Zen.Acquisition.ExecuteMultiImages(zenExperiment)
output2 = Zen.Acquisition.ExecuteMultiBlockImages(zenExperiment)
output2 = Zen.Acquisition.ExecutePanoramaExperiment(zenExperiment)

Not sure if all 'special experiments' listed here are available on 2.6 but I would give it a try.

Hope this helps.
Yohsuke Fukai
Posts: 7
Joined: Thu Mar 17, 2022 10:54 am

Re: Definite focus for tiled images in Macro

Post by Yohsuke Fukai »

Thank you for your detailed reply!
My guess is, that you already tried to manually choose the zenExperiment on the acquisition tab (by its name), then click 'Start Experiment' and finally got an image.
Yes, and it works (after showing the "Prepare Definite Focus Initialization" dialog box), and when I change the focus strategy to "None", it even works from a macro. The error only occurs when I choose "Definite focus". The phenomena is also observed with another experiment once I set the focus strategy to "Definite focus". With that, I rather think this behavior is a bug associated with the way the macro treats "Prepare Definite Focus Initialization" dialog box. Is there any way to disable showing this dialog box before starting an experiment?
Yohsuke Fukai
Posts: 7
Joined: Thu Mar 17, 2022 10:54 am

Re: Definite focus for tiled images in Macro

Post by Yohsuke Fukai »

Code: Select all

output2 = Zen.Acquisition.ExecuteMultiImages(zenExperiment)
output2 = Zen.Acquisition.ExecuteMultiBlockImages(zenExperiment)
output2 = Zen.Acquisition.ExecutePanoramaExperiment(zenExperiment)
We tried all of them, but unfortunately they did not solve the problem.
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: Definite focus for tiled images in Macro

Post by CarlZeissMicroscopy3 »

Hello Yohsuke Fukai,

thank you for your reply with additional information!
I will discuss this internally and come back on you.

Maybe there is a 'quick' workaround for you:

Code: Select all

Zen.Acquisition.Execute(exp2)
output2 = Zen.Application.ActiveDocument
output2.Save( "/path/to/file.czi")
... just came to my mind ...
Yohsuke Fukai
Posts: 7
Joined: Thu Mar 17, 2022 10:54 am

Re: Definite focus for tiled images in Macro

Post by Yohsuke Fukai »

Thank you CarlZeissMicroscopy3 for your suggestion! We will definitely try this.
Yohsuke Fukai
Posts: 7
Joined: Thu Mar 17, 2022 10:54 am

Re: Definite focus for tiled images in Macro

Post by Yohsuke Fukai »

That way actually improved the situation: the image is saved after the acquisition is finished.
However, "Prepare Definite Focus Initialization" dialog still appears, which makes automation difficult... (one need to click the button every time.)
I will discuss this internally and come back on you.
Thank you, looking forward to hearing the update!
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: Definite focus for tiled images in Macro

Post by CarlZeissMicroscopy3 »

Hello Yohsuke Fukai,

there might be some misunderstanding as far as 'Definite Focus' is concerned.

'Definite Focus' is more a 'keep Focus' than a 'find Focus'.
Therefore, the "Prepare Definite Focus Initialization" dialog reminds a user to 'manually search' for the focus position to get a 'crisp and clear' image.

If you set the z-position by another Focus Strategy, see attachments, then the dialog will not pop up.

Alternatively, you can set the Focus-Position with e.g.
Zen.Acquisition.FindAutofocus()
Zen.Acquisition.FindSurface()
Zen.Devices.Focus.TargetPosition = myZposition
In these cases the dialog is not needed any more.

To get rid of the dialog, choose (in the menu bar)
Tools / Options... / Acquisition / Focus Strategy
and disable 'Show a Dialog to Prepare Definite Focus Initialization"
Attachments
FocusStrategy.png
FocusStrategy.png (27.05 KiB) Viewed 3178 times
Post Reply