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

confine projection #305

Merged
merged 6 commits into from
Feb 27, 2020
Merged
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
14 changes: 14 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ Install
Instructions on how to add the OMERO.iviewer app to your installed OMERO.web apps
can be found in the `OMERO.iviewer README <plugin/omero_iviewer/README.rst>`_.

Settings
========

OMERO.iviewer limits the size of Z-projections to reduce load on the server.
The limit is defined as the number of bytes of raw pixel data in a Z-stack and
is equivalent to 1024 * 1024 * 256 bytes.
For example, an 8-bit image (1 byte per pixel) of size 1024 * 1024 * 256 is
equal to the default threshold. To double the limit, use::

$ omero config set omero.web.iviewer.max_projection_bytes 536870912

NB: Z-projection is not supported for tiled images in OMERO
(Images larger than 2000 * 2000 pixels per plane are tiled in iviewer).

Supported URLs
==============

Expand Down
7 changes: 7 additions & 0 deletions plugin/omero_iviewer/iviewer_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
# load settings
IVIEWER_SETTINGS_MAPPING = {

"omero.web.iviewer.max_projection_bytes":
["MAX_PROJECTION_BYTES",
1024 * 1024 * 256,
int,
("Maximum bytes of raw pixel data allowed for Z-projection. "
"Above this threshold, Z-projection is disabled")],
Copy link
Member

Choose a reason for hiding this comment

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

Maybe indicate that this value will be ignored if the limit is greater that the one set server-side.
Server side is work-in-progress but when it is in-place that will be the rule.

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems wrong for the documentation to describe future functionality.
Since I'll need to open a PR to update the functionality, I can change the description at the time to match (depending on what we end up with).

Copy link
Member

Choose a reason for hiding this comment

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

we can review the wording later on when we implement the size limit from server
My point is that if people start setting a high limit, this will be ignored later on and will default to the server one. This might come at a surprise for that.


"omero.web.iviewer.roi_page_size":
["ROI_PAGE_SIZE",
500,
Expand Down
2 changes: 2 additions & 0 deletions plugin/omero_iviewer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

ROI_PAGE_SIZE = getattr(iviewer_settings, 'ROI_PAGE_SIZE')
ROI_PAGE_SIZE = min(MAX_LIMIT, ROI_PAGE_SIZE)
MAX_PROJECTION_BYTES = getattr(iviewer_settings, 'MAX_PROJECTION_BYTES')

PROJECTIONS = {
'normal': -1,
Expand Down Expand Up @@ -84,6 +85,7 @@ def index(request, iid=None, conn=None, **kwargs):
if settings.FORCE_SCRIPT_NAME is not None:
params['URI_PREFIX'] = settings.FORCE_SCRIPT_NAME
params['ROI_PAGE_SIZE'] = ROI_PAGE_SIZE
params['MAX_PROJECTION_BYTES'] = MAX_PROJECTION_BYTES

return render(
request, 'omero_iviewer/index.html',
Expand Down
2 changes: 2 additions & 0 deletions src/app/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ export default class Context {
this.interpolate = (interpolate === 'true');
this.version = this.getInitialRequestParam(REQUEST_PARAMS.VERSION);
this.roi_page_size = this.initParams[REQUEST_PARAMS.ROI_PAGE_SIZE] || 500;
this.max_projection_bytes = parseInt(this.initParams[REQUEST_PARAMS.MAX_PROJECTION_BYTES], 10)
|| (1024 * 1024 * 256);
}

/**
Expand Down
8 changes: 7 additions & 1 deletion src/controls/dimension-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,13 @@ export default class DimensionSlider {
*/
getZProjectionDisabled(handle, forwards) {
let dims = this.image_config.image_info.dimensions;
return (handle !== null && forwards || (dims.max_x * dims.max_y) > UNTILED_RETRIEVAL_LIMIT);
let tiled = (dims.max_x * dims.max_y) > UNTILED_RETRIEVAL_LIMIT;
let bytes_per_pixel = Math.ceil(Math.log2(this.image_config.image_info.range[1]) / 8.0);
Copy link
Member

Choose a reason for hiding this comment

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

you may want to add a TODO and create an issue so we can use the omero-model property when available ome/omero-model#47

Copy link
Member

@joshmoore joshmoore Feb 21, 2020

Choose a reason for hiding this comment

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

Ah interesting, so: see if someone set a value explicitly for iviewer, then check the server default, then use a client fallback?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently we don't have the config available from the server.
When that is available, we could teach iviewer to use that as a default value, but if it is set in iviewer itself then use that. That could allow iviewer to be more restrictive than the server (but not less restrictive since the server would enforce it's own limit).

let size_c = this.image_config.image_info.channels.length;
let stack_size = dims.max_x * dims.max_y * dims.max_z * bytes_per_pixel * size_c;
let proj_limit = this.context.max_projection_bytes;

return (handle !== null && forwards || tiled || stack_size > proj_limit);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/index-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
window.INITIAL_REQUEST_PARAMS = {
'VERSION': "DEV_SERVER",
'WEB_API_BASE': 'api/v0/',
'ROI_PAGE_SIZE': 500,
'IMAGES': "79833", // "4420" // "73537",
'ROI_PAGE_SIZE': '500',
'MAX_PROJECTION_BYTES': "268435456", // 1024 * 1024 * 256
'IMAGES': "1252", // "4420" // "73537",
// 'DATASET': "1",
//'WELL': "1"
};
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export const REQUEST_PARAMS = {
WELL_ID: 'WELL',
ZOOM: 'ZM',
ROI_PAGE_SIZE: 'ROI_PAGE_SIZE',
MAX_PROJECTION_BYTES: 'MAX_PROJECTION_BYTES',
}

/**
Expand Down