Automating Batch Processing Immediately Following Imaging

Post your acquisition-related questions and macros here
Post Reply
Samuel Budoff
Posts: 1
Joined: Tue May 16, 2023 9:32 pm

Automating Batch Processing Immediately Following Imaging

Post by Samuel Budoff »

Hello,

I am a new Zeiss user following an established workflow in my lab, with our M.2 microscope and Zen 2.3 pro software. I was referred to this forum by tech support to automate the repetitive batch-processing sequence. In short, my protocol is as follows:
  • Draw polygons around all tissue regions for tile acquisition
  • Specify Z reference points for each tile set
  • Image set of tile regions as z-stacks with each scene saved separately
  • Load all scenes into batch processing and perform apotome raw convert
  • Empty the batch processing list and load all apotome converted images to perform stitching
I believe there must be a way to automate the last two steps such that as soon as the images are acquired they can begin one after another, but I am unsure how to do so exactly? Looking at the github for Automation tool scripts, https://github.com/zeiss-microscopy/OAD ... ol_Scripts, it looks like 'Apotome_processing' and 'Stitching' are what I need, however, I do not know specifically how to combine them. Please help me fill in the initial portion of this macro, and let me know if there are any other suggestions you have to help make this workflow function. Thank you!

Code: Select all

# Prompt User to specify output folder
Outputfolder = ???

# Load the newly acquired image
raw_im = ???

# Perform ApoTome raw convert
nb_phase = image.Bounds.SizeH
image_apotome = Zen.Processing.Utilities.ApoTomeSimConvert(raw_im,
                                                           ZenApoTomeProcessingMode.Sectioned,
                                                           ZenSimCorrectionMode.LocalIntensity,
                                                           ZenNormalizeMode.Clip,
                                                           ZenApoTomeFilter.Off,
                                                           False)


# Save Processed file
image_name = image.Name.Replace('.czi', '_Apotome.czi')
imageName = Path.Combine(Outputfolder, image_name)
image_apotome.Save(imageName)

# get the stitching settings
Stitchset = r'Stitching_Channel_1.czips'

# create a function setting for the Stiching Function
functionsetting1 = Zen.Processing.Transformation.Geometric.Stitching(image_apotome)

# apply the setting
functionsetting1.Load(Stitchset)

# Save Stitched file
image_name = image.Name.Replace('_Apotome.czi', '_Stitched.czi')
imageName = Path.Combine(Outputfolder, image_name)
functionsetting1.Save(imageName)
julie diane
Posts: 19
Joined: Wed Jun 28, 2023 1:25 am

Re: Automating Batch Processing Immediately Following Imaging

Post by julie diane »

It appears you're looking to automate a specific workflow using Zeiss Zen software and its scripting capabilities. You've shared a code snippet that outlines the steps you want to automate, and you're seeking help with completing the script. While I can provide some guidance, please note that writing, testing, and debugging scripts can sometimes be complex and require familiarity with the specific software environment.

Your script aims to perform two main tasks: ApoTome raw conversion and stitching. Based on your provided code and comments, here's how you might structure the script:

python
Copy code
# Prompt User to specify output folder
Outputfolder = "C:\\Path\\To\\Output\\Folder"

# Load the newly acquired image
raw_im = Zen.Application.Documents.LoadDocument("C:\\Path\\To\\Raw\\Image.czi")

# Perform ApoTome raw convert
image_apotome = Zen.Processing.Utilities.ApoTomeSimConvert(raw_im,
ZenApoTomeProcessingMode.Sectioned,
ZenSimCorrectionMode.LocalIntensity,
ZenNormalizeMode.Clip,
ZenApoTomeFilter.Off,
False)

# Save Processed file
image_name = raw_im.Name.Replace('.czi', '_Apotome.czi')
imageName = System.IO.Path.Combine(Outputfolder, image_name)
image_apotome.Save(imageName)

# Load the apotome converted image
apotome_im = Zen.Application.Documents.LoadDocument(imageName)
pool deck resurfacing jacksonville
# Load the stitching settings
Stitchset = Zen.Application.Settings.SaveSettingsFile("C:\\Path\\To\\Stitching\\Settings.zes")

# Create a function setting for the Stitching Function
functionsetting1 = Zen.Processing.Transformation.Geometric.Stitching(apotome_im)

# Apply the setting
functionsetting1.Load(Stitchset)

# Save Stitched file
image_name = apotome_im.Name.Replace('_Apotome.czi', '_Stitched.czi')
imageName = System.IO.Path.Combine(Outputfolder, image_name)
functionsetting1.Save(imageName)
Please note that this code is a template and will need to be adapted to your specific file paths, folder locations, and any additional settings specific to your environment. It's important to test the script thoroughly on sample data to ensure it performs as expected and makes the necessary adjustments as required.

Since writing complex scripts can be challenging, it's a good idea to collaborate with someone who has experience with scripting in the Zeiss Zen environment, or to consult the Zeiss technical support or community for more detailed assistance.
James Millere
Posts: 4
Joined: Wed Nov 29, 2023 5:09 am
Location: USA
Contact:

Re: Automating Batch Processing Immediately Following Imaging

Post by James Millere »

Hi,

Few times back, I was facing the same issue as I was totally new to it. I agree the Answer posted by @juliediane

Good job.
Thanks
James
jhon benz
Posts: 1
Joined: Fri Dec 15, 2023 2:43 pm

Re: Automating Batch Processing Immediately Following Imaging

Post by jhon benz »

Hi there,

Welcome to the Zeiss community! It's great to see you're actively optimizing your workflow. To specify the output folder, you can use:

python
Copy code
# Prompt User to specify output folder
Outputfolder = Zen.Application.UserInterface.Application.GetFolderDialog("Select Output Folder")
For loading the newly acquired image:

python
Copy code
# Load the newly acquired image
raw_im = Zen.Application.Documents.AddDocument("YourImagePath")
These adjustments should help you proceed with the rest of your script. Feel free to reach out to https://www.techspotty.com/ if you need further assistance. Good luck with your automation!

Best regards.
Post Reply