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

Codomain web #4839

Merged
merged 19 commits into from
Oct 27, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
32ff94c
Add reverse intensity methods to Blitz Gateway.
will-moore Sep 9, 2016
743dd85
Add reverseMap support to webgateway split_channel_info()
will-moore Sep 9, 2016
ff794dc
Move Blitz isReverseIntensity() to channel from image
will-moore Sep 12, 2016
7c3bc03
channelMarshal includes reverseIntensity: boolean
will-moore Sep 12, 2016
d3fe66a
Show 'Reverse Intensity' checkbox in colorpicker dialog
will-moore Sep 12, 2016
a5ca492
Adding cyan to list of colors in colorpicker
will-moore Sep 12, 2016
d768054
Handle 'reverseIntensity' in undo, save, compare channels
will-moore Sep 12, 2016
6b5dd2e
Include 'reverseIntensity' in Blitz image.getAllRenderingDefs()
will-moore Sep 12, 2016
6bb7066
Use no 'r' in rdef string to disable reverse
will-moore Sep 12, 2016
50a077b
Include 'r' for reverseIntensity in copy_image_rdef_json
will-moore Sep 13, 2016
6cfb26b
Update image marshal test to expect 'reverseIntensity' in channels
will-moore Sep 22, 2016
bea20b8
Use '-r' flag to turn OFF reverse intensity explicitly
will-moore Sep 23, 2016
614ebc1
Handle -r flag in setQuery()
will-moore Sep 23, 2016
e79b5a9
Fix Click user thumbnail rdef removes reverse-intensity
will-moore Sep 29, 2016
5b0479d
Reverse Intensity checkbox doesn't scroll in dialog
will-moore Sep 30, 2016
0a1c0ae
Merge remote-tracking branch 'origin/develop' into codomain_web
will-moore Oct 5, 2016
54689c0
Merge remote-tracking branch 'origin/develop' into codomain_web
will-moore Oct 5, 2016
996a4da
Include reverseIntensity in test copy_paste rdefs
will-moore Oct 17, 2016
f616178
Include reverseIntensity in test_all_rendering_defs
will-moore Oct 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 41 additions & 1 deletion components/tools/OmeroPy/src/omero/gateway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7621,7 +7621,8 @@ def getZoomLevelScaling(self):
rv[i] = float(level)/sizeXList[0]
return rv

def setActiveChannels(self, channels, windows=None, colors=None):
def setActiveChannels(self, channels, windows=None, colors=None,
reverseMaps=None):
"""
Sets the active channels on the rendering engine.
Also sets rendering windows and channel colors
Expand All @@ -7645,12 +7646,17 @@ def setActiveChannels(self, channels, windows=None, colors=None):
Must be list for each channel
:param colors: List of colors. ['F00', None, '00FF00'].
Must be item for each channel
:param reverseMaps: List of boolean (or None). If True/False then
set/remove reverseIntensityMap on channel
"""
abs_channels = [abs(c) for c in channels]
idx = 0 # index of windows/colors args above
for c in range(len(self.getChannels())):
self._re.setActive(c, (c+1) in channels, self._conn.SERVICE_OPTS)
if (c+1) in channels:
if (reverseMaps is not None and
reverseMaps[idx] is not None):
self.setReverseIntensity(c, reverseMaps[idx])
if (windows is not None
and windows[idx][0] is not None
and windows[idx][1] is not None):
Expand Down Expand Up @@ -7894,6 +7900,40 @@ def isGreyscaleRenderingModel(self):
"""
return self.getRenderingModel().value.lower() == 'greyscale'

@assert_re()
def setReverseIntensity(self, channelIndex, reverse=True):
"""
Sets or removes a ReverseIntensityMapContext from the
specified channel. If set, the intensity of the channel
is mapped in reverse: brightest -> darkest.

:param channelIndex: The index of channel (int)
:param reverse: If True, set reverse intensity (boolean)
"""
r = omero.romio.ReverseIntensityMapContext()
# Always remove map from channel
# (doesn't throw exception, even if not on channel)
self._re.removeCodomainMapFromChannel(r, channelIndex)
# If we want to reverse, add it to the channel (again)
if reverse:
self._re.addCodomainMapToChannel(r, channelIndex)

@assert_re()
def isReverseIntensity(self, channelIndex):
"""
Returns True if the specified channel has ReverseIntensityContext
set on it.

:return: True if ReverseIntensityContext found
:rtype: Boolean
"""
ctx = self._re.getCodomainMapContext(channelIndex)
reverse = False
for c in ctx:
if isinstance(c, omero.model.ReverseIntensityContext):
reverse = True
return reverse

@assert_re(ignoreExceptions=(omero.ConcurrencyException))
def getRenderingDefId(self):
"""
Expand Down
27 changes: 22 additions & 5 deletions components/tools/OmeroWeb/omeroweb/webgateway/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,35 @@ def _split_channel_info(rchannels):
channels = []
windows = []
colors = []
reverses = []
for chan in rchannels.split(','):
# chan 1|12:1386r$0000FF
chan = chan.split('|', 1)
# chan ['1', '12:1386r$0000FF']
t = chan[0].strip()
# t = '1'
color = None
rev = None
# Not normally used...
if t.find('$') >= 0:
t, color = t.split('$')
try:
channels.append(int(t))
ch_window = (None, None)
if len(chan) > 1:
t = chan[1].strip()
# t = '12:1386r$0000FF'
if t.find('$') >= 0:
t, color = t.split('$', 1)
# color = '0000FF'
# t = 12:1386r
# Optional flag to enable/disable reverse codomain
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@will-moore sorry, I know I'm being a bit knitpicky here but would it be a major problem if we handled that with a split for ':' . Syntactically it seems a tad clearer/cleaner to get a tuple/triple with min:max:optRev.

something like this maybe?

t = t.split(':')
if len(t) == 2:
    try:
        ch_window = [float(x) for x in t]
    except ValueError:
        pass

if len(t) == 3:
    rev = len(y[2]) > 0 and y[2] == 'r'

if t.endswith('-r'):
rev = False
t = t[:-2]
elif t.endswith('r'):
rev = True
t = t[:-1]
t = t.split(':')
if len(t) == 2:
try:
Expand All @@ -227,10 +243,11 @@ def _split_channel_info(rchannels):
pass
windows.append(ch_window)
colors.append(color)
reverses.append(rev)
except ValueError:
pass
logger.debug(str(channels)+","+str(windows)+","+str(colors))
return channels, windows, colors
return channels, windows, colors, reverses


def getImgDetailsFromReq(request, as_string=False):
Expand Down Expand Up @@ -754,8 +771,8 @@ def _get_prepared_image(request, iid, server_id=None, conn=None,
return
if 'c' in r:
logger.debug("c="+r['c'])
channels, windows, colors = _split_channel_info(r['c'])
if not img.setActiveChannels(channels, windows, colors):
channels, windows, colors, reverses = _split_channel_info(r['c'])
if not img.setActiveChannels(channels, windows, colors, reverses):
logger.debug(
"Something bad happened while setting the active channels...")
if r.get('m', None) == 'g':
Expand Down Expand Up @@ -1858,9 +1875,9 @@ def getRenderingSettings(image):
return rv

def applyRenderingSettings(image, rdef):
channels, windows, colors = _split_channel_info(rdef['c'])
channels, windows, colors, reverse = _split_channel_info(rdef['c'])
# also prepares _re
image.setActiveChannels(channels, windows, colors)
image.setActiveChannels(channels, windows, colors, reverse)
if rdef['m'] == 'g':
image.setGreyscaleRenderingModel()
else:
Expand Down