|
a |
|
b/src/reorientImage2.cxx |
|
|
1 |
|
|
|
2 |
|
|
|
3 |
#include <nanobind/nanobind.h> |
|
|
4 |
#include <nanobind/stl/vector.h> |
|
|
5 |
#include <nanobind/stl/string.h> |
|
|
6 |
#include <nanobind/stl/tuple.h> |
|
|
7 |
#include <nanobind/ndarray.h> |
|
|
8 |
|
|
|
9 |
#include "itkImage.h" |
|
|
10 |
#include "itkOrientImageFilter.h" |
|
|
11 |
|
|
|
12 |
#include "antsImage.h" |
|
|
13 |
|
|
|
14 |
namespace nb = nanobind; |
|
|
15 |
using namespace nb::literals; |
|
|
16 |
|
|
|
17 |
template <typename ImageType> |
|
|
18 |
AntsImage<ImageType> reorientImage2( AntsImage<ImageType> & antsImage , std::string newOrientation ) |
|
|
19 |
{ |
|
|
20 |
typename ImageType::Pointer itkImage = antsImage.ptr; |
|
|
21 |
|
|
|
22 |
typename itk::OrientImageFilter<ImageType,ImageType>::Pointer orienter = itk::OrientImageFilter<ImageType,ImageType>::New(); |
|
|
23 |
orienter->UseImageDirectionOn(); |
|
|
24 |
|
|
|
25 |
if (newOrientation == "RIP") { |
|
|
26 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RIP); |
|
|
27 |
} |
|
|
28 |
else if (newOrientation == "LIP") { |
|
|
29 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LIP); |
|
|
30 |
} |
|
|
31 |
else if (newOrientation == "RSP") { |
|
|
32 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RSP); |
|
|
33 |
} |
|
|
34 |
else if (newOrientation == "LSP") { |
|
|
35 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LSP); |
|
|
36 |
} |
|
|
37 |
else if (newOrientation == "RIA") { |
|
|
38 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RIA); |
|
|
39 |
} |
|
|
40 |
else if (newOrientation == "LIA") { |
|
|
41 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LIA); |
|
|
42 |
} |
|
|
43 |
else if (newOrientation == "RSA") { |
|
|
44 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RSA); |
|
|
45 |
} |
|
|
46 |
else if (newOrientation == "LSA") { |
|
|
47 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LSA); |
|
|
48 |
} |
|
|
49 |
else if (newOrientation == "IRP") { |
|
|
50 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_IRP); |
|
|
51 |
} |
|
|
52 |
else if (newOrientation == "ILP") { |
|
|
53 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_ILP); |
|
|
54 |
} |
|
|
55 |
else if (newOrientation == "SRP") { |
|
|
56 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_SRP); |
|
|
57 |
} |
|
|
58 |
else if (newOrientation == "SLP") { |
|
|
59 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_SLP); |
|
|
60 |
} |
|
|
61 |
else if (newOrientation == "IRA") { |
|
|
62 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_IRA); |
|
|
63 |
} |
|
|
64 |
else if (newOrientation == "ILA") { |
|
|
65 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_ILA); |
|
|
66 |
} |
|
|
67 |
else if (newOrientation == "SRA") { |
|
|
68 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_SRA); |
|
|
69 |
} |
|
|
70 |
else if (newOrientation == "SLA") { |
|
|
71 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_SLA); |
|
|
72 |
} |
|
|
73 |
else if (newOrientation == "RPI") { |
|
|
74 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RPI); |
|
|
75 |
} |
|
|
76 |
else if (newOrientation == "LPI") { |
|
|
77 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LPI); |
|
|
78 |
} |
|
|
79 |
else if (newOrientation == "RAI") { |
|
|
80 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAI); |
|
|
81 |
} |
|
|
82 |
else if (newOrientation == "LAI") { |
|
|
83 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LAI); |
|
|
84 |
} |
|
|
85 |
else if (newOrientation == "RPS") { |
|
|
86 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RPS); |
|
|
87 |
} |
|
|
88 |
else if (newOrientation == "LPS") { |
|
|
89 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LPS); |
|
|
90 |
} |
|
|
91 |
else if (newOrientation == "RAS") { |
|
|
92 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAS); |
|
|
93 |
} |
|
|
94 |
else if (newOrientation == "LAS") { |
|
|
95 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LAS); |
|
|
96 |
} |
|
|
97 |
else if (newOrientation == "PRI") { |
|
|
98 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_PRI); |
|
|
99 |
} |
|
|
100 |
else if (newOrientation == "PLI") { |
|
|
101 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_PLI); |
|
|
102 |
} |
|
|
103 |
else if (newOrientation == "ARI") { |
|
|
104 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_ARI); |
|
|
105 |
} |
|
|
106 |
else if (newOrientation == "ALI") { |
|
|
107 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_ALI); |
|
|
108 |
} |
|
|
109 |
else if (newOrientation == "PRS") { |
|
|
110 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_PRS); |
|
|
111 |
} |
|
|
112 |
else if (newOrientation == "PLS") { |
|
|
113 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_PLS); |
|
|
114 |
} |
|
|
115 |
else if (newOrientation == "ARS") { |
|
|
116 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_ARS); |
|
|
117 |
} |
|
|
118 |
else if (newOrientation == "ALS") { |
|
|
119 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_ALS); |
|
|
120 |
} |
|
|
121 |
else if (newOrientation == "IPR") { |
|
|
122 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_IPR); |
|
|
123 |
} |
|
|
124 |
else if (newOrientation == "SPR") { |
|
|
125 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_SPR); |
|
|
126 |
} |
|
|
127 |
else if (newOrientation == "IAR") { |
|
|
128 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_IAR); |
|
|
129 |
} |
|
|
130 |
else if (newOrientation == "SAR") { |
|
|
131 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_SAR); |
|
|
132 |
} |
|
|
133 |
else if (newOrientation == "IPL") { |
|
|
134 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_IPL); |
|
|
135 |
} |
|
|
136 |
else if (newOrientation == "SPL") { |
|
|
137 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_SPL); |
|
|
138 |
} |
|
|
139 |
else if (newOrientation == "IAL") { |
|
|
140 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_IAL); |
|
|
141 |
} |
|
|
142 |
else if (newOrientation == "SAL") { |
|
|
143 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_SAL); |
|
|
144 |
} |
|
|
145 |
else if (newOrientation == "PIR") { |
|
|
146 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_PIR); |
|
|
147 |
} |
|
|
148 |
else if (newOrientation == "PSR") { |
|
|
149 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_PSR); |
|
|
150 |
} |
|
|
151 |
else if (newOrientation == "AIR") { |
|
|
152 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_AIR); |
|
|
153 |
} |
|
|
154 |
else if (newOrientation == "ASR") { |
|
|
155 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_ASR); |
|
|
156 |
} |
|
|
157 |
else if (newOrientation == "PIL") { |
|
|
158 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_PIL); |
|
|
159 |
} |
|
|
160 |
else if (newOrientation == "PSL") { |
|
|
161 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_PSL); |
|
|
162 |
} |
|
|
163 |
else if (newOrientation == "AIL") { |
|
|
164 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_AIL); |
|
|
165 |
} |
|
|
166 |
else if (newOrientation == "ASL") { |
|
|
167 |
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_ASL); |
|
|
168 |
} |
|
|
169 |
orienter->SetInput( itkImage ); |
|
|
170 |
orienter->Update(); |
|
|
171 |
AntsImage<ImageType> myImage = { orienter->GetOutput() }; |
|
|
172 |
return myImage; |
|
|
173 |
} |
|
|
174 |
|
|
|
175 |
void local_reorientImage2(nb::module_ &m) |
|
|
176 |
{ |
|
|
177 |
m.def("reorientImage2", &reorientImage2<itk::Image<float,3>>); |
|
|
178 |
} |