Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FIX force vmin/vmax to 0/1 whenever an array is passed as alpha #461

Merged
merged 2 commits into from
Sep 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions cortex/dataset/viewRGB.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import colorsys
import warnings

from .views import Dataview, Volume, Vertex
from .braindata import VolumeData, VertexData, _hash
Expand Down Expand Up @@ -256,7 +257,14 @@ def alpha(self):
alpha = np.ones(self.red.volume.shape)
alpha = Volume(alpha, self.red.subject, self.red.xfmname, vmin=0, vmax=1)
if not isinstance(alpha, Volume):
alpha = Volume(alpha, self.red.subject, self.red.xfmname)
if alpha.min() < 0 or alpha.max() > 1:
warnings.warn(
"Some alpha values are outside the range of [0, 1]. "
"Consider passing a Volume object as alpha with explicit vmin, vmax "
"keyword arguments.",
Warning
)
alpha = Volume(alpha, self.red.subject, self.red.xfmname, vmin=0, vmax=1)

rgb = np.array([self.red.volume, self.green.volume, self.blue.volume])
mask = np.isnan(rgb).any(axis=0)
Expand Down Expand Up @@ -523,7 +531,14 @@ def alpha(self):
alpha = np.ones(self.red.vertices.shape[1])
alpha = Vertex(alpha, self.red.subject, vmin=0, vmax=1)
if not isinstance(alpha, Vertex):
alpha = Vertex(alpha, self.red.subject)
if alpha.min() < 0 or alpha.max() > 1:
warnings.warn(
"Some alpha values are outside the range of [0, 1]. "
"Consider passing a Vertex object as alpha with explicit vmin, vmax "
"keyword arguments.",
Warning
)
alpha = Vertex(alpha, self.red.subject, vmin=0, vmax=1)

rgb = np.array([self.red.data, self.green.data, self.blue.data])
mask = np.isnan(rgb).any(axis=0)
Expand Down