Viewing channel name in multi-channel image

Hi everyone,

Is there a option to display names (instead of 1, 2, 3, etc) for each channel when loading a muti channel image in Napari?

Thank you very much.

Best,
Ajit.

2 Likes

Hey Ajit!

I don’t believe it has been released yet but if you install napari from master for the latest version, you can also install napari-aicsimageio which is a plugin I wrote to use aicsimageio bindings for reading images. So as long as the file is a CZI or OME-Tiff, it will split the channels into different images that you can turn on or off and labels each one with the channel name.

An example of reading a 6 channel OME-Tiff with the plugin can be seen here:

Below are the commands to get the latest napari and napari-aicsimageio:

pip install git+https://github.com/napari/napari.git
pip install napari-aicsimageio

Note: All channels are turned off on initial load of the file. Manually turn on the channels you want to see.

Hope that solves your issue!

9 Likes

@ajitjohnson from code, to label layers, you can do:

viewer = napari.Viewer()
layer = viewer.add_image(data, name='channel_name', ...)

To label the axes, you can add the axis_labels= keyword argument to the Viewer creation:

viewer = napari.Viewer(axis_labels=list('zyx'))
3 Likes

Nice, this is great!

1 Like

and just for the sake of completeness. If you like the result of @JacksonMaxfield’s plugin above (splitting a multichannel image into different layers with different names for each channel), you can accomplish that directly in napari using the channel_axis argument to view_image along with a list of names (Note: this does not change the number where the red arrow is in your example):

import napari
import numpy as np

multi_channel_stack = np.random.rand(4, 50, 256, 256)

napari.view_image(
    multi_channel_stack,
    channel_axis=0,
    name=['dapi', 'fitc', 'tritc', 'cy5']
)
2 Likes

Thank you very much, Jack. How do I use the plugin though? Below is what I generally do.

im = tifffile.imread('/Users/aj/exemplar-001/registration/exemplar-001.ome.tif')
viewer = napari.view_image(im)

I tried this but it crashes my kernel.

from aicsimageio import AICSImage
img = AICSImage('/Users/aj/exemplar-001/registration/exemplar-001.ome.tif')
img.view_napari() 

However, @talley response works as well :slight_smile:

Thank you very much @talley. This works perfectly.

1 Like

Ahhh yes I should have asked how you were using napari. The plugin works when you just use napari the application not the code.

In a terminal if you just run:

napari

It will launch a napari application window that you can then open images like any other viewer.

Also note, plugins are an upcoming feature, so it’s critical here that you install napari from github master as @JacksonMaxfield pointed out in his first comment… otherwise the plugin won’t work. But the next release with plugin support is coming soon!

2 Likes

Aha. Yes that works, thank you :slight_smile: