MRG, BUG: Fix alpha for volumes #8663
Merged
+42
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Some simple code to plot with
hot_r
withtransparent=True
andalpha=1.
(should yield an opaque volume where values are large) looks like this onmaster
:And on this PR it's correct:
The key was the opacity and color transfer functions both need to yield floats between 0 and 1, so we just need to divide both by 255 (ctable is
np.int8
) rather than doing whatever silly gymnastics we were doing before where the colors ranged from 0 to 255 and the alphas 0 to 1/255 (effectively).While I was messing around with this I noticed
add_data
could not usecolormap='mne'
so I refactored ourget_cmap
calls. I also added a simple test totest_brain
to make sure ourctable
is correct.@GuillaumeFavelier can you take a quick look? Not sure if this or #8335 should go in first, but I think they're going to conflict.