niwrap-mrtrix 0.8.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.
Files changed (119) hide show
  1. niwrap_mrtrix/mrtrix/__init__.py +263 -0
  2. niwrap_mrtrix/mrtrix/afdconnectivity.py +527 -0
  3. niwrap_mrtrix/mrtrix/amp2response.py +560 -0
  4. niwrap_mrtrix/mrtrix/amp2sh.py +870 -0
  5. niwrap_mrtrix/mrtrix/connectome2tck.py +583 -0
  6. niwrap_mrtrix/mrtrix/connectomeedit.py +413 -0
  7. niwrap_mrtrix/mrtrix/connectomestats.py +956 -0
  8. niwrap_mrtrix/mrtrix/dcmedit.py +552 -0
  9. niwrap_mrtrix/mrtrix/dcminfo.py +529 -0
  10. niwrap_mrtrix/mrtrix/dirflip.py +440 -0
  11. niwrap_mrtrix/mrtrix/dirgen.py +514 -0
  12. niwrap_mrtrix/mrtrix/dirmerge.py +446 -0
  13. niwrap_mrtrix/mrtrix/dirorder.py +421 -0
  14. niwrap_mrtrix/mrtrix/dirsplit.py +436 -0
  15. niwrap_mrtrix/mrtrix/dirstat.py +640 -0
  16. niwrap_mrtrix/mrtrix/dwi2adc.py +531 -0
  17. niwrap_mrtrix/mrtrix/dwi2fod.py +1156 -0
  18. niwrap_mrtrix/mrtrix/dwi2mask.py +570 -0
  19. niwrap_mrtrix/mrtrix/dwi2response.py +1774 -0
  20. niwrap_mrtrix/mrtrix/dwi2tensor.py +715 -0
  21. niwrap_mrtrix/mrtrix/dwibiascorrect.py +673 -0
  22. niwrap_mrtrix/mrtrix/dwidenoise.py +570 -0
  23. niwrap_mrtrix/mrtrix/dwiextract.py +1111 -0
  24. niwrap_mrtrix/mrtrix/dwigradcheck.py +665 -0
  25. niwrap_mrtrix/mrtrix/fixel2peaks.py +613 -0
  26. niwrap_mrtrix/mrtrix/fixel2sh.py +430 -0
  27. niwrap_mrtrix/mrtrix/fixel2tsf.py +435 -0
  28. niwrap_mrtrix/mrtrix/fixel2voxel.py +523 -0
  29. niwrap_mrtrix/mrtrix/fixelcfestats.py +1179 -0
  30. niwrap_mrtrix/mrtrix/fixelconnectivity.py +477 -0
  31. niwrap_mrtrix/mrtrix/fixelconvert.py +850 -0
  32. niwrap_mrtrix/mrtrix/fixelcorrespondence.py +455 -0
  33. niwrap_mrtrix/mrtrix/fixelcrop.py +422 -0
  34. niwrap_mrtrix/mrtrix/fixelfilter.py +882 -0
  35. niwrap_mrtrix/mrtrix/fixelreorient.py +435 -0
  36. niwrap_mrtrix/mrtrix/fod2dec.py +571 -0
  37. niwrap_mrtrix/mrtrix/fod2fixel.py +646 -0
  38. niwrap_mrtrix/mrtrix/label2colour.py +426 -0
  39. niwrap_mrtrix/mrtrix/label2mesh.py +417 -0
  40. niwrap_mrtrix/mrtrix/labelconvert.py +460 -0
  41. niwrap_mrtrix/mrtrix/labelstats.py +418 -0
  42. niwrap_mrtrix/mrtrix/maskdump.py +404 -0
  43. niwrap_mrtrix/mrtrix/maskfilter.py +730 -0
  44. niwrap_mrtrix/mrtrix/mesh2voxel.py +422 -0
  45. niwrap_mrtrix/mrtrix/meshconvert.py +514 -0
  46. niwrap_mrtrix/mrtrix/meshfilter.py +452 -0
  47. niwrap_mrtrix/mrtrix/mraverageheader.py +485 -0
  48. niwrap_mrtrix/mrtrix/mrcalc.py +4302 -0
  49. niwrap_mrtrix/mrtrix/mrcat.py +467 -0
  50. niwrap_mrtrix/mrtrix/mrcentroid.py +418 -0
  51. niwrap_mrtrix/mrtrix/mrcheckerboardmask.py +446 -0
  52. niwrap_mrtrix/mrtrix/mrclusterstats.py +930 -0
  53. niwrap_mrtrix/mrtrix/mrcolour.py +490 -0
  54. niwrap_mrtrix/mrtrix/mrconvert.py +1967 -0
  55. niwrap_mrtrix/mrtrix/mrdegibbs.py +535 -0
  56. niwrap_mrtrix/mrtrix/mrdump.py +423 -0
  57. niwrap_mrtrix/mrtrix/mredit.py +737 -0
  58. niwrap_mrtrix/mrtrix/mrfilter.py +971 -0
  59. niwrap_mrtrix/mrtrix/mrgrid.py +1079 -0
  60. niwrap_mrtrix/mrtrix/mrhistmatch.py +494 -0
  61. niwrap_mrtrix/mrtrix/mrhistogram.py +484 -0
  62. niwrap_mrtrix/mrtrix/mrinfo.py +1282 -0
  63. niwrap_mrtrix/mrtrix/mrmath.py +503 -0
  64. niwrap_mrtrix/mrtrix/mrmetric.py +525 -0
  65. niwrap_mrtrix/mrtrix/mrregister.py +2098 -0
  66. niwrap_mrtrix/mrtrix/mrstats.py +534 -0
  67. niwrap_mrtrix/mrtrix/mrthreshold.py +666 -0
  68. niwrap_mrtrix/mrtrix/mrtransform.py +1372 -0
  69. niwrap_mrtrix/mrtrix/mtnormalise.py +725 -0
  70. niwrap_mrtrix/mrtrix/peaks2amp.py +403 -0
  71. niwrap_mrtrix/mrtrix/peaks2fixel.py +422 -0
  72. niwrap_mrtrix/mrtrix/responsemean.py +385 -0
  73. niwrap_mrtrix/mrtrix/sh2amp.py +844 -0
  74. niwrap_mrtrix/mrtrix/sh2peaks.py +632 -0
  75. niwrap_mrtrix/mrtrix/sh2power.py +427 -0
  76. niwrap_mrtrix/mrtrix/sh2response.py +481 -0
  77. niwrap_mrtrix/mrtrix/shbasis.py +445 -0
  78. niwrap_mrtrix/mrtrix/shconv.py +661 -0
  79. niwrap_mrtrix/mrtrix/tck2connectome.py +727 -0
  80. niwrap_mrtrix/mrtrix/tck2fixel.py +447 -0
  81. niwrap_mrtrix/mrtrix/tckconvert.py +775 -0
  82. niwrap_mrtrix/mrtrix/tckdfc.py +684 -0
  83. niwrap_mrtrix/mrtrix/tckedit.py +1478 -0
  84. niwrap_mrtrix/mrtrix/tckgen.py +2733 -0
  85. niwrap_mrtrix/mrtrix/tckglobal.py +944 -0
  86. niwrap_mrtrix/mrtrix/tckinfo.py +402 -0
  87. niwrap_mrtrix/mrtrix/tckmap.py +1004 -0
  88. niwrap_mrtrix/mrtrix/tckresample.py +760 -0
  89. niwrap_mrtrix/mrtrix/tcksample.py +497 -0
  90. niwrap_mrtrix/mrtrix/tcksift.py +739 -0
  91. niwrap_mrtrix/mrtrix/tcksift2.py +902 -0
  92. niwrap_mrtrix/mrtrix/tckstats.py +550 -0
  93. niwrap_mrtrix/mrtrix/tcktransform.py +414 -0
  94. niwrap_mrtrix/mrtrix/tensor2metric.py +659 -0
  95. niwrap_mrtrix/mrtrix/transformcalc.py +421 -0
  96. niwrap_mrtrix/mrtrix/transformcompose.py +625 -0
  97. niwrap_mrtrix/mrtrix/transformconvert.py +423 -0
  98. niwrap_mrtrix/mrtrix/tsfdivide.py +414 -0
  99. niwrap_mrtrix/mrtrix/tsfinfo.py +421 -0
  100. niwrap_mrtrix/mrtrix/tsfmult.py +401 -0
  101. niwrap_mrtrix/mrtrix/tsfsmooth.py +420 -0
  102. niwrap_mrtrix/mrtrix/tsfthreshold.py +428 -0
  103. niwrap_mrtrix/mrtrix/tsfvalidate.py +398 -0
  104. niwrap_mrtrix/mrtrix/v_5tt2gmwmi.py +432 -0
  105. niwrap_mrtrix/mrtrix/v_5tt2vis.py +505 -0
  106. niwrap_mrtrix/mrtrix/v_5ttcheck.py +409 -0
  107. niwrap_mrtrix/mrtrix/v_5ttedit.py +513 -0
  108. niwrap_mrtrix/mrtrix/v_5ttgen.py +1107 -0
  109. niwrap_mrtrix/mrtrix/vectorstats.py +736 -0
  110. niwrap_mrtrix/mrtrix/voxel2fixel.py +430 -0
  111. niwrap_mrtrix/mrtrix/voxel2mesh.py +454 -0
  112. niwrap_mrtrix/mrtrix/warp2metric.py +556 -0
  113. niwrap_mrtrix/mrtrix/warpconvert.py +498 -0
  114. niwrap_mrtrix/mrtrix/warpcorrect.py +448 -0
  115. niwrap_mrtrix/mrtrix/warpinit.py +425 -0
  116. niwrap_mrtrix/mrtrix/warpinvert.py +448 -0
  117. niwrap_mrtrix-0.8.0.dist-info/METADATA +8 -0
  118. niwrap_mrtrix-0.8.0.dist-info/RECORD +119 -0
  119. niwrap_mrtrix-0.8.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,715 @@
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
+ DWI2TENSOR_METADATA = Metadata(
9
+ id="700cecd2ddde8992557eb31468df42097fa6e2b1.boutiques",
10
+ name="dwi2tensor",
11
+ package="mrtrix",
12
+ container_image_tag="mrtrix3/mrtrix3:3.0.4",
13
+ )
14
+
15
+
16
+ _Dwi2tensorFslgradParamsDictNoTag = typing.TypedDict('_Dwi2tensorFslgradParamsDictNoTag', {
17
+ "bvecs": InputPathType,
18
+ "bvals": InputPathType,
19
+ })
20
+ Dwi2tensorFslgradParamsDictTagged = typing.TypedDict('Dwi2tensorFslgradParamsDictTagged', {
21
+ "@type": typing.Literal["fslgrad"],
22
+ "bvecs": InputPathType,
23
+ "bvals": InputPathType,
24
+ })
25
+ Dwi2tensorFslgradParamsDict = _Dwi2tensorFslgradParamsDictNoTag | Dwi2tensorFslgradParamsDictTagged
26
+
27
+
28
+ _Dwi2tensorConfigParamsDictNoTag = typing.TypedDict('_Dwi2tensorConfigParamsDictNoTag', {
29
+ "key": str,
30
+ "value": str,
31
+ })
32
+ Dwi2tensorConfigParamsDictTagged = typing.TypedDict('Dwi2tensorConfigParamsDictTagged', {
33
+ "@type": typing.Literal["config"],
34
+ "key": str,
35
+ "value": str,
36
+ })
37
+ Dwi2tensorConfigParamsDict = _Dwi2tensorConfigParamsDictNoTag | Dwi2tensorConfigParamsDictTagged
38
+
39
+
40
+ _Dwi2tensorParamsDictNoTag = typing.TypedDict('_Dwi2tensorParamsDictNoTag', {
41
+ "ols": bool,
42
+ "mask": typing.NotRequired[InputPathType | None],
43
+ "b0": typing.NotRequired[str | None],
44
+ "dkt": typing.NotRequired[str | None],
45
+ "iter": typing.NotRequired[int | None],
46
+ "predicted_signal": typing.NotRequired[str | None],
47
+ "grad": typing.NotRequired[InputPathType | None],
48
+ "fslgrad": typing.NotRequired[Dwi2tensorFslgradParamsDict | None],
49
+ "info": bool,
50
+ "quiet": bool,
51
+ "debug": bool,
52
+ "force": bool,
53
+ "nthreads": typing.NotRequired[int | None],
54
+ "config": typing.NotRequired[list[Dwi2tensorConfigParamsDict] | None],
55
+ "help": bool,
56
+ "version": bool,
57
+ "dwi": InputPathType,
58
+ "dt": str,
59
+ })
60
+ Dwi2tensorParamsDictTagged = typing.TypedDict('Dwi2tensorParamsDictTagged', {
61
+ "@type": typing.Literal["mrtrix/dwi2tensor"],
62
+ "ols": bool,
63
+ "mask": typing.NotRequired[InputPathType | None],
64
+ "b0": typing.NotRequired[str | None],
65
+ "dkt": typing.NotRequired[str | None],
66
+ "iter": typing.NotRequired[int | None],
67
+ "predicted_signal": typing.NotRequired[str | None],
68
+ "grad": typing.NotRequired[InputPathType | None],
69
+ "fslgrad": typing.NotRequired[Dwi2tensorFslgradParamsDict | None],
70
+ "info": bool,
71
+ "quiet": bool,
72
+ "debug": bool,
73
+ "force": bool,
74
+ "nthreads": typing.NotRequired[int | None],
75
+ "config": typing.NotRequired[list[Dwi2tensorConfigParamsDict] | None],
76
+ "help": bool,
77
+ "version": bool,
78
+ "dwi": InputPathType,
79
+ "dt": str,
80
+ })
81
+ Dwi2tensorParamsDict = _Dwi2tensorParamsDictNoTag | Dwi2tensorParamsDictTagged
82
+
83
+
84
+ def dwi2tensor_fslgrad(
85
+ bvecs: InputPathType,
86
+ bvals: InputPathType,
87
+ ) -> Dwi2tensorFslgradParamsDictTagged:
88
+ """
89
+ Build parameters.
90
+
91
+ Args:
92
+ bvecs: Provide the diffusion-weighted gradient scheme used in the\
93
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
94
+ scheme is present in the input image header, the data provided with\
95
+ this option will be instead used.
96
+ bvals: Provide the diffusion-weighted gradient scheme used in the\
97
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
98
+ scheme is present in the input image header, the data provided with\
99
+ this option will be instead used.
100
+ Returns:
101
+ Parameter dictionary
102
+ """
103
+ params = {
104
+ "@type": "fslgrad",
105
+ "bvecs": bvecs,
106
+ "bvals": bvals,
107
+ }
108
+ return params
109
+
110
+
111
+ def dwi2tensor_fslgrad_validate(
112
+ params: typing.Any,
113
+ ) -> None:
114
+ """
115
+ Validate parameters. Throws an error if `params` is not a valid
116
+ `Dwi2tensorFslgradParamsDict` object.
117
+
118
+ Args:
119
+ params: The parameters object to validate.
120
+ """
121
+ if params is None or not isinstance(params, dict):
122
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
123
+ if params.get("bvecs", None) is None:
124
+ raise StyxValidationError("`bvecs` must not be None")
125
+ if not isinstance(params["bvecs"], (pathlib.Path, str)):
126
+ raise StyxValidationError(f'`bvecs` has the wrong type: Received `{type(params.get("bvecs", None))}` expected `InputPathType`')
127
+ if params.get("bvals", None) is None:
128
+ raise StyxValidationError("`bvals` must not be None")
129
+ if not isinstance(params["bvals"], (pathlib.Path, str)):
130
+ raise StyxValidationError(f'`bvals` has the wrong type: Received `{type(params.get("bvals", None))}` expected `InputPathType`')
131
+
132
+
133
+ def dwi2tensor_fslgrad_cargs(
134
+ params: Dwi2tensorFslgradParamsDict,
135
+ execution: Execution,
136
+ ) -> list[str]:
137
+ """
138
+ Build command-line arguments from parameters.
139
+
140
+ Args:
141
+ params: The parameters.
142
+ execution: The execution object for resolving input paths.
143
+ Returns:
144
+ Command-line arguments.
145
+ """
146
+ cargs = []
147
+ cargs.append("-fslgrad")
148
+ cargs.append(execution.input_file(params.get("bvecs", None)))
149
+ cargs.append(execution.input_file(params.get("bvals", None)))
150
+ return cargs
151
+
152
+
153
+ def dwi2tensor_config(
154
+ key: str,
155
+ value: str,
156
+ ) -> Dwi2tensorConfigParamsDictTagged:
157
+ """
158
+ Build parameters.
159
+
160
+ Args:
161
+ key: temporarily set the value of an MRtrix config file entry.
162
+ value: temporarily set the value of an MRtrix config file entry.
163
+ Returns:
164
+ Parameter dictionary
165
+ """
166
+ params = {
167
+ "@type": "config",
168
+ "key": key,
169
+ "value": value,
170
+ }
171
+ return params
172
+
173
+
174
+ def dwi2tensor_config_validate(
175
+ params: typing.Any,
176
+ ) -> None:
177
+ """
178
+ Validate parameters. Throws an error if `params` is not a valid
179
+ `Dwi2tensorConfigParamsDict` object.
180
+
181
+ Args:
182
+ params: The parameters object to validate.
183
+ """
184
+ if params is None or not isinstance(params, dict):
185
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
186
+ if params.get("key", None) is None:
187
+ raise StyxValidationError("`key` must not be None")
188
+ if not isinstance(params["key"], str):
189
+ raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
190
+ if params.get("value", None) is None:
191
+ raise StyxValidationError("`value` must not be None")
192
+ if not isinstance(params["value"], str):
193
+ raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')
194
+
195
+
196
+ def dwi2tensor_config_cargs(
197
+ params: Dwi2tensorConfigParamsDict,
198
+ execution: Execution,
199
+ ) -> list[str]:
200
+ """
201
+ Build command-line arguments from parameters.
202
+
203
+ Args:
204
+ params: The parameters.
205
+ execution: The execution object for resolving input paths.
206
+ Returns:
207
+ Command-line arguments.
208
+ """
209
+ cargs = []
210
+ cargs.append("-config")
211
+ cargs.append(params.get("key", None))
212
+ cargs.append(params.get("value", None))
213
+ return cargs
214
+
215
+
216
+ class Dwi2tensorOutputs(typing.NamedTuple):
217
+ """
218
+ Output object returned when calling `Dwi2tensorParamsDict(...)`.
219
+ """
220
+ root: OutputPathType
221
+ """Output root folder. This is the root folder for all outputs."""
222
+ dt: OutputPathType
223
+ """the output dt image."""
224
+ b0: OutputPathType | None
225
+ """the output b0 image. """
226
+ dkt: OutputPathType | None
227
+ """the output dkt image. """
228
+ predicted_signal: OutputPathType | None
229
+ """the predicted dwi image. """
230
+
231
+
232
+ def dwi2tensor_params(
233
+ dwi: InputPathType,
234
+ dt: str,
235
+ ols: bool = False,
236
+ mask: InputPathType | None = None,
237
+ b0: str | None = None,
238
+ dkt: str | None = None,
239
+ iter_: int | None = None,
240
+ predicted_signal: str | None = None,
241
+ grad: InputPathType | None = None,
242
+ fslgrad: Dwi2tensorFslgradParamsDict | None = None,
243
+ info: bool = False,
244
+ quiet: bool = False,
245
+ debug: bool = False,
246
+ force: bool = False,
247
+ nthreads: int | None = None,
248
+ config: list[Dwi2tensorConfigParamsDict] | None = None,
249
+ help_: bool = False,
250
+ version: bool = False,
251
+ ) -> Dwi2tensorParamsDictTagged:
252
+ """
253
+ Build parameters.
254
+
255
+ Args:
256
+ dwi: the input dwi image.
257
+ dt: the output dt image.
258
+ ols: perform initial fit using an ordinary least-squares (OLS) fit (see\
259
+ Description).
260
+ mask: only perform computation within the specified binary brain mask\
261
+ image.
262
+ b0: the output b0 image.
263
+ dkt: the output dkt image.
264
+ iter_: number of iterative reweightings for IWLS algorithm (default: 2)\
265
+ (see Description).
266
+ predicted_signal: the predicted dwi image.
267
+ grad: Provide the diffusion-weighted gradient scheme used in the\
268
+ acquisition in a text file. This should be supplied as a 4xN text file\
269
+ with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
270
+ the direction of the applied gradient, and b gives the b-value in units\
271
+ of s/mm^2. If a diffusion gradient scheme is present in the input image\
272
+ header, the data provided with this option will be instead used.
273
+ fslgrad: Provide the diffusion-weighted gradient scheme used in the\
274
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
275
+ scheme is present in the input image header, the data provided with\
276
+ this option will be instead used.
277
+ info: display information messages.
278
+ quiet: do not display information messages or progress status;\
279
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
280
+ environment variable to a non-empty string.
281
+ debug: display debugging messages.
282
+ force: force overwrite of output files (caution: using the same file as\
283
+ input and output might cause unexpected behaviour).
284
+ nthreads: use this number of threads in multi-threaded applications\
285
+ (set to 0 to disable multi-threading).
286
+ config: temporarily set the value of an MRtrix config file entry.
287
+ help_: display this information page and exit.
288
+ version: display version information and exit.
289
+ Returns:
290
+ Parameter dictionary
291
+ """
292
+ params = {
293
+ "@type": "mrtrix/dwi2tensor",
294
+ "ols": ols,
295
+ "info": info,
296
+ "quiet": quiet,
297
+ "debug": debug,
298
+ "force": force,
299
+ "help": help_,
300
+ "version": version,
301
+ "dwi": dwi,
302
+ "dt": dt,
303
+ }
304
+ if mask is not None:
305
+ params["mask"] = mask
306
+ if b0 is not None:
307
+ params["b0"] = b0
308
+ if dkt is not None:
309
+ params["dkt"] = dkt
310
+ if iter_ is not None:
311
+ params["iter"] = iter_
312
+ if predicted_signal is not None:
313
+ params["predicted_signal"] = predicted_signal
314
+ if grad is not None:
315
+ params["grad"] = grad
316
+ if fslgrad is not None:
317
+ params["fslgrad"] = fslgrad
318
+ if nthreads is not None:
319
+ params["nthreads"] = nthreads
320
+ if config is not None:
321
+ params["config"] = config
322
+ return params
323
+
324
+
325
+ def dwi2tensor_validate(
326
+ params: typing.Any,
327
+ ) -> None:
328
+ """
329
+ Validate parameters. Throws an error if `params` is not a valid
330
+ `Dwi2tensorParamsDict` object.
331
+
332
+ Args:
333
+ params: The parameters object to validate.
334
+ """
335
+ if params is None or not isinstance(params, dict):
336
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
337
+ if params.get("ols", False) is None:
338
+ raise StyxValidationError("`ols` must not be None")
339
+ if not isinstance(params["ols"], bool):
340
+ raise StyxValidationError(f'`ols` has the wrong type: Received `{type(params.get("ols", False))}` expected `bool`')
341
+ if params.get("mask", None) is not None:
342
+ if not isinstance(params["mask"], (pathlib.Path, str)):
343
+ raise StyxValidationError(f'`mask` has the wrong type: Received `{type(params.get("mask", None))}` expected `InputPathType | None`')
344
+ if params.get("b0", None) is not None:
345
+ if not isinstance(params["b0"], str):
346
+ raise StyxValidationError(f'`b0` has the wrong type: Received `{type(params.get("b0", None))}` expected `str | None`')
347
+ if params.get("dkt", None) is not None:
348
+ if not isinstance(params["dkt"], str):
349
+ raise StyxValidationError(f'`dkt` has the wrong type: Received `{type(params.get("dkt", None))}` expected `str | None`')
350
+ if params.get("iter", None) is not None:
351
+ if not isinstance(params["iter"], int):
352
+ raise StyxValidationError(f'`iter` has the wrong type: Received `{type(params.get("iter", None))}` expected `int | None`')
353
+ if params.get("predicted_signal", None) is not None:
354
+ if not isinstance(params["predicted_signal"], str):
355
+ raise StyxValidationError(f'`predicted_signal` has the wrong type: Received `{type(params.get("predicted_signal", None))}` expected `str | None`')
356
+ if params.get("grad", None) is not None:
357
+ if not isinstance(params["grad"], (pathlib.Path, str)):
358
+ raise StyxValidationError(f'`grad` has the wrong type: Received `{type(params.get("grad", None))}` expected `InputPathType | None`')
359
+ if params.get("fslgrad", None) is not None:
360
+ dwi2tensor_fslgrad_validate(params["fslgrad"])
361
+ if params.get("info", False) is None:
362
+ raise StyxValidationError("`info` must not be None")
363
+ if not isinstance(params["info"], bool):
364
+ raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
365
+ if params.get("quiet", False) is None:
366
+ raise StyxValidationError("`quiet` must not be None")
367
+ if not isinstance(params["quiet"], bool):
368
+ raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
369
+ if params.get("debug", False) is None:
370
+ raise StyxValidationError("`debug` must not be None")
371
+ if not isinstance(params["debug"], bool):
372
+ raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
373
+ if params.get("force", False) is None:
374
+ raise StyxValidationError("`force` must not be None")
375
+ if not isinstance(params["force"], bool):
376
+ raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
377
+ if params.get("nthreads", None) is not None:
378
+ if not isinstance(params["nthreads"], int):
379
+ raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
380
+ if params.get("config", None) is not None:
381
+ if not isinstance(params["config"], list):
382
+ raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[Dwi2tensorConfigParamsDict] | None`')
383
+ for e in params["config"]:
384
+ dwi2tensor_config_validate(e)
385
+ if params.get("help", False) is None:
386
+ raise StyxValidationError("`help` must not be None")
387
+ if not isinstance(params["help"], bool):
388
+ raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
389
+ if params.get("version", False) is None:
390
+ raise StyxValidationError("`version` must not be None")
391
+ if not isinstance(params["version"], bool):
392
+ raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
393
+ if params.get("dwi", None) is None:
394
+ raise StyxValidationError("`dwi` must not be None")
395
+ if not isinstance(params["dwi"], (pathlib.Path, str)):
396
+ raise StyxValidationError(f'`dwi` has the wrong type: Received `{type(params.get("dwi", None))}` expected `InputPathType`')
397
+ if params.get("dt", None) is None:
398
+ raise StyxValidationError("`dt` must not be None")
399
+ if not isinstance(params["dt"], str):
400
+ raise StyxValidationError(f'`dt` has the wrong type: Received `{type(params.get("dt", None))}` expected `str`')
401
+
402
+
403
+ def dwi2tensor_cargs(
404
+ params: Dwi2tensorParamsDict,
405
+ execution: Execution,
406
+ ) -> list[str]:
407
+ """
408
+ Build command-line arguments from parameters.
409
+
410
+ Args:
411
+ params: The parameters.
412
+ execution: The execution object for resolving input paths.
413
+ Returns:
414
+ Command-line arguments.
415
+ """
416
+ cargs = []
417
+ cargs.append("dwi2tensor")
418
+ if params.get("ols", False):
419
+ cargs.append("-ols")
420
+ if params.get("mask", None) is not None:
421
+ cargs.extend([
422
+ "-mask",
423
+ execution.input_file(params.get("mask", None))
424
+ ])
425
+ if params.get("b0", None) is not None:
426
+ cargs.extend([
427
+ "-b0",
428
+ params.get("b0", None)
429
+ ])
430
+ if params.get("dkt", None) is not None:
431
+ cargs.extend([
432
+ "-dkt",
433
+ params.get("dkt", None)
434
+ ])
435
+ if params.get("iter", None) is not None:
436
+ cargs.extend([
437
+ "-iter",
438
+ str(params.get("iter", None))
439
+ ])
440
+ if params.get("predicted_signal", None) is not None:
441
+ cargs.extend([
442
+ "-predicted_signal",
443
+ params.get("predicted_signal", None)
444
+ ])
445
+ if params.get("grad", None) is not None:
446
+ cargs.extend([
447
+ "-grad",
448
+ execution.input_file(params.get("grad", None))
449
+ ])
450
+ if params.get("fslgrad", None) is not None:
451
+ cargs.extend(dwi2tensor_fslgrad_cargs(params.get("fslgrad", None), execution))
452
+ if params.get("info", False):
453
+ cargs.append("-info")
454
+ if params.get("quiet", False):
455
+ cargs.append("-quiet")
456
+ if params.get("debug", False):
457
+ cargs.append("-debug")
458
+ if params.get("force", False):
459
+ cargs.append("-force")
460
+ if params.get("nthreads", None) is not None:
461
+ cargs.extend([
462
+ "-nthreads",
463
+ str(params.get("nthreads", None))
464
+ ])
465
+ if params.get("config", None) is not None:
466
+ cargs.extend([a for c in [dwi2tensor_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
467
+ if params.get("help", False):
468
+ cargs.append("-help")
469
+ if params.get("version", False):
470
+ cargs.append("-version")
471
+ cargs.append(execution.input_file(params.get("dwi", None)))
472
+ cargs.append(params.get("dt", None))
473
+ return cargs
474
+
475
+
476
+ def dwi2tensor_outputs(
477
+ params: Dwi2tensorParamsDict,
478
+ execution: Execution,
479
+ ) -> Dwi2tensorOutputs:
480
+ """
481
+ Build outputs object containing output file paths and possibly stdout/stderr.
482
+
483
+ Args:
484
+ params: The parameters.
485
+ execution: The execution object for resolving input paths.
486
+ Returns:
487
+ Outputs object.
488
+ """
489
+ ret = Dwi2tensorOutputs(
490
+ root=execution.output_file("."),
491
+ dt=execution.output_file(params.get("dt", None)),
492
+ b0=execution.output_file(params.get("b0", None)) if (params.get("b0") is not None) else None,
493
+ dkt=execution.output_file(params.get("dkt", None)) if (params.get("dkt") is not None) else None,
494
+ predicted_signal=execution.output_file(params.get("predicted_signal", None)) if (params.get("predicted_signal") is not None) else None,
495
+ )
496
+ return ret
497
+
498
+
499
+ def dwi2tensor_execute(
500
+ params: Dwi2tensorParamsDict,
501
+ runner: Runner | None = None,
502
+ ) -> Dwi2tensorOutputs:
503
+ """
504
+ dwi2tensor
505
+
506
+ Diffusion (kurtosis) tensor estimation.
507
+
508
+ By default, the diffusion tensor (and optionally its kurtosis) is fitted to
509
+ the log-signal in two steps: firstly, using weighted least-squares (WLS)
510
+ with weights based on the empirical signal intensities; secondly, by further
511
+ iterated weighted least-squares (IWLS) with weights determined by the signal
512
+ predictions from the previous iteration (by default, 2 iterations will be
513
+ performed). This behaviour can be altered in two ways:
514
+
515
+ * The -ols option will cause the first fitting step to be performed using
516
+ ordinary least-squares (OLS); that is, all measurements contribute equally
517
+ to the fit, instead of the default behaviour of weighting based on the
518
+ empirical signal intensities.
519
+
520
+ * The -iter option controls the number of iterations of the IWLS prodedure.
521
+ If this is set to zero, then the output model parameters will be those
522
+ resulting from the first fitting step only: either WLS by default, or OLS if
523
+ the -ols option is used in conjunction with -iter 0.
524
+
525
+ The tensor coefficients are stored in the output image as follows:
526
+ volumes 0-5: D11, D22, D33, D12, D13, D23
527
+
528
+ If diffusion kurtosis is estimated using the -dkt option, these are stored
529
+ as follows:
530
+ volumes 0-2: W1111, W2222, W3333
531
+ volumes 3-8: W1112, W1113, W1222, W1333, W2223, W2333
532
+ volumes 9-11: W1122, W1133, W2233
533
+ volumes 12-14: W1123, W1223, W1233
534
+
535
+ References:
536
+
537
+ References based on fitting algorithm used:
538
+
539
+ * OLS, WLS:
540
+ Basser, P.J.; Mattiello, J.; LeBihan, D. Estimation of the effective
541
+ self-diffusion tensor from the NMR spin echo. J Magn Reson B., 1994, 103,
542
+ 247–254.
543
+
544
+ * IWLS:
545
+ Veraart, J.; Sijbers, J.; Sunaert, S.; Leemans, A. & Jeurissen, B. Weighted
546
+ linear least squares estimation of diffusion MRI parameters: strengths,
547
+ limitations, and pitfalls. NeuroImage, 2013, 81, 335-346.
548
+
549
+ Author: MRTrix3 Developers
550
+
551
+ URL: https://www.mrtrix.org/
552
+
553
+ Args:
554
+ params: The parameters.
555
+ runner: Command runner.
556
+ Returns:
557
+ NamedTuple of outputs (described in `Dwi2tensorOutputs`).
558
+ """
559
+ dwi2tensor_validate(params)
560
+ runner = runner or get_global_runner()
561
+ execution = runner.start_execution(DWI2TENSOR_METADATA)
562
+ params = execution.params(params)
563
+ cargs = dwi2tensor_cargs(params, execution)
564
+ ret = dwi2tensor_outputs(params, execution)
565
+ execution.run(cargs)
566
+ return ret
567
+
568
+
569
+ def dwi2tensor(
570
+ dwi: InputPathType,
571
+ dt: str,
572
+ ols: bool = False,
573
+ mask: InputPathType | None = None,
574
+ b0: str | None = None,
575
+ dkt: str | None = None,
576
+ iter_: int | None = None,
577
+ predicted_signal: str | None = None,
578
+ grad: InputPathType | None = None,
579
+ fslgrad: Dwi2tensorFslgradParamsDict | None = None,
580
+ info: bool = False,
581
+ quiet: bool = False,
582
+ debug: bool = False,
583
+ force: bool = False,
584
+ nthreads: int | None = None,
585
+ config: list[Dwi2tensorConfigParamsDict] | None = None,
586
+ help_: bool = False,
587
+ version: bool = False,
588
+ runner: Runner | None = None,
589
+ ) -> Dwi2tensorOutputs:
590
+ """
591
+ dwi2tensor
592
+
593
+ Diffusion (kurtosis) tensor estimation.
594
+
595
+ By default, the diffusion tensor (and optionally its kurtosis) is fitted to
596
+ the log-signal in two steps: firstly, using weighted least-squares (WLS)
597
+ with weights based on the empirical signal intensities; secondly, by further
598
+ iterated weighted least-squares (IWLS) with weights determined by the signal
599
+ predictions from the previous iteration (by default, 2 iterations will be
600
+ performed). This behaviour can be altered in two ways:
601
+
602
+ * The -ols option will cause the first fitting step to be performed using
603
+ ordinary least-squares (OLS); that is, all measurements contribute equally
604
+ to the fit, instead of the default behaviour of weighting based on the
605
+ empirical signal intensities.
606
+
607
+ * The -iter option controls the number of iterations of the IWLS prodedure.
608
+ If this is set to zero, then the output model parameters will be those
609
+ resulting from the first fitting step only: either WLS by default, or OLS if
610
+ the -ols option is used in conjunction with -iter 0.
611
+
612
+ The tensor coefficients are stored in the output image as follows:
613
+ volumes 0-5: D11, D22, D33, D12, D13, D23
614
+
615
+ If diffusion kurtosis is estimated using the -dkt option, these are stored
616
+ as follows:
617
+ volumes 0-2: W1111, W2222, W3333
618
+ volumes 3-8: W1112, W1113, W1222, W1333, W2223, W2333
619
+ volumes 9-11: W1122, W1133, W2233
620
+ volumes 12-14: W1123, W1223, W1233
621
+
622
+ References:
623
+
624
+ References based on fitting algorithm used:
625
+
626
+ * OLS, WLS:
627
+ Basser, P.J.; Mattiello, J.; LeBihan, D. Estimation of the effective
628
+ self-diffusion tensor from the NMR spin echo. J Magn Reson B., 1994, 103,
629
+ 247–254.
630
+
631
+ * IWLS:
632
+ Veraart, J.; Sijbers, J.; Sunaert, S.; Leemans, A. & Jeurissen, B. Weighted
633
+ linear least squares estimation of diffusion MRI parameters: strengths,
634
+ limitations, and pitfalls. NeuroImage, 2013, 81, 335-346.
635
+
636
+ Author: MRTrix3 Developers
637
+
638
+ URL: https://www.mrtrix.org/
639
+
640
+ Args:
641
+ dwi: the input dwi image.
642
+ dt: the output dt image.
643
+ ols: perform initial fit using an ordinary least-squares (OLS) fit (see\
644
+ Description).
645
+ mask: only perform computation within the specified binary brain mask\
646
+ image.
647
+ b0: the output b0 image.
648
+ dkt: the output dkt image.
649
+ iter_: number of iterative reweightings for IWLS algorithm (default: 2)\
650
+ (see Description).
651
+ predicted_signal: the predicted dwi image.
652
+ grad: Provide the diffusion-weighted gradient scheme used in the\
653
+ acquisition in a text file. This should be supplied as a 4xN text file\
654
+ with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
655
+ the direction of the applied gradient, and b gives the b-value in units\
656
+ of s/mm^2. If a diffusion gradient scheme is present in the input image\
657
+ header, the data provided with this option will be instead used.
658
+ fslgrad: Provide the diffusion-weighted gradient scheme used in the\
659
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
660
+ scheme is present in the input image header, the data provided with\
661
+ this option will be instead used.
662
+ info: display information messages.
663
+ quiet: do not display information messages or progress status;\
664
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
665
+ environment variable to a non-empty string.
666
+ debug: display debugging messages.
667
+ force: force overwrite of output files (caution: using the same file as\
668
+ input and output might cause unexpected behaviour).
669
+ nthreads: use this number of threads in multi-threaded applications\
670
+ (set to 0 to disable multi-threading).
671
+ config: temporarily set the value of an MRtrix config file entry.
672
+ help_: display this information page and exit.
673
+ version: display version information and exit.
674
+ runner: Command runner.
675
+ Returns:
676
+ NamedTuple of outputs (described in `Dwi2tensorOutputs`).
677
+ """
678
+ params = dwi2tensor_params(
679
+ ols=ols,
680
+ mask=mask,
681
+ b0=b0,
682
+ dkt=dkt,
683
+ iter_=iter_,
684
+ predicted_signal=predicted_signal,
685
+ grad=grad,
686
+ fslgrad=fslgrad,
687
+ info=info,
688
+ quiet=quiet,
689
+ debug=debug,
690
+ force=force,
691
+ nthreads=nthreads,
692
+ config=config,
693
+ help_=help_,
694
+ version=version,
695
+ dwi=dwi,
696
+ dt=dt,
697
+ )
698
+ return dwi2tensor_execute(params, runner)
699
+
700
+
701
+ __all__ = [
702
+ "DWI2TENSOR_METADATA",
703
+ "Dwi2tensorConfigParamsDict",
704
+ "Dwi2tensorConfigParamsDictTagged",
705
+ "Dwi2tensorFslgradParamsDict",
706
+ "Dwi2tensorFslgradParamsDictTagged",
707
+ "Dwi2tensorOutputs",
708
+ "Dwi2tensorParamsDict",
709
+ "Dwi2tensorParamsDictTagged",
710
+ "dwi2tensor",
711
+ "dwi2tensor_config",
712
+ "dwi2tensor_execute",
713
+ "dwi2tensor_fslgrad",
714
+ "dwi2tensor_params",
715
+ ]