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

Add support for arbitrarily ordered image axes in image content assertions #18891

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from

Conversation

kostrykin
Copy link
Contributor

@kostrykin kostrykin commented Sep 25, 2024

Image content assertions were introduced in #17581, but only had support for 2-D images with the axes of the image ordered like YX or YXC, i.e. the channel axis is the last axis of the image (if present at all). However, TIFF files can also have three and more dimensions (aka axes) and their order may vary. The axes are described in the metadata of the TIFF file.

This PR adds support for using the content assertions with higher-dimensional TIFF files and arbitrarily ordered image axes by relying on the metadata of the TIFF file. The supported axes are T time steps, Z slices, Y vertical coordinates, X horizontal coordinates, C channels, and S samples. Only the YX axes are mandatory, all other axes are optional.

This is accomplished by normalizing all images to TZYXC when they are loaded. Normalization is performed without modifying the loaded image, but using numpy functions which yield views, and is thus efficient. The S axis is treated as an alias of a C axis (it doesn't make sense to include both in a TIFF file).

In addition, the following assertions are added:

  • has_image_depth to verify the number of slices along the Z axis
  • has_image_frames to verify the number of time steps along the T axis

The optional slice and frame attributes are added to the existing content checking assertions to restrict those to specific slices, frames, or combinations thereof.

Fix #18851 cc @lldelisle

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

@lldelisle
Copy link
Contributor

This is a huge work. Thank you so much!

Copy link
Contributor

@lldelisle lldelisle left a comment

Choose a reason for hiding this comment

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

Found a typo

lib/galaxy/tool_util/verify/assertion_models.py Outdated Show resolved Hide resolved
lib/galaxy/tool_util/verify/assertion_models.py Outdated Show resolved Hide resolved
lib/galaxy/tool_util/verify/asserts/image.py Outdated Show resolved Hide resolved
lib/galaxy/tool_util/xsd/galaxy.xsd Outdated Show resolved Hide resolved
lib/galaxy/tool_util/xsd/galaxy.xsd Outdated Show resolved Hide resolved
lib/galaxy/tool_util/xsd/galaxy.xsd Outdated Show resolved Hide resolved
lib/galaxy/tool_util/verify/assertion_models.py Outdated Show resolved Hide resolved
lib/galaxy/tool_util/xsd/galaxy.xsd Outdated Show resolved Hide resolved
@kostrykin
Copy link
Contributor Author

kostrykin commented Sep 26, 2024

2d9910a: The failing Integration / Test (3.8, 2) is unrelated to this PR, I think:

test/integration/objectstore/test_swift_objectstore.py::test_tools[composite_output] <- lib/galaxy_test/driver/integration_util.py FAILED [ 97%]

@bgruening
Copy link
Member

@kostrykin the tests are failing in other PRs as well. They are unrelated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected results with assert image on tiff
3 participants