diff --git a/README.rst b/README.rst index c780064c8..190d74fb8 100644 --- a/README.rst +++ b/README.rst @@ -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 `_. +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 ============== diff --git a/plugin/omero_iviewer/iviewer_settings.py b/plugin/omero_iviewer/iviewer_settings.py index 1edbbd84b..e5e28bb87 100644 --- a/plugin/omero_iviewer/iviewer_settings.py +++ b/plugin/omero_iviewer/iviewer_settings.py @@ -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")], + "omero.web.iviewer.roi_page_size": ["ROI_PAGE_SIZE", 500, diff --git a/plugin/omero_iviewer/views.py b/plugin/omero_iviewer/views.py index 40d337d81..9b2566928 100644 --- a/plugin/omero_iviewer/views.py +++ b/plugin/omero_iviewer/views.py @@ -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, @@ -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', diff --git a/src/app/context.js b/src/app/context.js index 97b9d49b3..fb9b1b3f9 100644 --- a/src/app/context.js +++ b/src/app/context.js @@ -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); } /** diff --git a/src/controls/dimension-slider.js b/src/controls/dimension-slider.js index 11eb81c80..4512d39fc 100644 --- a/src/controls/dimension-slider.js +++ b/src/controls/dimension-slider.js @@ -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); + 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); } /** diff --git a/src/index-dev.html b/src/index-dev.html index 56b783eda..5ce904f29 100644 --- a/src/index-dev.html +++ b/src/index-dev.html @@ -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" }; diff --git a/src/utils/constants.js b/src/utils/constants.js index a7bcd46c1..a3c29cd1f 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -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', } /**