BodenmillerGroup / xtiff

A tiny Python library for writing multi-channel TIFF stacks.
MIT License
27 stars 2 forks source link

Show only one channel when opening with Photoshop #21

Open tlxfif opened 1 year ago

tlxfif commented 1 year ago
import numpy as np
from xtiff import to_tiff
def test_to_tiff(tmp_path):
    path = tmp_path + "test.ome.tiff"
    num_channels = 10
    img = np.zeros((1, 1, num_channels, 200, 200, 1))
    channel_names = [f"Channel {i + 1}" for i in range(num_channels)]
    print(channel_names)
    to_tiff(
        img,
        path,
        image_name="test.ome.tiff",
        channel_names=channel_names,
        pixel_size=1.0,
        pixel_depth=2.0,
    )
test_to_tiff("./")
nilseling commented 1 year ago

There's little info given to this issue. Are you trying to open a multichannel image with Photoshop? What if you use FIJI?

tlxfif commented 1 year ago

There's little info given to this issue. Are you trying to open a multichannel image with Photoshop? What if you use FIJI?

Yes, I need to open it in photoshop, and I need to display the custom channel name in photoshop, but I have tried tifffile, but I don’t understand, thank you for your suggestion, I will try it, thank you very much

YammyHuang commented 4 months ago

sorry~,I try to use this code to rename the channel names of my OME-TIFF file,however I found it add another axis which let my OME-TIFF cannot show up correctly.The shape of my original OME-TIFF is [1,1,5,7785,9289],however,after

import os
import numpy as np
from xtiff import to_tiff
labs = [
    'FoxP3',
    'Tryptase',
    'GZMB',
    'Ki67',
    'CollagenI'
]
def test_to_tiff(input_image_path, output_image_path):
    num_channels = 5
    img = np.zeros((1, 1, num_channels, 7785, 9279))
    channel_names = labs
    to_tiff(
        img,
        output_image_path,
        image_name=os.path.basename(output_image_path),
        channel_names=channel_names,
    )

input_image_path = "E:/tmp/DEMO/channel test.ome.tiff"
output_image_path = "E:/tmp/DEMO/channel test2.ome.tiff"
test_to_tiff(input_image_path, output_image_path)

file changed into[1,1,5,7785,9279,3] I don't know how to correct this, can you help me please.