Task #8670 (closed)
Opened 7 years ago
Closed 7 years ago
RFE Blitz setActiveChannels
| Reported by: | wmoore | Owned by: | wmoore |
|---|---|---|---|
| Priority: | major | Milestone: | OMERO-4.4.4 |
| Component: | Web | Version: | n.a. |
| Keywords: | n.a. | Cc: | atarkowska, cxallan |
| Resources: | n.a. | Referenced By: | n.a. |
| References: | n.a. | Remaining Time: | n.a. |
| Sprint: | n.a. |
Description (last modified by wmoore)
I would like urls such as this to be supported:
http://localhost:8000/webgateway/render_image/4852/0/0/?c=3
OR
/webgateway/render_image/4852/0/0/?c=2|228:2007$00FF00,3|745:2819$FF0000
Currently these gives me:
Traceback: File "/Users/will/Desktop/OMERO/dist/lib/python/django/core/handlers/base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/../omeroweb/webgateway/views.py" in handler 538. return func(request, *args, **kwargs) File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/../omeroweb/webgateway/views.py" in render_image 1080. pi = _get_prepared_image(request, iid, server_id=server_id, _conn=_conn) File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/../omeroweb/webgateway/views.py" in handler 538. return func(request, *args, **kwargs) File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/../omeroweb/webgateway/views.py" in _get_prepared_image 963. if not img.setActiveChannels(channels, windows, colors): File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py" in setActiveChannels 5985. if windows is not None and windows[c][0] is not None and windows[c][1] is not None: Exception Type: IndexError at /webgateway/render_image/4852/0/0/ Exception Value: list index out of range
Here's a fix that works for me
def setActiveChannels(self, channels, windows=None, colors=None):
"""
Sets the active channels on the rendering engine.
Also sets rendering windows and channel colors (for channels that are active)
@param channels: List of active channel indexes ** 1-based index **
@type channels: List of int
@param windows: Start and stop values for active channel rendering settings
@type windows: List of tuples. [(20, 300), (None, None), (50, 500)]. One for each active channel
@param colors: List of colors. ['F00', None, '00FF00']. Must be item for each active 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.CONFIG['SERVICE_OPTS'])
print c, idx
if (c+1) in channels:
if windows is not None and windows[idx][0] is not None and windows[idx][1] is not None:
self._re.setChannelWindow(c, *(windows[idx] + [self._conn.CONFIG['SERVICE_OPTS']]))
if colors is not None and colors[idx]:
rgba = splitHTMLColor(colors[idx])
if rgba:
self._re.setRGBA(c, *(rgba + [self._conn.CONFIG['SERVICE_OPTS']]))
if (c+1 in abs_channels):
idx += 1
return True
I'm failing to test this in the main image viewer at the moment, but does this look OK?
Change History (10)
comment:1 Changed 7 years ago by wmoore
- Description modified (diff)
comment:2 Changed 7 years ago by cneves
- Owner changed from cneves-x to wmoore
comment:3 Changed 7 years ago by wmoore
Yes - Additionally, if channel can be turned on/off in the url without updating color or levels.
E.g. Channel 2 in this example:
webgateway/render_image/4852/0/0/?c=2,3|620:3879$FF0000
This is already supported by the code above! ;)
comment:4 Changed 7 years ago by wmoore
Need to check that the examples / API described here are correct: http://trac.openmicroscopy.org.uk/ome/wiki/OmeroWeb/WebGateway
comment:5 Changed 7 years ago by wmoore
- Milestone changed from OMERO-Beta4.4 to OMERO-Beta4.4.1
Not urgent for 4.4
comment:6 Changed 7 years ago by jmoore
Referencing ticket #9092 has changed sprint.
comment:7 Changed 7 years ago by wmoore
- Milestone changed from OMERO-4.4.x to OMERO-4.4.2
Could also do with some tests for this. NB: since adding SERVICE_OPTS, this method has failed when using tuples instead of lists (or vice versa). Need to doc / test /fix
comment:8 Changed 7 years ago by wmoore
comment:9 Changed 7 years ago by Will Moore <will@…>
(In [7b92fed5c8e88c672ad6b226c6da4823df831a66/ome.git] on branch develop) Blitz setActiveChannels() handles missing indexes. See #8670
comment:10 Changed 7 years ago by wmoore
- Resolution set to fixed
- Status changed from new to closed
PR above has been merged
These examples fail because no assumption about channel on or off is made when there's a custom channel rendering option in the url. We can easily change that, but I need to be sure everyone agrees on the assumptions made:
Is this what you expect?