How do I delete a channel in Qupath? (Programatically)

Is there a way to programatically(or manually) delete a channel in QuPath? I’ve looked around the code base but can’t seem to figure out to delete a channel. I don’t see anything in ImageServer or ImageServerBuilder that would help me.

Problem: I used a script to create a ConcatChannelsImageServer of NDPI files (I know NDPIS is supported but my files are malformed and don’t work properly with Bioformats. I can’t get the scientists to change their behavior with regard to scanner settings so i’m stuck doing this).

The problem with my method however is that I have 6 or 9 channel files instead of a 2 or 3 channel files(Depending on how many files I concat). This works fine, but it’d be nicer if I didn’t have to deal with the empty channels.

Not currently. Actually I was thinking about this yesterday… the closest code currently is ChannelDisplayTransformServer, but this does not support saving/reloading from a project.

You might be able to use ChannelDisplayTransformServer to hack together something that creates such a server temporarily, and then use it to write to an OME-TIFF - although I haven’t tried this. But it may end up taking rather a lot more space, despite the reduction in channels, since it will be 32-bit rather than (I presume) 8-bit as in the original.

For now, I’d recommend trying to write the file in the necessary form outside of QuPath, or tolerating the ‘empty’ channels.

Ok, Thanks Pete.

I haven’t looked for this, but as an alternative is there a way to set the options in the “Brightness & Contrast” dialog programatically?

That is set the display and set the min/max.

Thanks,

There are discussions about it, I’d need to go hunting for them.

Summary: it should be possible, but will require interacting with an ImageDisplay object. This is subject to change when I finally get around to revisiting that bit of the code, I think the currently design could/should be substantially improved.

I will make a note to look into a temporarily more straightforward workaround.

Thanks, I will go hunting.

I’ve mostly gotten away with using the stuff here, though I’m not sure how to actually turn a channel on or off.
https://gist.github.com/Svidro/e00021dff92ea1173e535008854be72e

Generally setting the min value to the max pixel value works just as well for fluorescent images since… well, black.