Closed StiThor closed 1 year ago
Hi @StiThor
xtiff is a small Python package for writing out images as standardized (OME-)TIFF files. Except for very specific use cases, I recommend to directly work with tifffile instead. If you for example want to stack multiple single-page TIFFs into a multi-channel TIFF, you could do the following in Python (untested, written on the bus :-) ):
import numpy as np
import tifffile
from pathlib import Path
img_dir = "/path/to/dir"
out_file = "/path/to/img.tiff"
img_files = sorted(Path(img_dir).glob("*.tiff"))
img = np.array([tifffile.imread(img_file) for img_file in img_files])
tifffile.imwrite(out_file, img)
Hope this helps. If you still want to use xtiff, e.g. for writing an OME-TIFF instead, give a shout.
Thanks so much, Jonas! :) That worked! Sorry for disturbing your bus ride more, but this causes another problem. So I`m using the Steinbock segmentation of data
And this approach does not give me the name for each channel, which makes it difficult to choose the right channels for segmentation. Is it easy to implement something in the code that preserves the name from each .tiff file?
And sorry again but I have to ask. I have like 250 different folders/tissues. Is it easy to make the code stack images for each of them?
Thanks so much again!
Unfortunately, the channel name is not saved by default in TIFF files, so Steinbock has no way of extracting them from there. If you had OME-TIFF files that would be a different story, but Steinbock currently does not support reading channel names from OME-TIFF.
To process multiple folders, you could use a for loop (pseudocode):
img_dirs = [
"/path/to/dir1",
"/path/to/dir2",
... # or use Path.glob to list all subdirectories of a directory
]
for img_dir in img_dirs:
... # reuse code from before
Ah, sorry, didn't read carefully enough. So you want to extract the name from the file of the image. I'll get back to you about that tomorrow.
I've figured it out :) Thanks for the help!
Best, Stian Tornaas
tor. 12. jan. 2023, 22:38 skrev Jonas Windhager @.***>:
Ah, sorry, didn't read carefully enough. So you want to extract the name from the file of the image. That's not supported by Steinbock out of the box, sorry. You will need to write your own script to automate that.
— Reply to this email directly, view it on GitHub https://github.com/BodenmillerGroup/xtiff/issues/13#issuecomment-1381022574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVO5NOILYPP2HH4IEDPVW2DWSB2W3ANCNFSM6AAAAAATZQKKVU . You are receiving this because you were mentioned.Message ID: @.***>
Hi and thanks for making this package. I`m trying to implement this on a set of .tiff images with Hyperion data, but without success. Could you please explain to me as descriptive as possible how to utilize this package on the premise that I have a folder with tiff images that I want to stack?