ome / omero-figure

An OMERO.web app for creating Figures from images in OMERO
http://figure.openmicroscopy.org
GNU Affero General Public License v3.0
15 stars 30 forks source link

Max projection bytes #560

Open will-moore opened 2 months ago

will-moore commented 2 months ago

Fixes #440.

--exclude

This protects users from requesting Z-projections exceeding the MAX_PROJECTION_BYTES limit of 1024 * 1024 * 256 bytes or a value configured on the server omero.pixeldata.max_projection_bytes. We always take into account the number of active channels rather than total channel count.

When a user enables Z-projection on an image, we test whether the full Z-range projection (with current channels enabled) exceeds the MAX_PROJECTION_BYTES. If so, the maximum number of Z-planes that can be projected is shown in red (tooltip includes the MAX_PROJECTION_BYTES limit). This limit will change when channels are turned on/off.

If a user exceeds the Z-projection limit using the Z-range sliders, we show a warning message instead of the Z-projected image.

Screenshot 2024-05-02 at 16 55 31

To test: (I have already created https://merge-ci.openmicroscopy.org/web/figure/file/3901 as follows):

sbesson commented 2 months ago

From a preliminary round of testing, this functionality seems to work as intended and prevents projections in the app when the selected Z-range exceeds the threshold configured server-side. One thing I noticed though is that the projection still happens when running the figure export script. I assume the script must also be updated accordingly but this raises the question of what the behavior should be when a figure has been saved with a Z-range exceeding the max projection limit threshold.

will-moore commented 1 month ago

@sbesson in 447144c I've updated the figure export script to respect the MAX_PROJECTION_BYTES limit. If that limit is exceeded then we render a black image (similar to screenshots above but without the warnings).

I think this is reasonable behaviour both for pre-existing figures saved with the Z-projection that exceeds the limit, as well as for newly created figures. In both cases the user will see that the limit has been exceeded in the browser as above before trying to run the export script.

will-moore commented 1 month ago

@sbesson Why should the sizeZ influence the ability to perform small Z-range projections? For example, if I can do Z-projection with a Z-range of 5 on an image of sizeZ: 10, why wouldn't I be allowed to do the same Z-range projection (same number of bytes) on an image with sizeZ: 100?

As I understood, the unconditional disabling of Z-projection in iviewer and webgateway viewer was due to this being simpler to implement (e.g. we don't base this on active channels but on sizeC since it's easier). I'm not sure if this is what you mean by "the current semantics of the server projection service"?

The default behaviour in OMERO.figure when you turn on Z-projection is to start with a small Z-range since this is often what users want and it is less work for the server. It would be nice to preserve this functionality when it is operating below the MAX_PROJECTED_BYTES.

will-moore commented 3 weeks ago

When combined with #563 this PR causes an error because re_path is no-longer imported.

09:32:53   File "/home/omero/workspace/OMERO-web/.venv3/lib64/python3.9/site-packages/omero_figure/urls.py", line 36, in <module>
09:32:53     re_path(r'^max_projection_range_exceeded/'
09:32:53 NameError: name 're_path' is not defined

We will try to get that PR merged first - excluding this one for now... (editing description)