cytomining / DeepProfiler

Morphological profiling using deep learning
Other
106 stars 39 forks source link

DeepProfiler produces incorrect crops if provided with images of different sizes #355

Open goncinious opened 8 months ago

goncinious commented 8 months ago

In profiling mode, if provided with images of different sizes than the specified in the config (in config["dataset"]["images"][{"width", "height"}]), DP will silently generate incorrect crops.

I think the issue comes from get_cropping_regions(), where the config-specified image size is used to normalise the bounding indices. Note that there's no exception raised when the input image mismatches the specified shape.

I also think the docs are slightly confusing, as it's mentioned:

The size of images is, in principle, flexible and DeepProfiler can work with different resolutions and image dimensions.

Please correct me if I'm wrong, but I think this is the only reason making DeepProfiler incompatible with images of variable size (for profiling) and could easily be solved by reading the image dimensions dynamically. I opened a PR to implement just that - https://github.com/cytomining/DeepProfiler/pull/354.

It'd be great if you could also update the docs to clarify how DeepProfiler handles images of variable size in training vs. profile mode.

Arkkienkeli commented 8 months ago

Hi @goncinious, thank you for the interest in our work and the PR!

The documentation part you mention:

The size of images is, in principle, flexible and DeepProfiler can work with different resolutions and image dimensions.

Meant that you can process different images, but I agree, it does not mention that a single pipeline should have fixed image size. We indeed need to clarify that.

I will return to you regarding the PR and fix documentation.