informatics-isi-edu / openseadragon-viewer

2D viewer with openseadragon
Apache License 2.0
5 stars 2 forks source link

Incorrect channel filters applied to multi-z multi-channel images #94

Open RFSH opened 2 years ago

RFSH commented 2 years ago

When users are navigating between different images in the z-plane for a multi-channel image, sometimes the filters (hue, gamma, etc) are applied incorrectly.

This is happening because we have no control over the order of channel urls that we're getting in the z-plane. Since we wanted to avoid sending multiple requests, the request to fetch the available z-index values is done with the same request to get the channel urls for each individual z-index like the following:

https://www.rebuildingakidney.org/ermrest/catalog/2/attributegroup/M:=Gene_Expression:Processed_Image/Reference_Image=16-2GQ0/Z_Index;images:=array(*)@sort(Z_Index)@after(138)?limit=11

As you can see, to make this work, we are using array(*). So we cannot be sure of the order of channel urls that we're getting. For this reason the loadImages function is actually mapping the url to channels by looking at the channelNumber. But the bug happens when we're asking OSD to show the images. We're adding images based on the response order (not sorted), and since we don't want the channel panel to flash/move we leave the channels with their original order (sorted).

To fix this, we have to make sure the images are displayed based on the original order and not the arbitrary response order.

RFSH commented 2 years ago

Since we wanted a quick fix for this, I decided to change chaise to always sort the given images based on channelNumber. So this issue is resolved for now.

I'm going to keep this issue open because I think we should modify the logic in the loadImages and avoid blindly asking OSD to display the images without checking the order.