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