Setting channel names

Setting channel names#

The naming of channels of multicolor images can be a bit ambiguous if not done properly directly from the start of the acquisition. Also, a microscope may name a channel simply after the name of the excitation laser wavelength or the emission filter - because the micrscope is unaware of the particular fluorophore or staining that is being used. In that situation, you can change the channel name to something more meaningful to you.

import ezomero
import omero
host = 'omero-int.biotec.tu-dresden.de'
user = ''  # replace this with your username
secure = True
port = 4064
group = 'default'

conn = ezomero.connect(host=host, user=user, secure=secure, port=port, group=group)

First, let’s retrieve the current metadata of our sample image:

metadata, image = ezomero.get_image(conn, image_id=330)
print('Channel labels: ', metadata.getChannelLabels())
Channel labels:  ['0', '1']

Our channels are currently named 0 and 1, which is obviously not very informative. We can change the channel names to something more meaningful. We create a dictionary for some new channel names.

Note

Per OMERO convention, the keys of the dictionary have to be numbers counting up from 1 to the number of channels in the image.

new_channel_names = {
    1: 'DAPI',
    2: 'GFP',
}

Now we can pass this dictionary to the remote image object to update the channel names. Note that the ids keyword requires a list of image ids and not a single image id.

conn.setChannelNames(data_type='Image', ids=[metadata.getId()], nameDict=new_channel_names)
{'imageCount': 1, 'updateCount': 1}

Let’s check for the information of the image again to see if the channel names have been updated.

metadata, image = ezomero.get_image(conn, image_id=330)
print('Channel labels: ', metadata.getChannelLabels())
Channel labels:  ['DAPI', 'GFP']