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

BUG: Fix incorrect reading of MINC2 files, convert RAS coordinates to LPS #4864

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

gdevenyi
Copy link
Contributor

@gdevenyi gdevenyi commented Sep 27, 2024

Replaces #147

PR Checklist

  • No API changes were made (or the changes have been approved)
  • No major design changes were made (or the changes have been approved)
  • Added test (or behavior not changed)
  • Updated API documentation (or API not changed)
  • Added license to new files (if any)
  • Added Python wrapping to new files (if any) as described in ITK Software Guide Section 9.5
  • Added ITK examples for all new major features (if any)

Refer to the ITK Software Guide for
further development details if necessary.

@github-actions github-actions bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances area:IO Issues affecting the IO module labels Sep 27, 2024
@gdevenyi
Copy link
Contributor Author

gdevenyi commented Sep 27, 2024

TODO:

  • port TransformMINC fixes
  • add tests
    • read in MINC file, read in NIFTI file, confirm identical with internal representation
  • wrap in some kind of ITK legacy warning

@seanm
Copy link
Contributor

seanm commented Oct 8, 2024

I'd be interested to try this in our app when you think it's in shape...

@vfonov
Copy link
Contributor

vfonov commented Oct 9, 2024

I'll try to make changes....

@vfonov
Copy link
Contributor

vfonov commented Oct 18, 2024

TODO:

  • port TransformMINC fixes

  • add tests

    • read in MINC file, read in NIFTI file, confirm identical with internal representation
  • wrap in some kind of ITK legacy warning

https://github.com/vfonov/ITK/commits/MINC_IMAGE_RAS_LPS_VF/ - here is my work in progress, i am going to add tests for all the new cases...

@blowekamp
Copy link
Member

Would any of the enums enums for the AnatomicalOrientaion PR be useful here?

I am seeing a lot of LPS and RAS terms in this PR which can be little ambiguous. At lease the public interface of "RAS_to_LPS" the setter getter could be clarified and be make unambiguous.

@vfonov
Copy link
Contributor

vfonov commented Oct 21, 2024

At lease the public interface of "RAS_to_LPS" the setter getter could be clarified and be make unambiguous.

What would make it less ambiguous?

@vfonov
Copy link
Contributor

vfonov commented Oct 22, 2024

OK, How do i push my changes here from https://github.com/vfonov/ITK/tree/MINC_IMAGE_RAS_LPS ?

@jhlegarreta
Copy link
Member

Pushing to Gabriel's branch should work:

git push gdevenyi MINC_IMAGE_RAS_LPS

The above assumes that the you have created your MINC_IMAGE_RAS_LPS branch from gdevenyi's branch. If not, I believe

git remote add gdevenyi https://github.com/gdevenyi/ITK.git
git fetch gdevenyi
git checkout MINC_IMAGE_RAS_LPS
git branch -u gdevenyi/MINC_IMAGE_RAS_LPS
git push gdevenyi MINC_IMAGE_RAS_LPS

should have the desired effect. If you run into trouble, you can start a fresh branch (assuming you rename your local MINC_IMAGE_RAS_LPS to something else to avoid issues) and cherry-pick your commit:

git remote add gdevenyi https://github.com/gdevenyi/ITK.git
git fetch gdevenyi
git checkout -b gdevenyi MINC_IMAGE_RAS_LPS
git cherry-pick 7688f522b685eb4ace0b9753f0bbf145fd6389bb
git push gdevenyi MINC_IMAGE_RAS_LPS

@vfonov
Copy link
Contributor

vfonov commented Oct 22, 2024

git push gdevenyi MINC_IMAGE_RAS_LPS

ERROR: Permission to gdevenyi/ITK.git denied to vfonov.

@jhlegarreta
Copy link
Member

ERROR: Permission to gdevenyi/ITK.git denied to vfonov.

@gdevenyi should be able to grant permissions to push to his ITK fork on GitHub, which should fix the issue.

@gdevenyi
Copy link
Contributor Author

I have invited @vfonov

@github-actions github-actions bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct labels Oct 22, 2024
@vfonov
Copy link
Contributor

vfonov commented Oct 23, 2024

So itkSPSAOptimizerTest fails on Windows, do we need to do anything about that?

@blowekamp
Copy link
Member

This newly merged class should provide some documentation to better describe the coordinate changes in an unambiguous fashion: https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkAnatomicalOrientation.h

@vfonov
Copy link
Contributor

vfonov commented Oct 23, 2024

so, where does this new class apply in the proposed change?

@blowekamp
Copy link
Member

so, where does this new class apply in the proposed change?

Please document what you mean by RAS in the unambiguous terminology described in that class.

@vfonov
Copy link
Contributor

vfonov commented Oct 23, 2024

so, where does this new class apply in the proposed change?

Please document what you mean by RAS in the unambiguous terminology described in that class.

So, it's a documentation question - i.e I should updated documentation of the MINC reader Module?

@vfonov
Copy link
Contributor

vfonov commented Oct 23, 2024

@gdevenyi - can you make changes requested by @blowekamp ? I do not understand what's required here.

Copy link
Member

@jhlegarreta jhlegarreta 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 doing this @gdevenyi. An in-line style comment.

Modules/IO/MINC/include/itkMINCImageIO.h Outdated Show resolved Hide resolved
Modules/IO/MINC/include/itkMINCImageIO.h Outdated Show resolved Hide resolved
Modules/IO/MINC/include/itkMINCImageIO.h Outdated Show resolved Hide resolved
@gdevenyi gdevenyi marked this pull request as ready for review December 2, 2024 19:39
@gdevenyi
Copy link
Contributor Author

gdevenyi commented Dec 2, 2024

@blowekamp I have enhanced and rewritten the various comments and notes to better match the OrientFilter's language.

@blowekamp blowekamp self-requested a review December 2, 2024 19:45
@blowekamp
Copy link
Member

@blowekamp I have enhanced and rewritten the various comments and notes to better match the OrientFilter's language.

Great. Thank you for the clarity.

@gdevenyi
Copy link
Contributor Author

gdevenyi commented Dec 2, 2024

Sorry, @vfonov whatever I did during the rebasing has lost you as author. Not sure how to fix that...

@jhlegarreta
Copy link
Member

Commit messages do not comply with the ITK standards:
https://github.com/InsightSoftwareConsortium/ITK/pull/4864/checks?check_run_id=33807924553

Also, can this commit 9ecb71c be squashed and (its commit message removed) into 5a46692, please?

@gdevenyi
Copy link
Contributor Author

gdevenyi commented Dec 4, 2024

Commit messages do not comply with the ITK standards: https://github.com/InsightSoftwareConsortium/ITK/pull/4864/checks?check_run_id=33807924553

I cannot satisfy both the request of @blowekamp for sufficent detail regarding this change and your request for single-line commit messages, as I will just violate the line length limit instead. What do you suggest?

Also, can this commit 9ecb71c be squashed and (its commit message removed) into 5a46692, please?

Done.

@jhlegarreta
Copy link
Member

jhlegarreta commented Dec 4, 2024

I cannot satisfy both the request of @blowekamp for sufficent detail regarding this change and your request for single-line commit messages, as I will just violate the line length limit instead. What do you suggest?

Yes, you can. Commit message subjects should be under 72 chars (although KWstyle seems to be more permissive in practice), and should briefly describe the change or proposed fix. The immediate next line should be empty, and the rationale for the change, bug and proposed fix should be in the commit message body:
https://docs.itk.org/en/stable/contributing/index.html#commit-messages
and
https://cbea.ms/git-commit/

Although many people disregard having a proper commit message body, it allows to explain the rationale of a change, the underlying issue, if any, and the proposed fix (including why other possibilities, if any, were discarded), and hence, it is essential to review a PR, and when inspecting history.

Thanks Gabriel.

@thewtex thewtex requested a review from jhlegarreta December 9, 2024 18:30
Copy link
Member

@jhlegarreta jhlegarreta left a comment

Choose a reason for hiding this comment

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

Left some style-related comments. There is a conflict that needs to be resolved since the code base has undergone some extensive style-related changes in the meantime.

While at it, stick to the commit message conventions: use sentence case (capitalize first letter), finish commit message BODY explanation with a period.

Modules/IO/MINC/src/itkMINCImageIO.cxx Outdated Show resolved Hide resolved
Modules/IO/MINC/src/itkMINCImageIO.cxx Outdated Show resolved Hide resolved
Modules/IO/MINC/src/itkMINCImageIO.cxx Show resolved Hide resolved
Modules/IO/MINC/src/itkMINCImageIO.cxx Show resolved Hide resolved
Modules/IO/MINC/src/itkMINCImageIO.cxx Outdated Show resolved Hide resolved
Modules/IO/TransformMINC/src/itkMINCTransformIO.cxx Outdated Show resolved Hide resolved
Modules/IO/TransformMINC/src/itkMINCTransformIO.cxx Outdated Show resolved Hide resolved
Modules/IO/TransformMINC/src/itkMINCTransformIO.cxx Outdated Show resolved Hide resolved
Modules/IO/TransformMINC/src/itkMINCTransformIO.cxx Outdated Show resolved Hide resolved
Modules/IO/TransformMINC/src/itkMINCTransformIO.cxx Outdated Show resolved Hide resolved
@blowekamp
Copy link
Member

@vfonov @gdevenyi It is my understanding that this PR has conflicts due to all the recent activity. Thank you for the contribution and maintaining MINC for ITK.

Can I help updating the PR, and trying to address some of these style issues?

Also, I think we should do this change in 2 steps. This first is adding the LPS as an option preserving compatibility. And is a second PR, change the default? Maybe introduce an environment variable for this setting too?

Let me know if I can help make changes to get this PR through.

@gdevenyi
Copy link
Contributor Author

Can I help updating the PR, and trying to address some of these style issues?

Yes please. I would very much appreciate the help.

This contribution to ITK has been 6 years in the making with the original technical solution remaining unchanged. I'm a generalist and ITK is a C++-expert level codebase, I'm a monkey at a typewriter here trying to keep up with the high churn and level of abstraction that this codebase demands. The complexity along with the serial reviews have made it very difficult.

I would very much appreciate any help you can offer.

@vfonov
Copy link
Contributor

vfonov commented Dec 16, 2024

So, I don't understand - what needs to be done right now. Do we neeed:

  1. rebase to the current ITK master?
  2. address various style comments by @jhlegarreta regarding "ITK SWG"
  3. fix the "This branch has conflicts that must be resolved" message?
  4. fix just the "bool mRAStoLPS" variable (that's what shows up in "requested" changes .

@blowekamp
Copy link
Member

So, I don't understand - what needs to be done right now. Do we neeed:

  1. rebase to the current ITK master?
  2. address various style comments by @jhlegarreta regarding "ITK SWG"
  3. fix the "This branch has conflicts that must be resolved" message?
  4. fix just the "bool mRAStoLPS" variable (that's what shows up in "requested" changes .

Yes, I thin that is a summary of what needs to be done. I am also going to separate the change in behavior for another PR, to make review easier. I am going to start working on update the PR branch.

@seanm
Copy link
Contributor

seanm commented Dec 17, 2024

Glad to see this work. Again, when it's in better shape, I'll give it a try in our app, which has various tests of its own that might exercise some of this.

gdevenyi and others added 4 commits December 18, 2024 09:08
convert MINC PositiveCoordinateOrientation RAS coordinates to ITK PositiveCoordinateOrientation LPS coordinates
during reading and writing
convert MINC PositiveCoordinateOrientation RAS coordinate system to ITK PositiveCoordinateOrientation LPS
@blowekamp
Copy link
Member

I have updated the PR. For now I removed the CMake option, and have kept the behavior the same as it was. This can be changed in another PR.

Is it useful to still write with the the corrected coordinates? I am thinking that the correct cordinates should always be written no, and the flag is used then loading.

The "RAStoLPS" flag was not immediately clear to be what it did. Perhaps something line "ApplyCoordiateConversionForITK" would be more descriptive?

Also is there meta-data written in the transform to indicate that coordinates have been corrected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:IO Issues affecting the IO module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants