brainglobe / brainglobe-heatmap

Rendering anatomical heatmaps with brainrender and matplotlib
https://brainglobe.info
MIT License
34 stars 10 forks source link

fix a bug with heatmap's colormap when values contained NaN #17

Closed carlocastoldi closed 9 months ago

carlocastoldi commented 11 months ago

Before submitting a pull request (PR), please read the contributing guide.

Description

What is this PR

Bug fix

I know this project is momentarily unmaintained. For this reason i don't expect this PR to be merged any time soon. In the meantime, I prefer submitting it.

Why is this PR needed?

with the following values, the color mapping is wrong:

import vedo as vd
import bgheatmaps as bgh
import numpy as np

vd.embedWindow("k3d")

values = {'MO': np.nan, 'RHP': 5, 'AUD': -5}    # does NOT work -> uses cmin=np.nan
# values = {'RHP': 5, 'MO': np.nan, 'AUD': -5}  # does NOT work -> uses cmin=-5
# values = {'RHP': 5, 'AUD': -5, 'MO': np.nan}  # does NOT work -> uses cmin=-5

h = bgh.heatmap(
    values,
    position=5000,  # when using a named orientation you can pass a single value!
    orientation="frontal",  # 'frontal' or 'sagittal', or 'horizontal' or a tuple (x,y,z)
    title="horizontal view",
    vmin=0,
    vmax=3,
    format="2D",
)
h.show()

What does this PR do? checks for nan values and allows users to set cmin=0 or cmax=0

How has this PR been tested?

with the above mentioned code

Is this a breaking change?

no

Does this PR require an update to the documentation?

no

adamltyson commented 11 months ago

Thanks @carlocastoldi. It will be looked at, just no ETA currently!

adamltyson commented 9 months ago

@carlocastoldi Thanks for this. I've closed this PR, but included your commits in #21. If you could test that PR that would be very helpful!