Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Watershed workflow #181

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
21 changes: 20 additions & 1 deletion volumina/colortables.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def partlyJetTransparent(N=256, ratio = 2./3):
QColor(240, 230, 140).rgba(), #khaki
QColor(69, 69, 69).rgba()] # dark grey


random256 = [
QColor(201, 200, 200).rgba(),
QColor(0, 0, 255).rgba(),
Expand Down Expand Up @@ -392,7 +393,25 @@ def create_random_8bit():
'''Create a colortable suitable for 8bit data.

Creates a pseudo-random colortable in the 8bit range'''
return random256;

# don't return random256 directly. Otherwise the list will be changed by some code directly,
# and everything gets messed up.
# use a creator instead
#return random256;
return [color for color in random256]

def create_random_8bit_zero_transparent():
'''Create a colortable suitable for 8bit data.

Creates a pseudo-random colortable in the 8bit range
Replace zero(th) Color with transparent'''
temp = random256
temp[0] = QColor(0, 0, 0, 0).rgba()

# don't return random256 directly. Otherwise the list will be changed by some code directly,
# and everything gets messed up.
# use a creator instead
return [color for color in temp]

def create_random_16bit():
'''Create a colortable suitable for 16bit data.
Expand Down
5 changes: 4 additions & 1 deletion volumina/pixelpipeline/imagesources.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,14 @@ def toImage( self ):
tImg = time.time()
img = QImage(a.shape[1], a.shape[0], QImage.Format_ARGB32)
if not issubclass( a.dtype.type, np.integer ):
raise NotImplementedError()
#FIXME: maybe this should be done in a better way using an operator before the colortable request which properly handles
#this problem
warnings.warn("Data for colortable layers cannot be float, casting",RuntimeWarning)
a = np.asanyarray(a, dtype=np.uint32)
warnings.warn("As a workaround, volumina/volumina/pixelpipeline/imagesource.py, comment the raise NotImplementedError; Or adjust your data-set to be np.integer conform",RuntimeWarning)
#TODO raise Error just stopped but doesn't handle anything.
# The Warning and conversion did the job
raise NotImplementedError()

# If we have a masked array with a non-trivial mask, ensure that mask is made transparent.
_colorTable = self._colorTable
Expand Down
21 changes: 21 additions & 0 deletions volumina/sliceSelectorHud.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ def _get_pos_widget(name, backgroundColor, foregroundColor):

spinbox = DelayedSpinBox(750)
spinbox.setAlignment(Qt.AlignCenter)
#set the information that will be viewed, if hovered over the Coordination Box
spinbox.setToolTip("{0} Spin Box".format(name))
spinbox.setButtonSymbols(QAbstractSpinBox.NoButtons)
spinbox.setMaximumHeight(20)
Expand Down Expand Up @@ -490,6 +491,16 @@ def createQuadViewStatusBar(self,
xbackgroundColor, xforegroundColor,
ybackgroundColor, yforegroundColor,
zbackgroundColor, zforegroundColor):
"""
adds the following properties to the lower part of the view
X value (X Spin Box)
Y value
Z value
Busy-waiting box (invisible)
Position
Time Spin Box

"""
self.xLabel, self.xSpinBox = _get_pos_widget('X',
xbackgroundColor,
xforegroundColor)
Expand All @@ -500,6 +511,11 @@ def createQuadViewStatusBar(self,
zbackgroundColor,
zforegroundColor)

#partial connection means:
#The partial object is created by definition of the connection,
#not when the event is triggered.
#That means: _handlePositionBoxValueChanged() is called when connecting, so that it will
#always handle the contents that have changed in the viewer.
self.xSpinBox.delayedValueChanged.connect( partial(self._handlePositionBoxValueChanged, 'x') )
self.ySpinBox.delayedValueChanged.connect( partial(self._handlePositionBoxValueChanged, 'y') )
self.zSpinBox.delayedValueChanged.connect( partial(self._handlePositionBoxValueChanged, 'z') )
Expand Down Expand Up @@ -640,6 +656,11 @@ def _onTimeSliderChanged(self):
self.timeSpinBox.setValue(self.timeSlider.value())

def _handlePositionBoxValueChanged(self, axis, value):
"""
Take the old values of the spinBoxes
and change the value of the given axis
Emit the signal with the new position
"""
new_position = [self.xSpinBox.value(), self.ySpinBox.value(), self.zSpinBox.value()]
changed_axis = ord(axis) - ord('x')
new_position[changed_axis] = value
Expand Down
1 change: 1 addition & 0 deletions volumina/widgets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
session.vim