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 the get_transform analog to set_transform #264

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

pattonw
Copy link

@pattonw pattonw commented Dec 10, 2024

given a set of scale and translation transforms, defined on both the group and individual individual images, each image will have a final scale and translation. These can now be conveniently retrieved with a little helper function that fetches all appropriate translations and applies them consecutively.

small test added to cover changes.

This reverts the formatting changes that were accidentally included with commit  0c21a73.
@ziw-liu ziw-liu added enhancement New feature or request NGFF OME-NGFF (OME-Zarr format) labels Dec 10, 2024
Copy link
Collaborator

@ziw-liu ziw-liu left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! I've left my comments inline.

iohub/ngff/nodes.py Outdated Show resolved Hide resolved
iohub/ngff/nodes.py Outdated Show resolved Hide resolved
iohub/ngff/nodes.py Outdated Show resolved Hide resolved
@ziw-liu ziw-liu added this to the 0.2.0 milestone Dec 10, 2024
@ziw-liu
Copy link
Collaborator

ziw-liu commented Dec 10, 2024

Re: CI failure: please refer to the contributing guide.

@pattonw
Copy link
Author

pattonw commented Dec 10, 2024

passed the precommit checks 👍

iohub/ngff/nodes.py Show resolved Hide resolved
iohub/ngff/nodes.py Outdated Show resolved Hide resolved
iohub/ngff/nodes.py Show resolved Hide resolved
tests/ngff/test_ngff.py Show resolved Hide resolved
Copy link
Member

@JoOkuma JoOkuma left a comment

Choose a reason for hiding this comment

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

@ziw-liu, If get_effective_translation[or scale] returns a single transformation object would it be more friendly to return a tuple of floats or an array-like object?

@pattonw, I agree with the other comments from @ziw-liu

@ziw-liu
Copy link
Collaborator

ziw-liu commented Dec 11, 2024

If get_effective_translation[or scale] returns a single transformation object would it be more friendly to return a tuple of floats or an array-like object?

If the dataset does not have all 5 axes, what should the length of the returned sequence be? I'm guessing that @pattonw's use cases are mostly 3D instead of 5D?

Edit: I remembered it wrong

@pattonw
Copy link
Author

pattonw commented Dec 11, 2024

If get_effective_translation[or scale] returns a single transformation object would it be more friendly to return a tuple of floats or an array-like object?

If the dataset does not have all 5 axes, what should the length of the returned sequence be? I'm guessing that @pattonw's use cases are mostly 3D instead of 5D?

Isn't it as simple as returning the .scale or .translation property of the TransformationMeta? Isn't the length always equal to the number of dimensions in the array?

@ziw-liu
Copy link
Collaborator

ziw-liu commented Dec 11, 2024

Isn't it as simple as returning the .scale or .translation property of the TransformationMeta? Isn't the length always equal to the number of dimensions in the array?

You're right! I mistakenly thought that Position.scale behaves differently (I was thinking of this one).

)
scale = [s1 * s2 for s1, s2 in zip(scale, trans.scale)]
return scale
return self.get_effective_scale("*").scale
Copy link
Collaborator

Choose a reason for hiding this comment

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

This used to be the scale of the highest resolution, so it should be the first array instead of "*".

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is why tests are failing for 6fc5ad6.

@pattonw
Copy link
Author

pattonw commented Dec 11, 2024

Separated into 2 unit tests, return plain list of floats instead of TransformationMeta classes, and removed the error I introduced in scale property to fetch the effective scale of the first dataset instead of just the root.

arr_name=short_alpha_numeric,
)
def test_get_effective_scale_image(transforms, ch_shape_dtype, arr_name):
"""Test `iohub.ngff.Position.set_transform()`"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"""Test `iohub.ngff.Position.set_transform()`"""
"""Test `iohub.ngff.Position.get_effective_scale()`"""

arr_name=short_alpha_numeric,
)
def test_get_effective_translation_image(transforms, ch_shape_dtype, arr_name):
"""Test `iohub.ngff.Position.set_transform()`"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"""Test `iohub.ngff.Position.set_transform()`"""
"""Test `iohub.ngff.Position.get_effective_translation()`"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request NGFF OME-NGFF (OME-Zarr format)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants