I am writing a stack file from several images in python using the tifffile package.
Then I modify it in Fiji (I do a manual segmentation) and I want to save it to be readable in python again.
Every image in the stack has as description the single image filename.
When I modify the Stack and save it as “Stack_segmented” the information is gone or not accessible.
What I would like is to get the single images after the manual segmentation in a new folder, each with their description as filename (the description contains their original filename).
This is how I write the Stack from single images:
import tifffile as tiff with tiff.TiffWriter(output_filename, bigtiff=True) as tif_writer: for filename in natsorted(os.listdir(path)): img=tiff.imread(os.path.join(path,filename),name=filename) tif_writer.save(img, photometric='minisblack', description=filename, metadata=None)
This is how I create the single images from a stack:
with tiff.TiffFile(input_filename, multifile=True) as tif: for page in tif.pages: img=page.asarray() description=page.description tiff.imsave(file=os.path.join(output_path,description), data=img, photometric='minisblack')
The code above works when I don’t modify the Stack on Fiji. But when I modify it then the description is overwritten and page.description contains:
for all images in the stack so I only create one file with the name “IMAGEJ~1.53C” which is overwritten in every iteration.
How could I keep the description data of each file after modifying the Stack?
I have tried it “Save as tif” as well as exporting with Bio-Formats but I have the same problem.
Thank you very much for your help.