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.

Files changed (119) hide show
  1. niwrap_mrtrix/mrtrix/__init__.py +130 -0
  2. niwrap_mrtrix/mrtrix/afdconnectivity.py +445 -0
  3. niwrap_mrtrix/mrtrix/amp2response.py +453 -0
  4. niwrap_mrtrix/mrtrix/amp2sh.py +656 -0
  5. niwrap_mrtrix/mrtrix/connectome2tck.py +470 -0
  6. niwrap_mrtrix/mrtrix/connectomeedit.py +338 -0
  7. niwrap_mrtrix/mrtrix/connectomestats.py +767 -0
  8. niwrap_mrtrix/mrtrix/dcmedit.py +440 -0
  9. niwrap_mrtrix/mrtrix/dcminfo.py +416 -0
  10. niwrap_mrtrix/mrtrix/dirflip.py +362 -0
  11. niwrap_mrtrix/mrtrix/dirgen.py +423 -0
  12. niwrap_mrtrix/mrtrix/dirmerge.py +365 -0
  13. niwrap_mrtrix/mrtrix/dirorder.py +347 -0
  14. niwrap_mrtrix/mrtrix/dirsplit.py +358 -0
  15. niwrap_mrtrix/mrtrix/dirstat.py +530 -0
  16. niwrap_mrtrix/mrtrix/dwi2adc.py +428 -0
  17. niwrap_mrtrix/mrtrix/dwi2fod.py +879 -0
  18. niwrap_mrtrix/mrtrix/dwi2mask.py +463 -0
  19. niwrap_mrtrix/mrtrix/dwi2response.py +1295 -0
  20. niwrap_mrtrix/mrtrix/dwi2tensor.py +587 -0
  21. niwrap_mrtrix/mrtrix/dwibiascorrect.py +467 -0
  22. niwrap_mrtrix/mrtrix/dwidenoise.py +478 -0
  23. niwrap_mrtrix/mrtrix/dwiextract.py +825 -0
  24. niwrap_mrtrix/mrtrix/dwigradcheck.py +534 -0
  25. niwrap_mrtrix/mrtrix/fixel2peaks.py +452 -0
  26. niwrap_mrtrix/mrtrix/fixel2sh.py +357 -0
  27. niwrap_mrtrix/mrtrix/fixel2tsf.py +357 -0
  28. niwrap_mrtrix/mrtrix/fixel2voxel.py +437 -0
  29. niwrap_mrtrix/mrtrix/fixelcfestats.py +893 -0
  30. niwrap_mrtrix/mrtrix/fixelconnectivity.py +391 -0
  31. niwrap_mrtrix/mrtrix/fixelconvert.py +588 -0
  32. niwrap_mrtrix/mrtrix/fixelcorrespondence.py +371 -0
  33. niwrap_mrtrix/mrtrix/fixelcrop.py +348 -0
  34. niwrap_mrtrix/mrtrix/fixelfilter.py +616 -0
  35. niwrap_mrtrix/mrtrix/fixelreorient.py +361 -0
  36. niwrap_mrtrix/mrtrix/fod2dec.py +469 -0
  37. niwrap_mrtrix/mrtrix/fod2fixel.py +530 -0
  38. niwrap_mrtrix/mrtrix/label2colour.py +351 -0
  39. niwrap_mrtrix/mrtrix/label2mesh.py +343 -0
  40. niwrap_mrtrix/mrtrix/labelconvert.py +377 -0
  41. niwrap_mrtrix/mrtrix/labelstats.py +344 -0
  42. niwrap_mrtrix/mrtrix/maskdump.py +336 -0
  43. niwrap_mrtrix/mrtrix/maskfilter.py +537 -0
  44. niwrap_mrtrix/mrtrix/mesh2voxel.py +348 -0
  45. niwrap_mrtrix/mrtrix/meshconvert.py +410 -0
  46. niwrap_mrtrix/mrtrix/meshfilter.py +370 -0
  47. niwrap_mrtrix/mrtrix/mraverageheader.py +396 -0
  48. niwrap_mrtrix/mrtrix/mrcalc.py +3047 -0
  49. niwrap_mrtrix/mrtrix/mrcat.py +382 -0
  50. niwrap_mrtrix/mrtrix/mrcentroid.py +344 -0
  51. niwrap_mrtrix/mrtrix/mrcheckerboardmask.py +363 -0
  52. niwrap_mrtrix/mrtrix/mrclusterstats.py +736 -0
  53. niwrap_mrtrix/mrtrix/mrcolour.py +401 -0
  54. niwrap_mrtrix/mrtrix/mrconvert.py +1423 -0
  55. niwrap_mrtrix/mrtrix/mrdegibbs.py +443 -0
  56. niwrap_mrtrix/mrtrix/mrdump.py +351 -0
  57. niwrap_mrtrix/mrtrix/mredit.py +546 -0
  58. niwrap_mrtrix/mrtrix/mrfilter.py +716 -0
  59. niwrap_mrtrix/mrtrix/mrgrid.py +819 -0
  60. niwrap_mrtrix/mrtrix/mrhistmatch.py +403 -0
  61. niwrap_mrtrix/mrtrix/mrhistogram.py +393 -0
  62. niwrap_mrtrix/mrtrix/mrinfo.py +990 -0
  63. niwrap_mrtrix/mrtrix/mrmath.py +413 -0
  64. niwrap_mrtrix/mrtrix/mrmetric.py +425 -0
  65. niwrap_mrtrix/mrtrix/mrregister.py +1676 -0
  66. niwrap_mrtrix/mrtrix/mrstats.py +427 -0
  67. niwrap_mrtrix/mrtrix/mrthreshold.py +549 -0
  68. niwrap_mrtrix/mrtrix/mrtransform.py +1061 -0
  69. niwrap_mrtrix/mrtrix/mtnormalise.py +596 -0
  70. niwrap_mrtrix/mrtrix/peaks2amp.py +334 -0
  71. niwrap_mrtrix/mrtrix/peaks2fixel.py +349 -0
  72. niwrap_mrtrix/mrtrix/responsemean.py +316 -0
  73. niwrap_mrtrix/mrtrix/sh2amp.py +640 -0
  74. niwrap_mrtrix/mrtrix/sh2peaks.py +505 -0
  75. niwrap_mrtrix/mrtrix/sh2power.py +353 -0
  76. niwrap_mrtrix/mrtrix/sh2response.py +394 -0
  77. niwrap_mrtrix/mrtrix/shbasis.py +373 -0
  78. niwrap_mrtrix/mrtrix/shconv.py +498 -0
  79. niwrap_mrtrix/mrtrix/tck2connectome.py +580 -0
  80. niwrap_mrtrix/mrtrix/tck2fixel.py +363 -0
  81. niwrap_mrtrix/mrtrix/tckconvert.py +580 -0
  82. niwrap_mrtrix/mrtrix/tckdfc.py +551 -0
  83. niwrap_mrtrix/mrtrix/tckedit.py +1003 -0
  84. niwrap_mrtrix/mrtrix/tckgen.py +1983 -0
  85. niwrap_mrtrix/mrtrix/tckglobal.py +758 -0
  86. niwrap_mrtrix/mrtrix/tckinfo.py +329 -0
  87. niwrap_mrtrix/mrtrix/tckmap.py +772 -0
  88. niwrap_mrtrix/mrtrix/tckresample.py +580 -0
  89. niwrap_mrtrix/mrtrix/tcksample.py +404 -0
  90. niwrap_mrtrix/mrtrix/tcksift.py +592 -0
  91. niwrap_mrtrix/mrtrix/tcksift2.py +730 -0
  92. niwrap_mrtrix/mrtrix/tckstats.py +441 -0
  93. niwrap_mrtrix/mrtrix/tcktransform.py +340 -0
  94. niwrap_mrtrix/mrtrix/tensor2metric.py +544 -0
  95. niwrap_mrtrix/mrtrix/transformcalc.py +344 -0
  96. niwrap_mrtrix/mrtrix/transformcompose.py +465 -0
  97. niwrap_mrtrix/mrtrix/transformconvert.py +346 -0
  98. niwrap_mrtrix/mrtrix/tsfdivide.py +340 -0
  99. niwrap_mrtrix/mrtrix/tsfinfo.py +344 -0
  100. niwrap_mrtrix/mrtrix/tsfmult.py +340 -0
  101. niwrap_mrtrix/mrtrix/tsfsmooth.py +347 -0
  102. niwrap_mrtrix/mrtrix/tsfthreshold.py +349 -0
  103. niwrap_mrtrix/mrtrix/tsfvalidate.py +328 -0
  104. niwrap_mrtrix/mrtrix/v_5tt2gmwmi.py +359 -0
  105. niwrap_mrtrix/mrtrix/v_5tt2vis.py +412 -0
  106. niwrap_mrtrix/mrtrix/v_5ttcheck.py +337 -0
  107. niwrap_mrtrix/mrtrix/v_5ttedit.py +420 -0
  108. niwrap_mrtrix/mrtrix/v_5ttgen.py +816 -0
  109. niwrap_mrtrix/mrtrix/vectorstats.py +585 -0
  110. niwrap_mrtrix/mrtrix/voxel2fixel.py +350 -0
  111. niwrap_mrtrix/mrtrix/voxel2mesh.py +376 -0
  112. niwrap_mrtrix/mrtrix/warp2metric.py +449 -0
  113. niwrap_mrtrix/mrtrix/warpconvert.py +411 -0
  114. niwrap_mrtrix/mrtrix/warpcorrect.py +368 -0
  115. niwrap_mrtrix/mrtrix/warpinit.py +356 -0
  116. niwrap_mrtrix/mrtrix/warpinvert.py +370 -0
  117. niwrap_mrtrix-0.5.0.dist-info/METADATA +8 -0
  118. niwrap_mrtrix-0.5.0.dist-info/RECORD +119 -0
  119. niwrap_mrtrix-0.5.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,1676 @@
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
+ MRREGISTER_METADATA = Metadata(
9
+ id="8bd7ed4526083be2350c2edade3ae34d8bed4865.boutiques",
10
+ name="mrregister",
11
+ package="mrtrix",
12
+ container_image_tag="mrtrix3/mrtrix3:3.0.4",
13
+ )
14
+
15
+
16
+ MrregisterTransformedParameters = typing.TypedDict('MrregisterTransformedParameters', {
17
+ "__STYX_TYPE__": typing.Literal["transformed"],
18
+ "image": str,
19
+ })
20
+
21
+
22
+ MrregisterTransformedMidwayParameters = typing.TypedDict('MrregisterTransformedMidwayParameters', {
23
+ "__STYX_TYPE__": typing.Literal["transformed_midway"],
24
+ "image1_transformed": str,
25
+ "image2_transformed": str,
26
+ })
27
+
28
+
29
+ MrregisterNlWarpParameters = typing.TypedDict('MrregisterNlWarpParameters', {
30
+ "__STYX_TYPE__": typing.Literal["nl_warp"],
31
+ "warp1": str,
32
+ "warp2": str,
33
+ })
34
+
35
+
36
+ MrregisterConfigParameters = typing.TypedDict('MrregisterConfigParameters', {
37
+ "__STYX_TYPE__": typing.Literal["config"],
38
+ "key": str,
39
+ "value": str,
40
+ })
41
+
42
+
43
+ MrregisterParameters = typing.TypedDict('MrregisterParameters', {
44
+ "__STYX_TYPE__": typing.Literal["mrregister"],
45
+ "type": typing.NotRequired[str | None],
46
+ "transformed": typing.NotRequired[list[MrregisterTransformedParameters] | None],
47
+ "transformed_midway": typing.NotRequired[list[MrregisterTransformedMidwayParameters] | None],
48
+ "mask1": typing.NotRequired[InputPathType | None],
49
+ "mask2": typing.NotRequired[InputPathType | None],
50
+ "nan": bool,
51
+ "rigid": typing.NotRequired[str | None],
52
+ "rigid_1tomidway": typing.NotRequired[str | None],
53
+ "rigid_2tomidway": typing.NotRequired[str | None],
54
+ "rigid_init_translation": typing.NotRequired[str | None],
55
+ "rigid_init_rotation": typing.NotRequired[str | None],
56
+ "rigid_init_matrix": typing.NotRequired[InputPathType | None],
57
+ "rigid_scale": typing.NotRequired[list[float] | None],
58
+ "rigid_niter": typing.NotRequired[list[int] | None],
59
+ "rigid_metric": typing.NotRequired[str | None],
60
+ "rigid_metric_diff_estimator": typing.NotRequired[str | None],
61
+ "rigid_lmax": typing.NotRequired[list[int] | None],
62
+ "rigid_log": typing.NotRequired[str | None],
63
+ "affine": typing.NotRequired[str | None],
64
+ "affine_1tomidway": typing.NotRequired[str | None],
65
+ "affine_2tomidway": typing.NotRequired[str | None],
66
+ "affine_init_translation": typing.NotRequired[str | None],
67
+ "affine_init_rotation": typing.NotRequired[str | None],
68
+ "affine_init_matrix": typing.NotRequired[InputPathType | None],
69
+ "affine_scale": typing.NotRequired[list[float] | None],
70
+ "affine_niter": typing.NotRequired[list[int] | None],
71
+ "affine_metric": typing.NotRequired[str | None],
72
+ "affine_metric_diff_estimator": typing.NotRequired[str | None],
73
+ "affine_lmax": typing.NotRequired[list[int] | None],
74
+ "affine_log": typing.NotRequired[str | None],
75
+ "init_translation_unmasked1": bool,
76
+ "init_translation_unmasked2": bool,
77
+ "init_rotation_unmasked1": bool,
78
+ "init_rotation_unmasked2": bool,
79
+ "init_rotation_search_angles": typing.NotRequired[list[float] | None],
80
+ "init_rotation_search_scale": typing.NotRequired[float | None],
81
+ "init_rotation_search_directions": typing.NotRequired[int | None],
82
+ "init_rotation_search_run_global": bool,
83
+ "init_rotation_search_global_iterations": typing.NotRequired[int | None],
84
+ "linstage_iterations": typing.NotRequired[list[int] | None],
85
+ "linstage_optimiser_first": typing.NotRequired[str | None],
86
+ "linstage_optimiser_last": typing.NotRequired[str | None],
87
+ "linstage_optimiser_default": typing.NotRequired[str | None],
88
+ "linstage_diagnostics_prefix": typing.NotRequired[str | None],
89
+ "nl_warp": typing.NotRequired[MrregisterNlWarpParameters | None],
90
+ "nl_warp_full": typing.NotRequired[str | None],
91
+ "nl_init": typing.NotRequired[InputPathType | None],
92
+ "nl_scale": typing.NotRequired[list[float] | None],
93
+ "nl_niter": typing.NotRequired[list[int] | None],
94
+ "nl_update_smooth": typing.NotRequired[float | None],
95
+ "nl_disp_smooth": typing.NotRequired[float | None],
96
+ "nl_grad_step": typing.NotRequired[float | None],
97
+ "nl_lmax": typing.NotRequired[list[int] | None],
98
+ "diagnostics_image": typing.NotRequired[str | None],
99
+ "directions": typing.NotRequired[InputPathType | None],
100
+ "noreorientation": bool,
101
+ "mc_weights": typing.NotRequired[list[float] | None],
102
+ "datatype": typing.NotRequired[str | None],
103
+ "info": bool,
104
+ "quiet": bool,
105
+ "debug": bool,
106
+ "force": bool,
107
+ "nthreads": typing.NotRequired[int | None],
108
+ "config": typing.NotRequired[list[MrregisterConfigParameters] | None],
109
+ "help": bool,
110
+ "version": bool,
111
+ "image1_image2": InputPathType,
112
+ "contrast1_contrast2": typing.NotRequired[list[InputPathType] | None],
113
+ })
114
+
115
+
116
+ def dyn_cargs(
117
+ t: str,
118
+ ) -> typing.Any:
119
+ """
120
+ Get build cargs function by command type.
121
+
122
+ Args:
123
+ t: Command type.
124
+ Returns:
125
+ Build cargs function.
126
+ """
127
+ return {
128
+ "mrregister": mrregister_cargs,
129
+ "transformed": mrregister_transformed_cargs,
130
+ "transformed_midway": mrregister_transformed_midway_cargs,
131
+ "nl_warp": mrregister_nl_warp_cargs,
132
+ "config": mrregister_config_cargs,
133
+ }.get(t)
134
+
135
+
136
+ def dyn_outputs(
137
+ t: str,
138
+ ) -> typing.Any:
139
+ """
140
+ Get build outputs function by command type.
141
+
142
+ Args:
143
+ t: Command type.
144
+ Returns:
145
+ Build outputs function.
146
+ """
147
+ return {
148
+ "mrregister": mrregister_outputs,
149
+ "transformed": mrregister_transformed_outputs,
150
+ "transformed_midway": mrregister_transformed_midway_outputs,
151
+ "nl_warp": mrregister_nl_warp_outputs,
152
+ }.get(t)
153
+
154
+
155
+ class MrregisterTransformedOutputs(typing.NamedTuple):
156
+ """
157
+ Output object returned when calling `list[MrregisterTransformedParameters] | None(...)`.
158
+ """
159
+ root: OutputPathType
160
+ """Output root folder. This is the root folder for all outputs."""
161
+ image: OutputPathType
162
+ """image1 after registration transformed and regridded to the space of
163
+ image2. Note that -transformed needs to be repeated for each contrast if
164
+ multi-contrast registration is used."""
165
+
166
+
167
+ def mrregister_transformed_params(
168
+ image: str,
169
+ ) -> MrregisterTransformedParameters:
170
+ """
171
+ Build parameters.
172
+
173
+ Args:
174
+ image: image1 after registration transformed and regridded to the space\
175
+ of image2. Note that -transformed needs to be repeated for each\
176
+ contrast if multi-contrast registration is used.
177
+ Returns:
178
+ Parameter dictionary
179
+ """
180
+ params = {
181
+ "__STYXTYPE__": "transformed",
182
+ "image": image,
183
+ }
184
+ return params
185
+
186
+
187
+ def mrregister_transformed_cargs(
188
+ params: MrregisterTransformedParameters,
189
+ execution: Execution,
190
+ ) -> list[str]:
191
+ """
192
+ Build command-line arguments from parameters.
193
+
194
+ Args:
195
+ params: The parameters.
196
+ execution: The execution object for resolving input paths.
197
+ Returns:
198
+ Command-line arguments.
199
+ """
200
+ cargs = []
201
+ cargs.append("-transformed")
202
+ cargs.append(params.get("image"))
203
+ return cargs
204
+
205
+
206
+ def mrregister_transformed_outputs(
207
+ params: MrregisterTransformedParameters,
208
+ execution: Execution,
209
+ ) -> MrregisterTransformedOutputs:
210
+ """
211
+ Build outputs object containing output file paths and possibly stdout/stderr.
212
+
213
+ Args:
214
+ params: The parameters.
215
+ execution: The execution object for resolving input paths.
216
+ Returns:
217
+ Outputs object.
218
+ """
219
+ ret = MrregisterTransformedOutputs(
220
+ root=execution.output_file("."),
221
+ image=execution.output_file(params.get("image")),
222
+ )
223
+ return ret
224
+
225
+
226
+ class MrregisterTransformedMidwayOutputs(typing.NamedTuple):
227
+ """
228
+ Output object returned when calling `list[MrregisterTransformedMidwayParameters] | None(...)`.
229
+ """
230
+ root: OutputPathType
231
+ """Output root folder. This is the root folder for all outputs."""
232
+ image1_transformed: OutputPathType
233
+ """image1 and image2 after registration transformed and regridded to the
234
+ midway space. Note that -transformed_midway needs to be repeated for each
235
+ contrast if multi-contrast registration is used."""
236
+ image2_transformed: OutputPathType
237
+ """image1 and image2 after registration transformed and regridded to the
238
+ midway space. Note that -transformed_midway needs to be repeated for each
239
+ contrast if multi-contrast registration is used."""
240
+
241
+
242
+ def mrregister_transformed_midway_params(
243
+ image1_transformed: str,
244
+ image2_transformed: str,
245
+ ) -> MrregisterTransformedMidwayParameters:
246
+ """
247
+ Build parameters.
248
+
249
+ Args:
250
+ image1_transformed: image1 and image2 after registration transformed\
251
+ and regridded to the midway space. Note that -transformed_midway needs\
252
+ to be repeated for each contrast if multi-contrast registration is\
253
+ used.
254
+ image2_transformed: image1 and image2 after registration transformed\
255
+ and regridded to the midway space. Note that -transformed_midway needs\
256
+ to be repeated for each contrast if multi-contrast registration is\
257
+ used.
258
+ Returns:
259
+ Parameter dictionary
260
+ """
261
+ params = {
262
+ "__STYXTYPE__": "transformed_midway",
263
+ "image1_transformed": image1_transformed,
264
+ "image2_transformed": image2_transformed,
265
+ }
266
+ return params
267
+
268
+
269
+ def mrregister_transformed_midway_cargs(
270
+ params: MrregisterTransformedMidwayParameters,
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("-transformed_midway")
284
+ cargs.append(params.get("image1_transformed"))
285
+ cargs.append(params.get("image2_transformed"))
286
+ return cargs
287
+
288
+
289
+ def mrregister_transformed_midway_outputs(
290
+ params: MrregisterTransformedMidwayParameters,
291
+ execution: Execution,
292
+ ) -> MrregisterTransformedMidwayOutputs:
293
+ """
294
+ Build outputs object containing output file paths and possibly stdout/stderr.
295
+
296
+ Args:
297
+ params: The parameters.
298
+ execution: The execution object for resolving input paths.
299
+ Returns:
300
+ Outputs object.
301
+ """
302
+ ret = MrregisterTransformedMidwayOutputs(
303
+ root=execution.output_file("."),
304
+ image1_transformed=execution.output_file(params.get("image1_transformed")),
305
+ image2_transformed=execution.output_file(params.get("image2_transformed")),
306
+ )
307
+ return ret
308
+
309
+
310
+ class MrregisterNlWarpOutputs(typing.NamedTuple):
311
+ """
312
+ Output object returned when calling `MrregisterNlWarpParameters | None(...)`.
313
+ """
314
+ root: OutputPathType
315
+ """Output root folder. This is the root folder for all outputs."""
316
+ warp1: OutputPathType
317
+ """the non-linear warp output defined as two deformation fields, where warp1
318
+ can be used to transform image1->image2 and warp2 to transform
319
+ image2->image1. The deformation fields also encapsulate any linear
320
+ transformation estimated prior to non-linear registration."""
321
+ warp2: OutputPathType
322
+ """the non-linear warp output defined as two deformation fields, where warp1
323
+ can be used to transform image1->image2 and warp2 to transform
324
+ image2->image1. The deformation fields also encapsulate any linear
325
+ transformation estimated prior to non-linear registration."""
326
+
327
+
328
+ def mrregister_nl_warp_params(
329
+ warp1: str,
330
+ warp2: str,
331
+ ) -> MrregisterNlWarpParameters:
332
+ """
333
+ Build parameters.
334
+
335
+ Args:
336
+ warp1: the non-linear warp output defined as two deformation fields,\
337
+ where warp1 can be used to transform image1->image2 and warp2 to\
338
+ transform image2->image1. The deformation fields also encapsulate any\
339
+ linear transformation estimated prior to non-linear registration.
340
+ warp2: the non-linear warp output defined as two deformation fields,\
341
+ where warp1 can be used to transform image1->image2 and warp2 to\
342
+ transform image2->image1. The deformation fields also encapsulate any\
343
+ linear transformation estimated prior to non-linear registration.
344
+ Returns:
345
+ Parameter dictionary
346
+ """
347
+ params = {
348
+ "__STYXTYPE__": "nl_warp",
349
+ "warp1": warp1,
350
+ "warp2": warp2,
351
+ }
352
+ return params
353
+
354
+
355
+ def mrregister_nl_warp_cargs(
356
+ params: MrregisterNlWarpParameters,
357
+ execution: Execution,
358
+ ) -> list[str]:
359
+ """
360
+ Build command-line arguments from parameters.
361
+
362
+ Args:
363
+ params: The parameters.
364
+ execution: The execution object for resolving input paths.
365
+ Returns:
366
+ Command-line arguments.
367
+ """
368
+ cargs = []
369
+ cargs.append("-nl_warp")
370
+ cargs.append(params.get("warp1"))
371
+ cargs.append(params.get("warp2"))
372
+ return cargs
373
+
374
+
375
+ def mrregister_nl_warp_outputs(
376
+ params: MrregisterNlWarpParameters,
377
+ execution: Execution,
378
+ ) -> MrregisterNlWarpOutputs:
379
+ """
380
+ Build outputs object containing output file paths and possibly stdout/stderr.
381
+
382
+ Args:
383
+ params: The parameters.
384
+ execution: The execution object for resolving input paths.
385
+ Returns:
386
+ Outputs object.
387
+ """
388
+ ret = MrregisterNlWarpOutputs(
389
+ root=execution.output_file("."),
390
+ warp1=execution.output_file(params.get("warp1")),
391
+ warp2=execution.output_file(params.get("warp2")),
392
+ )
393
+ return ret
394
+
395
+
396
+ def mrregister_config_params(
397
+ key: str,
398
+ value: str,
399
+ ) -> MrregisterConfigParameters:
400
+ """
401
+ Build parameters.
402
+
403
+ Args:
404
+ key: temporarily set the value of an MRtrix config file entry.
405
+ value: temporarily set the value of an MRtrix config file entry.
406
+ Returns:
407
+ Parameter dictionary
408
+ """
409
+ params = {
410
+ "__STYXTYPE__": "config",
411
+ "key": key,
412
+ "value": value,
413
+ }
414
+ return params
415
+
416
+
417
+ def mrregister_config_cargs(
418
+ params: MrregisterConfigParameters,
419
+ execution: Execution,
420
+ ) -> list[str]:
421
+ """
422
+ Build command-line arguments from parameters.
423
+
424
+ Args:
425
+ params: The parameters.
426
+ execution: The execution object for resolving input paths.
427
+ Returns:
428
+ Command-line arguments.
429
+ """
430
+ cargs = []
431
+ cargs.append("-config")
432
+ cargs.append(params.get("key"))
433
+ cargs.append(params.get("value"))
434
+ return cargs
435
+
436
+
437
+ class MrregisterOutputs(typing.NamedTuple):
438
+ """
439
+ Output object returned when calling `mrregister(...)`.
440
+ """
441
+ root: OutputPathType
442
+ """Output root folder. This is the root folder for all outputs."""
443
+ rigid: OutputPathType | None
444
+ """the output text file containing the rigid transformation as a 4x4 matrix
445
+ """
446
+ rigid_1tomidway: OutputPathType | None
447
+ """the output text file containing the rigid transformation that aligns
448
+ image1 to image2 in their common midway space as a 4x4 matrix """
449
+ rigid_2tomidway: OutputPathType | None
450
+ """the output text file containing the rigid transformation that aligns
451
+ image2 to image1 in their common midway space as a 4x4 matrix """
452
+ rigid_log: OutputPathType | None
453
+ """write gradient descent parameter evolution to log file """
454
+ affine: OutputPathType | None
455
+ """the output text file containing the affine transformation as a 4x4 matrix
456
+ """
457
+ affine_1tomidway: OutputPathType | None
458
+ """the output text file containing the affine transformation that aligns
459
+ image1 to image2 in their common midway space as a 4x4 matrix """
460
+ affine_2tomidway: OutputPathType | None
461
+ """the output text file containing the affine transformation that aligns
462
+ image2 to image1 in their common midway space as a 4x4 matrix """
463
+ affine_log: OutputPathType | None
464
+ """write gradient descent parameter evolution to log file """
465
+ nl_warp_full: OutputPathType | None
466
+ """output all warps used during registration. This saves four different
467
+ warps that map each image to a midway space and their inverses in a single
468
+ 5D image file. The 4th image dimension indexes the x,y,z component of the
469
+ deformation vector and the 5th dimension indexes the field in this order:
470
+ image1->midway, midway->image1, image2->midway, midway->image2. Where
471
+ image1->midway defines the field that maps image1 onto the midway space
472
+ using the reverse convention When linear registration is performed first,
473
+ the estimated linear transform will be included in the comments of the image
474
+ header, and therefore the entire linear and non-linear transform can be
475
+ applied (in either direction) using this output warp file with mrtransform
476
+ """
477
+ transformed: list[MrregisterTransformedOutputs] | None
478
+ """Outputs from `mrregister_transformed_outputs`.This is a list of outputs
479
+ with the same length and order as the inputs."""
480
+ transformed_midway: list[MrregisterTransformedMidwayOutputs] | None
481
+ """Outputs from `mrregister_transformed_midway_outputs`.This is a list of
482
+ outputs with the same length and order as the inputs."""
483
+ nl_warp: MrregisterNlWarpOutputs | None
484
+ """Outputs from `mrregister_nl_warp_outputs`."""
485
+
486
+
487
+ def mrregister_params(
488
+ image1_image2: InputPathType,
489
+ type_: str | None = None,
490
+ transformed: list[MrregisterTransformedParameters] | None = None,
491
+ transformed_midway: list[MrregisterTransformedMidwayParameters] | None = None,
492
+ mask1: InputPathType | None = None,
493
+ mask2: InputPathType | None = None,
494
+ nan: bool = False,
495
+ rigid: str | None = None,
496
+ rigid_1tomidway: str | None = None,
497
+ rigid_2tomidway: str | None = None,
498
+ rigid_init_translation: str | None = None,
499
+ rigid_init_rotation: str | None = None,
500
+ rigid_init_matrix: InputPathType | None = None,
501
+ rigid_scale: list[float] | None = None,
502
+ rigid_niter: list[int] | None = None,
503
+ rigid_metric: str | None = None,
504
+ rigid_metric_diff_estimator: str | None = None,
505
+ rigid_lmax: list[int] | None = None,
506
+ rigid_log: str | None = None,
507
+ affine: str | None = None,
508
+ affine_1tomidway: str | None = None,
509
+ affine_2tomidway: str | None = None,
510
+ affine_init_translation: str | None = None,
511
+ affine_init_rotation: str | None = None,
512
+ affine_init_matrix: InputPathType | None = None,
513
+ affine_scale: list[float] | None = None,
514
+ affine_niter: list[int] | None = None,
515
+ affine_metric: str | None = None,
516
+ affine_metric_diff_estimator: str | None = None,
517
+ affine_lmax: list[int] | None = None,
518
+ affine_log: str | None = None,
519
+ init_translation_unmasked1: bool = False,
520
+ init_translation_unmasked2: bool = False,
521
+ init_rotation_unmasked1: bool = False,
522
+ init_rotation_unmasked2: bool = False,
523
+ init_rotation_search_angles: list[float] | None = None,
524
+ init_rotation_search_scale: float | None = None,
525
+ init_rotation_search_directions: int | None = None,
526
+ init_rotation_search_run_global: bool = False,
527
+ init_rotation_search_global_iterations: int | None = None,
528
+ linstage_iterations: list[int] | None = None,
529
+ linstage_optimiser_first: str | None = None,
530
+ linstage_optimiser_last: str | None = None,
531
+ linstage_optimiser_default: str | None = None,
532
+ linstage_diagnostics_prefix: str | None = None,
533
+ nl_warp: MrregisterNlWarpParameters | None = None,
534
+ nl_warp_full: str | None = None,
535
+ nl_init: InputPathType | None = None,
536
+ nl_scale: list[float] | None = None,
537
+ nl_niter: list[int] | None = None,
538
+ nl_update_smooth: float | None = None,
539
+ nl_disp_smooth: float | None = None,
540
+ nl_grad_step: float | None = None,
541
+ nl_lmax: list[int] | None = None,
542
+ diagnostics_image: str | None = None,
543
+ directions: InputPathType | None = None,
544
+ noreorientation: bool = False,
545
+ mc_weights: list[float] | None = None,
546
+ datatype: str | None = None,
547
+ info: bool = False,
548
+ quiet: bool = False,
549
+ debug: bool = False,
550
+ force: bool = False,
551
+ nthreads: int | None = None,
552
+ config: list[MrregisterConfigParameters] | None = None,
553
+ help_: bool = False,
554
+ version: bool = False,
555
+ contrast1_contrast2: list[InputPathType] | None = None,
556
+ ) -> MrregisterParameters:
557
+ """
558
+ Build parameters.
559
+
560
+ Args:
561
+ image1_image2: input image 1 ('moving') and input image 2 ('template').
562
+ type_: the registration type. Valid choices are: rigid, affine,\
563
+ nonlinear, rigid_affine, rigid_nonlinear, affine_nonlinear,\
564
+ rigid_affine_nonlinear (Default: affine_nonlinear).
565
+ transformed: image1 after registration transformed and regridded to the\
566
+ space of image2. Note that -transformed needs to be repeated for each\
567
+ contrast if multi-contrast registration is used.
568
+ transformed_midway: image1 and image2 after registration transformed\
569
+ and regridded to the midway space. Note that -transformed_midway needs\
570
+ to be repeated for each contrast if multi-contrast registration is\
571
+ used.
572
+ mask1: a mask to define the region of image1 to use for optimisation.
573
+ mask2: a mask to define the region of image2 to use for optimisation.
574
+ nan: use NaN as out of bounds value. (Default: 0.0).
575
+ rigid: the output text file containing the rigid transformation as a\
576
+ 4x4 matrix.
577
+ rigid_1tomidway: the output text file containing the rigid\
578
+ transformation that aligns image1 to image2 in their common midway\
579
+ space as a 4x4 matrix.
580
+ rigid_2tomidway: the output text file containing the rigid\
581
+ transformation that aligns image2 to image1 in their common midway\
582
+ space as a 4x4 matrix.
583
+ rigid_init_translation: initialise the translation and centre of\
584
+ rotation\
585
+ Valid choices are:\
586
+ mass (aligns the centers of mass of both images, default),\
587
+ geometric (aligns geometric image centres) and none.
588
+ rigid_init_rotation: initialise the rotation Valid choices are:\
589
+ search (search for the best rotation using mean squared residuals),\
590
+ moments (rotation based on directions of intensity variance with\
591
+ respect to centre of mass),\
592
+ none (default).
593
+ rigid_init_matrix: initialise either the rigid, affine, or syn\
594
+ registration with the supplied rigid transformation (as a 4x4 matrix in\
595
+ scanner coordinates). Note that this overrides rigid_init_translation\
596
+ and rigid_init_rotation initialisation.
597
+ rigid_scale: use a multi-resolution scheme by defining a scale factor\
598
+ for each level using comma separated values (Default: 0.25,0.5,1.0).
599
+ rigid_niter: the maximum number of gradient descent iterations per\
600
+ stage. This can be specified either as a single number for all\
601
+ multi-resolution levels, or a single value for each level. (Default:\
602
+ 1000).
603
+ rigid_metric: valid choices are: diff (intensity differences), Default:\
604
+ diff.
605
+ rigid_metric_diff_estimator: Valid choices are: l1 (least absolute:\
606
+ |x|), l2 (ordinary least squares), lp (least powers: |x|^1.2), Default:\
607
+ l2.
608
+ rigid_lmax: explicitly set the lmax to be used per scale factor in\
609
+ rigid FOD registration. By default FOD registration will use lmax 0,2,4\
610
+ with default scale factors 0.25,0.5,1.0 respectively. Note that no\
611
+ reorientation will be performed with lmax = 0.
612
+ rigid_log: write gradient descent parameter evolution to log file.
613
+ affine: the output text file containing the affine transformation as a\
614
+ 4x4 matrix.
615
+ affine_1tomidway: the output text file containing the affine\
616
+ transformation that aligns image1 to image2 in their common midway\
617
+ space as a 4x4 matrix.
618
+ affine_2tomidway: the output text file containing the affine\
619
+ transformation that aligns image2 to image1 in their common midway\
620
+ space as a 4x4 matrix.
621
+ affine_init_translation: initialise the translation and centre of\
622
+ rotation\
623
+ Valid choices are:\
624
+ mass (aligns the centers of mass of both images),\
625
+ geometric (aligns geometric image centres) and none. (Default:\
626
+ mass).
627
+ affine_init_rotation: initialise the rotation Valid choices are:\
628
+ search (search for the best rotation using mean squared residuals),\
629
+ moments (rotation based on directions of intensity variance with\
630
+ respect to centre of mass),\
631
+ none (Default: none).
632
+ affine_init_matrix: initialise either the affine, or syn registration\
633
+ with the supplied affine transformation (as a 4x4 matrix in scanner\
634
+ coordinates). Note that this overrides affine_init_translation and\
635
+ affine_init_rotation initialisation.
636
+ affine_scale: use a multi-resolution scheme by defining a scale factor\
637
+ for each level using comma separated values (Default: 0.25,0.5,1.0).
638
+ affine_niter: the maximum number of gradient descent iterations per\
639
+ stage. This can be specified either as a single number for all\
640
+ multi-resolution levels, or a single value for each level. (Default:\
641
+ 1000).
642
+ affine_metric: valid choices are: diff (intensity differences),\
643
+ Default: diff.
644
+ affine_metric_diff_estimator: Valid choices are: l1 (least absolute:\
645
+ |x|), l2 (ordinary least squares), lp (least powers: |x|^1.2), Default:\
646
+ l2.
647
+ affine_lmax: explicitly set the lmax to be used per scale factor in\
648
+ affine FOD registration. By default FOD registration will use lmax\
649
+ 0,2,4 with default scale factors 0.25,0.5,1.0 respectively. Note that\
650
+ no reorientation will be performed with lmax = 0.
651
+ affine_log: write gradient descent parameter evolution to log file.
652
+ init_translation_unmasked1: disregard mask1 for the translation\
653
+ initialisation (affects 'mass').
654
+ init_translation_unmasked2: disregard mask2 for the translation\
655
+ initialisation (affects 'mass').
656
+ init_rotation_unmasked1: disregard mask1 for the rotation\
657
+ initialisation (affects 'search' and 'moments').
658
+ init_rotation_unmasked2: disregard mask2 for the rotation\
659
+ initialisation (affects 'search' and 'moments').
660
+ init_rotation_search_angles: rotation angles for the local search in\
661
+ degrees between 0 and 180. (Default: 2,5,10,15,20).
662
+ init_rotation_search_scale: relative size of the images used for the\
663
+ rotation search. (Default: 0.15).
664
+ init_rotation_search_directions: number of rotation axis for local\
665
+ search. (Default: 250).
666
+ init_rotation_search_run_global: perform a global search. (Default:\
667
+ local).
668
+ init_rotation_search_global_iterations: number of rotations to\
669
+ investigate (Default: 10000).
670
+ linstage_iterations: number of iterations for each registration stage,\
671
+ not to be confused with -rigid_niter or -affine_niter. This can be used\
672
+ to generate intermediate diagnostics images\
673
+ (-linstage.diagnostics.prefix) or to change the cost function optimiser\
674
+ during registration (without the need to repeatedly resize the images).\
675
+ (Default: 1 == no repetition).
676
+ linstage_optimiser_first: Cost function optimisation algorithm to use\
677
+ at first iteration of all stages. Valid choices: bbgd (Barzilai-Borwein\
678
+ gradient descent) or gd (simple gradient descent). (Default: bbgd).
679
+ linstage_optimiser_last: Cost function optimisation algorithm to use at\
680
+ last iteration of all stages (if there are more than one). Valid\
681
+ choices: bbgd (Barzilai-Borwein gradient descent) or gd (simple\
682
+ gradient descent). (Default: bbgd).
683
+ linstage_optimiser_default: Cost function optimisation algorithm to use\
684
+ at any stage iteration other than first or last iteration. Valid\
685
+ choices: bbgd (Barzilai-Borwein gradient descent) or gd (simple\
686
+ gradient descent). (Default: bbgd).
687
+ linstage_diagnostics_prefix: generate diagnostics images after every\
688
+ registration stage.
689
+ nl_warp: the non-linear warp output defined as two deformation fields,\
690
+ where warp1 can be used to transform image1->image2 and warp2 to\
691
+ transform image2->image1. The deformation fields also encapsulate any\
692
+ linear transformation estimated prior to non-linear registration.
693
+ nl_warp_full: output all warps used during registration. This saves\
694
+ four different warps that map each image to a midway space and their\
695
+ inverses in a single 5D image file. The 4th image dimension indexes the\
696
+ x,y,z component of the deformation vector and the 5th dimension indexes\
697
+ the field in this order: image1->midway, midway->image1,\
698
+ image2->midway, midway->image2. Where image1->midway defines the field\
699
+ that maps image1 onto the midway space using the reverse convention\
700
+ When linear registration is performed first, the estimated linear\
701
+ transform will be included in the comments of the image header, and\
702
+ therefore the entire linear and non-linear transform can be applied (in\
703
+ either direction) using this output warp file with mrtransform.
704
+ nl_init: initialise the non-linear registration with the supplied warp\
705
+ image. The supplied warp must be in the same format as output using the\
706
+ -nl_warp_full option (i.e. have 4 deformation fields with the linear\
707
+ transforms in the image header).
708
+ nl_scale: use a multi-resolution scheme by defining a scale factor for\
709
+ each level using comma separated values (Default: 0.25,0.5,1.0).
710
+ nl_niter: the maximum number of iterations. This can be specified\
711
+ either as a single number for all multi-resolution levels, or a single\
712
+ value for each level. (Default: 50).
713
+ nl_update_smooth: regularise the gradient update field with Gaussian\
714
+ smoothing (standard deviation in voxel units, Default 2.0).
715
+ nl_disp_smooth: regularise the displacement field with Gaussian\
716
+ smoothing (standard deviation in voxel units, Default 1.0).
717
+ nl_grad_step: the gradient step size for non-linear registration\
718
+ (Default: 0.5).
719
+ nl_lmax: explicitly set the lmax to be used per scale factor in\
720
+ non-linear FOD registration. By default FOD registration will use lmax\
721
+ 0,2,4 with default scale factors 0.25,0.5,1.0 respectively. Note that\
722
+ no reorientation will be performed with lmax = 0.
723
+ diagnostics_image: write intermediate images for diagnostics purposes.
724
+ directions: the directions used for FOD reorientation using apodised\
725
+ point spread functions (Default: 60 directions).
726
+ noreorientation: turn off FOD reorientation. Reorientation is on by\
727
+ default if the number of volumes in the 4th dimension corresponds to\
728
+ the number of coefficients in an antipodally symmetric spherical\
729
+ harmonic series (i.e. 6, 15, 28, 45, 66 etc).
730
+ mc_weights: relative weight of images used for multi-contrast\
731
+ registration. Default: 1.0 (equal weighting).
732
+ datatype: specify output image data type. Valid choices are: float32,\
733
+ float32le, float32be, float64, float64le, float64be, int64, uint64,\
734
+ int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
735
+ int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
736
+ cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
737
+ int8, uint8, bit.
738
+ info: display information messages.
739
+ quiet: do not display information messages or progress status;\
740
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
741
+ environment variable to a non-empty string.
742
+ debug: display debugging messages.
743
+ force: force overwrite of output files (caution: using the same file as\
744
+ input and output might cause unexpected behaviour).
745
+ nthreads: use this number of threads in multi-threaded applications\
746
+ (set to 0 to disable multi-threading).
747
+ config: temporarily set the value of an MRtrix config file entry.
748
+ help_: display this information page and exit.
749
+ version: display version information and exit.
750
+ contrast1_contrast2: optional list of additional input images used as\
751
+ additional contrasts. Can be used multiple times. contrastX and imageX\
752
+ must share the same coordinate system.
753
+ Returns:
754
+ Parameter dictionary
755
+ """
756
+ params = {
757
+ "__STYXTYPE__": "mrregister",
758
+ "nan": nan,
759
+ "init_translation_unmasked1": init_translation_unmasked1,
760
+ "init_translation_unmasked2": init_translation_unmasked2,
761
+ "init_rotation_unmasked1": init_rotation_unmasked1,
762
+ "init_rotation_unmasked2": init_rotation_unmasked2,
763
+ "init_rotation_search_run_global": init_rotation_search_run_global,
764
+ "noreorientation": noreorientation,
765
+ "info": info,
766
+ "quiet": quiet,
767
+ "debug": debug,
768
+ "force": force,
769
+ "help": help_,
770
+ "version": version,
771
+ "image1_image2": image1_image2,
772
+ }
773
+ if type_ is not None:
774
+ params["type"] = type_
775
+ if transformed is not None:
776
+ params["transformed"] = transformed
777
+ if transformed_midway is not None:
778
+ params["transformed_midway"] = transformed_midway
779
+ if mask1 is not None:
780
+ params["mask1"] = mask1
781
+ if mask2 is not None:
782
+ params["mask2"] = mask2
783
+ if rigid is not None:
784
+ params["rigid"] = rigid
785
+ if rigid_1tomidway is not None:
786
+ params["rigid_1tomidway"] = rigid_1tomidway
787
+ if rigid_2tomidway is not None:
788
+ params["rigid_2tomidway"] = rigid_2tomidway
789
+ if rigid_init_translation is not None:
790
+ params["rigid_init_translation"] = rigid_init_translation
791
+ if rigid_init_rotation is not None:
792
+ params["rigid_init_rotation"] = rigid_init_rotation
793
+ if rigid_init_matrix is not None:
794
+ params["rigid_init_matrix"] = rigid_init_matrix
795
+ if rigid_scale is not None:
796
+ params["rigid_scale"] = rigid_scale
797
+ if rigid_niter is not None:
798
+ params["rigid_niter"] = rigid_niter
799
+ if rigid_metric is not None:
800
+ params["rigid_metric"] = rigid_metric
801
+ if rigid_metric_diff_estimator is not None:
802
+ params["rigid_metric_diff_estimator"] = rigid_metric_diff_estimator
803
+ if rigid_lmax is not None:
804
+ params["rigid_lmax"] = rigid_lmax
805
+ if rigid_log is not None:
806
+ params["rigid_log"] = rigid_log
807
+ if affine is not None:
808
+ params["affine"] = affine
809
+ if affine_1tomidway is not None:
810
+ params["affine_1tomidway"] = affine_1tomidway
811
+ if affine_2tomidway is not None:
812
+ params["affine_2tomidway"] = affine_2tomidway
813
+ if affine_init_translation is not None:
814
+ params["affine_init_translation"] = affine_init_translation
815
+ if affine_init_rotation is not None:
816
+ params["affine_init_rotation"] = affine_init_rotation
817
+ if affine_init_matrix is not None:
818
+ params["affine_init_matrix"] = affine_init_matrix
819
+ if affine_scale is not None:
820
+ params["affine_scale"] = affine_scale
821
+ if affine_niter is not None:
822
+ params["affine_niter"] = affine_niter
823
+ if affine_metric is not None:
824
+ params["affine_metric"] = affine_metric
825
+ if affine_metric_diff_estimator is not None:
826
+ params["affine_metric_diff_estimator"] = affine_metric_diff_estimator
827
+ if affine_lmax is not None:
828
+ params["affine_lmax"] = affine_lmax
829
+ if affine_log is not None:
830
+ params["affine_log"] = affine_log
831
+ if init_rotation_search_angles is not None:
832
+ params["init_rotation_search_angles"] = init_rotation_search_angles
833
+ if init_rotation_search_scale is not None:
834
+ params["init_rotation_search_scale"] = init_rotation_search_scale
835
+ if init_rotation_search_directions is not None:
836
+ params["init_rotation_search_directions"] = init_rotation_search_directions
837
+ if init_rotation_search_global_iterations is not None:
838
+ params["init_rotation_search_global_iterations"] = init_rotation_search_global_iterations
839
+ if linstage_iterations is not None:
840
+ params["linstage_iterations"] = linstage_iterations
841
+ if linstage_optimiser_first is not None:
842
+ params["linstage_optimiser_first"] = linstage_optimiser_first
843
+ if linstage_optimiser_last is not None:
844
+ params["linstage_optimiser_last"] = linstage_optimiser_last
845
+ if linstage_optimiser_default is not None:
846
+ params["linstage_optimiser_default"] = linstage_optimiser_default
847
+ if linstage_diagnostics_prefix is not None:
848
+ params["linstage_diagnostics_prefix"] = linstage_diagnostics_prefix
849
+ if nl_warp is not None:
850
+ params["nl_warp"] = nl_warp
851
+ if nl_warp_full is not None:
852
+ params["nl_warp_full"] = nl_warp_full
853
+ if nl_init is not None:
854
+ params["nl_init"] = nl_init
855
+ if nl_scale is not None:
856
+ params["nl_scale"] = nl_scale
857
+ if nl_niter is not None:
858
+ params["nl_niter"] = nl_niter
859
+ if nl_update_smooth is not None:
860
+ params["nl_update_smooth"] = nl_update_smooth
861
+ if nl_disp_smooth is not None:
862
+ params["nl_disp_smooth"] = nl_disp_smooth
863
+ if nl_grad_step is not None:
864
+ params["nl_grad_step"] = nl_grad_step
865
+ if nl_lmax is not None:
866
+ params["nl_lmax"] = nl_lmax
867
+ if diagnostics_image is not None:
868
+ params["diagnostics_image"] = diagnostics_image
869
+ if directions is not None:
870
+ params["directions"] = directions
871
+ if mc_weights is not None:
872
+ params["mc_weights"] = mc_weights
873
+ if datatype is not None:
874
+ params["datatype"] = datatype
875
+ if nthreads is not None:
876
+ params["nthreads"] = nthreads
877
+ if config is not None:
878
+ params["config"] = config
879
+ if contrast1_contrast2 is not None:
880
+ params["contrast1_contrast2"] = contrast1_contrast2
881
+ return params
882
+
883
+
884
+ def mrregister_cargs(
885
+ params: MrregisterParameters,
886
+ execution: Execution,
887
+ ) -> list[str]:
888
+ """
889
+ Build command-line arguments from parameters.
890
+
891
+ Args:
892
+ params: The parameters.
893
+ execution: The execution object for resolving input paths.
894
+ Returns:
895
+ Command-line arguments.
896
+ """
897
+ cargs = []
898
+ cargs.append("mrregister")
899
+ if params.get("type") is not None:
900
+ cargs.extend([
901
+ "-type",
902
+ params.get("type")
903
+ ])
904
+ if params.get("transformed") is not None:
905
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("transformed")] for a in c])
906
+ if params.get("transformed_midway") is not None:
907
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("transformed_midway")] for a in c])
908
+ if params.get("mask1") is not None:
909
+ cargs.extend([
910
+ "-mask1",
911
+ execution.input_file(params.get("mask1"))
912
+ ])
913
+ if params.get("mask2") is not None:
914
+ cargs.extend([
915
+ "-mask2",
916
+ execution.input_file(params.get("mask2"))
917
+ ])
918
+ if params.get("nan"):
919
+ cargs.append("-nan")
920
+ if params.get("rigid") is not None:
921
+ cargs.extend([
922
+ "-rigid",
923
+ params.get("rigid")
924
+ ])
925
+ if params.get("rigid_1tomidway") is not None:
926
+ cargs.extend([
927
+ "-rigid_1tomidway",
928
+ params.get("rigid_1tomidway")
929
+ ])
930
+ if params.get("rigid_2tomidway") is not None:
931
+ cargs.extend([
932
+ "-rigid_2tomidway",
933
+ params.get("rigid_2tomidway")
934
+ ])
935
+ if params.get("rigid_init_translation") is not None:
936
+ cargs.extend([
937
+ "-rigid_init_translation",
938
+ params.get("rigid_init_translation")
939
+ ])
940
+ if params.get("rigid_init_rotation") is not None:
941
+ cargs.extend([
942
+ "-rigid_init_rotation",
943
+ params.get("rigid_init_rotation")
944
+ ])
945
+ if params.get("rigid_init_matrix") is not None:
946
+ cargs.extend([
947
+ "-rigid_init_matrix",
948
+ execution.input_file(params.get("rigid_init_matrix"))
949
+ ])
950
+ if params.get("rigid_scale") is not None:
951
+ cargs.extend([
952
+ "-rigid_scale",
953
+ *map(str, params.get("rigid_scale"))
954
+ ])
955
+ if params.get("rigid_niter") is not None:
956
+ cargs.extend([
957
+ "-rigid_niter",
958
+ *map(str, params.get("rigid_niter"))
959
+ ])
960
+ if params.get("rigid_metric") is not None:
961
+ cargs.extend([
962
+ "-rigid_metric",
963
+ params.get("rigid_metric")
964
+ ])
965
+ if params.get("rigid_metric_diff_estimator") is not None:
966
+ cargs.extend([
967
+ "-rigid_metric.diff.estimator",
968
+ params.get("rigid_metric_diff_estimator")
969
+ ])
970
+ if params.get("rigid_lmax") is not None:
971
+ cargs.extend([
972
+ "-rigid_lmax",
973
+ *map(str, params.get("rigid_lmax"))
974
+ ])
975
+ if params.get("rigid_log") is not None:
976
+ cargs.extend([
977
+ "-rigid_log",
978
+ params.get("rigid_log")
979
+ ])
980
+ if params.get("affine") is not None:
981
+ cargs.extend([
982
+ "-affine",
983
+ params.get("affine")
984
+ ])
985
+ if params.get("affine_1tomidway") is not None:
986
+ cargs.extend([
987
+ "-affine_1tomidway",
988
+ params.get("affine_1tomidway")
989
+ ])
990
+ if params.get("affine_2tomidway") is not None:
991
+ cargs.extend([
992
+ "-affine_2tomidway",
993
+ params.get("affine_2tomidway")
994
+ ])
995
+ if params.get("affine_init_translation") is not None:
996
+ cargs.extend([
997
+ "-affine_init_translation",
998
+ params.get("affine_init_translation")
999
+ ])
1000
+ if params.get("affine_init_rotation") is not None:
1001
+ cargs.extend([
1002
+ "-affine_init_rotation",
1003
+ params.get("affine_init_rotation")
1004
+ ])
1005
+ if params.get("affine_init_matrix") is not None:
1006
+ cargs.extend([
1007
+ "-affine_init_matrix",
1008
+ execution.input_file(params.get("affine_init_matrix"))
1009
+ ])
1010
+ if params.get("affine_scale") is not None:
1011
+ cargs.extend([
1012
+ "-affine_scale",
1013
+ *map(str, params.get("affine_scale"))
1014
+ ])
1015
+ if params.get("affine_niter") is not None:
1016
+ cargs.extend([
1017
+ "-affine_niter",
1018
+ *map(str, params.get("affine_niter"))
1019
+ ])
1020
+ if params.get("affine_metric") is not None:
1021
+ cargs.extend([
1022
+ "-affine_metric",
1023
+ params.get("affine_metric")
1024
+ ])
1025
+ if params.get("affine_metric_diff_estimator") is not None:
1026
+ cargs.extend([
1027
+ "-affine_metric.diff.estimator",
1028
+ params.get("affine_metric_diff_estimator")
1029
+ ])
1030
+ if params.get("affine_lmax") is not None:
1031
+ cargs.extend([
1032
+ "-affine_lmax",
1033
+ *map(str, params.get("affine_lmax"))
1034
+ ])
1035
+ if params.get("affine_log") is not None:
1036
+ cargs.extend([
1037
+ "-affine_log",
1038
+ params.get("affine_log")
1039
+ ])
1040
+ if params.get("init_translation_unmasked1"):
1041
+ cargs.append("-init_translation.unmasked1")
1042
+ if params.get("init_translation_unmasked2"):
1043
+ cargs.append("-init_translation.unmasked2")
1044
+ if params.get("init_rotation_unmasked1"):
1045
+ cargs.append("-init_rotation.unmasked1")
1046
+ if params.get("init_rotation_unmasked2"):
1047
+ cargs.append("-init_rotation.unmasked2")
1048
+ if params.get("init_rotation_search_angles") is not None:
1049
+ cargs.extend([
1050
+ "-init_rotation.search.angles",
1051
+ *map(str, params.get("init_rotation_search_angles"))
1052
+ ])
1053
+ if params.get("init_rotation_search_scale") is not None:
1054
+ cargs.extend([
1055
+ "-init_rotation.search.scale",
1056
+ str(params.get("init_rotation_search_scale"))
1057
+ ])
1058
+ if params.get("init_rotation_search_directions") is not None:
1059
+ cargs.extend([
1060
+ "-init_rotation.search.directions",
1061
+ str(params.get("init_rotation_search_directions"))
1062
+ ])
1063
+ if params.get("init_rotation_search_run_global"):
1064
+ cargs.append("-init_rotation.search.run_global")
1065
+ if params.get("init_rotation_search_global_iterations") is not None:
1066
+ cargs.extend([
1067
+ "-init_rotation.search.global.iterations",
1068
+ str(params.get("init_rotation_search_global_iterations"))
1069
+ ])
1070
+ if params.get("linstage_iterations") is not None:
1071
+ cargs.extend([
1072
+ "-linstage.iterations",
1073
+ *map(str, params.get("linstage_iterations"))
1074
+ ])
1075
+ if params.get("linstage_optimiser_first") is not None:
1076
+ cargs.extend([
1077
+ "-linstage.optimiser.first",
1078
+ params.get("linstage_optimiser_first")
1079
+ ])
1080
+ if params.get("linstage_optimiser_last") is not None:
1081
+ cargs.extend([
1082
+ "-linstage.optimiser.last",
1083
+ params.get("linstage_optimiser_last")
1084
+ ])
1085
+ if params.get("linstage_optimiser_default") is not None:
1086
+ cargs.extend([
1087
+ "-linstage.optimiser.default",
1088
+ params.get("linstage_optimiser_default")
1089
+ ])
1090
+ if params.get("linstage_diagnostics_prefix") is not None:
1091
+ cargs.extend([
1092
+ "-linstage.diagnostics.prefix",
1093
+ params.get("linstage_diagnostics_prefix")
1094
+ ])
1095
+ if params.get("nl_warp") is not None:
1096
+ cargs.extend(dyn_cargs(params.get("nl_warp")["__STYXTYPE__"])(params.get("nl_warp"), execution))
1097
+ if params.get("nl_warp_full") is not None:
1098
+ cargs.extend([
1099
+ "-nl_warp_full",
1100
+ params.get("nl_warp_full")
1101
+ ])
1102
+ if params.get("nl_init") is not None:
1103
+ cargs.extend([
1104
+ "-nl_init",
1105
+ execution.input_file(params.get("nl_init"))
1106
+ ])
1107
+ if params.get("nl_scale") is not None:
1108
+ cargs.extend([
1109
+ "-nl_scale",
1110
+ *map(str, params.get("nl_scale"))
1111
+ ])
1112
+ if params.get("nl_niter") is not None:
1113
+ cargs.extend([
1114
+ "-nl_niter",
1115
+ *map(str, params.get("nl_niter"))
1116
+ ])
1117
+ if params.get("nl_update_smooth") is not None:
1118
+ cargs.extend([
1119
+ "-nl_update_smooth",
1120
+ str(params.get("nl_update_smooth"))
1121
+ ])
1122
+ if params.get("nl_disp_smooth") is not None:
1123
+ cargs.extend([
1124
+ "-nl_disp_smooth",
1125
+ str(params.get("nl_disp_smooth"))
1126
+ ])
1127
+ if params.get("nl_grad_step") is not None:
1128
+ cargs.extend([
1129
+ "-nl_grad_step",
1130
+ str(params.get("nl_grad_step"))
1131
+ ])
1132
+ if params.get("nl_lmax") is not None:
1133
+ cargs.extend([
1134
+ "-nl_lmax",
1135
+ *map(str, params.get("nl_lmax"))
1136
+ ])
1137
+ if params.get("diagnostics_image") is not None:
1138
+ cargs.extend([
1139
+ "-diagnostics_image",
1140
+ params.get("diagnostics_image")
1141
+ ])
1142
+ if params.get("directions") is not None:
1143
+ cargs.extend([
1144
+ "-directions",
1145
+ execution.input_file(params.get("directions"))
1146
+ ])
1147
+ if params.get("noreorientation"):
1148
+ cargs.append("-noreorientation")
1149
+ if params.get("mc_weights") is not None:
1150
+ cargs.extend([
1151
+ "-mc_weights",
1152
+ *map(str, params.get("mc_weights"))
1153
+ ])
1154
+ if params.get("datatype") is not None:
1155
+ cargs.extend([
1156
+ "-datatype",
1157
+ params.get("datatype")
1158
+ ])
1159
+ if params.get("info"):
1160
+ cargs.append("-info")
1161
+ if params.get("quiet"):
1162
+ cargs.append("-quiet")
1163
+ if params.get("debug"):
1164
+ cargs.append("-debug")
1165
+ if params.get("force"):
1166
+ cargs.append("-force")
1167
+ if params.get("nthreads") is not None:
1168
+ cargs.extend([
1169
+ "-nthreads",
1170
+ str(params.get("nthreads"))
1171
+ ])
1172
+ if params.get("config") is not None:
1173
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("config")] for a in c])
1174
+ if params.get("help"):
1175
+ cargs.append("-help")
1176
+ if params.get("version"):
1177
+ cargs.append("-version")
1178
+ cargs.append(execution.input_file(params.get("image1_image2")))
1179
+ if params.get("contrast1_contrast2") is not None:
1180
+ cargs.extend([execution.input_file(f) for f in params.get("contrast1_contrast2")])
1181
+ return cargs
1182
+
1183
+
1184
+ def mrregister_outputs(
1185
+ params: MrregisterParameters,
1186
+ execution: Execution,
1187
+ ) -> MrregisterOutputs:
1188
+ """
1189
+ Build outputs object containing output file paths and possibly stdout/stderr.
1190
+
1191
+ Args:
1192
+ params: The parameters.
1193
+ execution: The execution object for resolving input paths.
1194
+ Returns:
1195
+ Outputs object.
1196
+ """
1197
+ ret = MrregisterOutputs(
1198
+ root=execution.output_file("."),
1199
+ rigid=execution.output_file(params.get("rigid")) if (params.get("rigid") is not None) else None,
1200
+ rigid_1tomidway=execution.output_file(params.get("rigid_1tomidway")) if (params.get("rigid_1tomidway") is not None) else None,
1201
+ rigid_2tomidway=execution.output_file(params.get("rigid_2tomidway")) if (params.get("rigid_2tomidway") is not None) else None,
1202
+ rigid_log=execution.output_file(params.get("rigid_log")) if (params.get("rigid_log") is not None) else None,
1203
+ affine=execution.output_file(params.get("affine")) if (params.get("affine") is not None) else None,
1204
+ affine_1tomidway=execution.output_file(params.get("affine_1tomidway")) if (params.get("affine_1tomidway") is not None) else None,
1205
+ affine_2tomidway=execution.output_file(params.get("affine_2tomidway")) if (params.get("affine_2tomidway") is not None) else None,
1206
+ affine_log=execution.output_file(params.get("affine_log")) if (params.get("affine_log") is not None) else None,
1207
+ nl_warp_full=execution.output_file(params.get("nl_warp_full")) if (params.get("nl_warp_full") is not None) else None,
1208
+ transformed=[dyn_outputs(i["__STYXTYPE__"])(i, execution) if dyn_outputs(i["__STYXTYPE__"]) else None for i in params.get("transformed")] if params.get("transformed") else None,
1209
+ transformed_midway=[dyn_outputs(i["__STYXTYPE__"])(i, execution) if dyn_outputs(i["__STYXTYPE__"]) else None for i in params.get("transformed_midway")] if params.get("transformed_midway") else None,
1210
+ nl_warp=dyn_outputs(params.get("nl_warp")["__STYXTYPE__"])(params.get("nl_warp"), execution) if params.get("nl_warp") else None,
1211
+ )
1212
+ return ret
1213
+
1214
+
1215
+ def mrregister_execute(
1216
+ params: MrregisterParameters,
1217
+ execution: Execution,
1218
+ ) -> MrregisterOutputs:
1219
+ """
1220
+ Register two images together using a symmetric rigid, affine or non-linear
1221
+ transformation model.
1222
+
1223
+ By default this application will perform an affine, followed by non-linear
1224
+ registration.
1225
+
1226
+ FOD registration (with apodised point spread reorientation) will be
1227
+ performed by default if the number of volumes in the 4th dimension equals
1228
+ the number of coefficients in an antipodally symmetric spherical harmonic
1229
+ series (e.g. 6, 15, 28 etc). The -no_reorientation option can be used to
1230
+ force reorientation off if required.
1231
+
1232
+ Non-linear registration computes warps to map from both image1->image2 and
1233
+ image2->image1. Similar to Avants (2008) Med Image Anal. 12(1): 26–41,
1234
+ registration is performed by matching both the image1 and image2 in a
1235
+ 'midway space'. Warps can be saved as two deformation fields that map
1236
+ directly between image1->image2 and image2->image1, or if using
1237
+ -nl_warp_full as a single 5D file that stores all 4 warps
1238
+ image1->mid->image2, and image2->mid->image1. The 5D warp format stores
1239
+ x,y,z deformations in the 4th dimension, and uses the 5th dimension to index
1240
+ the 4 warps. The affine transforms estimated (to midway space) are also
1241
+ stored as comments in the image header. The 5D warp file can be used to
1242
+ reinitialise subsequent registrations, in addition to transforming images to
1243
+ midway space (e.g. for intra-subject alignment in a 2-time-point
1244
+ longitudinal analysis).
1245
+
1246
+ References:
1247
+
1248
+ * If FOD registration is being performed:
1249
+ Raffelt, D.; Tournier, J.-D.; Fripp, J; Crozier, S.; Connelly, A. & Salvado,
1250
+ O. Symmetric diffeomorphic registration of fibre orientation distributions.
1251
+ NeuroImage, 2011, 56(3), 1171-1180
1252
+
1253
+ Raffelt, D.; Tournier, J.-D.; Crozier, S.; Connelly, A. & Salvado, O.
1254
+ Reorientation of fiber orientation distributions using apodized point spread
1255
+ functions. Magnetic Resonance in Medicine, 2012, 67, 844-855.
1256
+
1257
+ Author: MRTrix3 Developers
1258
+
1259
+ URL: https://www.mrtrix.org/
1260
+
1261
+ Args:
1262
+ params: The parameters.
1263
+ execution: The execution object.
1264
+ Returns:
1265
+ NamedTuple of outputs (described in `MrregisterOutputs`).
1266
+ """
1267
+ params = execution.params(params)
1268
+ cargs = mrregister_cargs(params, execution)
1269
+ ret = mrregister_outputs(params, execution)
1270
+ execution.run(cargs)
1271
+ return ret
1272
+
1273
+
1274
+ def mrregister(
1275
+ image1_image2: InputPathType,
1276
+ type_: str | None = None,
1277
+ transformed: list[MrregisterTransformedParameters] | None = None,
1278
+ transformed_midway: list[MrregisterTransformedMidwayParameters] | None = None,
1279
+ mask1: InputPathType | None = None,
1280
+ mask2: InputPathType | None = None,
1281
+ nan: bool = False,
1282
+ rigid: str | None = None,
1283
+ rigid_1tomidway: str | None = None,
1284
+ rigid_2tomidway: str | None = None,
1285
+ rigid_init_translation: str | None = None,
1286
+ rigid_init_rotation: str | None = None,
1287
+ rigid_init_matrix: InputPathType | None = None,
1288
+ rigid_scale: list[float] | None = None,
1289
+ rigid_niter: list[int] | None = None,
1290
+ rigid_metric: str | None = None,
1291
+ rigid_metric_diff_estimator: str | None = None,
1292
+ rigid_lmax: list[int] | None = None,
1293
+ rigid_log: str | None = None,
1294
+ affine: str | None = None,
1295
+ affine_1tomidway: str | None = None,
1296
+ affine_2tomidway: str | None = None,
1297
+ affine_init_translation: str | None = None,
1298
+ affine_init_rotation: str | None = None,
1299
+ affine_init_matrix: InputPathType | None = None,
1300
+ affine_scale: list[float] | None = None,
1301
+ affine_niter: list[int] | None = None,
1302
+ affine_metric: str | None = None,
1303
+ affine_metric_diff_estimator: str | None = None,
1304
+ affine_lmax: list[int] | None = None,
1305
+ affine_log: str | None = None,
1306
+ init_translation_unmasked1: bool = False,
1307
+ init_translation_unmasked2: bool = False,
1308
+ init_rotation_unmasked1: bool = False,
1309
+ init_rotation_unmasked2: bool = False,
1310
+ init_rotation_search_angles: list[float] | None = None,
1311
+ init_rotation_search_scale: float | None = None,
1312
+ init_rotation_search_directions: int | None = None,
1313
+ init_rotation_search_run_global: bool = False,
1314
+ init_rotation_search_global_iterations: int | None = None,
1315
+ linstage_iterations: list[int] | None = None,
1316
+ linstage_optimiser_first: str | None = None,
1317
+ linstage_optimiser_last: str | None = None,
1318
+ linstage_optimiser_default: str | None = None,
1319
+ linstage_diagnostics_prefix: str | None = None,
1320
+ nl_warp: MrregisterNlWarpParameters | None = None,
1321
+ nl_warp_full: str | None = None,
1322
+ nl_init: InputPathType | None = None,
1323
+ nl_scale: list[float] | None = None,
1324
+ nl_niter: list[int] | None = None,
1325
+ nl_update_smooth: float | None = None,
1326
+ nl_disp_smooth: float | None = None,
1327
+ nl_grad_step: float | None = None,
1328
+ nl_lmax: list[int] | None = None,
1329
+ diagnostics_image: str | None = None,
1330
+ directions: InputPathType | None = None,
1331
+ noreorientation: bool = False,
1332
+ mc_weights: list[float] | None = None,
1333
+ datatype: str | None = None,
1334
+ info: bool = False,
1335
+ quiet: bool = False,
1336
+ debug: bool = False,
1337
+ force: bool = False,
1338
+ nthreads: int | None = None,
1339
+ config: list[MrregisterConfigParameters] | None = None,
1340
+ help_: bool = False,
1341
+ version: bool = False,
1342
+ contrast1_contrast2: list[InputPathType] | None = None,
1343
+ runner: Runner | None = None,
1344
+ ) -> MrregisterOutputs:
1345
+ """
1346
+ Register two images together using a symmetric rigid, affine or non-linear
1347
+ transformation model.
1348
+
1349
+ By default this application will perform an affine, followed by non-linear
1350
+ registration.
1351
+
1352
+ FOD registration (with apodised point spread reorientation) will be
1353
+ performed by default if the number of volumes in the 4th dimension equals
1354
+ the number of coefficients in an antipodally symmetric spherical harmonic
1355
+ series (e.g. 6, 15, 28 etc). The -no_reorientation option can be used to
1356
+ force reorientation off if required.
1357
+
1358
+ Non-linear registration computes warps to map from both image1->image2 and
1359
+ image2->image1. Similar to Avants (2008) Med Image Anal. 12(1): 26–41,
1360
+ registration is performed by matching both the image1 and image2 in a
1361
+ 'midway space'. Warps can be saved as two deformation fields that map
1362
+ directly between image1->image2 and image2->image1, or if using
1363
+ -nl_warp_full as a single 5D file that stores all 4 warps
1364
+ image1->mid->image2, and image2->mid->image1. The 5D warp format stores
1365
+ x,y,z deformations in the 4th dimension, and uses the 5th dimension to index
1366
+ the 4 warps. The affine transforms estimated (to midway space) are also
1367
+ stored as comments in the image header. The 5D warp file can be used to
1368
+ reinitialise subsequent registrations, in addition to transforming images to
1369
+ midway space (e.g. for intra-subject alignment in a 2-time-point
1370
+ longitudinal analysis).
1371
+
1372
+ References:
1373
+
1374
+ * If FOD registration is being performed:
1375
+ Raffelt, D.; Tournier, J.-D.; Fripp, J; Crozier, S.; Connelly, A. & Salvado,
1376
+ O. Symmetric diffeomorphic registration of fibre orientation distributions.
1377
+ NeuroImage, 2011, 56(3), 1171-1180
1378
+
1379
+ Raffelt, D.; Tournier, J.-D.; Crozier, S.; Connelly, A. & Salvado, O.
1380
+ Reorientation of fiber orientation distributions using apodized point spread
1381
+ functions. Magnetic Resonance in Medicine, 2012, 67, 844-855.
1382
+
1383
+ Author: MRTrix3 Developers
1384
+
1385
+ URL: https://www.mrtrix.org/
1386
+
1387
+ Args:
1388
+ image1_image2: input image 1 ('moving') and input image 2 ('template').
1389
+ type_: the registration type. Valid choices are: rigid, affine,\
1390
+ nonlinear, rigid_affine, rigid_nonlinear, affine_nonlinear,\
1391
+ rigid_affine_nonlinear (Default: affine_nonlinear).
1392
+ transformed: image1 after registration transformed and regridded to the\
1393
+ space of image2. Note that -transformed needs to be repeated for each\
1394
+ contrast if multi-contrast registration is used.
1395
+ transformed_midway: image1 and image2 after registration transformed\
1396
+ and regridded to the midway space. Note that -transformed_midway needs\
1397
+ to be repeated for each contrast if multi-contrast registration is\
1398
+ used.
1399
+ mask1: a mask to define the region of image1 to use for optimisation.
1400
+ mask2: a mask to define the region of image2 to use for optimisation.
1401
+ nan: use NaN as out of bounds value. (Default: 0.0).
1402
+ rigid: the output text file containing the rigid transformation as a\
1403
+ 4x4 matrix.
1404
+ rigid_1tomidway: the output text file containing the rigid\
1405
+ transformation that aligns image1 to image2 in their common midway\
1406
+ space as a 4x4 matrix.
1407
+ rigid_2tomidway: the output text file containing the rigid\
1408
+ transformation that aligns image2 to image1 in their common midway\
1409
+ space as a 4x4 matrix.
1410
+ rigid_init_translation: initialise the translation and centre of\
1411
+ rotation\
1412
+ Valid choices are:\
1413
+ mass (aligns the centers of mass of both images, default),\
1414
+ geometric (aligns geometric image centres) and none.
1415
+ rigid_init_rotation: initialise the rotation Valid choices are:\
1416
+ search (search for the best rotation using mean squared residuals),\
1417
+ moments (rotation based on directions of intensity variance with\
1418
+ respect to centre of mass),\
1419
+ none (default).
1420
+ rigid_init_matrix: initialise either the rigid, affine, or syn\
1421
+ registration with the supplied rigid transformation (as a 4x4 matrix in\
1422
+ scanner coordinates). Note that this overrides rigid_init_translation\
1423
+ and rigid_init_rotation initialisation.
1424
+ rigid_scale: use a multi-resolution scheme by defining a scale factor\
1425
+ for each level using comma separated values (Default: 0.25,0.5,1.0).
1426
+ rigid_niter: the maximum number of gradient descent iterations per\
1427
+ stage. This can be specified either as a single number for all\
1428
+ multi-resolution levels, or a single value for each level. (Default:\
1429
+ 1000).
1430
+ rigid_metric: valid choices are: diff (intensity differences), Default:\
1431
+ diff.
1432
+ rigid_metric_diff_estimator: Valid choices are: l1 (least absolute:\
1433
+ |x|), l2 (ordinary least squares), lp (least powers: |x|^1.2), Default:\
1434
+ l2.
1435
+ rigid_lmax: explicitly set the lmax to be used per scale factor in\
1436
+ rigid FOD registration. By default FOD registration will use lmax 0,2,4\
1437
+ with default scale factors 0.25,0.5,1.0 respectively. Note that no\
1438
+ reorientation will be performed with lmax = 0.
1439
+ rigid_log: write gradient descent parameter evolution to log file.
1440
+ affine: the output text file containing the affine transformation as a\
1441
+ 4x4 matrix.
1442
+ affine_1tomidway: the output text file containing the affine\
1443
+ transformation that aligns image1 to image2 in their common midway\
1444
+ space as a 4x4 matrix.
1445
+ affine_2tomidway: the output text file containing the affine\
1446
+ transformation that aligns image2 to image1 in their common midway\
1447
+ space as a 4x4 matrix.
1448
+ affine_init_translation: initialise the translation and centre of\
1449
+ rotation\
1450
+ Valid choices are:\
1451
+ mass (aligns the centers of mass of both images),\
1452
+ geometric (aligns geometric image centres) and none. (Default:\
1453
+ mass).
1454
+ affine_init_rotation: initialise the rotation Valid choices are:\
1455
+ search (search for the best rotation using mean squared residuals),\
1456
+ moments (rotation based on directions of intensity variance with\
1457
+ respect to centre of mass),\
1458
+ none (Default: none).
1459
+ affine_init_matrix: initialise either the affine, or syn registration\
1460
+ with the supplied affine transformation (as a 4x4 matrix in scanner\
1461
+ coordinates). Note that this overrides affine_init_translation and\
1462
+ affine_init_rotation initialisation.
1463
+ affine_scale: use a multi-resolution scheme by defining a scale factor\
1464
+ for each level using comma separated values (Default: 0.25,0.5,1.0).
1465
+ affine_niter: the maximum number of gradient descent iterations per\
1466
+ stage. This can be specified either as a single number for all\
1467
+ multi-resolution levels, or a single value for each level. (Default:\
1468
+ 1000).
1469
+ affine_metric: valid choices are: diff (intensity differences),\
1470
+ Default: diff.
1471
+ affine_metric_diff_estimator: Valid choices are: l1 (least absolute:\
1472
+ |x|), l2 (ordinary least squares), lp (least powers: |x|^1.2), Default:\
1473
+ l2.
1474
+ affine_lmax: explicitly set the lmax to be used per scale factor in\
1475
+ affine FOD registration. By default FOD registration will use lmax\
1476
+ 0,2,4 with default scale factors 0.25,0.5,1.0 respectively. Note that\
1477
+ no reorientation will be performed with lmax = 0.
1478
+ affine_log: write gradient descent parameter evolution to log file.
1479
+ init_translation_unmasked1: disregard mask1 for the translation\
1480
+ initialisation (affects 'mass').
1481
+ init_translation_unmasked2: disregard mask2 for the translation\
1482
+ initialisation (affects 'mass').
1483
+ init_rotation_unmasked1: disregard mask1 for the rotation\
1484
+ initialisation (affects 'search' and 'moments').
1485
+ init_rotation_unmasked2: disregard mask2 for the rotation\
1486
+ initialisation (affects 'search' and 'moments').
1487
+ init_rotation_search_angles: rotation angles for the local search in\
1488
+ degrees between 0 and 180. (Default: 2,5,10,15,20).
1489
+ init_rotation_search_scale: relative size of the images used for the\
1490
+ rotation search. (Default: 0.15).
1491
+ init_rotation_search_directions: number of rotation axis for local\
1492
+ search. (Default: 250).
1493
+ init_rotation_search_run_global: perform a global search. (Default:\
1494
+ local).
1495
+ init_rotation_search_global_iterations: number of rotations to\
1496
+ investigate (Default: 10000).
1497
+ linstage_iterations: number of iterations for each registration stage,\
1498
+ not to be confused with -rigid_niter or -affine_niter. This can be used\
1499
+ to generate intermediate diagnostics images\
1500
+ (-linstage.diagnostics.prefix) or to change the cost function optimiser\
1501
+ during registration (without the need to repeatedly resize the images).\
1502
+ (Default: 1 == no repetition).
1503
+ linstage_optimiser_first: Cost function optimisation algorithm to use\
1504
+ at first iteration of all stages. Valid choices: bbgd (Barzilai-Borwein\
1505
+ gradient descent) or gd (simple gradient descent). (Default: bbgd).
1506
+ linstage_optimiser_last: Cost function optimisation algorithm to use at\
1507
+ last iteration of all stages (if there are more than one). Valid\
1508
+ choices: bbgd (Barzilai-Borwein gradient descent) or gd (simple\
1509
+ gradient descent). (Default: bbgd).
1510
+ linstage_optimiser_default: Cost function optimisation algorithm to use\
1511
+ at any stage iteration other than first or last iteration. Valid\
1512
+ choices: bbgd (Barzilai-Borwein gradient descent) or gd (simple\
1513
+ gradient descent). (Default: bbgd).
1514
+ linstage_diagnostics_prefix: generate diagnostics images after every\
1515
+ registration stage.
1516
+ nl_warp: the non-linear warp output defined as two deformation fields,\
1517
+ where warp1 can be used to transform image1->image2 and warp2 to\
1518
+ transform image2->image1. The deformation fields also encapsulate any\
1519
+ linear transformation estimated prior to non-linear registration.
1520
+ nl_warp_full: output all warps used during registration. This saves\
1521
+ four different warps that map each image to a midway space and their\
1522
+ inverses in a single 5D image file. The 4th image dimension indexes the\
1523
+ x,y,z component of the deformation vector and the 5th dimension indexes\
1524
+ the field in this order: image1->midway, midway->image1,\
1525
+ image2->midway, midway->image2. Where image1->midway defines the field\
1526
+ that maps image1 onto the midway space using the reverse convention\
1527
+ When linear registration is performed first, the estimated linear\
1528
+ transform will be included in the comments of the image header, and\
1529
+ therefore the entire linear and non-linear transform can be applied (in\
1530
+ either direction) using this output warp file with mrtransform.
1531
+ nl_init: initialise the non-linear registration with the supplied warp\
1532
+ image. The supplied warp must be in the same format as output using the\
1533
+ -nl_warp_full option (i.e. have 4 deformation fields with the linear\
1534
+ transforms in the image header).
1535
+ nl_scale: use a multi-resolution scheme by defining a scale factor for\
1536
+ each level using comma separated values (Default: 0.25,0.5,1.0).
1537
+ nl_niter: the maximum number of iterations. This can be specified\
1538
+ either as a single number for all multi-resolution levels, or a single\
1539
+ value for each level. (Default: 50).
1540
+ nl_update_smooth: regularise the gradient update field with Gaussian\
1541
+ smoothing (standard deviation in voxel units, Default 2.0).
1542
+ nl_disp_smooth: regularise the displacement field with Gaussian\
1543
+ smoothing (standard deviation in voxel units, Default 1.0).
1544
+ nl_grad_step: the gradient step size for non-linear registration\
1545
+ (Default: 0.5).
1546
+ nl_lmax: explicitly set the lmax to be used per scale factor in\
1547
+ non-linear FOD registration. By default FOD registration will use lmax\
1548
+ 0,2,4 with default scale factors 0.25,0.5,1.0 respectively. Note that\
1549
+ no reorientation will be performed with lmax = 0.
1550
+ diagnostics_image: write intermediate images for diagnostics purposes.
1551
+ directions: the directions used for FOD reorientation using apodised\
1552
+ point spread functions (Default: 60 directions).
1553
+ noreorientation: turn off FOD reorientation. Reorientation is on by\
1554
+ default if the number of volumes in the 4th dimension corresponds to\
1555
+ the number of coefficients in an antipodally symmetric spherical\
1556
+ harmonic series (i.e. 6, 15, 28, 45, 66 etc).
1557
+ mc_weights: relative weight of images used for multi-contrast\
1558
+ registration. Default: 1.0 (equal weighting).
1559
+ datatype: specify output image data type. Valid choices are: float32,\
1560
+ float32le, float32be, float64, float64le, float64be, int64, uint64,\
1561
+ int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
1562
+ int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
1563
+ cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
1564
+ int8, uint8, bit.
1565
+ info: display information messages.
1566
+ quiet: do not display information messages or progress status;\
1567
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
1568
+ environment variable to a non-empty string.
1569
+ debug: display debugging messages.
1570
+ force: force overwrite of output files (caution: using the same file as\
1571
+ input and output might cause unexpected behaviour).
1572
+ nthreads: use this number of threads in multi-threaded applications\
1573
+ (set to 0 to disable multi-threading).
1574
+ config: temporarily set the value of an MRtrix config file entry.
1575
+ help_: display this information page and exit.
1576
+ version: display version information and exit.
1577
+ contrast1_contrast2: optional list of additional input images used as\
1578
+ additional contrasts. Can be used multiple times. contrastX and imageX\
1579
+ must share the same coordinate system.
1580
+ runner: Command runner.
1581
+ Returns:
1582
+ NamedTuple of outputs (described in `MrregisterOutputs`).
1583
+ """
1584
+ runner = runner or get_global_runner()
1585
+ execution = runner.start_execution(MRREGISTER_METADATA)
1586
+ params = mrregister_params(
1587
+ type_=type_,
1588
+ transformed=transformed,
1589
+ transformed_midway=transformed_midway,
1590
+ mask1=mask1,
1591
+ mask2=mask2,
1592
+ nan=nan,
1593
+ rigid=rigid,
1594
+ rigid_1tomidway=rigid_1tomidway,
1595
+ rigid_2tomidway=rigid_2tomidway,
1596
+ rigid_init_translation=rigid_init_translation,
1597
+ rigid_init_rotation=rigid_init_rotation,
1598
+ rigid_init_matrix=rigid_init_matrix,
1599
+ rigid_scale=rigid_scale,
1600
+ rigid_niter=rigid_niter,
1601
+ rigid_metric=rigid_metric,
1602
+ rigid_metric_diff_estimator=rigid_metric_diff_estimator,
1603
+ rigid_lmax=rigid_lmax,
1604
+ rigid_log=rigid_log,
1605
+ affine=affine,
1606
+ affine_1tomidway=affine_1tomidway,
1607
+ affine_2tomidway=affine_2tomidway,
1608
+ affine_init_translation=affine_init_translation,
1609
+ affine_init_rotation=affine_init_rotation,
1610
+ affine_init_matrix=affine_init_matrix,
1611
+ affine_scale=affine_scale,
1612
+ affine_niter=affine_niter,
1613
+ affine_metric=affine_metric,
1614
+ affine_metric_diff_estimator=affine_metric_diff_estimator,
1615
+ affine_lmax=affine_lmax,
1616
+ affine_log=affine_log,
1617
+ init_translation_unmasked1=init_translation_unmasked1,
1618
+ init_translation_unmasked2=init_translation_unmasked2,
1619
+ init_rotation_unmasked1=init_rotation_unmasked1,
1620
+ init_rotation_unmasked2=init_rotation_unmasked2,
1621
+ init_rotation_search_angles=init_rotation_search_angles,
1622
+ init_rotation_search_scale=init_rotation_search_scale,
1623
+ init_rotation_search_directions=init_rotation_search_directions,
1624
+ init_rotation_search_run_global=init_rotation_search_run_global,
1625
+ init_rotation_search_global_iterations=init_rotation_search_global_iterations,
1626
+ linstage_iterations=linstage_iterations,
1627
+ linstage_optimiser_first=linstage_optimiser_first,
1628
+ linstage_optimiser_last=linstage_optimiser_last,
1629
+ linstage_optimiser_default=linstage_optimiser_default,
1630
+ linstage_diagnostics_prefix=linstage_diagnostics_prefix,
1631
+ nl_warp=nl_warp,
1632
+ nl_warp_full=nl_warp_full,
1633
+ nl_init=nl_init,
1634
+ nl_scale=nl_scale,
1635
+ nl_niter=nl_niter,
1636
+ nl_update_smooth=nl_update_smooth,
1637
+ nl_disp_smooth=nl_disp_smooth,
1638
+ nl_grad_step=nl_grad_step,
1639
+ nl_lmax=nl_lmax,
1640
+ diagnostics_image=diagnostics_image,
1641
+ directions=directions,
1642
+ noreorientation=noreorientation,
1643
+ mc_weights=mc_weights,
1644
+ datatype=datatype,
1645
+ info=info,
1646
+ quiet=quiet,
1647
+ debug=debug,
1648
+ force=force,
1649
+ nthreads=nthreads,
1650
+ config=config,
1651
+ help_=help_,
1652
+ version=version,
1653
+ image1_image2=image1_image2,
1654
+ contrast1_contrast2=contrast1_contrast2,
1655
+ )
1656
+ return mrregister_execute(params, execution)
1657
+
1658
+
1659
+ __all__ = [
1660
+ "MRREGISTER_METADATA",
1661
+ "MrregisterConfigParameters",
1662
+ "MrregisterNlWarpOutputs",
1663
+ "MrregisterNlWarpParameters",
1664
+ "MrregisterOutputs",
1665
+ "MrregisterParameters",
1666
+ "MrregisterTransformedMidwayOutputs",
1667
+ "MrregisterTransformedMidwayParameters",
1668
+ "MrregisterTransformedOutputs",
1669
+ "MrregisterTransformedParameters",
1670
+ "mrregister",
1671
+ "mrregister_config_params",
1672
+ "mrregister_nl_warp_params",
1673
+ "mrregister_params",
1674
+ "mrregister_transformed_midway_params",
1675
+ "mrregister_transformed_params",
1676
+ ]