Changing channel visibility

Hi all,

I want to check and see if I am doing something the right way - turning off channel visibility, in this case.

Theoretical test case would be exporting a variety of snapshots with different viewer settings per image.

I came up with:

viewer = getCurrentViewer()
c = viewer.getImageDisplay().availableChannels()
channelsOn = [0,2,4,6]
c.eachWithIndex{channelInfo, x->
        viewer.getImageDisplay().setChannelSelected(channelInfo, true)
        viewer.getImageDisplay().setChannelSelected(channelInfo, false)

Is this the most efficient way to code this? I could set the min and max of certain channels to the max value, but that seemed more awkward.

This looks fine to me, why do you ask?

1 Like

I wanted to make sure I was not missing another method similar to setChannelNames or setChannelColors. There are several posts related to altering channel color and intensity, but I was not able to find one directly addressing the best way to turn channels on or off.

Ah ok, ImageDisplay remains a temporary thing that shows no sign of leaving… you can access the list of selected channels, but it is read-only – so I believe that one channel at a time is the best way.

1 Like