Open neuroBazzi opened 2 years ago
Cordmap's generate_prob_map has no concept of population. It has the concept of points/cells. When multiple populations are active in the UI, under the hood, to get the density map, we treat them as one big population. Cordmap generates the probability map for the big population and we convert the probability to a greyscale image.
With the greyscale image and PIL we can generate a colored image like:
color = ImageOps.colorize(i, black="black", white="yellow")
We end up with something like this:
( @filippomc how do you like the new colors? :duck: )
Does that answer your question @neuroBazzi ? Would you like me to implement that? If so when multiple populations are chosen is it all right if I merge the colors of those population together and use that for the 'new white'?
Do we need further discussion on this point after our conversation last week?
Not for now, thanks.
The plan is to: 1 - Generate, for each population 2 images (one with just the centroids and other with just the heatmap) 2 - Blend them correctly according to the user inputs (in the UI), which can be: show only centroids, show only heatmap or show both together, each of the alternatives should work for one or more populations.
Potentially I might have some questions on the blend logic but it's a discussion that it's better to have after having some examples
ok great
Recolor density map:
mask = i.convert('L')
i = ImageOps.colorize(mask, black="black", white="yellow")
Recolor centroids:
data = np.array(c_img) # "data" is a height x width x 4 numpy array
red, green, blue, alpha = data.T # Temporarily unpack the bands for readability
# Replace white with red... (leaves alpha values alone...)
white_areas = (red == 255) & (blue == 255) & (green == 255)
data[..., :-1][white_areas.T] = (255, 255, 0) # Transpose back needed
c_img = Image.fromarray(data)
Stacked together:
beautiful!
Question: can we match the color of the heatmap with the the color picker of the active population? the reason is that when we have more than one populations selected, we see the heatmap only in white and we cannot tell to which populations it refers to.