Batch tool for resampling

Discuss questions and projects related to processing of imaging data here
Post Reply
Praveen Krishnamoorthy
Posts: 5
Joined: Tue Mar 29, 2022 7:46 pm

Batch tool for resampling

Post by Praveen Krishnamoorthy »

Hello,
I was wondering if ZEN Blue has a batch tool for resampling multiple .czi files. Currently , I have been running the "Resample" tool in the processing tab one file at a time.
Thanks!
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: Batch tool for resampling

Post by CarlZeissMicroscopy3 »

Hello Praveen Krishnamoorthy,

you have to write something like

Code: Select all

from System.IO import File, Directory, FileInfo

path = r'C:\Users\...\Pictures\MyImages'

files = Directory.GetFiles(path,'*.czi') 

for i in range(0,files.Length): 
    file = files[i] 
    fileInfo = FileInfo(file) 
    pathAndFile = path + "\\" + fileInfo.Name
    image = Zen.Application.LoadImage(pathAndFile,False)
    
    imageResampled = Zen.Processing.Transformation.Geometric.Resample(image, True, ZenInterpolation.Linear, ZenThirdProcessingDimension.None, 0, 0, 0, 1, 1, 1, False)

    pathAndFileResampled = path + "\\" + fileInfo.Name.Substring(0, fileInfo.Name.Length-4) + "Resampled.czi"
    imageResampled.Save(pathAndFileResampled)

    imageResampled.Close()
    image.Close()

Zen.Application.Pause('Number of Files: ' + str(files.Length))
I hope you will be able to modify it to your needs ;-)
Post Reply