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 AnatomicalOrientation class #4804

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

Conversation

blowekamp
Copy link
Member

This PR is a WIP, and more details will be added here when ready for discussion and review.

See #4788 for this issue and discussion of these changes.

@github-actions github-actions bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots area:Python wrapping Python bindings for a class type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module area:IO Issues affecting the IO module labels Aug 14, 2024
Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

Looks good so far!

@gdevenyi

This comment was marked as off-topic.

@issakomi

This comment was marked as off-topic.

@gdevenyi

This comment was marked as off-topic.

@blowekamp
Copy link
Member Author

Please move this conversation about MINC to #147 or another place on topic.

@blowekamp
Copy link
Member Author

@dzenanz Almost there. There is currently both the ToEnum, and FromEnum. The class "AnatomicalOrientation" can be seen to hold the representation of the orientation, and provide conversion with the Enum's, direction matrix, and perhaps the preferred handling it as 3 components.

There is still the ToEnum string representation left over from the original DICOMOrientation class. That is AnatomicalOreination("LPS") construction and AnatomicalOrientation(OE::LPS).ToString() == "LPS". Anatomicalorientation::operator<< produce something like "left-to-right, anterior-to-posterior, inferior-to-superior" now, which is unambiguous. Perhaps the string character tripplets should just be removed? However the string representation is convent with a Python interface.

@dzenanz
Copy link
Member

dzenanz commented Aug 16, 2024

AnatomicalOreination("LPS") construction and AnatomicalOrientation(OE::LPS).ToString() == "LPS"

I would like to have this. This convenience did not exist within ITK proper before, so there is no need for some sort of backwards compatibility. I wonder whether we should have a method to convert "To" string from a "From" string and vice versa. E.g. if an application has "RAI" string as a "From" code, it can call something like AnatomicalOrientation::ConvertToFrom("RAI") and get "LPS". Such method would be symmetric, as the same operation would be needed to go from "From" to "To", and from "To" to "From" convention.

@blowekamp
Copy link
Member Author

So your suggestion is to keep the ambiguous "ToEnum" character representation, and just add a method to convert To/From character representations?

The concern here is really when AnatomicalOrientation("RIA") would be used, it is not clear if the string is being interpreted as a ToEnum or a FromEnum.

@dzenanz
Copy link
Member

dzenanz commented Aug 16, 2024

If you want, you can remove the string constructor. Is there another similarly convenient way to initialize it? Something like:

auto identityAO = AnatomicalOrientation::ToEnum("LPS");
AnatomicalOrientation ao(identityAO);

@dzenanz
Copy link
Member

dzenanz commented Aug 16, 2024

More generally,:

std::string toCode = "LPS";
auto aoEnum = AnatomicalOrientation::ToEnum(toCode);
AnatomicalOrientation ao(aoEnum);

@dzenanz
Copy link
Member

dzenanz commented Aug 21, 2024

What is the status of this PR? I would like it to be finished/merged before it becomes stale, as PR revival usually involves extra effort.

@github-actions github-actions bot added the area:Filtering Issues affecting the Filtering module label Sep 3, 2024
@blowekamp
Copy link
Member Author

@dzenanz Shall we have the SpatialOrientation filter changes be in another PR?

@dzenanz
Copy link
Member

dzenanz commented Sep 3, 2024

I am fine with that. And that might even be better, to not hold up this PR.

@github-actions github-actions bot removed the area:Filtering Issues affecting the Filtering module label Sep 3, 2024
@blowekamp
Copy link
Member Author

blowekamp commented Sep 4, 2024

When Legacy Remove is enabled deprecated warnings are generated causing one of the ITK Linux builds to failed. What is the expected behavior here?

Addendum: Added ITK_LEGACY_SILENT support.

@blowekamp
Copy link
Member Author

Current warning is due to testing of the deprecated methods:

2024-09-05T14:28:44.5388532Z /home/vsts/work/1/s/Modules/Core/Common/test/itkAnatomicalOrientationGTest.cxx:244:73: warning: 'itk::AnatomicalOrientation::AnatomicalOrientation(itk::AnatomicalOrientation::LegacyOrientationType)' is deprecated: Use the AnatomicalOrientation::FromEnum type instead. [-Wdeprecated-declarations]
2024-09-05T14:28:44.5389330Z   244 |   itk::AnatomicalOrientation itk_rai(SOE::ITK_COORDINATE_ORIENTATION_RAI);
2024-09-05T14:28:44.5389692Z       |                                                                         ^
2024-09-05T14:28:44.5390384Z In file included from /home/vsts/work/1/s/Modules/Core/Common/test/itkAnatomicalOrientationGTest.cxx:22:
2024-09-05T14:28:44.5390862Z /home/vsts/work/1/s/Modules/Core/Common/include/itkAnatomicalOrientation.h:424:3: note: declared here
2024-09-05T14:28:44.5391276Z   424 |   AnatomicalOrientation(LegacyOrientationType legacyOrientation);

Anyone know other locations in ITK which test deprecated methods with out warnings?

@dzenanz
Copy link
Member

dzenanz commented Sep 6, 2024

This might be the answer you are looking for:

#ifndef ITK_LEGACY_REMOVE
# define ITK_LEGACY_TEST // so deprecation warnings are not triggered by this test
#endif

@dzenanz
Copy link
Member

dzenanz commented Sep 6, 2024

Taking a look at the definition in itkMacro.h, it might not.

A uniform class for multiple descriptions of patient specifc
orientations of 3D images.
Prefer describing orientation in IO classis with unambiguous
CoordinateEnum triple.
Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

This is primarily rebase and squash? With removal of #ifdef ITK_AMBIGUOUS_TO_COORDINATE_ENUMS?

@blowekamp
Copy link
Member Author

This is primarily rebase and squash? With removal of #ifdef ITK_AMBIGUOUS_TO_COORDINATE_ENUMS?

Yes

@dzenanz
Copy link
Member

dzenanz commented Sep 9, 2024

Mark as "ready for review"?

@blowekamp blowekamp marked this pull request as ready for review September 9, 2024 17:18
@blowekamp
Copy link
Member Author

The Documentation still needs work.

Copy link
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

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

Very nice!!

Inline comment regarding method naming.

Wish list, could come later: *Long* methods to work with the names as used in PrintSelf.

}

/** \brief Return the closest orientation for a direction cosine matrix. */
static ToEnum
Copy link
Member Author

Choose a reason for hiding this comment

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

These following methods have asymmetry with regards to the currently names "ToEnum" and "FromEnum".

Perhaps the following would be consistent with the other "CreateFrom..Enum" methods:

static AnatomicalOrientation CreateFromDirectionCosines( const DirectionType &)

@blowekamp
Copy link
Member Author

Wish list, could come later: *Long* methods to work with the names as used in PrintSelf.

The class has an "operator<<" so it work sells as a ivar for ITK classes derived from LightObject with a PrintSelf methods. Could you please explain this further or be more specific.

Move asymmetric conversion utility methods to protected functions.
Add missing NegativeEnum methods for symmetry.
@thewtex
Copy link
Member

thewtex commented Sep 11, 2024

The class has an "operator<<" so it work sells as a ivar for ITK classes derived from LightObject with a PrintSelf methods.

Yes, that is nice.

Could you please explain this further or be more specific.

I was thinking:

  static const std::map<PositiveEnum, std::string> &
  GetCodeToLongString();
// returns "left-to-right", for example

  static const std::map<std::string, PositiveEnum> &
  GetLongStringToCode()
// has "left-to-right", etc. keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Core Issues affecting the Core module area:IO Issues affecting the IO module area:Python wrapping Python bindings for a class 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.

7 participants