Deeplabcut: Picking colors -- Labels: First and last body parts have same color

Created on 22 Nov 2018  路  8Comments  路  Source: DeepLabCut/DeepLabCut

When creating labeled frames or videos (with DLC 2.0.0 on Windows 10 or Windows 7), the labels of the first and last body parts have the same color (they're both red) due to the unfortunate choice of a circular color map (hsv). Would it be possible to use a color map such as the Glasbey LUT for label colors?

(See also: https://twitter.com/helenajambor/status/1065355996632092672)

question

Most helpful comment

https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html any matplotlib colormap is useable...

All 8 comments

You can set whatever color map you want in the config file. https://github.com/AlexEMG/DeepLabCut/blob/master/docs/functionDetails.md#a-create-a-new-project

Unfortunately, Matplotlib doesn't seem to include a full 8-bit qualitative color map such as ImageJ's Glasbey LUT (according to this list).

As a fallback, I'd recommend to set the default color map (in all these locations) to tab10 or tab20. Both of them don't have the issue of resulting in the same color for first and last label, and do work reasonably well for up to 20 different body parts.

(reminder to fix this in next push! @AlexEMG)

Done, DLC 2.0.2, also on pypi now as there were quite a few minor fixes: https://github.com/AlexEMG/DeepLabCut/compare/v2.0.1...master

As a follow-up, is it possible to have all parts to be labeled with the same color?

I see in the docs that "By default, each body part is plotted in a different color (governed by the colormap) and the plot labels indicate their source." Is it possible to change this to a single color?
Thank you!

https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html any matplotlib colormap is useable...

Update:

Run the snippet in the notebook:

 from matplotlib.colors import LinearSegmentedColormap
 from matplotlib import cm
 colors = [(0, 0, 1), (0, 0, 1), (0, 0, 1)]  # R -> G -> B
 cmap_name = 'const_blue'
 c_map_new = LinearSegmentedColormap.from_list(cmap_name, colors)
 cm.register_cmap(name=cmap_name, cmap=c_map_new)

The above registers custom color map (for the current session), and you can call it as you'd call other color maps from config.yaml (like "jet")

Set colormap variable in config.yaml_ as 'const_blue'.

Was this page helpful?
0 / 5 - 0 ratings