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

feat: Add support for reading model-to-image transformation information. #23

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

uermel
Copy link
Collaborator

@uermel uermel commented Dec 4, 2024

IMOD stores model-to-image transforms in an optional chunk called MINX with the below contents:

Length Type         Name     Description
------------------------------------------------------------------------------
12     float * 3    oscale   Old scale values (unused in file) 
12     float * 3    otrans   Old translations (file stores image origin values)
12     float * 3    orot     Old rotations around X, Y, Z axes (unused in file)
12     float * 3    cscale   New scale values in X, Y, Z
12     float * 3    ctrans   New translations in X, Y, Z
12     float * 3    crot     New rotations around X, Y, Z axes

See also: imod binspec

This PR adds support for parsing the MINX chunk using the model based API and stores it in a field called minx in the parsed ImodModel. Also adds a test for parsing.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@uermel uermel requested a review from alisterburt December 4, 2024 01:41
Copy link
Collaborator

@alisterburt alisterburt left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for the PR - looks great to me, let's get it in

Comment on lines +76 to +78
assert model.minx.cscale == pytest.approx((10.680000, 10.680000, 10.680000), abs=1e-6)
assert model.minx.ctrans == pytest.approx((-2228.0, 2228.0, 681.099976), abs=1e-6)
assert model.minx.crot == pytest.approx((0.0, 0.0, 0.0), abs=1e-6)
Copy link
Collaborator

Choose a reason for hiding this comment

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

ooh didn't know about pytest.approx - snazzy!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, pretty useful for any tests involving any type of computation or parsing!

@alisterburt alisterburt merged commit f761e1a into teamtomo:main Dec 4, 2024
5 checks passed
@alisterburt
Copy link
Collaborator

Assuming you want to push a release, you've got maintainer access so it should be as easy as

git checkout main
git tag -a v0.0.14 -m "v0.0.14"
git push --follow-tags upstream/main

Let me know if you run into any issues, thanks!!

@uermel
Copy link
Collaborator Author

uermel commented Dec 5, 2024

Assuming you want to push a release, you've got maintainer access so it should be as easy as

git checkout main
git tag -a v0.0.14 -m "v0.0.14"
git push --follow-tags upstream/main

Let me know if you run into any issues, thanks!!

For some reason that last command does not seem to work for me. Are you calling these commands on a fork of this repo or on this repo itself? Do you have to set this one as an additional remote?

Fails with

fatal: 'upstream/main' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

@alisterburt
Copy link
Collaborator

This repo (teamtomo/imodmodel) is set as the remote named 'upstream' - are your ssh keys set up for this GitHub account?

@uermel
Copy link
Collaborator Author

uermel commented Dec 6, 2024

Yes, all of that is set up, but I figured it out, it should be

git push --follow-tags upstream main

space instead of slash.

This auto-release setup is cool though, I shall copy it for my own packages.

@alisterburt
Copy link
Collaborator

@uermel sorry my bad - I recommend starting projects from the copier template here to auto set up all of this :-) https://pydev-guide.github.io/quickstart/

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

Successfully merging this pull request may close these issues.

None yet

2 participants