@@ -110,58 +110,63 @@ class ReorientOutputSpec(TraitedSpec):
110
110
class Reorient (SimpleInterface ):
111
111
"""Conform an image to a given orientation
112
112
113
- Flips and reorder the image data array so that the axes match the
114
- directions indicated in ``orientation``.
115
- The default ``RAS`` orientation corresponds to the first axis being ordered
116
- from left to right, the second axis from posterior to anterior, and the
117
- third axis from inferior to superior.
113
+ Flips and reorder the image data array so that the axes match the
114
+ directions indicated in ``orientation``.
115
+ The default ``RAS`` orientation corresponds to the first axis being ordered
116
+ from left to right, the second axis from posterior to anterior, and the
117
+ third axis from inferior to superior.
118
118
119
- For oblique images, the original orientation is considered to be the
120
- closest plumb orientation.
119
+ For oblique images, the original orientation is considered to be the
120
+ closest plumb orientation.
121
121
122
- No resampling is performed, and thus the output image is not de-obliqued
123
- or registered to any other image or template.
122
+ No resampling is performed, and thus the output image is not de-obliqued
123
+ or registered to any other image or template.
124
124
125
- The effective transform is calculated from the original affine matrix to
126
- the reoriented affine matrix.
125
+ The effective transform is calculated from the original affine matrix to
126
+ the reoriented affine matrix.
127
127
128
- Examples
129
- --------
128
+ Examples
129
+ --------
130
130
131
- If an image is not reoriented, the original file is not modified
131
+ If an image is not reoriented, the original file is not modified
132
132
133
- >>> import numpy as np
134
- >>> from nipype.interfaces.image import Reorient
135
- >>> reorient = Reorient(orientation='LPS')
136
- >>> reorient.inputs.in_file = 'segmentation0.nii.gz'
137
- >>> res = reorient.run()
138
- >>> res.outputs.out_file
139
- 'segmentation0.nii.gz'
133
+ .. testsetup::
140
134
141
- >>> print(np.loadtxt(res.outputs.transform))
142
- [[1. 0. 0. 0.]
143
- [0. 1. 0. 0.]
144
- [0. 0. 1. 0.]
145
- [0. 0. 0. 1.]]
135
+ >>> def print_affine(matrix):
136
+ ... print(str(matrix).replace(']', ' ').replace('[', ' '))
146
137
147
- >>> reorient.inputs.orientation = 'RAS'
148
- >>> res = reorient.run()
149
- >>> res.outputs.out_file # doctest: +ELLIPSIS
150
- '.../segmentation0_ras.nii.gz'
138
+ >>> import numpy as np
139
+ >>> from nipype.interfaces.image import Reorient
140
+ >>> reorient = Reorient(orientation='LPS')
141
+ >>> reorient.inputs.in_file = 'segmentation0.nii.gz'
142
+ >>> res = reorient.run()
143
+ >>> res.outputs.out_file
144
+ 'segmentation0.nii.gz'
151
145
152
- >>> print (np.loadtxt(res.outputs.transform))
153
- [[- 1. 0. 0. 60.]
154
- [ 0. - 1. 0. 72.]
155
- [ 0. 0. 1. 0.]
156
- [ 0. 0. 0. 1.]]
146
+ >>> print_affine (np.loadtxt(res.outputs.transform))
147
+ 1. 0. 0. 0.
148
+ 0. 1. 0. 0.
149
+ 0. 0. 1. 0.
150
+ 0. 0. 0. 1.
157
151
158
- .. testcleanup::
152
+ >>> reorient.inputs.orientation = 'RAS'
153
+ >>> res = reorient.run()
154
+ >>> res.outputs.out_file # doctest: +ELLIPSIS
155
+ '.../segmentation0_ras.nii.gz'
159
156
160
- >>> import os
161
- >>> os.unlink(res.outputs.out_file)
162
- >>> os.unlink(res.outputs.transform)
157
+ >>> print_affine(np.loadtxt(res.outputs.transform))
158
+ -1. 0. 0. 60.
159
+ 0. -1. 0. 72.
160
+ 0. 0. 1. 0.
161
+ 0. 0. 0. 1.
163
162
164
- """
163
+ .. testcleanup::
164
+
165
+ >>> import os
166
+ >>> os.unlink(res.outputs.out_file)
167
+ >>> os.unlink(res.outputs.transform)
168
+
169
+ """
165
170
input_spec = ReorientInputSpec
166
171
output_spec = ReorientOutputSpec
167
172
0 commit comments