[Python] I want to remove 1 color channel from a tif in zcyx and save it in zyx

Discussão em 'Python' iniciado por Stack, Agosto 14, 2025.

  1. Stack

    Stack Membro Participativo

    I though it would be as simple as picking 1 color and keeping the rest of the axis the same.

    from tkinter import filedialog
    import tifffile as tif
    import os

    def SplitChannel(ImName):
    TifIm = tif.imread(ImName)
    return TifIm[:,1,:,:] #for some reason this makes the tiff read cyx vs zyx


    if __name__ == "__main__":
    Folder = filedialog.askdirectory(title = "Select the directory containing Tif files")
    ImageNames = os.listdir(Folder)
    SaveFolder = Folder + " Split Red Channel2"
    os.mkdir(SaveFolder)
    os.chdir(Folder)
    for Image in ImageNames:
    if Image.split(".")[-1] == "tif":
    print("here")
    SplitRed = SplitChannel(Image)
    os.chdir("...")
    os.chdir(SaveFolder)
    tif.imwrite(Image + "_Red.ome.tif",SplitRed,imagej= True)
    os.chdir("...")
    os.chdir(Folder)


    But this gives me a tif in cyx vs zyx. How can I make sure the resulting tif knows I removed a color channel, and not z

    Continue reading...

Compartilhe esta Página