niwrap-mrtrix 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of niwrap-mrtrix might be problematic. Click here for more details.
- niwrap_mrtrix/mrtrix/__init__.py +130 -0
- niwrap_mrtrix/mrtrix/afdconnectivity.py +445 -0
- niwrap_mrtrix/mrtrix/amp2response.py +453 -0
- niwrap_mrtrix/mrtrix/amp2sh.py +656 -0
- niwrap_mrtrix/mrtrix/connectome2tck.py +470 -0
- niwrap_mrtrix/mrtrix/connectomeedit.py +338 -0
- niwrap_mrtrix/mrtrix/connectomestats.py +767 -0
- niwrap_mrtrix/mrtrix/dcmedit.py +440 -0
- niwrap_mrtrix/mrtrix/dcminfo.py +416 -0
- niwrap_mrtrix/mrtrix/dirflip.py +362 -0
- niwrap_mrtrix/mrtrix/dirgen.py +423 -0
- niwrap_mrtrix/mrtrix/dirmerge.py +365 -0
- niwrap_mrtrix/mrtrix/dirorder.py +347 -0
- niwrap_mrtrix/mrtrix/dirsplit.py +358 -0
- niwrap_mrtrix/mrtrix/dirstat.py +530 -0
- niwrap_mrtrix/mrtrix/dwi2adc.py +428 -0
- niwrap_mrtrix/mrtrix/dwi2fod.py +879 -0
- niwrap_mrtrix/mrtrix/dwi2mask.py +463 -0
- niwrap_mrtrix/mrtrix/dwi2response.py +1295 -0
- niwrap_mrtrix/mrtrix/dwi2tensor.py +587 -0
- niwrap_mrtrix/mrtrix/dwibiascorrect.py +467 -0
- niwrap_mrtrix/mrtrix/dwidenoise.py +478 -0
- niwrap_mrtrix/mrtrix/dwiextract.py +825 -0
- niwrap_mrtrix/mrtrix/dwigradcheck.py +534 -0
- niwrap_mrtrix/mrtrix/fixel2peaks.py +452 -0
- niwrap_mrtrix/mrtrix/fixel2sh.py +357 -0
- niwrap_mrtrix/mrtrix/fixel2tsf.py +357 -0
- niwrap_mrtrix/mrtrix/fixel2voxel.py +437 -0
- niwrap_mrtrix/mrtrix/fixelcfestats.py +893 -0
- niwrap_mrtrix/mrtrix/fixelconnectivity.py +391 -0
- niwrap_mrtrix/mrtrix/fixelconvert.py +588 -0
- niwrap_mrtrix/mrtrix/fixelcorrespondence.py +371 -0
- niwrap_mrtrix/mrtrix/fixelcrop.py +348 -0
- niwrap_mrtrix/mrtrix/fixelfilter.py +616 -0
- niwrap_mrtrix/mrtrix/fixelreorient.py +361 -0
- niwrap_mrtrix/mrtrix/fod2dec.py +469 -0
- niwrap_mrtrix/mrtrix/fod2fixel.py +530 -0
- niwrap_mrtrix/mrtrix/label2colour.py +351 -0
- niwrap_mrtrix/mrtrix/label2mesh.py +343 -0
- niwrap_mrtrix/mrtrix/labelconvert.py +377 -0
- niwrap_mrtrix/mrtrix/labelstats.py +344 -0
- niwrap_mrtrix/mrtrix/maskdump.py +336 -0
- niwrap_mrtrix/mrtrix/maskfilter.py +537 -0
- niwrap_mrtrix/mrtrix/mesh2voxel.py +348 -0
- niwrap_mrtrix/mrtrix/meshconvert.py +410 -0
- niwrap_mrtrix/mrtrix/meshfilter.py +370 -0
- niwrap_mrtrix/mrtrix/mraverageheader.py +396 -0
- niwrap_mrtrix/mrtrix/mrcalc.py +3047 -0
- niwrap_mrtrix/mrtrix/mrcat.py +382 -0
- niwrap_mrtrix/mrtrix/mrcentroid.py +344 -0
- niwrap_mrtrix/mrtrix/mrcheckerboardmask.py +363 -0
- niwrap_mrtrix/mrtrix/mrclusterstats.py +736 -0
- niwrap_mrtrix/mrtrix/mrcolour.py +401 -0
- niwrap_mrtrix/mrtrix/mrconvert.py +1423 -0
- niwrap_mrtrix/mrtrix/mrdegibbs.py +443 -0
- niwrap_mrtrix/mrtrix/mrdump.py +351 -0
- niwrap_mrtrix/mrtrix/mredit.py +546 -0
- niwrap_mrtrix/mrtrix/mrfilter.py +716 -0
- niwrap_mrtrix/mrtrix/mrgrid.py +819 -0
- niwrap_mrtrix/mrtrix/mrhistmatch.py +403 -0
- niwrap_mrtrix/mrtrix/mrhistogram.py +393 -0
- niwrap_mrtrix/mrtrix/mrinfo.py +990 -0
- niwrap_mrtrix/mrtrix/mrmath.py +413 -0
- niwrap_mrtrix/mrtrix/mrmetric.py +425 -0
- niwrap_mrtrix/mrtrix/mrregister.py +1676 -0
- niwrap_mrtrix/mrtrix/mrstats.py +427 -0
- niwrap_mrtrix/mrtrix/mrthreshold.py +549 -0
- niwrap_mrtrix/mrtrix/mrtransform.py +1061 -0
- niwrap_mrtrix/mrtrix/mtnormalise.py +596 -0
- niwrap_mrtrix/mrtrix/peaks2amp.py +334 -0
- niwrap_mrtrix/mrtrix/peaks2fixel.py +349 -0
- niwrap_mrtrix/mrtrix/responsemean.py +316 -0
- niwrap_mrtrix/mrtrix/sh2amp.py +640 -0
- niwrap_mrtrix/mrtrix/sh2peaks.py +505 -0
- niwrap_mrtrix/mrtrix/sh2power.py +353 -0
- niwrap_mrtrix/mrtrix/sh2response.py +394 -0
- niwrap_mrtrix/mrtrix/shbasis.py +373 -0
- niwrap_mrtrix/mrtrix/shconv.py +498 -0
- niwrap_mrtrix/mrtrix/tck2connectome.py +580 -0
- niwrap_mrtrix/mrtrix/tck2fixel.py +363 -0
- niwrap_mrtrix/mrtrix/tckconvert.py +580 -0
- niwrap_mrtrix/mrtrix/tckdfc.py +551 -0
- niwrap_mrtrix/mrtrix/tckedit.py +1003 -0
- niwrap_mrtrix/mrtrix/tckgen.py +1983 -0
- niwrap_mrtrix/mrtrix/tckglobal.py +758 -0
- niwrap_mrtrix/mrtrix/tckinfo.py +329 -0
- niwrap_mrtrix/mrtrix/tckmap.py +772 -0
- niwrap_mrtrix/mrtrix/tckresample.py +580 -0
- niwrap_mrtrix/mrtrix/tcksample.py +404 -0
- niwrap_mrtrix/mrtrix/tcksift.py +592 -0
- niwrap_mrtrix/mrtrix/tcksift2.py +730 -0
- niwrap_mrtrix/mrtrix/tckstats.py +441 -0
- niwrap_mrtrix/mrtrix/tcktransform.py +340 -0
- niwrap_mrtrix/mrtrix/tensor2metric.py +544 -0
- niwrap_mrtrix/mrtrix/transformcalc.py +344 -0
- niwrap_mrtrix/mrtrix/transformcompose.py +465 -0
- niwrap_mrtrix/mrtrix/transformconvert.py +346 -0
- niwrap_mrtrix/mrtrix/tsfdivide.py +340 -0
- niwrap_mrtrix/mrtrix/tsfinfo.py +344 -0
- niwrap_mrtrix/mrtrix/tsfmult.py +340 -0
- niwrap_mrtrix/mrtrix/tsfsmooth.py +347 -0
- niwrap_mrtrix/mrtrix/tsfthreshold.py +349 -0
- niwrap_mrtrix/mrtrix/tsfvalidate.py +328 -0
- niwrap_mrtrix/mrtrix/v_5tt2gmwmi.py +359 -0
- niwrap_mrtrix/mrtrix/v_5tt2vis.py +412 -0
- niwrap_mrtrix/mrtrix/v_5ttcheck.py +337 -0
- niwrap_mrtrix/mrtrix/v_5ttedit.py +420 -0
- niwrap_mrtrix/mrtrix/v_5ttgen.py +816 -0
- niwrap_mrtrix/mrtrix/vectorstats.py +585 -0
- niwrap_mrtrix/mrtrix/voxel2fixel.py +350 -0
- niwrap_mrtrix/mrtrix/voxel2mesh.py +376 -0
- niwrap_mrtrix/mrtrix/warp2metric.py +449 -0
- niwrap_mrtrix/mrtrix/warpconvert.py +411 -0
- niwrap_mrtrix/mrtrix/warpcorrect.py +368 -0
- niwrap_mrtrix/mrtrix/warpinit.py +356 -0
- niwrap_mrtrix/mrtrix/warpinvert.py +370 -0
- niwrap_mrtrix-0.5.0.dist-info/METADATA +8 -0
- niwrap_mrtrix-0.5.0.dist-info/RECORD +119 -0
- niwrap_mrtrix-0.5.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,1061 @@
|
|
|
1
|
+
# This file was auto generated by Styx.
|
|
2
|
+
# Do not edit this file directly.
|
|
3
|
+
|
|
4
|
+
import typing
|
|
5
|
+
import pathlib
|
|
6
|
+
from styxdefs import *
|
|
7
|
+
|
|
8
|
+
MRTRANSFORM_METADATA = Metadata(
|
|
9
|
+
id="faaa07c120c0bcc84911ab27778920e0d881a5ea.boutiques",
|
|
10
|
+
name="mrtransform",
|
|
11
|
+
package="mrtrix",
|
|
12
|
+
container_image_tag="mrtrix3/mrtrix3:3.0.4",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
MrtransformFslgradParameters = typing.TypedDict('MrtransformFslgradParameters', {
|
|
17
|
+
"__STYX_TYPE__": typing.Literal["fslgrad"],
|
|
18
|
+
"bvecs": InputPathType,
|
|
19
|
+
"bvals": InputPathType,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
MrtransformExportGradFslParameters = typing.TypedDict('MrtransformExportGradFslParameters', {
|
|
24
|
+
"__STYX_TYPE__": typing.Literal["export_grad_fsl"],
|
|
25
|
+
"bvecs_path": str,
|
|
26
|
+
"bvals_path": str,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
MrtransformVariousStringParameters = typing.TypedDict('MrtransformVariousStringParameters', {
|
|
31
|
+
"__STYX_TYPE__": typing.Literal["VariousString"],
|
|
32
|
+
"obj": str,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
MrtransformVariousFileParameters = typing.TypedDict('MrtransformVariousFileParameters', {
|
|
37
|
+
"__STYX_TYPE__": typing.Literal["VariousFile"],
|
|
38
|
+
"obj": InputPathType,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
MrtransformConfigParameters = typing.TypedDict('MrtransformConfigParameters', {
|
|
43
|
+
"__STYX_TYPE__": typing.Literal["config"],
|
|
44
|
+
"key": str,
|
|
45
|
+
"value": str,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
MrtransformParameters = typing.TypedDict('MrtransformParameters', {
|
|
50
|
+
"__STYX_TYPE__": typing.Literal["mrtransform"],
|
|
51
|
+
"linear": typing.NotRequired[InputPathType | None],
|
|
52
|
+
"flip": typing.NotRequired[list[int] | None],
|
|
53
|
+
"inverse": bool,
|
|
54
|
+
"half": bool,
|
|
55
|
+
"replace": typing.NotRequired[InputPathType | None],
|
|
56
|
+
"identity": bool,
|
|
57
|
+
"template": typing.NotRequired[InputPathType | None],
|
|
58
|
+
"midway_space": bool,
|
|
59
|
+
"interp": typing.NotRequired[str | None],
|
|
60
|
+
"oversample": typing.NotRequired[list[int] | None],
|
|
61
|
+
"warp": typing.NotRequired[InputPathType | None],
|
|
62
|
+
"warp_full": typing.NotRequired[InputPathType | None],
|
|
63
|
+
"from": typing.NotRequired[int | None],
|
|
64
|
+
"modulate": typing.NotRequired[str | None],
|
|
65
|
+
"directions": typing.NotRequired[InputPathType | None],
|
|
66
|
+
"reorient_fod": typing.NotRequired[str | None],
|
|
67
|
+
"grad": typing.NotRequired[InputPathType | None],
|
|
68
|
+
"fslgrad": typing.NotRequired[MrtransformFslgradParameters | None],
|
|
69
|
+
"export_grad_mrtrix": typing.NotRequired[str | None],
|
|
70
|
+
"export_grad_fsl": typing.NotRequired[MrtransformExportGradFslParameters | None],
|
|
71
|
+
"datatype": typing.NotRequired[str | None],
|
|
72
|
+
"strides": typing.NotRequired[typing.Union[MrtransformVariousStringParameters, MrtransformVariousFileParameters] | None],
|
|
73
|
+
"nan": bool,
|
|
74
|
+
"no_reorientation": bool,
|
|
75
|
+
"info": bool,
|
|
76
|
+
"quiet": bool,
|
|
77
|
+
"debug": bool,
|
|
78
|
+
"force": bool,
|
|
79
|
+
"nthreads": typing.NotRequired[int | None],
|
|
80
|
+
"config": typing.NotRequired[list[MrtransformConfigParameters] | None],
|
|
81
|
+
"help": bool,
|
|
82
|
+
"version": bool,
|
|
83
|
+
"input": InputPathType,
|
|
84
|
+
"output": str,
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def dyn_cargs(
|
|
89
|
+
t: str,
|
|
90
|
+
) -> typing.Any:
|
|
91
|
+
"""
|
|
92
|
+
Get build cargs function by command type.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
t: Command type.
|
|
96
|
+
Returns:
|
|
97
|
+
Build cargs function.
|
|
98
|
+
"""
|
|
99
|
+
return {
|
|
100
|
+
"mrtransform": mrtransform_cargs,
|
|
101
|
+
"fslgrad": mrtransform_fslgrad_cargs,
|
|
102
|
+
"export_grad_fsl": mrtransform_export_grad_fsl_cargs,
|
|
103
|
+
"VariousString": mrtransform_various_string_cargs,
|
|
104
|
+
"VariousFile": mrtransform_various_file_cargs,
|
|
105
|
+
"config": mrtransform_config_cargs,
|
|
106
|
+
}.get(t)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def dyn_outputs(
|
|
110
|
+
t: str,
|
|
111
|
+
) -> typing.Any:
|
|
112
|
+
"""
|
|
113
|
+
Get build outputs function by command type.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
t: Command type.
|
|
117
|
+
Returns:
|
|
118
|
+
Build outputs function.
|
|
119
|
+
"""
|
|
120
|
+
return {
|
|
121
|
+
"mrtransform": mrtransform_outputs,
|
|
122
|
+
"export_grad_fsl": mrtransform_export_grad_fsl_outputs,
|
|
123
|
+
}.get(t)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def mrtransform_fslgrad_params(
|
|
127
|
+
bvecs: InputPathType,
|
|
128
|
+
bvals: InputPathType,
|
|
129
|
+
) -> MrtransformFslgradParameters:
|
|
130
|
+
"""
|
|
131
|
+
Build parameters.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
bvecs: Provide the diffusion-weighted gradient scheme used in the\
|
|
135
|
+
acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
|
|
136
|
+
scheme is present in the input image header, the data provided with\
|
|
137
|
+
this option will be instead used.
|
|
138
|
+
bvals: Provide the diffusion-weighted gradient scheme used in the\
|
|
139
|
+
acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
|
|
140
|
+
scheme is present in the input image header, the data provided with\
|
|
141
|
+
this option will be instead used.
|
|
142
|
+
Returns:
|
|
143
|
+
Parameter dictionary
|
|
144
|
+
"""
|
|
145
|
+
params = {
|
|
146
|
+
"__STYXTYPE__": "fslgrad",
|
|
147
|
+
"bvecs": bvecs,
|
|
148
|
+
"bvals": bvals,
|
|
149
|
+
}
|
|
150
|
+
return params
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def mrtransform_fslgrad_cargs(
|
|
154
|
+
params: MrtransformFslgradParameters,
|
|
155
|
+
execution: Execution,
|
|
156
|
+
) -> list[str]:
|
|
157
|
+
"""
|
|
158
|
+
Build command-line arguments from parameters.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
params: The parameters.
|
|
162
|
+
execution: The execution object for resolving input paths.
|
|
163
|
+
Returns:
|
|
164
|
+
Command-line arguments.
|
|
165
|
+
"""
|
|
166
|
+
cargs = []
|
|
167
|
+
cargs.append("-fslgrad")
|
|
168
|
+
cargs.append(execution.input_file(params.get("bvecs")))
|
|
169
|
+
cargs.append(execution.input_file(params.get("bvals")))
|
|
170
|
+
return cargs
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class MrtransformExportGradFslOutputs(typing.NamedTuple):
|
|
174
|
+
"""
|
|
175
|
+
Output object returned when calling `MrtransformExportGradFslParameters | None(...)`.
|
|
176
|
+
"""
|
|
177
|
+
root: OutputPathType
|
|
178
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
179
|
+
bvecs_path: OutputPathType
|
|
180
|
+
"""export the diffusion-weighted gradient table to files in FSL (bvecs /
|
|
181
|
+
bvals) format"""
|
|
182
|
+
bvals_path: OutputPathType
|
|
183
|
+
"""export the diffusion-weighted gradient table to files in FSL (bvecs /
|
|
184
|
+
bvals) format"""
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def mrtransform_export_grad_fsl_params(
|
|
188
|
+
bvecs_path: str,
|
|
189
|
+
bvals_path: str,
|
|
190
|
+
) -> MrtransformExportGradFslParameters:
|
|
191
|
+
"""
|
|
192
|
+
Build parameters.
|
|
193
|
+
|
|
194
|
+
Args:
|
|
195
|
+
bvecs_path: export the diffusion-weighted gradient table to files in\
|
|
196
|
+
FSL (bvecs / bvals) format.
|
|
197
|
+
bvals_path: export the diffusion-weighted gradient table to files in\
|
|
198
|
+
FSL (bvecs / bvals) format.
|
|
199
|
+
Returns:
|
|
200
|
+
Parameter dictionary
|
|
201
|
+
"""
|
|
202
|
+
params = {
|
|
203
|
+
"__STYXTYPE__": "export_grad_fsl",
|
|
204
|
+
"bvecs_path": bvecs_path,
|
|
205
|
+
"bvals_path": bvals_path,
|
|
206
|
+
}
|
|
207
|
+
return params
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def mrtransform_export_grad_fsl_cargs(
|
|
211
|
+
params: MrtransformExportGradFslParameters,
|
|
212
|
+
execution: Execution,
|
|
213
|
+
) -> list[str]:
|
|
214
|
+
"""
|
|
215
|
+
Build command-line arguments from parameters.
|
|
216
|
+
|
|
217
|
+
Args:
|
|
218
|
+
params: The parameters.
|
|
219
|
+
execution: The execution object for resolving input paths.
|
|
220
|
+
Returns:
|
|
221
|
+
Command-line arguments.
|
|
222
|
+
"""
|
|
223
|
+
cargs = []
|
|
224
|
+
cargs.append("-export_grad_fsl")
|
|
225
|
+
cargs.append(params.get("bvecs_path"))
|
|
226
|
+
cargs.append(params.get("bvals_path"))
|
|
227
|
+
return cargs
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def mrtransform_export_grad_fsl_outputs(
|
|
231
|
+
params: MrtransformExportGradFslParameters,
|
|
232
|
+
execution: Execution,
|
|
233
|
+
) -> MrtransformExportGradFslOutputs:
|
|
234
|
+
"""
|
|
235
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
236
|
+
|
|
237
|
+
Args:
|
|
238
|
+
params: The parameters.
|
|
239
|
+
execution: The execution object for resolving input paths.
|
|
240
|
+
Returns:
|
|
241
|
+
Outputs object.
|
|
242
|
+
"""
|
|
243
|
+
ret = MrtransformExportGradFslOutputs(
|
|
244
|
+
root=execution.output_file("."),
|
|
245
|
+
bvecs_path=execution.output_file(params.get("bvecs_path")),
|
|
246
|
+
bvals_path=execution.output_file(params.get("bvals_path")),
|
|
247
|
+
)
|
|
248
|
+
return ret
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def mrtransform_various_string_params(
|
|
252
|
+
obj: str,
|
|
253
|
+
) -> MrtransformVariousStringParameters:
|
|
254
|
+
"""
|
|
255
|
+
Build parameters.
|
|
256
|
+
|
|
257
|
+
Args:
|
|
258
|
+
obj: String object.
|
|
259
|
+
Returns:
|
|
260
|
+
Parameter dictionary
|
|
261
|
+
"""
|
|
262
|
+
params = {
|
|
263
|
+
"__STYXTYPE__": "VariousString",
|
|
264
|
+
"obj": obj,
|
|
265
|
+
}
|
|
266
|
+
return params
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def mrtransform_various_string_cargs(
|
|
270
|
+
params: MrtransformVariousStringParameters,
|
|
271
|
+
execution: Execution,
|
|
272
|
+
) -> list[str]:
|
|
273
|
+
"""
|
|
274
|
+
Build command-line arguments from parameters.
|
|
275
|
+
|
|
276
|
+
Args:
|
|
277
|
+
params: The parameters.
|
|
278
|
+
execution: The execution object for resolving input paths.
|
|
279
|
+
Returns:
|
|
280
|
+
Command-line arguments.
|
|
281
|
+
"""
|
|
282
|
+
cargs = []
|
|
283
|
+
cargs.append(params.get("obj"))
|
|
284
|
+
return cargs
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
def mrtransform_various_file_params(
|
|
288
|
+
obj: InputPathType,
|
|
289
|
+
) -> MrtransformVariousFileParameters:
|
|
290
|
+
"""
|
|
291
|
+
Build parameters.
|
|
292
|
+
|
|
293
|
+
Args:
|
|
294
|
+
obj: File object.
|
|
295
|
+
Returns:
|
|
296
|
+
Parameter dictionary
|
|
297
|
+
"""
|
|
298
|
+
params = {
|
|
299
|
+
"__STYXTYPE__": "VariousFile",
|
|
300
|
+
"obj": obj,
|
|
301
|
+
}
|
|
302
|
+
return params
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def mrtransform_various_file_cargs(
|
|
306
|
+
params: MrtransformVariousFileParameters,
|
|
307
|
+
execution: Execution,
|
|
308
|
+
) -> list[str]:
|
|
309
|
+
"""
|
|
310
|
+
Build command-line arguments from parameters.
|
|
311
|
+
|
|
312
|
+
Args:
|
|
313
|
+
params: The parameters.
|
|
314
|
+
execution: The execution object for resolving input paths.
|
|
315
|
+
Returns:
|
|
316
|
+
Command-line arguments.
|
|
317
|
+
"""
|
|
318
|
+
cargs = []
|
|
319
|
+
cargs.append(execution.input_file(params.get("obj")))
|
|
320
|
+
return cargs
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
def mrtransform_config_params(
|
|
324
|
+
key: str,
|
|
325
|
+
value: str,
|
|
326
|
+
) -> MrtransformConfigParameters:
|
|
327
|
+
"""
|
|
328
|
+
Build parameters.
|
|
329
|
+
|
|
330
|
+
Args:
|
|
331
|
+
key: temporarily set the value of an MRtrix config file entry.
|
|
332
|
+
value: temporarily set the value of an MRtrix config file entry.
|
|
333
|
+
Returns:
|
|
334
|
+
Parameter dictionary
|
|
335
|
+
"""
|
|
336
|
+
params = {
|
|
337
|
+
"__STYXTYPE__": "config",
|
|
338
|
+
"key": key,
|
|
339
|
+
"value": value,
|
|
340
|
+
}
|
|
341
|
+
return params
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def mrtransform_config_cargs(
|
|
345
|
+
params: MrtransformConfigParameters,
|
|
346
|
+
execution: Execution,
|
|
347
|
+
) -> list[str]:
|
|
348
|
+
"""
|
|
349
|
+
Build command-line arguments from parameters.
|
|
350
|
+
|
|
351
|
+
Args:
|
|
352
|
+
params: The parameters.
|
|
353
|
+
execution: The execution object for resolving input paths.
|
|
354
|
+
Returns:
|
|
355
|
+
Command-line arguments.
|
|
356
|
+
"""
|
|
357
|
+
cargs = []
|
|
358
|
+
cargs.append("-config")
|
|
359
|
+
cargs.append(params.get("key"))
|
|
360
|
+
cargs.append(params.get("value"))
|
|
361
|
+
return cargs
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
class MrtransformOutputs(typing.NamedTuple):
|
|
365
|
+
"""
|
|
366
|
+
Output object returned when calling `mrtransform(...)`.
|
|
367
|
+
"""
|
|
368
|
+
root: OutputPathType
|
|
369
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
370
|
+
output: OutputPathType
|
|
371
|
+
"""the output image."""
|
|
372
|
+
export_grad_mrtrix: OutputPathType | None
|
|
373
|
+
"""export the diffusion-weighted gradient table to file in MRtrix format """
|
|
374
|
+
export_grad_fsl: MrtransformExportGradFslOutputs | None
|
|
375
|
+
"""Outputs from `mrtransform_export_grad_fsl_outputs`."""
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
def mrtransform_params(
|
|
379
|
+
input_: InputPathType,
|
|
380
|
+
output: str,
|
|
381
|
+
linear: InputPathType | None = None,
|
|
382
|
+
flip: list[int] | None = None,
|
|
383
|
+
inverse: bool = False,
|
|
384
|
+
half: bool = False,
|
|
385
|
+
replace: InputPathType | None = None,
|
|
386
|
+
identity: bool = False,
|
|
387
|
+
template: InputPathType | None = None,
|
|
388
|
+
midway_space: bool = False,
|
|
389
|
+
interp: str | None = None,
|
|
390
|
+
oversample: list[int] | None = None,
|
|
391
|
+
warp: InputPathType | None = None,
|
|
392
|
+
warp_full: InputPathType | None = None,
|
|
393
|
+
from_: int | None = None,
|
|
394
|
+
modulate: str | None = None,
|
|
395
|
+
directions: InputPathType | None = None,
|
|
396
|
+
reorient_fod: str | None = None,
|
|
397
|
+
grad: InputPathType | None = None,
|
|
398
|
+
fslgrad: MrtransformFslgradParameters | None = None,
|
|
399
|
+
export_grad_mrtrix: str | None = None,
|
|
400
|
+
export_grad_fsl: MrtransformExportGradFslParameters | None = None,
|
|
401
|
+
datatype: str | None = None,
|
|
402
|
+
strides: typing.Union[MrtransformVariousStringParameters, MrtransformVariousFileParameters] | None = None,
|
|
403
|
+
nan: bool = False,
|
|
404
|
+
no_reorientation: bool = False,
|
|
405
|
+
info: bool = False,
|
|
406
|
+
quiet: bool = False,
|
|
407
|
+
debug: bool = False,
|
|
408
|
+
force: bool = False,
|
|
409
|
+
nthreads: int | None = None,
|
|
410
|
+
config: list[MrtransformConfigParameters] | None = None,
|
|
411
|
+
help_: bool = False,
|
|
412
|
+
version: bool = False,
|
|
413
|
+
) -> MrtransformParameters:
|
|
414
|
+
"""
|
|
415
|
+
Build parameters.
|
|
416
|
+
|
|
417
|
+
Args:
|
|
418
|
+
input_: input image to be transformed.
|
|
419
|
+
output: the output image.
|
|
420
|
+
linear: specify a linear transform to apply, in the form of a 3x4 or\
|
|
421
|
+
4x4 ascii file. Note the standard 'reverse' convention is used, where\
|
|
422
|
+
the transform maps points in the template image to the moving image.\
|
|
423
|
+
Note that the reverse convention is still assumed even if no -template\
|
|
424
|
+
image is supplied.
|
|
425
|
+
flip: flip the specified axes, provided as a comma-separated list of\
|
|
426
|
+
indices (0:x, 1:y, 2:z).
|
|
427
|
+
inverse: apply the inverse transformation.
|
|
428
|
+
half: apply the matrix square root of the transformation. This can be\
|
|
429
|
+
combined with the inverse option.
|
|
430
|
+
replace: replace the linear transform of the original image by that\
|
|
431
|
+
specified, rather than applying it to the original image. The specified\
|
|
432
|
+
transform can be either a template image, or a 3x4 or 4x4 ascii file.
|
|
433
|
+
identity: set the header transform of the image to the identity matrix.
|
|
434
|
+
template: reslice the input image to match the specified template image\
|
|
435
|
+
grid.
|
|
436
|
+
midway_space: reslice the input image to the midway space. Requires\
|
|
437
|
+
either the -template or -warp option. If used with -template and\
|
|
438
|
+
-linear option the input image will be resliced onto the grid halfway\
|
|
439
|
+
between the input and template. If used with the -warp option the input\
|
|
440
|
+
will be warped to the midway space defined by the grid of the input\
|
|
441
|
+
warp (i.e. half way between image1 and image2).
|
|
442
|
+
interp: set the interpolation method to use when reslicing (choices:\
|
|
443
|
+
nearest, linear, cubic, sinc. Default: cubic).
|
|
444
|
+
oversample: set the amount of over-sampling (in the target space) to\
|
|
445
|
+
perform when regridding. This is particularly relevant when downsamping\
|
|
446
|
+
a high-resolution image to a low-resolution image, to avoid aliasing\
|
|
447
|
+
artefacts. This can consist of a single integer, or a comma-separated\
|
|
448
|
+
list of 3 integers if different oversampling factors are desired along\
|
|
449
|
+
the different axes. Default is determined from ratio of voxel\
|
|
450
|
+
dimensions (disabled for nearest-neighbour interpolation).
|
|
451
|
+
warp: apply a non-linear 4D deformation field to warp the input image.\
|
|
452
|
+
Each voxel in the deformation field must define the scanner space\
|
|
453
|
+
position that will be used to interpolate the input image during\
|
|
454
|
+
warping (i.e. pull-back/reverse warp convention). If the -template\
|
|
455
|
+
image is also supplied the deformation field will be resliced first to\
|
|
456
|
+
the template image grid. If no -template option is supplied then the\
|
|
457
|
+
output image will have the same image grid as the deformation field.\
|
|
458
|
+
This option can be used in combination with the -affine option, in\
|
|
459
|
+
which case the affine will be applied first).
|
|
460
|
+
warp_full: warp the input image using a 5D warp file output from\
|
|
461
|
+
mrregister. Any linear transforms in the warp image header will also be\
|
|
462
|
+
applied. The -warp_full option must be used in combination with either\
|
|
463
|
+
the -template option or the -midway_space option. If a -template image\
|
|
464
|
+
is supplied then the full warp will be used. By default the\
|
|
465
|
+
image1->image2 transform will be applied, however the -from 2 option\
|
|
466
|
+
can be used to apply the image2->image1 transform. Use the\
|
|
467
|
+
-midway_space option to warp the input image to the midway space. The\
|
|
468
|
+
-from option can also be used to define which warp to use when\
|
|
469
|
+
transforming to midway space.
|
|
470
|
+
from_: used to define which space the input image is when using the\
|
|
471
|
+
-warp_mid option. Use -from 1 to warp from image1 or -from 2 to warp\
|
|
472
|
+
from image2.
|
|
473
|
+
modulate: Valid choices are: fod and jac.\
|
|
474
|
+
fod: modulate FODs during reorientation to preserve the apparent\
|
|
475
|
+
fibre density across fibre bundle widths before and after the\
|
|
476
|
+
transformation.\
|
|
477
|
+
jac: modulate the image intensity with the determinant of the\
|
|
478
|
+
Jacobian of the warp of linear transformation to preserve the total\
|
|
479
|
+
intensity before and after the transformation.
|
|
480
|
+
directions: directions defining the number and orientation of the\
|
|
481
|
+
apodised point spread functions used in FOD reorientation (Default: 300\
|
|
482
|
+
directions).
|
|
483
|
+
reorient_fod: specify whether to perform FOD reorientation. This is\
|
|
484
|
+
required if the number of volumes in the 4th dimension corresponds to\
|
|
485
|
+
the number of coefficients in an antipodally symmetric spherical\
|
|
486
|
+
harmonic series with lmax >= 2 (i.e. 6, 15, 28, 45, 66 volumes).
|
|
487
|
+
grad: Provide the diffusion-weighted gradient scheme used in the\
|
|
488
|
+
acquisition in a text file. This should be supplied as a 4xN text file\
|
|
489
|
+
with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
|
|
490
|
+
the direction of the applied gradient, and b gives the b-value in units\
|
|
491
|
+
of s/mm^2. If a diffusion gradient scheme is present in the input image\
|
|
492
|
+
header, the data provided with this option will be instead used.
|
|
493
|
+
fslgrad: Provide the diffusion-weighted gradient scheme used in the\
|
|
494
|
+
acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
|
|
495
|
+
scheme is present in the input image header, the data provided with\
|
|
496
|
+
this option will be instead used.
|
|
497
|
+
export_grad_mrtrix: export the diffusion-weighted gradient table to\
|
|
498
|
+
file in MRtrix format.
|
|
499
|
+
export_grad_fsl: export the diffusion-weighted gradient table to files\
|
|
500
|
+
in FSL (bvecs / bvals) format.
|
|
501
|
+
datatype: specify output image data type. Valid choices are: float32,\
|
|
502
|
+
float32le, float32be, float64, float64le, float64be, int64, uint64,\
|
|
503
|
+
int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
|
|
504
|
+
int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
|
|
505
|
+
cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
|
|
506
|
+
int8, uint8, bit.
|
|
507
|
+
strides: specify the strides of the output data in memory; either as a\
|
|
508
|
+
comma-separated list of (signed) integers, or as a template image from\
|
|
509
|
+
which the strides shall be extracted and used. The actual strides\
|
|
510
|
+
produced will depend on whether the output image format can support it.
|
|
511
|
+
nan: Use NaN as the out of bounds value (Default: 0.0).
|
|
512
|
+
no_reorientation: deprecated, use -reorient_fod instead.
|
|
513
|
+
info: display information messages.
|
|
514
|
+
quiet: do not display information messages or progress status;\
|
|
515
|
+
alternatively, this can be achieved by setting the MRTRIX_QUIET\
|
|
516
|
+
environment variable to a non-empty string.
|
|
517
|
+
debug: display debugging messages.
|
|
518
|
+
force: force overwrite of output files (caution: using the same file as\
|
|
519
|
+
input and output might cause unexpected behaviour).
|
|
520
|
+
nthreads: use this number of threads in multi-threaded applications\
|
|
521
|
+
(set to 0 to disable multi-threading).
|
|
522
|
+
config: temporarily set the value of an MRtrix config file entry.
|
|
523
|
+
help_: display this information page and exit.
|
|
524
|
+
version: display version information and exit.
|
|
525
|
+
Returns:
|
|
526
|
+
Parameter dictionary
|
|
527
|
+
"""
|
|
528
|
+
params = {
|
|
529
|
+
"__STYXTYPE__": "mrtransform",
|
|
530
|
+
"inverse": inverse,
|
|
531
|
+
"half": half,
|
|
532
|
+
"identity": identity,
|
|
533
|
+
"midway_space": midway_space,
|
|
534
|
+
"nan": nan,
|
|
535
|
+
"no_reorientation": no_reorientation,
|
|
536
|
+
"info": info,
|
|
537
|
+
"quiet": quiet,
|
|
538
|
+
"debug": debug,
|
|
539
|
+
"force": force,
|
|
540
|
+
"help": help_,
|
|
541
|
+
"version": version,
|
|
542
|
+
"input": input_,
|
|
543
|
+
"output": output,
|
|
544
|
+
}
|
|
545
|
+
if linear is not None:
|
|
546
|
+
params["linear"] = linear
|
|
547
|
+
if flip is not None:
|
|
548
|
+
params["flip"] = flip
|
|
549
|
+
if replace is not None:
|
|
550
|
+
params["replace"] = replace
|
|
551
|
+
if template is not None:
|
|
552
|
+
params["template"] = template
|
|
553
|
+
if interp is not None:
|
|
554
|
+
params["interp"] = interp
|
|
555
|
+
if oversample is not None:
|
|
556
|
+
params["oversample"] = oversample
|
|
557
|
+
if warp is not None:
|
|
558
|
+
params["warp"] = warp
|
|
559
|
+
if warp_full is not None:
|
|
560
|
+
params["warp_full"] = warp_full
|
|
561
|
+
if from_ is not None:
|
|
562
|
+
params["from"] = from_
|
|
563
|
+
if modulate is not None:
|
|
564
|
+
params["modulate"] = modulate
|
|
565
|
+
if directions is not None:
|
|
566
|
+
params["directions"] = directions
|
|
567
|
+
if reorient_fod is not None:
|
|
568
|
+
params["reorient_fod"] = reorient_fod
|
|
569
|
+
if grad is not None:
|
|
570
|
+
params["grad"] = grad
|
|
571
|
+
if fslgrad is not None:
|
|
572
|
+
params["fslgrad"] = fslgrad
|
|
573
|
+
if export_grad_mrtrix is not None:
|
|
574
|
+
params["export_grad_mrtrix"] = export_grad_mrtrix
|
|
575
|
+
if export_grad_fsl is not None:
|
|
576
|
+
params["export_grad_fsl"] = export_grad_fsl
|
|
577
|
+
if datatype is not None:
|
|
578
|
+
params["datatype"] = datatype
|
|
579
|
+
if strides is not None:
|
|
580
|
+
params["strides"] = strides
|
|
581
|
+
if nthreads is not None:
|
|
582
|
+
params["nthreads"] = nthreads
|
|
583
|
+
if config is not None:
|
|
584
|
+
params["config"] = config
|
|
585
|
+
return params
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
def mrtransform_cargs(
|
|
589
|
+
params: MrtransformParameters,
|
|
590
|
+
execution: Execution,
|
|
591
|
+
) -> list[str]:
|
|
592
|
+
"""
|
|
593
|
+
Build command-line arguments from parameters.
|
|
594
|
+
|
|
595
|
+
Args:
|
|
596
|
+
params: The parameters.
|
|
597
|
+
execution: The execution object for resolving input paths.
|
|
598
|
+
Returns:
|
|
599
|
+
Command-line arguments.
|
|
600
|
+
"""
|
|
601
|
+
cargs = []
|
|
602
|
+
cargs.append("mrtransform")
|
|
603
|
+
if params.get("linear") is not None:
|
|
604
|
+
cargs.extend([
|
|
605
|
+
"-linear",
|
|
606
|
+
execution.input_file(params.get("linear"))
|
|
607
|
+
])
|
|
608
|
+
if params.get("flip") is not None:
|
|
609
|
+
cargs.extend([
|
|
610
|
+
"-flip",
|
|
611
|
+
",".join(map(str, params.get("flip")))
|
|
612
|
+
])
|
|
613
|
+
if params.get("inverse"):
|
|
614
|
+
cargs.append("-inverse")
|
|
615
|
+
if params.get("half"):
|
|
616
|
+
cargs.append("-half")
|
|
617
|
+
if params.get("replace") is not None:
|
|
618
|
+
cargs.extend([
|
|
619
|
+
"-replace",
|
|
620
|
+
execution.input_file(params.get("replace"))
|
|
621
|
+
])
|
|
622
|
+
if params.get("identity"):
|
|
623
|
+
cargs.append("-identity")
|
|
624
|
+
if params.get("template") is not None:
|
|
625
|
+
cargs.extend([
|
|
626
|
+
"-template",
|
|
627
|
+
execution.input_file(params.get("template"))
|
|
628
|
+
])
|
|
629
|
+
if params.get("midway_space"):
|
|
630
|
+
cargs.append("-midway_space")
|
|
631
|
+
if params.get("interp") is not None:
|
|
632
|
+
cargs.extend([
|
|
633
|
+
"-interp",
|
|
634
|
+
params.get("interp")
|
|
635
|
+
])
|
|
636
|
+
if params.get("oversample") is not None:
|
|
637
|
+
cargs.extend([
|
|
638
|
+
"-oversample",
|
|
639
|
+
",".join(map(str, params.get("oversample")))
|
|
640
|
+
])
|
|
641
|
+
if params.get("warp") is not None:
|
|
642
|
+
cargs.extend([
|
|
643
|
+
"-warp",
|
|
644
|
+
execution.input_file(params.get("warp"))
|
|
645
|
+
])
|
|
646
|
+
if params.get("warp_full") is not None:
|
|
647
|
+
cargs.extend([
|
|
648
|
+
"-warp_full",
|
|
649
|
+
execution.input_file(params.get("warp_full"))
|
|
650
|
+
])
|
|
651
|
+
if params.get("from") is not None:
|
|
652
|
+
cargs.extend([
|
|
653
|
+
"-from",
|
|
654
|
+
str(params.get("from"))
|
|
655
|
+
])
|
|
656
|
+
if params.get("modulate") is not None:
|
|
657
|
+
cargs.extend([
|
|
658
|
+
"-modulate",
|
|
659
|
+
params.get("modulate")
|
|
660
|
+
])
|
|
661
|
+
if params.get("directions") is not None:
|
|
662
|
+
cargs.extend([
|
|
663
|
+
"-directions",
|
|
664
|
+
execution.input_file(params.get("directions"))
|
|
665
|
+
])
|
|
666
|
+
if params.get("reorient_fod") is not None:
|
|
667
|
+
cargs.extend([
|
|
668
|
+
"-reorient_fod",
|
|
669
|
+
params.get("reorient_fod")
|
|
670
|
+
])
|
|
671
|
+
if params.get("grad") is not None:
|
|
672
|
+
cargs.extend([
|
|
673
|
+
"-grad",
|
|
674
|
+
execution.input_file(params.get("grad"))
|
|
675
|
+
])
|
|
676
|
+
if params.get("fslgrad") is not None:
|
|
677
|
+
cargs.extend(dyn_cargs(params.get("fslgrad")["__STYXTYPE__"])(params.get("fslgrad"), execution))
|
|
678
|
+
if params.get("export_grad_mrtrix") is not None:
|
|
679
|
+
cargs.extend([
|
|
680
|
+
"-export_grad_mrtrix",
|
|
681
|
+
params.get("export_grad_mrtrix")
|
|
682
|
+
])
|
|
683
|
+
if params.get("export_grad_fsl") is not None:
|
|
684
|
+
cargs.extend(dyn_cargs(params.get("export_grad_fsl")["__STYXTYPE__"])(params.get("export_grad_fsl"), execution))
|
|
685
|
+
if params.get("datatype") is not None:
|
|
686
|
+
cargs.extend([
|
|
687
|
+
"-datatype",
|
|
688
|
+
params.get("datatype")
|
|
689
|
+
])
|
|
690
|
+
if params.get("strides") is not None:
|
|
691
|
+
cargs.extend([
|
|
692
|
+
"-strides",
|
|
693
|
+
*dyn_cargs(params.get("strides")["__STYXTYPE__"])(params.get("strides"), execution)
|
|
694
|
+
])
|
|
695
|
+
if params.get("nan"):
|
|
696
|
+
cargs.append("-nan")
|
|
697
|
+
if params.get("no_reorientation"):
|
|
698
|
+
cargs.append("-no_reorientation")
|
|
699
|
+
if params.get("info"):
|
|
700
|
+
cargs.append("-info")
|
|
701
|
+
if params.get("quiet"):
|
|
702
|
+
cargs.append("-quiet")
|
|
703
|
+
if params.get("debug"):
|
|
704
|
+
cargs.append("-debug")
|
|
705
|
+
if params.get("force"):
|
|
706
|
+
cargs.append("-force")
|
|
707
|
+
if params.get("nthreads") is not None:
|
|
708
|
+
cargs.extend([
|
|
709
|
+
"-nthreads",
|
|
710
|
+
str(params.get("nthreads"))
|
|
711
|
+
])
|
|
712
|
+
if params.get("config") is not None:
|
|
713
|
+
cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("config")] for a in c])
|
|
714
|
+
if params.get("help"):
|
|
715
|
+
cargs.append("-help")
|
|
716
|
+
if params.get("version"):
|
|
717
|
+
cargs.append("-version")
|
|
718
|
+
cargs.append(execution.input_file(params.get("input")))
|
|
719
|
+
cargs.append(params.get("output"))
|
|
720
|
+
return cargs
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
def mrtransform_outputs(
|
|
724
|
+
params: MrtransformParameters,
|
|
725
|
+
execution: Execution,
|
|
726
|
+
) -> MrtransformOutputs:
|
|
727
|
+
"""
|
|
728
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
729
|
+
|
|
730
|
+
Args:
|
|
731
|
+
params: The parameters.
|
|
732
|
+
execution: The execution object for resolving input paths.
|
|
733
|
+
Returns:
|
|
734
|
+
Outputs object.
|
|
735
|
+
"""
|
|
736
|
+
ret = MrtransformOutputs(
|
|
737
|
+
root=execution.output_file("."),
|
|
738
|
+
output=execution.output_file(params.get("output")),
|
|
739
|
+
export_grad_mrtrix=execution.output_file(params.get("export_grad_mrtrix")) if (params.get("export_grad_mrtrix") is not None) else None,
|
|
740
|
+
export_grad_fsl=dyn_outputs(params.get("export_grad_fsl")["__STYXTYPE__"])(params.get("export_grad_fsl"), execution) if params.get("export_grad_fsl") else None,
|
|
741
|
+
)
|
|
742
|
+
return ret
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
def mrtransform_execute(
|
|
746
|
+
params: MrtransformParameters,
|
|
747
|
+
execution: Execution,
|
|
748
|
+
) -> MrtransformOutputs:
|
|
749
|
+
"""
|
|
750
|
+
Apply spatial transformations to an image.
|
|
751
|
+
|
|
752
|
+
If a linear transform is applied without a template image the command will
|
|
753
|
+
modify the image header transform matrix
|
|
754
|
+
|
|
755
|
+
FOD reorientation (with apodised point spread functions) can be performed if
|
|
756
|
+
the number of volumes in the 4th dimension equals the number of coefficients
|
|
757
|
+
in an antipodally symmetric spherical harmonic series (e.g. 6, 15, 28 etc).
|
|
758
|
+
For such data, the -reorient_fod yes/no option must be used to specify if
|
|
759
|
+
reorientation is required.
|
|
760
|
+
|
|
761
|
+
The output image intensity can be modulated using the (local or global)
|
|
762
|
+
volume change if a linear or nonlinear transformation is applied. 'FOD'
|
|
763
|
+
modulation preserves the apparent fibre density across the fibre bundle
|
|
764
|
+
width and can only be applied if FOD reorientation is used. Alternatively,
|
|
765
|
+
non-directional scaling by the Jacobian determinant can be applied to any
|
|
766
|
+
image type.
|
|
767
|
+
|
|
768
|
+
If a DW scheme is contained in the header (or specified separately), and the
|
|
769
|
+
number of directions matches the number of volumes in the images, any
|
|
770
|
+
transformation applied using the -linear option will also be applied to the
|
|
771
|
+
directions.
|
|
772
|
+
|
|
773
|
+
When the -template option is used to specify the target image grid, the
|
|
774
|
+
image provided via this option will not influence the axis data strides of
|
|
775
|
+
the output image; these are determined based on the input image, or the
|
|
776
|
+
input to the -strides option.
|
|
777
|
+
|
|
778
|
+
References:
|
|
779
|
+
|
|
780
|
+
* If FOD reorientation is being performed:
|
|
781
|
+
Raffelt, D.; Tournier, J.-D.; Crozier, S.; Connelly, A. & Salvado, O.
|
|
782
|
+
Reorientation of fiber orientation distributions using apodized point spread
|
|
783
|
+
functions. Magnetic Resonance in Medicine, 2012, 67, 844-855
|
|
784
|
+
|
|
785
|
+
* If FOD modulation is being performed:
|
|
786
|
+
Raffelt, D.; Tournier, J.-D.; Rose, S.; Ridgway, G.R.; Henderson, R.;
|
|
787
|
+
Crozier, S.; Salvado, O.; Connelly, A.; Apparent Fibre Density: a novel
|
|
788
|
+
measure for the analysis of diffusion-weighted magnetic resonance images.
|
|
789
|
+
NeuroImage, 2012, 15;59(4), 3976-94.
|
|
790
|
+
|
|
791
|
+
Author: MRTrix3 Developers
|
|
792
|
+
|
|
793
|
+
URL: https://www.mrtrix.org/
|
|
794
|
+
|
|
795
|
+
Args:
|
|
796
|
+
params: The parameters.
|
|
797
|
+
execution: The execution object.
|
|
798
|
+
Returns:
|
|
799
|
+
NamedTuple of outputs (described in `MrtransformOutputs`).
|
|
800
|
+
"""
|
|
801
|
+
params = execution.params(params)
|
|
802
|
+
cargs = mrtransform_cargs(params, execution)
|
|
803
|
+
ret = mrtransform_outputs(params, execution)
|
|
804
|
+
execution.run(cargs)
|
|
805
|
+
return ret
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
def mrtransform(
|
|
809
|
+
input_: InputPathType,
|
|
810
|
+
output: str,
|
|
811
|
+
linear: InputPathType | None = None,
|
|
812
|
+
flip: list[int] | None = None,
|
|
813
|
+
inverse: bool = False,
|
|
814
|
+
half: bool = False,
|
|
815
|
+
replace: InputPathType | None = None,
|
|
816
|
+
identity: bool = False,
|
|
817
|
+
template: InputPathType | None = None,
|
|
818
|
+
midway_space: bool = False,
|
|
819
|
+
interp: str | None = None,
|
|
820
|
+
oversample: list[int] | None = None,
|
|
821
|
+
warp: InputPathType | None = None,
|
|
822
|
+
warp_full: InputPathType | None = None,
|
|
823
|
+
from_: int | None = None,
|
|
824
|
+
modulate: str | None = None,
|
|
825
|
+
directions: InputPathType | None = None,
|
|
826
|
+
reorient_fod: str | None = None,
|
|
827
|
+
grad: InputPathType | None = None,
|
|
828
|
+
fslgrad: MrtransformFslgradParameters | None = None,
|
|
829
|
+
export_grad_mrtrix: str | None = None,
|
|
830
|
+
export_grad_fsl: MrtransformExportGradFslParameters | None = None,
|
|
831
|
+
datatype: str | None = None,
|
|
832
|
+
strides: typing.Union[MrtransformVariousStringParameters, MrtransformVariousFileParameters] | None = None,
|
|
833
|
+
nan: bool = False,
|
|
834
|
+
no_reorientation: bool = False,
|
|
835
|
+
info: bool = False,
|
|
836
|
+
quiet: bool = False,
|
|
837
|
+
debug: bool = False,
|
|
838
|
+
force: bool = False,
|
|
839
|
+
nthreads: int | None = None,
|
|
840
|
+
config: list[MrtransformConfigParameters] | None = None,
|
|
841
|
+
help_: bool = False,
|
|
842
|
+
version: bool = False,
|
|
843
|
+
runner: Runner | None = None,
|
|
844
|
+
) -> MrtransformOutputs:
|
|
845
|
+
"""
|
|
846
|
+
Apply spatial transformations to an image.
|
|
847
|
+
|
|
848
|
+
If a linear transform is applied without a template image the command will
|
|
849
|
+
modify the image header transform matrix
|
|
850
|
+
|
|
851
|
+
FOD reorientation (with apodised point spread functions) can be performed if
|
|
852
|
+
the number of volumes in the 4th dimension equals the number of coefficients
|
|
853
|
+
in an antipodally symmetric spherical harmonic series (e.g. 6, 15, 28 etc).
|
|
854
|
+
For such data, the -reorient_fod yes/no option must be used to specify if
|
|
855
|
+
reorientation is required.
|
|
856
|
+
|
|
857
|
+
The output image intensity can be modulated using the (local or global)
|
|
858
|
+
volume change if a linear or nonlinear transformation is applied. 'FOD'
|
|
859
|
+
modulation preserves the apparent fibre density across the fibre bundle
|
|
860
|
+
width and can only be applied if FOD reorientation is used. Alternatively,
|
|
861
|
+
non-directional scaling by the Jacobian determinant can be applied to any
|
|
862
|
+
image type.
|
|
863
|
+
|
|
864
|
+
If a DW scheme is contained in the header (or specified separately), and the
|
|
865
|
+
number of directions matches the number of volumes in the images, any
|
|
866
|
+
transformation applied using the -linear option will also be applied to the
|
|
867
|
+
directions.
|
|
868
|
+
|
|
869
|
+
When the -template option is used to specify the target image grid, the
|
|
870
|
+
image provided via this option will not influence the axis data strides of
|
|
871
|
+
the output image; these are determined based on the input image, or the
|
|
872
|
+
input to the -strides option.
|
|
873
|
+
|
|
874
|
+
References:
|
|
875
|
+
|
|
876
|
+
* If FOD reorientation is being performed:
|
|
877
|
+
Raffelt, D.; Tournier, J.-D.; Crozier, S.; Connelly, A. & Salvado, O.
|
|
878
|
+
Reorientation of fiber orientation distributions using apodized point spread
|
|
879
|
+
functions. Magnetic Resonance in Medicine, 2012, 67, 844-855
|
|
880
|
+
|
|
881
|
+
* If FOD modulation is being performed:
|
|
882
|
+
Raffelt, D.; Tournier, J.-D.; Rose, S.; Ridgway, G.R.; Henderson, R.;
|
|
883
|
+
Crozier, S.; Salvado, O.; Connelly, A.; Apparent Fibre Density: a novel
|
|
884
|
+
measure for the analysis of diffusion-weighted magnetic resonance images.
|
|
885
|
+
NeuroImage, 2012, 15;59(4), 3976-94.
|
|
886
|
+
|
|
887
|
+
Author: MRTrix3 Developers
|
|
888
|
+
|
|
889
|
+
URL: https://www.mrtrix.org/
|
|
890
|
+
|
|
891
|
+
Args:
|
|
892
|
+
input_: input image to be transformed.
|
|
893
|
+
output: the output image.
|
|
894
|
+
linear: specify a linear transform to apply, in the form of a 3x4 or\
|
|
895
|
+
4x4 ascii file. Note the standard 'reverse' convention is used, where\
|
|
896
|
+
the transform maps points in the template image to the moving image.\
|
|
897
|
+
Note that the reverse convention is still assumed even if no -template\
|
|
898
|
+
image is supplied.
|
|
899
|
+
flip: flip the specified axes, provided as a comma-separated list of\
|
|
900
|
+
indices (0:x, 1:y, 2:z).
|
|
901
|
+
inverse: apply the inverse transformation.
|
|
902
|
+
half: apply the matrix square root of the transformation. This can be\
|
|
903
|
+
combined with the inverse option.
|
|
904
|
+
replace: replace the linear transform of the original image by that\
|
|
905
|
+
specified, rather than applying it to the original image. The specified\
|
|
906
|
+
transform can be either a template image, or a 3x4 or 4x4 ascii file.
|
|
907
|
+
identity: set the header transform of the image to the identity matrix.
|
|
908
|
+
template: reslice the input image to match the specified template image\
|
|
909
|
+
grid.
|
|
910
|
+
midway_space: reslice the input image to the midway space. Requires\
|
|
911
|
+
either the -template or -warp option. If used with -template and\
|
|
912
|
+
-linear option the input image will be resliced onto the grid halfway\
|
|
913
|
+
between the input and template. If used with the -warp option the input\
|
|
914
|
+
will be warped to the midway space defined by the grid of the input\
|
|
915
|
+
warp (i.e. half way between image1 and image2).
|
|
916
|
+
interp: set the interpolation method to use when reslicing (choices:\
|
|
917
|
+
nearest, linear, cubic, sinc. Default: cubic).
|
|
918
|
+
oversample: set the amount of over-sampling (in the target space) to\
|
|
919
|
+
perform when regridding. This is particularly relevant when downsamping\
|
|
920
|
+
a high-resolution image to a low-resolution image, to avoid aliasing\
|
|
921
|
+
artefacts. This can consist of a single integer, or a comma-separated\
|
|
922
|
+
list of 3 integers if different oversampling factors are desired along\
|
|
923
|
+
the different axes. Default is determined from ratio of voxel\
|
|
924
|
+
dimensions (disabled for nearest-neighbour interpolation).
|
|
925
|
+
warp: apply a non-linear 4D deformation field to warp the input image.\
|
|
926
|
+
Each voxel in the deformation field must define the scanner space\
|
|
927
|
+
position that will be used to interpolate the input image during\
|
|
928
|
+
warping (i.e. pull-back/reverse warp convention). If the -template\
|
|
929
|
+
image is also supplied the deformation field will be resliced first to\
|
|
930
|
+
the template image grid. If no -template option is supplied then the\
|
|
931
|
+
output image will have the same image grid as the deformation field.\
|
|
932
|
+
This option can be used in combination with the -affine option, in\
|
|
933
|
+
which case the affine will be applied first).
|
|
934
|
+
warp_full: warp the input image using a 5D warp file output from\
|
|
935
|
+
mrregister. Any linear transforms in the warp image header will also be\
|
|
936
|
+
applied. The -warp_full option must be used in combination with either\
|
|
937
|
+
the -template option or the -midway_space option. If a -template image\
|
|
938
|
+
is supplied then the full warp will be used. By default the\
|
|
939
|
+
image1->image2 transform will be applied, however the -from 2 option\
|
|
940
|
+
can be used to apply the image2->image1 transform. Use the\
|
|
941
|
+
-midway_space option to warp the input image to the midway space. The\
|
|
942
|
+
-from option can also be used to define which warp to use when\
|
|
943
|
+
transforming to midway space.
|
|
944
|
+
from_: used to define which space the input image is when using the\
|
|
945
|
+
-warp_mid option. Use -from 1 to warp from image1 or -from 2 to warp\
|
|
946
|
+
from image2.
|
|
947
|
+
modulate: Valid choices are: fod and jac.\
|
|
948
|
+
fod: modulate FODs during reorientation to preserve the apparent\
|
|
949
|
+
fibre density across fibre bundle widths before and after the\
|
|
950
|
+
transformation.\
|
|
951
|
+
jac: modulate the image intensity with the determinant of the\
|
|
952
|
+
Jacobian of the warp of linear transformation to preserve the total\
|
|
953
|
+
intensity before and after the transformation.
|
|
954
|
+
directions: directions defining the number and orientation of the\
|
|
955
|
+
apodised point spread functions used in FOD reorientation (Default: 300\
|
|
956
|
+
directions).
|
|
957
|
+
reorient_fod: specify whether to perform FOD reorientation. This is\
|
|
958
|
+
required if the number of volumes in the 4th dimension corresponds to\
|
|
959
|
+
the number of coefficients in an antipodally symmetric spherical\
|
|
960
|
+
harmonic series with lmax >= 2 (i.e. 6, 15, 28, 45, 66 volumes).
|
|
961
|
+
grad: Provide the diffusion-weighted gradient scheme used in the\
|
|
962
|
+
acquisition in a text file. This should be supplied as a 4xN text file\
|
|
963
|
+
with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
|
|
964
|
+
the direction of the applied gradient, and b gives the b-value in units\
|
|
965
|
+
of s/mm^2. If a diffusion gradient scheme is present in the input image\
|
|
966
|
+
header, the data provided with this option will be instead used.
|
|
967
|
+
fslgrad: Provide the diffusion-weighted gradient scheme used in the\
|
|
968
|
+
acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
|
|
969
|
+
scheme is present in the input image header, the data provided with\
|
|
970
|
+
this option will be instead used.
|
|
971
|
+
export_grad_mrtrix: export the diffusion-weighted gradient table to\
|
|
972
|
+
file in MRtrix format.
|
|
973
|
+
export_grad_fsl: export the diffusion-weighted gradient table to files\
|
|
974
|
+
in FSL (bvecs / bvals) format.
|
|
975
|
+
datatype: specify output image data type. Valid choices are: float32,\
|
|
976
|
+
float32le, float32be, float64, float64le, float64be, int64, uint64,\
|
|
977
|
+
int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
|
|
978
|
+
int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
|
|
979
|
+
cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
|
|
980
|
+
int8, uint8, bit.
|
|
981
|
+
strides: specify the strides of the output data in memory; either as a\
|
|
982
|
+
comma-separated list of (signed) integers, or as a template image from\
|
|
983
|
+
which the strides shall be extracted and used. The actual strides\
|
|
984
|
+
produced will depend on whether the output image format can support it.
|
|
985
|
+
nan: Use NaN as the out of bounds value (Default: 0.0).
|
|
986
|
+
no_reorientation: deprecated, use -reorient_fod instead.
|
|
987
|
+
info: display information messages.
|
|
988
|
+
quiet: do not display information messages or progress status;\
|
|
989
|
+
alternatively, this can be achieved by setting the MRTRIX_QUIET\
|
|
990
|
+
environment variable to a non-empty string.
|
|
991
|
+
debug: display debugging messages.
|
|
992
|
+
force: force overwrite of output files (caution: using the same file as\
|
|
993
|
+
input and output might cause unexpected behaviour).
|
|
994
|
+
nthreads: use this number of threads in multi-threaded applications\
|
|
995
|
+
(set to 0 to disable multi-threading).
|
|
996
|
+
config: temporarily set the value of an MRtrix config file entry.
|
|
997
|
+
help_: display this information page and exit.
|
|
998
|
+
version: display version information and exit.
|
|
999
|
+
runner: Command runner.
|
|
1000
|
+
Returns:
|
|
1001
|
+
NamedTuple of outputs (described in `MrtransformOutputs`).
|
|
1002
|
+
"""
|
|
1003
|
+
runner = runner or get_global_runner()
|
|
1004
|
+
execution = runner.start_execution(MRTRANSFORM_METADATA)
|
|
1005
|
+
params = mrtransform_params(
|
|
1006
|
+
linear=linear,
|
|
1007
|
+
flip=flip,
|
|
1008
|
+
inverse=inverse,
|
|
1009
|
+
half=half,
|
|
1010
|
+
replace=replace,
|
|
1011
|
+
identity=identity,
|
|
1012
|
+
template=template,
|
|
1013
|
+
midway_space=midway_space,
|
|
1014
|
+
interp=interp,
|
|
1015
|
+
oversample=oversample,
|
|
1016
|
+
warp=warp,
|
|
1017
|
+
warp_full=warp_full,
|
|
1018
|
+
from_=from_,
|
|
1019
|
+
modulate=modulate,
|
|
1020
|
+
directions=directions,
|
|
1021
|
+
reorient_fod=reorient_fod,
|
|
1022
|
+
grad=grad,
|
|
1023
|
+
fslgrad=fslgrad,
|
|
1024
|
+
export_grad_mrtrix=export_grad_mrtrix,
|
|
1025
|
+
export_grad_fsl=export_grad_fsl,
|
|
1026
|
+
datatype=datatype,
|
|
1027
|
+
strides=strides,
|
|
1028
|
+
nan=nan,
|
|
1029
|
+
no_reorientation=no_reorientation,
|
|
1030
|
+
info=info,
|
|
1031
|
+
quiet=quiet,
|
|
1032
|
+
debug=debug,
|
|
1033
|
+
force=force,
|
|
1034
|
+
nthreads=nthreads,
|
|
1035
|
+
config=config,
|
|
1036
|
+
help_=help_,
|
|
1037
|
+
version=version,
|
|
1038
|
+
input_=input_,
|
|
1039
|
+
output=output,
|
|
1040
|
+
)
|
|
1041
|
+
return mrtransform_execute(params, execution)
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
__all__ = [
|
|
1045
|
+
"MRTRANSFORM_METADATA",
|
|
1046
|
+
"MrtransformConfigParameters",
|
|
1047
|
+
"MrtransformExportGradFslOutputs",
|
|
1048
|
+
"MrtransformExportGradFslParameters",
|
|
1049
|
+
"MrtransformFslgradParameters",
|
|
1050
|
+
"MrtransformOutputs",
|
|
1051
|
+
"MrtransformParameters",
|
|
1052
|
+
"MrtransformVariousFileParameters",
|
|
1053
|
+
"MrtransformVariousStringParameters",
|
|
1054
|
+
"mrtransform",
|
|
1055
|
+
"mrtransform_config_params",
|
|
1056
|
+
"mrtransform_export_grad_fsl_params",
|
|
1057
|
+
"mrtransform_fslgrad_params",
|
|
1058
|
+
"mrtransform_params",
|
|
1059
|
+
"mrtransform_various_file_params",
|
|
1060
|
+
"mrtransform_various_string_params",
|
|
1061
|
+
]
|