Can label from track objects be used to generate indexed images

Hi CP folks,

I am trying to use the “ConvertObjectsToImage” module to output each cell’s tracking label instead of its object number. Is it possible to substitute the tracking label for the object number so I can generate indexed grayscale images for all tracked cells within a z-stack?

You could use “DisplayDataOnImage” on the greyscale image you want and have it show the TrackObjects label number. Let me know if that does what you want!

I am using the “DisplayDataOnImage” for display purposes but I would also like to use the feature of encoding the tracking number as a grayscale intensity value like what is does with the ObjectNumber when converted to an image. Is that possible currectly?

It is- while you’re in DisplayDataOnImage for the DisplayMode choose “Color” instead of text, then set your colormap to “gray” (not “Greys” unless you want it inverted- you can see examples of all the possible colormaps here). Since presumably your highest label won’t yet be present in your first frame I’d suggest setting the range manually (to some number that’s 10-20% higher than the approximate number of labels you expect unless you already happen to know the exact number) so that the colors stay consistent.

Thanks Beth. The suggestion that you made does work for encoding the tracking number in the image as grayscale values. The only issue I am running into at the moment is that the downstream image appears to be resized so the nuclei segmentation outlines do not overlap. I think the figure legend is causing the image to be rescaled so it breaks the downstream segmented object outline overlay step. Here is an example of what the pipeline outputs from display data on image module. The output image dimensions from DisplayDataOnImage is correct and is 1024x1024 but in subsequent downstream steps it appears to be resized to a little over 800x800.

Yeah, that’s not right.

Apparently DisplayDataOnImage is pretty complicated under the hood and actually involves destruction of the original image and use of a scaled copy; I’ll file an issue to see if there’s a simpler way to do this but I think getting this to work would involved a major retool of the module as currently written.

In the meantime if the outlines convey important information that you really need overlaid you can introduce a Crop and a Resize step onto the DisplayImage output to get it back to the original dimensions. I’m afraid that’s the best I can offer at this point, sorry.

Hi Beth,

Thanks for your suggestion to use the crop and resize function to correct for the rescale bug in DisplayDataOnImage module. The two steps seem to work but have introduced a multiplicative rescaling error that gets worse from the left to right and top to bottom edges. I think a crop with the wrong pixel offset shouldn’t lead to this type of non-linear scaling artifact. Do you happen to know the correct crop dimensions settings to use for a 1024x1024 px image?

Sorry, I don’t- other than advising you to keep it square. It’s a hacky way to get around the problem so it may not perform perfectly, but it should be enough to convey the data you need conveyed.