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,1156 @@
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
+ DWI2FOD_METADATA = Metadata(
9
+ id="6d16386fcfa6e4701ad68f4333de7173683fda45.boutiques",
10
+ name="dwi2fod",
11
+ package="mrtrix",
12
+ container_image_tag="mrtrix3/mrtrix3:3.0.4",
13
+ )
14
+
15
+
16
+ _Dwi2fodFslgradParamsDictNoTag = typing.TypedDict('_Dwi2fodFslgradParamsDictNoTag', {
17
+ "bvecs": InputPathType,
18
+ "bvals": InputPathType,
19
+ })
20
+ Dwi2fodFslgradParamsDictTagged = typing.TypedDict('Dwi2fodFslgradParamsDictTagged', {
21
+ "@type": typing.Literal["fslgrad"],
22
+ "bvecs": InputPathType,
23
+ "bvals": InputPathType,
24
+ })
25
+ Dwi2fodFslgradParamsDict = _Dwi2fodFslgradParamsDictNoTag | Dwi2fodFslgradParamsDictTagged
26
+
27
+
28
+ _Dwi2fodVariousStringParamsDictNoTag = typing.TypedDict('_Dwi2fodVariousStringParamsDictNoTag', {
29
+ "obj": str,
30
+ })
31
+ Dwi2fodVariousStringParamsDictTagged = typing.TypedDict('Dwi2fodVariousStringParamsDictTagged', {
32
+ "@type": typing.Literal["VariousString"],
33
+ "obj": str,
34
+ })
35
+ Dwi2fodVariousStringParamsDict = _Dwi2fodVariousStringParamsDictNoTag | Dwi2fodVariousStringParamsDictTagged
36
+
37
+
38
+ _Dwi2fodVariousFileParamsDictNoTag = typing.TypedDict('_Dwi2fodVariousFileParamsDictNoTag', {
39
+ "obj": InputPathType,
40
+ })
41
+ Dwi2fodVariousFileParamsDictTagged = typing.TypedDict('Dwi2fodVariousFileParamsDictTagged', {
42
+ "@type": typing.Literal["VariousFile"],
43
+ "obj": InputPathType,
44
+ })
45
+ Dwi2fodVariousFileParamsDict = _Dwi2fodVariousFileParamsDictNoTag | Dwi2fodVariousFileParamsDictTagged
46
+
47
+
48
+ _Dwi2fodConfigParamsDictNoTag = typing.TypedDict('_Dwi2fodConfigParamsDictNoTag', {
49
+ "key": str,
50
+ "value": str,
51
+ })
52
+ Dwi2fodConfigParamsDictTagged = typing.TypedDict('Dwi2fodConfigParamsDictTagged', {
53
+ "@type": typing.Literal["config"],
54
+ "key": str,
55
+ "value": str,
56
+ })
57
+ Dwi2fodConfigParamsDict = _Dwi2fodConfigParamsDictNoTag | Dwi2fodConfigParamsDictTagged
58
+
59
+
60
+ _Dwi2fodResponseOdfParamsDictNoTag = typing.TypedDict('_Dwi2fodResponseOdfParamsDictNoTag', {
61
+ "response": InputPathType,
62
+ "odf": str,
63
+ })
64
+ Dwi2fodResponseOdfParamsDictTagged = typing.TypedDict('Dwi2fodResponseOdfParamsDictTagged', {
65
+ "@type": typing.Literal["response_odf"],
66
+ "response": InputPathType,
67
+ "odf": str,
68
+ })
69
+ Dwi2fodResponseOdfParamsDict = _Dwi2fodResponseOdfParamsDictNoTag | Dwi2fodResponseOdfParamsDictTagged
70
+
71
+
72
+ _Dwi2fodParamsDictNoTag = typing.TypedDict('_Dwi2fodParamsDictNoTag', {
73
+ "grad": typing.NotRequired[InputPathType | None],
74
+ "fslgrad": typing.NotRequired[Dwi2fodFslgradParamsDict | None],
75
+ "shells": typing.NotRequired[list[float] | None],
76
+ "directions": typing.NotRequired[InputPathType | None],
77
+ "lmax": typing.NotRequired[list[int] | None],
78
+ "mask": typing.NotRequired[InputPathType | None],
79
+ "filter": typing.NotRequired[InputPathType | None],
80
+ "neg_lambda": typing.NotRequired[float | None],
81
+ "norm_lambda": typing.NotRequired[float | None],
82
+ "threshold": typing.NotRequired[float | None],
83
+ "niter": typing.NotRequired[int | None],
84
+ "norm_lambda_1": typing.NotRequired[float | None],
85
+ "neg_lambda_1": typing.NotRequired[float | None],
86
+ "predicted_signal": typing.NotRequired[str | None],
87
+ "strides": typing.NotRequired[typing.Union[Dwi2fodVariousStringParamsDictTagged, Dwi2fodVariousFileParamsDictTagged] | None],
88
+ "info": bool,
89
+ "quiet": bool,
90
+ "debug": bool,
91
+ "force": bool,
92
+ "nthreads": typing.NotRequired[int | None],
93
+ "config": typing.NotRequired[list[Dwi2fodConfigParamsDict] | None],
94
+ "help": bool,
95
+ "version": bool,
96
+ "algorithm": str,
97
+ "dwi": InputPathType,
98
+ "response_odf": list[Dwi2fodResponseOdfParamsDict],
99
+ })
100
+ Dwi2fodParamsDictTagged = typing.TypedDict('Dwi2fodParamsDictTagged', {
101
+ "@type": typing.Literal["mrtrix/dwi2fod"],
102
+ "grad": typing.NotRequired[InputPathType | None],
103
+ "fslgrad": typing.NotRequired[Dwi2fodFslgradParamsDict | None],
104
+ "shells": typing.NotRequired[list[float] | None],
105
+ "directions": typing.NotRequired[InputPathType | None],
106
+ "lmax": typing.NotRequired[list[int] | None],
107
+ "mask": typing.NotRequired[InputPathType | None],
108
+ "filter": typing.NotRequired[InputPathType | None],
109
+ "neg_lambda": typing.NotRequired[float | None],
110
+ "norm_lambda": typing.NotRequired[float | None],
111
+ "threshold": typing.NotRequired[float | None],
112
+ "niter": typing.NotRequired[int | None],
113
+ "norm_lambda_1": typing.NotRequired[float | None],
114
+ "neg_lambda_1": typing.NotRequired[float | None],
115
+ "predicted_signal": typing.NotRequired[str | None],
116
+ "strides": typing.NotRequired[typing.Union[Dwi2fodVariousStringParamsDictTagged, Dwi2fodVariousFileParamsDictTagged] | None],
117
+ "info": bool,
118
+ "quiet": bool,
119
+ "debug": bool,
120
+ "force": bool,
121
+ "nthreads": typing.NotRequired[int | None],
122
+ "config": typing.NotRequired[list[Dwi2fodConfigParamsDict] | None],
123
+ "help": bool,
124
+ "version": bool,
125
+ "algorithm": str,
126
+ "dwi": InputPathType,
127
+ "response_odf": list[Dwi2fodResponseOdfParamsDict],
128
+ })
129
+ Dwi2fodParamsDict = _Dwi2fodParamsDictNoTag | Dwi2fodParamsDictTagged
130
+
131
+
132
+ def dwi2fod_strides_cargs_dyn_fn(
133
+ t: str,
134
+ ) -> typing.Any:
135
+ """
136
+ Get build cargs function by command type.
137
+
138
+ Args:
139
+ t: Command type.
140
+ Returns:
141
+ Build cargs function.
142
+ """
143
+ return {
144
+ "VariousString": dwi2fod_various_string_cargs,
145
+ "VariousFile": dwi2fod_various_file_cargs,
146
+ }.get(t)
147
+
148
+
149
+ def dwi2fod_strides_validate_dyn_fn(
150
+ t: str,
151
+ ) -> typing.Any:
152
+ """
153
+ Get validate params function by command type.
154
+
155
+ Args:
156
+ t: Command type.
157
+ Returns:
158
+ Validate params function.
159
+ """
160
+ return {
161
+ "VariousString": dwi2fod_various_string_validate,
162
+ "VariousFile": dwi2fod_various_file_validate,
163
+ }.get(t)
164
+
165
+
166
+ def dwi2fod_fslgrad(
167
+ bvecs: InputPathType,
168
+ bvals: InputPathType,
169
+ ) -> Dwi2fodFslgradParamsDictTagged:
170
+ """
171
+ Build parameters.
172
+
173
+ Args:
174
+ bvecs: Provide the diffusion-weighted gradient scheme used in the\
175
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
176
+ scheme is present in the input image header, the data provided with\
177
+ this option will be instead used.
178
+ bvals: Provide the diffusion-weighted gradient scheme used in the\
179
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
180
+ scheme is present in the input image header, the data provided with\
181
+ this option will be instead used.
182
+ Returns:
183
+ Parameter dictionary
184
+ """
185
+ params = {
186
+ "@type": "fslgrad",
187
+ "bvecs": bvecs,
188
+ "bvals": bvals,
189
+ }
190
+ return params
191
+
192
+
193
+ def dwi2fod_fslgrad_validate(
194
+ params: typing.Any,
195
+ ) -> None:
196
+ """
197
+ Validate parameters. Throws an error if `params` is not a valid
198
+ `Dwi2fodFslgradParamsDict` object.
199
+
200
+ Args:
201
+ params: The parameters object to validate.
202
+ """
203
+ if params is None or not isinstance(params, dict):
204
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
205
+ if params.get("bvecs", None) is None:
206
+ raise StyxValidationError("`bvecs` must not be None")
207
+ if not isinstance(params["bvecs"], (pathlib.Path, str)):
208
+ raise StyxValidationError(f'`bvecs` has the wrong type: Received `{type(params.get("bvecs", None))}` expected `InputPathType`')
209
+ if params.get("bvals", None) is None:
210
+ raise StyxValidationError("`bvals` must not be None")
211
+ if not isinstance(params["bvals"], (pathlib.Path, str)):
212
+ raise StyxValidationError(f'`bvals` has the wrong type: Received `{type(params.get("bvals", None))}` expected `InputPathType`')
213
+
214
+
215
+ def dwi2fod_fslgrad_cargs(
216
+ params: Dwi2fodFslgradParamsDict,
217
+ execution: Execution,
218
+ ) -> list[str]:
219
+ """
220
+ Build command-line arguments from parameters.
221
+
222
+ Args:
223
+ params: The parameters.
224
+ execution: The execution object for resolving input paths.
225
+ Returns:
226
+ Command-line arguments.
227
+ """
228
+ cargs = []
229
+ cargs.append("-fslgrad")
230
+ cargs.append(execution.input_file(params.get("bvecs", None)))
231
+ cargs.append(execution.input_file(params.get("bvals", None)))
232
+ return cargs
233
+
234
+
235
+ def dwi2fod_various_string(
236
+ obj: str,
237
+ ) -> Dwi2fodVariousStringParamsDictTagged:
238
+ """
239
+ Build parameters.
240
+
241
+ Args:
242
+ obj: String object.
243
+ Returns:
244
+ Parameter dictionary
245
+ """
246
+ params = {
247
+ "@type": "VariousString",
248
+ "obj": obj,
249
+ }
250
+ return params
251
+
252
+
253
+ def dwi2fod_various_string_validate(
254
+ params: typing.Any,
255
+ ) -> None:
256
+ """
257
+ Validate parameters. Throws an error if `params` is not a valid
258
+ `Dwi2fodVariousStringParamsDict` object.
259
+
260
+ Args:
261
+ params: The parameters object to validate.
262
+ """
263
+ if params is None or not isinstance(params, dict):
264
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
265
+ if params.get("obj", None) is None:
266
+ raise StyxValidationError("`obj` must not be None")
267
+ if not isinstance(params["obj"], str):
268
+ raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `str`')
269
+
270
+
271
+ def dwi2fod_various_string_cargs(
272
+ params: Dwi2fodVariousStringParamsDict,
273
+ execution: Execution,
274
+ ) -> list[str]:
275
+ """
276
+ Build command-line arguments from parameters.
277
+
278
+ Args:
279
+ params: The parameters.
280
+ execution: The execution object for resolving input paths.
281
+ Returns:
282
+ Command-line arguments.
283
+ """
284
+ cargs = []
285
+ cargs.append(params.get("obj", None))
286
+ return cargs
287
+
288
+
289
+ def dwi2fod_various_file(
290
+ obj: InputPathType,
291
+ ) -> Dwi2fodVariousFileParamsDictTagged:
292
+ """
293
+ Build parameters.
294
+
295
+ Args:
296
+ obj: File object.
297
+ Returns:
298
+ Parameter dictionary
299
+ """
300
+ params = {
301
+ "@type": "VariousFile",
302
+ "obj": obj,
303
+ }
304
+ return params
305
+
306
+
307
+ def dwi2fod_various_file_validate(
308
+ params: typing.Any,
309
+ ) -> None:
310
+ """
311
+ Validate parameters. Throws an error if `params` is not a valid
312
+ `Dwi2fodVariousFileParamsDict` object.
313
+
314
+ Args:
315
+ params: The parameters object to validate.
316
+ """
317
+ if params is None or not isinstance(params, dict):
318
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
319
+ if params.get("obj", None) is None:
320
+ raise StyxValidationError("`obj` must not be None")
321
+ if not isinstance(params["obj"], (pathlib.Path, str)):
322
+ raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `InputPathType`')
323
+
324
+
325
+ def dwi2fod_various_file_cargs(
326
+ params: Dwi2fodVariousFileParamsDict,
327
+ execution: Execution,
328
+ ) -> list[str]:
329
+ """
330
+ Build command-line arguments from parameters.
331
+
332
+ Args:
333
+ params: The parameters.
334
+ execution: The execution object for resolving input paths.
335
+ Returns:
336
+ Command-line arguments.
337
+ """
338
+ cargs = []
339
+ cargs.append(execution.input_file(params.get("obj", None)))
340
+ return cargs
341
+
342
+
343
+ def dwi2fod_config(
344
+ key: str,
345
+ value: str,
346
+ ) -> Dwi2fodConfigParamsDictTagged:
347
+ """
348
+ Build parameters.
349
+
350
+ Args:
351
+ key: temporarily set the value of an MRtrix config file entry.
352
+ value: temporarily set the value of an MRtrix config file entry.
353
+ Returns:
354
+ Parameter dictionary
355
+ """
356
+ params = {
357
+ "@type": "config",
358
+ "key": key,
359
+ "value": value,
360
+ }
361
+ return params
362
+
363
+
364
+ def dwi2fod_config_validate(
365
+ params: typing.Any,
366
+ ) -> None:
367
+ """
368
+ Validate parameters. Throws an error if `params` is not a valid
369
+ `Dwi2fodConfigParamsDict` object.
370
+
371
+ Args:
372
+ params: The parameters object to validate.
373
+ """
374
+ if params is None or not isinstance(params, dict):
375
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
376
+ if params.get("key", None) is None:
377
+ raise StyxValidationError("`key` must not be None")
378
+ if not isinstance(params["key"], str):
379
+ raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
380
+ if params.get("value", None) is None:
381
+ raise StyxValidationError("`value` must not be None")
382
+ if not isinstance(params["value"], str):
383
+ raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')
384
+
385
+
386
+ def dwi2fod_config_cargs(
387
+ params: Dwi2fodConfigParamsDict,
388
+ execution: Execution,
389
+ ) -> list[str]:
390
+ """
391
+ Build command-line arguments from parameters.
392
+
393
+ Args:
394
+ params: The parameters.
395
+ execution: The execution object for resolving input paths.
396
+ Returns:
397
+ Command-line arguments.
398
+ """
399
+ cargs = []
400
+ cargs.append("-config")
401
+ cargs.append(params.get("key", None))
402
+ cargs.append(params.get("value", None))
403
+ return cargs
404
+
405
+
406
+ class Dwi2fodResponseOdfOutputs(typing.NamedTuple):
407
+ """
408
+ Output object returned when calling `list[Dwi2fodResponseOdfParamsDict](...)`.
409
+ """
410
+ root: OutputPathType
411
+ """Output root folder. This is the root folder for all outputs."""
412
+ odf: OutputPathType
413
+ """output ODF image"""
414
+
415
+
416
+ def dwi2fod_response_odf(
417
+ response: InputPathType,
418
+ odf: str,
419
+ ) -> Dwi2fodResponseOdfParamsDictTagged:
420
+ """
421
+ Build parameters.
422
+
423
+ Args:
424
+ response: input tissue response.
425
+ odf: output ODF image.
426
+ Returns:
427
+ Parameter dictionary
428
+ """
429
+ params = {
430
+ "@type": "response_odf",
431
+ "response": response,
432
+ "odf": odf,
433
+ }
434
+ return params
435
+
436
+
437
+ def dwi2fod_response_odf_validate(
438
+ params: typing.Any,
439
+ ) -> None:
440
+ """
441
+ Validate parameters. Throws an error if `params` is not a valid
442
+ `Dwi2fodResponseOdfParamsDict` object.
443
+
444
+ Args:
445
+ params: The parameters object to validate.
446
+ """
447
+ if params is None or not isinstance(params, dict):
448
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
449
+ if params.get("response", None) is None:
450
+ raise StyxValidationError("`response` must not be None")
451
+ if not isinstance(params["response"], (pathlib.Path, str)):
452
+ raise StyxValidationError(f'`response` has the wrong type: Received `{type(params.get("response", None))}` expected `InputPathType`')
453
+ if params.get("odf", None) is None:
454
+ raise StyxValidationError("`odf` must not be None")
455
+ if not isinstance(params["odf"], str):
456
+ raise StyxValidationError(f'`odf` has the wrong type: Received `{type(params.get("odf", None))}` expected `str`')
457
+
458
+
459
+ def dwi2fod_response_odf_cargs(
460
+ params: Dwi2fodResponseOdfParamsDict,
461
+ execution: Execution,
462
+ ) -> list[str]:
463
+ """
464
+ Build command-line arguments from parameters.
465
+
466
+ Args:
467
+ params: The parameters.
468
+ execution: The execution object for resolving input paths.
469
+ Returns:
470
+ Command-line arguments.
471
+ """
472
+ cargs = []
473
+ cargs.append(execution.input_file(params.get("response", None)))
474
+ cargs.append(params.get("odf", None))
475
+ return cargs
476
+
477
+
478
+ def dwi2fod_response_odf_outputs(
479
+ params: Dwi2fodResponseOdfParamsDict,
480
+ execution: Execution,
481
+ ) -> Dwi2fodResponseOdfOutputs:
482
+ """
483
+ Build outputs object containing output file paths and possibly stdout/stderr.
484
+
485
+ Args:
486
+ params: The parameters.
487
+ execution: The execution object for resolving input paths.
488
+ Returns:
489
+ Outputs object.
490
+ """
491
+ ret = Dwi2fodResponseOdfOutputs(
492
+ root=execution.output_file("."),
493
+ odf=execution.output_file(params.get("odf", None)),
494
+ )
495
+ return ret
496
+
497
+
498
+ class Dwi2fodOutputs(typing.NamedTuple):
499
+ """
500
+ Output object returned when calling `Dwi2fodParamsDict(...)`.
501
+ """
502
+ root: OutputPathType
503
+ """Output root folder. This is the root folder for all outputs."""
504
+ predicted_signal: OutputPathType | None
505
+ """output the predicted dwi image. """
506
+ response_odf: list[Dwi2fodResponseOdfOutputs]
507
+ """Outputs from `dwi2fod_response_odf_outputs`.This is a list of outputs
508
+ with the same length and order as the inputs."""
509
+
510
+
511
+ def dwi2fod_params(
512
+ algorithm: str,
513
+ dwi: InputPathType,
514
+ response_odf: list[Dwi2fodResponseOdfParamsDict],
515
+ grad: InputPathType | None = None,
516
+ fslgrad: Dwi2fodFslgradParamsDict | None = None,
517
+ shells: list[float] | None = None,
518
+ directions: InputPathType | None = None,
519
+ lmax: list[int] | None = None,
520
+ mask: InputPathType | None = None,
521
+ filter_: InputPathType | None = None,
522
+ neg_lambda: float | None = None,
523
+ norm_lambda: float | None = None,
524
+ threshold: float | None = None,
525
+ niter: int | None = None,
526
+ norm_lambda_1: float | None = None,
527
+ neg_lambda_1: float | None = None,
528
+ predicted_signal: str | None = None,
529
+ strides: typing.Union[Dwi2fodVariousStringParamsDictTagged, Dwi2fodVariousFileParamsDictTagged] | None = None,
530
+ info: bool = False,
531
+ quiet: bool = False,
532
+ debug: bool = False,
533
+ force: bool = False,
534
+ nthreads: int | None = None,
535
+ config: list[Dwi2fodConfigParamsDict] | None = None,
536
+ help_: bool = False,
537
+ version: bool = False,
538
+ ) -> Dwi2fodParamsDictTagged:
539
+ """
540
+ Build parameters.
541
+
542
+ Args:
543
+ algorithm: the algorithm to use for FOD estimation. (options are:\
544
+ csd,msmt_csd).
545
+ dwi: the input diffusion-weighted image.
546
+ response_odf: pairs of input tissue response and output ODF images.
547
+ grad: Provide the diffusion-weighted gradient scheme used in the\
548
+ acquisition in a text file. This should be supplied as a 4xN text file\
549
+ with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
550
+ the direction of the applied gradient, and b gives the b-value in units\
551
+ of s/mm^2. If a diffusion gradient scheme is present in the input image\
552
+ header, the data provided with this option will be instead used.
553
+ fslgrad: Provide the diffusion-weighted gradient scheme used in the\
554
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
555
+ scheme is present in the input image header, the data provided with\
556
+ this option will be instead used.
557
+ shells: specify one or more b-values to use during processing, as a\
558
+ comma-separated list of the desired approximate b-values (b-values are\
559
+ clustered to allow for small deviations). Note that some commands are\
560
+ incompatible with multiple b-values, and will report an error if more\
561
+ than one b-value is provided.\
562
+ WARNING: note that, even though the b=0 volumes are never referred\
563
+ to as shells in the literature, they still have to be explicitly\
564
+ included in the list of b-values as provided to the -shell option!\
565
+ Several algorithms which include the b=0 volumes in their\
566
+ computations may otherwise return an undesired result.
567
+ directions: specify the directions over which to apply the\
568
+ non-negativity constraint (by default, the built-in 300 direction set\
569
+ is used). These should be supplied as a text file containing [ az el ]\
570
+ pairs for the directions.
571
+ lmax: the maximum spherical harmonic order for the output FOD(s).For\
572
+ algorithms with multiple outputs, this should be provided as a\
573
+ comma-separated list of integers, one for each output image; for\
574
+ single-output algorithms, only a single integer should be provided. If\
575
+ omitted, the command will use the lmax of the corresponding response\
576
+ function (i.e based on its number of coefficients), up to a maximum of\
577
+ 8.
578
+ mask: only perform computation within the specified binary brain mask\
579
+ image.
580
+ filter_: the linear frequency filtering parameters used for the initial\
581
+ linear spherical deconvolution step (default = [ 1 1 1 0 0 ]). These\
582
+ should be supplied as a text file containing the filtering coefficients\
583
+ for each even harmonic order.
584
+ neg_lambda: the regularisation parameter lambda that controls the\
585
+ strength of the non-negativity constraint (default = 1).
586
+ norm_lambda: the regularisation parameter lambda that controls the\
587
+ strength of the constraint on the norm of the solution (default = 1).
588
+ threshold: the threshold below which the amplitude of the FOD is\
589
+ assumed to be zero, expressed as an absolute amplitude (default = 0).
590
+ niter: the maximum number of iterations to perform for each voxel\
591
+ (default = 50). Use '-niter 0' for a linear unconstrained spherical\
592
+ deconvolution.
593
+ norm_lambda_1: the regularisation parameter lambda that controls the\
594
+ strength of the constraint on the norm of the solution (default =\
595
+ 1e-10).
596
+ neg_lambda_1: the regularisation parameter lambda that controls the\
597
+ strength of the non-negativity constraint (default = 1e-10).
598
+ predicted_signal: output the predicted dwi image.
599
+ strides: specify the strides of the output data in memory; either as a\
600
+ comma-separated list of (signed) integers, or as a template image from\
601
+ which the strides shall be extracted and used. The actual strides\
602
+ produced will depend on whether the output image format can support it.
603
+ info: display information messages.
604
+ quiet: do not display information messages or progress status;\
605
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
606
+ environment variable to a non-empty string.
607
+ debug: display debugging messages.
608
+ force: force overwrite of output files (caution: using the same file as\
609
+ input and output might cause unexpected behaviour).
610
+ nthreads: use this number of threads in multi-threaded applications\
611
+ (set to 0 to disable multi-threading).
612
+ config: temporarily set the value of an MRtrix config file entry.
613
+ help_: display this information page and exit.
614
+ version: display version information and exit.
615
+ Returns:
616
+ Parameter dictionary
617
+ """
618
+ params = {
619
+ "@type": "mrtrix/dwi2fod",
620
+ "info": info,
621
+ "quiet": quiet,
622
+ "debug": debug,
623
+ "force": force,
624
+ "help": help_,
625
+ "version": version,
626
+ "algorithm": algorithm,
627
+ "dwi": dwi,
628
+ "response_odf": response_odf,
629
+ }
630
+ if grad is not None:
631
+ params["grad"] = grad
632
+ if fslgrad is not None:
633
+ params["fslgrad"] = fslgrad
634
+ if shells is not None:
635
+ params["shells"] = shells
636
+ if directions is not None:
637
+ params["directions"] = directions
638
+ if lmax is not None:
639
+ params["lmax"] = lmax
640
+ if mask is not None:
641
+ params["mask"] = mask
642
+ if filter_ is not None:
643
+ params["filter"] = filter_
644
+ if neg_lambda is not None:
645
+ params["neg_lambda"] = neg_lambda
646
+ if norm_lambda is not None:
647
+ params["norm_lambda"] = norm_lambda
648
+ if threshold is not None:
649
+ params["threshold"] = threshold
650
+ if niter is not None:
651
+ params["niter"] = niter
652
+ if norm_lambda_1 is not None:
653
+ params["norm_lambda_1"] = norm_lambda_1
654
+ if neg_lambda_1 is not None:
655
+ params["neg_lambda_1"] = neg_lambda_1
656
+ if predicted_signal is not None:
657
+ params["predicted_signal"] = predicted_signal
658
+ if strides is not None:
659
+ params["strides"] = strides
660
+ if nthreads is not None:
661
+ params["nthreads"] = nthreads
662
+ if config is not None:
663
+ params["config"] = config
664
+ return params
665
+
666
+
667
+ def dwi2fod_validate(
668
+ params: typing.Any,
669
+ ) -> None:
670
+ """
671
+ Validate parameters. Throws an error if `params` is not a valid
672
+ `Dwi2fodParamsDict` object.
673
+
674
+ Args:
675
+ params: The parameters object to validate.
676
+ """
677
+ if params is None or not isinstance(params, dict):
678
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
679
+ if params.get("grad", None) is not None:
680
+ if not isinstance(params["grad"], (pathlib.Path, str)):
681
+ raise StyxValidationError(f'`grad` has the wrong type: Received `{type(params.get("grad", None))}` expected `InputPathType | None`')
682
+ if params.get("fslgrad", None) is not None:
683
+ dwi2fod_fslgrad_validate(params["fslgrad"])
684
+ if params.get("shells", None) is not None:
685
+ if not isinstance(params["shells"], list):
686
+ raise StyxValidationError(f'`shells` has the wrong type: Received `{type(params.get("shells", None))}` expected `list[float] | None`')
687
+ for e in params["shells"]:
688
+ if not isinstance(e, (float, int)):
689
+ raise StyxValidationError(f'`shells` has the wrong type: Received `{type(params.get("shells", None))}` expected `list[float] | None`')
690
+ if params.get("directions", None) is not None:
691
+ if not isinstance(params["directions"], (pathlib.Path, str)):
692
+ raise StyxValidationError(f'`directions` has the wrong type: Received `{type(params.get("directions", None))}` expected `InputPathType | None`')
693
+ if params.get("lmax", None) is not None:
694
+ if not isinstance(params["lmax"], list):
695
+ raise StyxValidationError(f'`lmax` has the wrong type: Received `{type(params.get("lmax", None))}` expected `list[int] | None`')
696
+ for e in params["lmax"]:
697
+ if not isinstance(e, int):
698
+ raise StyxValidationError(f'`lmax` has the wrong type: Received `{type(params.get("lmax", None))}` expected `list[int] | None`')
699
+ if params.get("mask", None) is not None:
700
+ if not isinstance(params["mask"], (pathlib.Path, str)):
701
+ raise StyxValidationError(f'`mask` has the wrong type: Received `{type(params.get("mask", None))}` expected `InputPathType | None`')
702
+ if params.get("filter", None) is not None:
703
+ if not isinstance(params["filter"], (pathlib.Path, str)):
704
+ raise StyxValidationError(f'`filter` has the wrong type: Received `{type(params.get("filter", None))}` expected `InputPathType | None`')
705
+ if params.get("neg_lambda", None) is not None:
706
+ if not isinstance(params["neg_lambda"], (float, int)):
707
+ raise StyxValidationError(f'`neg_lambda` has the wrong type: Received `{type(params.get("neg_lambda", None))}` expected `float | None`')
708
+ if params.get("norm_lambda", None) is not None:
709
+ if not isinstance(params["norm_lambda"], (float, int)):
710
+ raise StyxValidationError(f'`norm_lambda` has the wrong type: Received `{type(params.get("norm_lambda", None))}` expected `float | None`')
711
+ if params.get("threshold", None) is not None:
712
+ if not isinstance(params["threshold"], (float, int)):
713
+ raise StyxValidationError(f'`threshold` has the wrong type: Received `{type(params.get("threshold", None))}` expected `float | None`')
714
+ if params.get("niter", None) is not None:
715
+ if not isinstance(params["niter"], int):
716
+ raise StyxValidationError(f'`niter` has the wrong type: Received `{type(params.get("niter", None))}` expected `int | None`')
717
+ if params.get("norm_lambda_1", None) is not None:
718
+ if not isinstance(params["norm_lambda_1"], (float, int)):
719
+ raise StyxValidationError(f'`norm_lambda_1` has the wrong type: Received `{type(params.get("norm_lambda_1", None))}` expected `float | None`')
720
+ if params.get("neg_lambda_1", None) is not None:
721
+ if not isinstance(params["neg_lambda_1"], (float, int)):
722
+ raise StyxValidationError(f'`neg_lambda_1` has the wrong type: Received `{type(params.get("neg_lambda_1", None))}` expected `float | None`')
723
+ if params.get("predicted_signal", None) is not None:
724
+ if not isinstance(params["predicted_signal"], str):
725
+ raise StyxValidationError(f'`predicted_signal` has the wrong type: Received `{type(params.get("predicted_signal", None))}` expected `str | None`')
726
+ if params.get("strides", None) is not None:
727
+ if not isinstance(params["strides"], dict):
728
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params["strides"])}\'')
729
+ if "@type" not in params["strides"]:
730
+ raise StyxValidationError("Params object is missing `@type`")
731
+ if params["strides"]["@type"] not in ["VariousString", "VariousFile"]:
732
+ raise StyxValidationError("Parameter `strides`s `@type` must be one of [\"VariousString\", \"VariousFile\"]")
733
+ dwi2fod_strides_validate_dyn_fn(params["strides"]["@type"])(params["strides"])
734
+ if params.get("info", False) is None:
735
+ raise StyxValidationError("`info` must not be None")
736
+ if not isinstance(params["info"], bool):
737
+ raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
738
+ if params.get("quiet", False) is None:
739
+ raise StyxValidationError("`quiet` must not be None")
740
+ if not isinstance(params["quiet"], bool):
741
+ raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
742
+ if params.get("debug", False) is None:
743
+ raise StyxValidationError("`debug` must not be None")
744
+ if not isinstance(params["debug"], bool):
745
+ raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
746
+ if params.get("force", False) is None:
747
+ raise StyxValidationError("`force` must not be None")
748
+ if not isinstance(params["force"], bool):
749
+ raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
750
+ if params.get("nthreads", None) is not None:
751
+ if not isinstance(params["nthreads"], int):
752
+ raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
753
+ if params.get("config", None) is not None:
754
+ if not isinstance(params["config"], list):
755
+ raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[Dwi2fodConfigParamsDict] | None`')
756
+ for e in params["config"]:
757
+ dwi2fod_config_validate(e)
758
+ if params.get("help", False) is None:
759
+ raise StyxValidationError("`help` must not be None")
760
+ if not isinstance(params["help"], bool):
761
+ raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
762
+ if params.get("version", False) is None:
763
+ raise StyxValidationError("`version` must not be None")
764
+ if not isinstance(params["version"], bool):
765
+ raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
766
+ if params.get("algorithm", None) is None:
767
+ raise StyxValidationError("`algorithm` must not be None")
768
+ if not isinstance(params["algorithm"], str):
769
+ raise StyxValidationError(f'`algorithm` has the wrong type: Received `{type(params.get("algorithm", None))}` expected `str`')
770
+ if params.get("dwi", None) is None:
771
+ raise StyxValidationError("`dwi` must not be None")
772
+ if not isinstance(params["dwi"], (pathlib.Path, str)):
773
+ raise StyxValidationError(f'`dwi` has the wrong type: Received `{type(params.get("dwi", None))}` expected `InputPathType`')
774
+ if params.get("response_odf", None) is None:
775
+ raise StyxValidationError("`response_odf` must not be None")
776
+ if not isinstance(params["response_odf"], list):
777
+ raise StyxValidationError(f'`response_odf` has the wrong type: Received `{type(params.get("response_odf", None))}` expected `list[Dwi2fodResponseOdfParamsDict]`')
778
+ for e in params["response_odf"]:
779
+ dwi2fod_response_odf_validate(e)
780
+
781
+
782
+ def dwi2fod_cargs(
783
+ params: Dwi2fodParamsDict,
784
+ execution: Execution,
785
+ ) -> list[str]:
786
+ """
787
+ Build command-line arguments from parameters.
788
+
789
+ Args:
790
+ params: The parameters.
791
+ execution: The execution object for resolving input paths.
792
+ Returns:
793
+ Command-line arguments.
794
+ """
795
+ cargs = []
796
+ cargs.append("dwi2fod")
797
+ if params.get("grad", None) is not None:
798
+ cargs.extend([
799
+ "-grad",
800
+ execution.input_file(params.get("grad", None))
801
+ ])
802
+ if params.get("fslgrad", None) is not None:
803
+ cargs.extend(dwi2fod_fslgrad_cargs(params.get("fslgrad", None), execution))
804
+ if params.get("shells", None) is not None:
805
+ cargs.extend([
806
+ "-shells",
807
+ ",".join(map(str, params.get("shells", None)))
808
+ ])
809
+ if params.get("directions", None) is not None:
810
+ cargs.extend([
811
+ "-directions",
812
+ execution.input_file(params.get("directions", None))
813
+ ])
814
+ if params.get("lmax", None) is not None:
815
+ cargs.extend([
816
+ "-lmax",
817
+ ",".join(map(str, params.get("lmax", None)))
818
+ ])
819
+ if params.get("mask", None) is not None:
820
+ cargs.extend([
821
+ "-mask",
822
+ execution.input_file(params.get("mask", None))
823
+ ])
824
+ if params.get("filter", None) is not None:
825
+ cargs.extend([
826
+ "-filter",
827
+ execution.input_file(params.get("filter", None))
828
+ ])
829
+ if params.get("neg_lambda", None) is not None:
830
+ cargs.extend([
831
+ "-neg_lambda",
832
+ str(params.get("neg_lambda", None))
833
+ ])
834
+ if params.get("norm_lambda", None) is not None:
835
+ cargs.extend([
836
+ "-norm_lambda",
837
+ str(params.get("norm_lambda", None))
838
+ ])
839
+ if params.get("threshold", None) is not None:
840
+ cargs.extend([
841
+ "-threshold",
842
+ str(params.get("threshold", None))
843
+ ])
844
+ if params.get("niter", None) is not None:
845
+ cargs.extend([
846
+ "-niter",
847
+ str(params.get("niter", None))
848
+ ])
849
+ if params.get("norm_lambda_1", None) is not None:
850
+ cargs.extend([
851
+ "-norm_lambda",
852
+ str(params.get("norm_lambda_1", None))
853
+ ])
854
+ if params.get("neg_lambda_1", None) is not None:
855
+ cargs.extend([
856
+ "-neg_lambda",
857
+ str(params.get("neg_lambda_1", None))
858
+ ])
859
+ if params.get("predicted_signal", None) is not None:
860
+ cargs.extend([
861
+ "-predicted_signal",
862
+ params.get("predicted_signal", None)
863
+ ])
864
+ if params.get("strides", None) is not None:
865
+ cargs.extend([
866
+ "-strides",
867
+ *dwi2fod_strides_cargs_dyn_fn(params.get("strides", None)["@type"])(params.get("strides", None), execution)
868
+ ])
869
+ if params.get("info", False):
870
+ cargs.append("-info")
871
+ if params.get("quiet", False):
872
+ cargs.append("-quiet")
873
+ if params.get("debug", False):
874
+ cargs.append("-debug")
875
+ if params.get("force", False):
876
+ cargs.append("-force")
877
+ if params.get("nthreads", None) is not None:
878
+ cargs.extend([
879
+ "-nthreads",
880
+ str(params.get("nthreads", None))
881
+ ])
882
+ if params.get("config", None) is not None:
883
+ cargs.extend([a for c in [dwi2fod_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
884
+ if params.get("help", False):
885
+ cargs.append("-help")
886
+ if params.get("version", False):
887
+ cargs.append("-version")
888
+ cargs.append(params.get("algorithm", None))
889
+ cargs.append(execution.input_file(params.get("dwi", None)))
890
+ cargs.extend([a for c in [dwi2fod_response_odf_cargs(s, execution) for s in params.get("response_odf", None)] for a in c])
891
+ return cargs
892
+
893
+
894
+ def dwi2fod_outputs(
895
+ params: Dwi2fodParamsDict,
896
+ execution: Execution,
897
+ ) -> Dwi2fodOutputs:
898
+ """
899
+ Build outputs object containing output file paths and possibly stdout/stderr.
900
+
901
+ Args:
902
+ params: The parameters.
903
+ execution: The execution object for resolving input paths.
904
+ Returns:
905
+ Outputs object.
906
+ """
907
+ ret = Dwi2fodOutputs(
908
+ root=execution.output_file("."),
909
+ predicted_signal=execution.output_file(params.get("predicted_signal", None)) if (params.get("predicted_signal") is not None) else None,
910
+ response_odf=[dwi2fod_response_odf_outputs(i, execution) if dwi2fod_response_odf_outputs else None for i in params.get("response_odf")],
911
+ )
912
+ return ret
913
+
914
+
915
+ def dwi2fod_execute(
916
+ params: Dwi2fodParamsDict,
917
+ runner: Runner | None = None,
918
+ ) -> Dwi2fodOutputs:
919
+ """
920
+ dwi2fod
921
+
922
+ Estimate fibre orientation distributions from diffusion data using spherical
923
+ deconvolution.
924
+
925
+ The spherical harmonic coefficients are stored according the conventions
926
+ described the main documentation, which can be found at the following link:
927
+ https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
928
+
929
+ References:
930
+
931
+ * If using csd algorithm:
932
+ Tournier, J.-D.; Calamante, F. & Connelly, A. Robust determination of the
933
+ fibre orientation distribution in diffusion MRI: Non-negativity constrained
934
+ super-resolved spherical deconvolution. NeuroImage, 2007, 35, 1459-1472
935
+
936
+ * If using msmt_csd algorithm:
937
+ Jeurissen, B; Tournier, J-D; Dhollander, T; Connelly, A & Sijbers, J.
938
+ Multi-tissue constrained spherical deconvolution for improved analysis of
939
+ multi-shell diffusion MRI data. NeuroImage, 2014, 103, 411-426
940
+
941
+ Tournier, J.-D.; Calamante, F., Gadian, D.G. & Connelly, A. Direct
942
+ estimation of the fiber orientation density function from diffusion-weighted
943
+ MRI data using spherical deconvolution. NeuroImage, 2004, 23, 1176-1185.
944
+
945
+ Author: MRTrix3 Developers
946
+
947
+ URL: https://www.mrtrix.org/
948
+
949
+ Args:
950
+ params: The parameters.
951
+ runner: Command runner.
952
+ Returns:
953
+ NamedTuple of outputs (described in `Dwi2fodOutputs`).
954
+ """
955
+ dwi2fod_validate(params)
956
+ runner = runner or get_global_runner()
957
+ execution = runner.start_execution(DWI2FOD_METADATA)
958
+ params = execution.params(params)
959
+ cargs = dwi2fod_cargs(params, execution)
960
+ ret = dwi2fod_outputs(params, execution)
961
+ execution.run(cargs)
962
+ return ret
963
+
964
+
965
+ def dwi2fod(
966
+ algorithm: str,
967
+ dwi: InputPathType,
968
+ response_odf: list[Dwi2fodResponseOdfParamsDict],
969
+ grad: InputPathType | None = None,
970
+ fslgrad: Dwi2fodFslgradParamsDict | None = None,
971
+ shells: list[float] | None = None,
972
+ directions: InputPathType | None = None,
973
+ lmax: list[int] | None = None,
974
+ mask: InputPathType | None = None,
975
+ filter_: InputPathType | None = None,
976
+ neg_lambda: float | None = None,
977
+ norm_lambda: float | None = None,
978
+ threshold: float | None = None,
979
+ niter: int | None = None,
980
+ norm_lambda_1: float | None = None,
981
+ neg_lambda_1: float | None = None,
982
+ predicted_signal: str | None = None,
983
+ strides: typing.Union[Dwi2fodVariousStringParamsDictTagged, Dwi2fodVariousFileParamsDictTagged] | None = None,
984
+ info: bool = False,
985
+ quiet: bool = False,
986
+ debug: bool = False,
987
+ force: bool = False,
988
+ nthreads: int | None = None,
989
+ config: list[Dwi2fodConfigParamsDict] | None = None,
990
+ help_: bool = False,
991
+ version: bool = False,
992
+ runner: Runner | None = None,
993
+ ) -> Dwi2fodOutputs:
994
+ """
995
+ dwi2fod
996
+
997
+ Estimate fibre orientation distributions from diffusion data using spherical
998
+ deconvolution.
999
+
1000
+ The spherical harmonic coefficients are stored according the conventions
1001
+ described the main documentation, which can be found at the following link:
1002
+ https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
1003
+
1004
+ References:
1005
+
1006
+ * If using csd algorithm:
1007
+ Tournier, J.-D.; Calamante, F. & Connelly, A. Robust determination of the
1008
+ fibre orientation distribution in diffusion MRI: Non-negativity constrained
1009
+ super-resolved spherical deconvolution. NeuroImage, 2007, 35, 1459-1472
1010
+
1011
+ * If using msmt_csd algorithm:
1012
+ Jeurissen, B; Tournier, J-D; Dhollander, T; Connelly, A & Sijbers, J.
1013
+ Multi-tissue constrained spherical deconvolution for improved analysis of
1014
+ multi-shell diffusion MRI data. NeuroImage, 2014, 103, 411-426
1015
+
1016
+ Tournier, J.-D.; Calamante, F., Gadian, D.G. & Connelly, A. Direct
1017
+ estimation of the fiber orientation density function from diffusion-weighted
1018
+ MRI data using spherical deconvolution. NeuroImage, 2004, 23, 1176-1185.
1019
+
1020
+ Author: MRTrix3 Developers
1021
+
1022
+ URL: https://www.mrtrix.org/
1023
+
1024
+ Args:
1025
+ algorithm: the algorithm to use for FOD estimation. (options are:\
1026
+ csd,msmt_csd).
1027
+ dwi: the input diffusion-weighted image.
1028
+ response_odf: pairs of input tissue response and output ODF images.
1029
+ grad: Provide the diffusion-weighted gradient scheme used in the\
1030
+ acquisition in a text file. This should be supplied as a 4xN text file\
1031
+ with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
1032
+ the direction of the applied gradient, and b gives the b-value in units\
1033
+ of s/mm^2. If a diffusion gradient scheme is present in the input image\
1034
+ header, the data provided with this option will be instead used.
1035
+ fslgrad: Provide the diffusion-weighted gradient scheme used in the\
1036
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
1037
+ scheme is present in the input image header, the data provided with\
1038
+ this option will be instead used.
1039
+ shells: specify one or more b-values to use during processing, as a\
1040
+ comma-separated list of the desired approximate b-values (b-values are\
1041
+ clustered to allow for small deviations). Note that some commands are\
1042
+ incompatible with multiple b-values, and will report an error if more\
1043
+ than one b-value is provided.\
1044
+ WARNING: note that, even though the b=0 volumes are never referred\
1045
+ to as shells in the literature, they still have to be explicitly\
1046
+ included in the list of b-values as provided to the -shell option!\
1047
+ Several algorithms which include the b=0 volumes in their\
1048
+ computations may otherwise return an undesired result.
1049
+ directions: specify the directions over which to apply the\
1050
+ non-negativity constraint (by default, the built-in 300 direction set\
1051
+ is used). These should be supplied as a text file containing [ az el ]\
1052
+ pairs for the directions.
1053
+ lmax: the maximum spherical harmonic order for the output FOD(s).For\
1054
+ algorithms with multiple outputs, this should be provided as a\
1055
+ comma-separated list of integers, one for each output image; for\
1056
+ single-output algorithms, only a single integer should be provided. If\
1057
+ omitted, the command will use the lmax of the corresponding response\
1058
+ function (i.e based on its number of coefficients), up to a maximum of\
1059
+ 8.
1060
+ mask: only perform computation within the specified binary brain mask\
1061
+ image.
1062
+ filter_: the linear frequency filtering parameters used for the initial\
1063
+ linear spherical deconvolution step (default = [ 1 1 1 0 0 ]). These\
1064
+ should be supplied as a text file containing the filtering coefficients\
1065
+ for each even harmonic order.
1066
+ neg_lambda: the regularisation parameter lambda that controls the\
1067
+ strength of the non-negativity constraint (default = 1).
1068
+ norm_lambda: the regularisation parameter lambda that controls the\
1069
+ strength of the constraint on the norm of the solution (default = 1).
1070
+ threshold: the threshold below which the amplitude of the FOD is\
1071
+ assumed to be zero, expressed as an absolute amplitude (default = 0).
1072
+ niter: the maximum number of iterations to perform for each voxel\
1073
+ (default = 50). Use '-niter 0' for a linear unconstrained spherical\
1074
+ deconvolution.
1075
+ norm_lambda_1: the regularisation parameter lambda that controls the\
1076
+ strength of the constraint on the norm of the solution (default =\
1077
+ 1e-10).
1078
+ neg_lambda_1: the regularisation parameter lambda that controls the\
1079
+ strength of the non-negativity constraint (default = 1e-10).
1080
+ predicted_signal: output the predicted dwi image.
1081
+ strides: specify the strides of the output data in memory; either as a\
1082
+ comma-separated list of (signed) integers, or as a template image from\
1083
+ which the strides shall be extracted and used. The actual strides\
1084
+ produced will depend on whether the output image format can support it.
1085
+ info: display information messages.
1086
+ quiet: do not display information messages or progress status;\
1087
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
1088
+ environment variable to a non-empty string.
1089
+ debug: display debugging messages.
1090
+ force: force overwrite of output files (caution: using the same file as\
1091
+ input and output might cause unexpected behaviour).
1092
+ nthreads: use this number of threads in multi-threaded applications\
1093
+ (set to 0 to disable multi-threading).
1094
+ config: temporarily set the value of an MRtrix config file entry.
1095
+ help_: display this information page and exit.
1096
+ version: display version information and exit.
1097
+ runner: Command runner.
1098
+ Returns:
1099
+ NamedTuple of outputs (described in `Dwi2fodOutputs`).
1100
+ """
1101
+ params = dwi2fod_params(
1102
+ grad=grad,
1103
+ fslgrad=fslgrad,
1104
+ shells=shells,
1105
+ directions=directions,
1106
+ lmax=lmax,
1107
+ mask=mask,
1108
+ filter_=filter_,
1109
+ neg_lambda=neg_lambda,
1110
+ norm_lambda=norm_lambda,
1111
+ threshold=threshold,
1112
+ niter=niter,
1113
+ norm_lambda_1=norm_lambda_1,
1114
+ neg_lambda_1=neg_lambda_1,
1115
+ predicted_signal=predicted_signal,
1116
+ strides=strides,
1117
+ info=info,
1118
+ quiet=quiet,
1119
+ debug=debug,
1120
+ force=force,
1121
+ nthreads=nthreads,
1122
+ config=config,
1123
+ help_=help_,
1124
+ version=version,
1125
+ algorithm=algorithm,
1126
+ dwi=dwi,
1127
+ response_odf=response_odf,
1128
+ )
1129
+ return dwi2fod_execute(params, runner)
1130
+
1131
+
1132
+ __all__ = [
1133
+ "DWI2FOD_METADATA",
1134
+ "Dwi2fodConfigParamsDict",
1135
+ "Dwi2fodConfigParamsDictTagged",
1136
+ "Dwi2fodFslgradParamsDict",
1137
+ "Dwi2fodFslgradParamsDictTagged",
1138
+ "Dwi2fodOutputs",
1139
+ "Dwi2fodParamsDict",
1140
+ "Dwi2fodParamsDictTagged",
1141
+ "Dwi2fodResponseOdfOutputs",
1142
+ "Dwi2fodResponseOdfParamsDict",
1143
+ "Dwi2fodResponseOdfParamsDictTagged",
1144
+ "Dwi2fodVariousFileParamsDict",
1145
+ "Dwi2fodVariousFileParamsDictTagged",
1146
+ "Dwi2fodVariousStringParamsDict",
1147
+ "Dwi2fodVariousStringParamsDictTagged",
1148
+ "dwi2fod",
1149
+ "dwi2fod_config",
1150
+ "dwi2fod_execute",
1151
+ "dwi2fod_fslgrad",
1152
+ "dwi2fod_params",
1153
+ "dwi2fod_response_odf",
1154
+ "dwi2fod_various_file",
1155
+ "dwi2fod_various_string",
1156
+ ]