Repository: InsightSoftwareConsortium/ITK (language: python)

Issue:
Use AnatomicalOrientation in  OrientImageFilter
Preserve compatibility with SpatialOrientation enums with implicit converstion. Additionally both the PositiveEnum and NegativeEnum are supported.

<!-- The text within this markup is a comment, and is intended to provide
guidelines to open a Pull Request for the ITK repository. This text will not
be part of the Pull Request. -->


<!-- See the CONTRIBUTING (CONTRIBUTING.md) guide. Specifically:

Start ITK commit messages with a standard prefix (and a space):

 * BUG: fix for runtime crash or incorrect result
 * COMP: compiler error or warning fix
 * DOC: documentation change
 * ENH: new functionality
 * PERF: performance improvement
 * STYLE: no logic impact (indentation, comments)
 * WIP: Work In Progress not ready for merge

Provide a short, meaningful message that describes the change you made.

When the PR is based on a single commit, the commit message is usually left as
the PR message.

A reference to a related issue or pull request (https://help.github.com/articles/basic-writing-and-formatting-syntax/#referencing-issues-and-pull-requests)
in your repository. You can automatically
close a related issues using keywords (https://help.github.com/articles/closing-issues-using-keywords/)

@mentions (https://help.github.com/articles/basic-writing-and-formatting-syntax/#mentioning-people-and-teams)
of the person or team responsible for reviewing proposed changes. -->

## PR Checklist
- [ ] No [API changes](https://github.com/InsightSoftwareConsortium/ITK/blob/master/CONTRIBUTING.md#breaking-changes) were made (or the changes have been approved)
- [ ] No [major design changes](https://github.com/InsightSoftwareConsortium/ITK/blob/master/CONTRIBUTING.md#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](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Utilities/KWStyle/ITKHeader.h) to new files (if any)
- [ ] Added Python wrapping to new files (if any) as described in [ITK Software Guide](https://itk.org/ItkSoftwareGuide.pdf) Section 9.5
- [ ] Added [ITK examples](https://github.com/InsightSoftwareConsortium/ITKSphinxExamples) for all new major features (if any)

Refer to the [ITK Software Guide](https://itk.org/ItkSoftwareGuide.pdf) for
further development details if necessary.

<!-- **Thanks for contributing to ITK!** -->



Discussion / hints:
The current failing test in related to a new tests added based on tests on the DICOMOrientedImage filter that tests streaming. This filter has a number of pipelining issues that also need to be addressed. I suppose that should be done in another PR.

Additionally the default behavior is to ignore the input image's direction cosine matrix, which is not the expected behavior of an ITK filter. Not sure what the "compatible" way to update this behavior is. The proposed approach of just a new filter with new/correct behavior did not seem to be liked by the community.


> Is the rest of the class design in accordance with [migration guide](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Documentation/docs/migration_guides/itk_5_migration_guide.md#strongly-typed-enumerations)?

I am not certain what you are asking about. The OrientImageFilter does not have enums itself.
I meant the anatomical orientation enum classes, are they in accordance with ITK5 style? I totally forgot about that before, and your wrapping commit reminded me of that.
> I meant the anatomical orientation enum classes, are they in accordance with ITK5 style? I totally forgot about that before, and your wrapping commit reminded me of that.

The AnatomicalOrientation class contains the enum and are not in the ITK namespace. This was done because scoping in the class space: itk::AnatomicalOrientation::PositiveEnum seemed more sensible than a single long Enum name e.g. itk::AnatomicalOrientationPositiveEnum.

However, the wrapping does not seems to be working for these enums. @thewtex  Can you look at the wrapping of these enums? Currently, I can't build ITK wrapping out of the box due to clang-xml binaries not working due to external library dependencies ( I create an issue some where for this).

> Additionally the default behavior is to ignore the input image's direction cosine matrix, which is not the expected behavior of an ITK filter. Not sure what the "compatible" way to update this behavior is. The proposed approach of just a new filter with new/correct behavior did not seem to be liked by the community.

I am not sure where there was discussion or opposition to this approach, but providing a new filter with the correct behaviors sounds right to me.

> However, the wrapping does not seems to be working for these enums. @thewtex Can you look at the wrapping of these enums? Currently, I can't build ITK wrapping out of the box due to clang-xml binaries not working due to external library dependencies ( I create an issue some where for this).

From [the build error](https://open.cdash.org/viewBuildError.php?buildid=9991223):

> Wrapping/castxml_inputs/itkAnatomicalOrientation.cxx:17:10: fatal error: 'itkPositiveEnum.h' file not found

I suspect `itk_wrap_include("itkPositiveEnum.h")`, etc. is needed.



Fix patch:
diff --git a/pyproject.toml b/pyproject.toml
index eeef43a62f1..3680de1eb4a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -106,6 +106,12 @@ cmd = "ctest -j3 --test-dir build-python"
 description = "Test ITK Python"
 depends-on = ["build-python"]
 
+[tool.pixi.feature.python.tasks.python-exe]
+cmd = '''cp ./build-python/Wrapping/Generators/Python/WrapITK.pth $(python -c "import site; print(next(p for p in site.getsitepackages() if \'site-packages\' in p))") &&
+  python'''
+description = "Run a Python executable with the development ITK Python package"
+depends-on = ["build-python"]
+
 [tool.pixi.feature.python.tasks.configure-debug-python]
 cmd = '''cmake
   -Bbuild-debug-python
@@ -115,12 +121,12 @@ cmd = '''cmake
   -DCMAKE_BUILD_TYPE:STRING=Debug
   -DBUILD_TESTING:BOOL=ON'''
 description = "Configure ITK Python - Debug"
-outputs = ["build-debug/CMakeFiles/"]
+outputs = ["build-debug-python/CMakeFiles/"]
 
 [tool.pixi.feature.python.tasks.build-debug-python]
 cmd = "cmake --build build-debug-python"
 description = "Build ITK Python - Debug"
-outputs = ["build-debug/lib/**"]
+outputs = ["build-debug-python/lib/**"]
 depends-on = ["configure-debug-python"]
 
 [tool.pixi.feature.python.tasks.test-debug-python]
@@ -128,6 +134,12 @@ cmd = "ctest -j3 --test-dir build-debug-python"
 description = "Test ITK Python - Debug"
 depends-on = ["build-debug-python"]
 
+[tool.pixi.feature.python.tasks.python-exe-debug]
+cmd = '''cp ./build-python/Wrapping/Generators/Python/WrapITK.pth $(python -c "import site; print(next(p for p in site.getsitepackages() if \'site-packages\' in p))") &&
+  python'''
+description = "Run a Python executable with the development ITK Python Debug build package"
+depends-on = ["build-debug-python"]
+
 [tool.pixi.environments]
 cxx = ["cxx"]
 python = ["python", "cxx"]


Test patch:
diff --git a/Documentation/docs/contributing/build_test_itk.md b/Documentation/docs/contributing/build_test_itk.md
index 712782007ce..704799c84ff 100644
--- a/Documentation/docs/contributing/build_test_itk.md
+++ b/Documentation/docs/contributing/build_test_itk.md
@@ -59,6 +59,24 @@ cd src/ITK
 pixi run test-python
 ```
 
+To run a python interpreter with the locally built `itk` Python package:
+
+```shell
+pixi run python-exe
+```
+
+A Python script can also be passed in, e.g.
+
+```shell
+pixi run python-exe ./test.py
+```
+
+To run a python interpreter with a locally built `itk` Python package with debug symbols,
+
+```shell
+pixi run python-exe-debug
+```
+
 ### Further testing and development
 
 Additional pixi tasks to run specific steps of the `configure`, `build`, `test` development process or create builds with other [CMake build types] are listed with