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,640 @@
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
+ DIRSTAT_METADATA = Metadata(
9
+ id="369098dbdbd016bf94682e0106a2f2e1711f2a5b.boutiques",
10
+ name="dirstat",
11
+ package="mrtrix",
12
+ container_image_tag="mrtrix3/mrtrix3:3.0.4",
13
+ )
14
+
15
+
16
+ _DirstatFslgradParamsDictNoTag = typing.TypedDict('_DirstatFslgradParamsDictNoTag', {
17
+ "bvecs": InputPathType,
18
+ "bvals": InputPathType,
19
+ })
20
+ DirstatFslgradParamsDictTagged = typing.TypedDict('DirstatFslgradParamsDictTagged', {
21
+ "@type": typing.Literal["fslgrad"],
22
+ "bvecs": InputPathType,
23
+ "bvals": InputPathType,
24
+ })
25
+ DirstatFslgradParamsDict = _DirstatFslgradParamsDictNoTag | DirstatFslgradParamsDictTagged
26
+
27
+
28
+ _DirstatConfigParamsDictNoTag = typing.TypedDict('_DirstatConfigParamsDictNoTag', {
29
+ "key": str,
30
+ "value": str,
31
+ })
32
+ DirstatConfigParamsDictTagged = typing.TypedDict('DirstatConfigParamsDictTagged', {
33
+ "@type": typing.Literal["config"],
34
+ "key": str,
35
+ "value": str,
36
+ })
37
+ DirstatConfigParamsDict = _DirstatConfigParamsDictNoTag | DirstatConfigParamsDictTagged
38
+
39
+
40
+ _DirstatParamsDictNoTag = typing.TypedDict('_DirstatParamsDictNoTag', {
41
+ "output": typing.NotRequired[str | None],
42
+ "shells": typing.NotRequired[list[float] | None],
43
+ "grad": typing.NotRequired[InputPathType | None],
44
+ "fslgrad": typing.NotRequired[DirstatFslgradParamsDict | None],
45
+ "info": bool,
46
+ "quiet": bool,
47
+ "debug": bool,
48
+ "force": bool,
49
+ "nthreads": typing.NotRequired[int | None],
50
+ "config": typing.NotRequired[list[DirstatConfigParamsDict] | None],
51
+ "help": bool,
52
+ "version": bool,
53
+ "dirs": InputPathType,
54
+ })
55
+ DirstatParamsDictTagged = typing.TypedDict('DirstatParamsDictTagged', {
56
+ "@type": typing.Literal["mrtrix/dirstat"],
57
+ "output": typing.NotRequired[str | None],
58
+ "shells": typing.NotRequired[list[float] | None],
59
+ "grad": typing.NotRequired[InputPathType | None],
60
+ "fslgrad": typing.NotRequired[DirstatFslgradParamsDict | None],
61
+ "info": bool,
62
+ "quiet": bool,
63
+ "debug": bool,
64
+ "force": bool,
65
+ "nthreads": typing.NotRequired[int | None],
66
+ "config": typing.NotRequired[list[DirstatConfigParamsDict] | None],
67
+ "help": bool,
68
+ "version": bool,
69
+ "dirs": InputPathType,
70
+ })
71
+ DirstatParamsDict = _DirstatParamsDictNoTag | DirstatParamsDictTagged
72
+
73
+
74
+ def dirstat_fslgrad(
75
+ bvecs: InputPathType,
76
+ bvals: InputPathType,
77
+ ) -> DirstatFslgradParamsDictTagged:
78
+ """
79
+ Build parameters.
80
+
81
+ Args:
82
+ bvecs: Provide the diffusion-weighted gradient scheme used in the\
83
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
84
+ scheme is present in the input image header, the data provided with\
85
+ this option will be instead used.
86
+ bvals: Provide the diffusion-weighted gradient scheme used in the\
87
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
88
+ scheme is present in the input image header, the data provided with\
89
+ this option will be instead used.
90
+ Returns:
91
+ Parameter dictionary
92
+ """
93
+ params = {
94
+ "@type": "fslgrad",
95
+ "bvecs": bvecs,
96
+ "bvals": bvals,
97
+ }
98
+ return params
99
+
100
+
101
+ def dirstat_fslgrad_validate(
102
+ params: typing.Any,
103
+ ) -> None:
104
+ """
105
+ Validate parameters. Throws an error if `params` is not a valid
106
+ `DirstatFslgradParamsDict` object.
107
+
108
+ Args:
109
+ params: The parameters object to validate.
110
+ """
111
+ if params is None or not isinstance(params, dict):
112
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
113
+ if params.get("bvecs", None) is None:
114
+ raise StyxValidationError("`bvecs` must not be None")
115
+ if not isinstance(params["bvecs"], (pathlib.Path, str)):
116
+ raise StyxValidationError(f'`bvecs` has the wrong type: Received `{type(params.get("bvecs", None))}` expected `InputPathType`')
117
+ if params.get("bvals", None) is None:
118
+ raise StyxValidationError("`bvals` must not be None")
119
+ if not isinstance(params["bvals"], (pathlib.Path, str)):
120
+ raise StyxValidationError(f'`bvals` has the wrong type: Received `{type(params.get("bvals", None))}` expected `InputPathType`')
121
+
122
+
123
+ def dirstat_fslgrad_cargs(
124
+ params: DirstatFslgradParamsDict,
125
+ execution: Execution,
126
+ ) -> list[str]:
127
+ """
128
+ Build command-line arguments from parameters.
129
+
130
+ Args:
131
+ params: The parameters.
132
+ execution: The execution object for resolving input paths.
133
+ Returns:
134
+ Command-line arguments.
135
+ """
136
+ cargs = []
137
+ cargs.append("-fslgrad")
138
+ cargs.append(execution.input_file(params.get("bvecs", None)))
139
+ cargs.append(execution.input_file(params.get("bvals", None)))
140
+ return cargs
141
+
142
+
143
+ def dirstat_config(
144
+ key: str,
145
+ value: str,
146
+ ) -> DirstatConfigParamsDictTagged:
147
+ """
148
+ Build parameters.
149
+
150
+ Args:
151
+ key: temporarily set the value of an MRtrix config file entry.
152
+ value: temporarily set the value of an MRtrix config file entry.
153
+ Returns:
154
+ Parameter dictionary
155
+ """
156
+ params = {
157
+ "@type": "config",
158
+ "key": key,
159
+ "value": value,
160
+ }
161
+ return params
162
+
163
+
164
+ def dirstat_config_validate(
165
+ params: typing.Any,
166
+ ) -> None:
167
+ """
168
+ Validate parameters. Throws an error if `params` is not a valid
169
+ `DirstatConfigParamsDict` object.
170
+
171
+ Args:
172
+ params: The parameters object to validate.
173
+ """
174
+ if params is None or not isinstance(params, dict):
175
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
176
+ if params.get("key", None) is None:
177
+ raise StyxValidationError("`key` must not be None")
178
+ if not isinstance(params["key"], str):
179
+ raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
180
+ if params.get("value", None) is None:
181
+ raise StyxValidationError("`value` must not be None")
182
+ if not isinstance(params["value"], str):
183
+ raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')
184
+
185
+
186
+ def dirstat_config_cargs(
187
+ params: DirstatConfigParamsDict,
188
+ execution: Execution,
189
+ ) -> list[str]:
190
+ """
191
+ Build command-line arguments from parameters.
192
+
193
+ Args:
194
+ params: The parameters.
195
+ execution: The execution object for resolving input paths.
196
+ Returns:
197
+ Command-line arguments.
198
+ """
199
+ cargs = []
200
+ cargs.append("-config")
201
+ cargs.append(params.get("key", None))
202
+ cargs.append(params.get("value", None))
203
+ return cargs
204
+
205
+
206
+ class DirstatOutputs(typing.NamedTuple):
207
+ """
208
+ Output object returned when calling `DirstatParamsDict(...)`.
209
+ """
210
+ root: OutputPathType
211
+ """Output root folder. This is the root folder for all outputs."""
212
+
213
+
214
+ def dirstat_params(
215
+ dirs: InputPathType,
216
+ output: str | None = None,
217
+ shells: list[float] | None = None,
218
+ grad: InputPathType | None = None,
219
+ fslgrad: DirstatFslgradParamsDict | None = None,
220
+ info: bool = False,
221
+ quiet: bool = False,
222
+ debug: bool = False,
223
+ force: bool = False,
224
+ nthreads: int | None = None,
225
+ config: list[DirstatConfigParamsDict] | None = None,
226
+ help_: bool = False,
227
+ version: bool = False,
228
+ ) -> DirstatParamsDictTagged:
229
+ """
230
+ Build parameters.
231
+
232
+ Args:
233
+ dirs: the text file or image containing the directions.
234
+ output: output selected metrics as a space-delimited list, suitable for\
235
+ use in scripts. This will produce one line of values per selected\
236
+ shell. Valid metrics are as specified in the description above.
237
+ shells: specify one or more b-values to use during processing, as a\
238
+ comma-separated list of the desired approximate b-values (b-values are\
239
+ clustered to allow for small deviations). Note that some commands are\
240
+ incompatible with multiple b-values, and will report an error if more\
241
+ than one b-value is provided.\
242
+ WARNING: note that, even though the b=0 volumes are never referred\
243
+ to as shells in the literature, they still have to be explicitly\
244
+ included in the list of b-values as provided to the -shell option!\
245
+ Several algorithms which include the b=0 volumes in their\
246
+ computations may otherwise return an undesired result.
247
+ grad: Provide the diffusion-weighted gradient scheme used in the\
248
+ acquisition in a text file. This should be supplied as a 4xN text file\
249
+ with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
250
+ the direction of the applied gradient, and b gives the b-value in units\
251
+ of s/mm^2. If a diffusion gradient scheme is present in the input image\
252
+ header, the data provided with this option will be instead used.
253
+ fslgrad: Provide the diffusion-weighted gradient scheme used in the\
254
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
255
+ scheme is present in the input image header, the data provided with\
256
+ this option will be instead used.
257
+ info: display information messages.
258
+ quiet: do not display information messages or progress status;\
259
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
260
+ environment variable to a non-empty string.
261
+ debug: display debugging messages.
262
+ force: force overwrite of output files (caution: using the same file as\
263
+ input and output might cause unexpected behaviour).
264
+ nthreads: use this number of threads in multi-threaded applications\
265
+ (set to 0 to disable multi-threading).
266
+ config: temporarily set the value of an MRtrix config file entry.
267
+ help_: display this information page and exit.
268
+ version: display version information and exit.
269
+ Returns:
270
+ Parameter dictionary
271
+ """
272
+ params = {
273
+ "@type": "mrtrix/dirstat",
274
+ "info": info,
275
+ "quiet": quiet,
276
+ "debug": debug,
277
+ "force": force,
278
+ "help": help_,
279
+ "version": version,
280
+ "dirs": dirs,
281
+ }
282
+ if output is not None:
283
+ params["output"] = output
284
+ if shells is not None:
285
+ params["shells"] = shells
286
+ if grad is not None:
287
+ params["grad"] = grad
288
+ if fslgrad is not None:
289
+ params["fslgrad"] = fslgrad
290
+ if nthreads is not None:
291
+ params["nthreads"] = nthreads
292
+ if config is not None:
293
+ params["config"] = config
294
+ return params
295
+
296
+
297
+ def dirstat_validate(
298
+ params: typing.Any,
299
+ ) -> None:
300
+ """
301
+ Validate parameters. Throws an error if `params` is not a valid
302
+ `DirstatParamsDict` object.
303
+
304
+ Args:
305
+ params: The parameters object to validate.
306
+ """
307
+ if params is None or not isinstance(params, dict):
308
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
309
+ if params.get("output", None) is not None:
310
+ if not isinstance(params["output"], str):
311
+ raise StyxValidationError(f'`output` has the wrong type: Received `{type(params.get("output", None))}` expected `str | None`')
312
+ if params.get("shells", None) is not None:
313
+ if not isinstance(params["shells"], list):
314
+ raise StyxValidationError(f'`shells` has the wrong type: Received `{type(params.get("shells", None))}` expected `list[float] | None`')
315
+ for e in params["shells"]:
316
+ if not isinstance(e, (float, int)):
317
+ raise StyxValidationError(f'`shells` has the wrong type: Received `{type(params.get("shells", None))}` expected `list[float] | None`')
318
+ if params.get("grad", None) is not None:
319
+ if not isinstance(params["grad"], (pathlib.Path, str)):
320
+ raise StyxValidationError(f'`grad` has the wrong type: Received `{type(params.get("grad", None))}` expected `InputPathType | None`')
321
+ if params.get("fslgrad", None) is not None:
322
+ dirstat_fslgrad_validate(params["fslgrad"])
323
+ if params.get("info", False) is None:
324
+ raise StyxValidationError("`info` must not be None")
325
+ if not isinstance(params["info"], bool):
326
+ raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
327
+ if params.get("quiet", False) is None:
328
+ raise StyxValidationError("`quiet` must not be None")
329
+ if not isinstance(params["quiet"], bool):
330
+ raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
331
+ if params.get("debug", False) is None:
332
+ raise StyxValidationError("`debug` must not be None")
333
+ if not isinstance(params["debug"], bool):
334
+ raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
335
+ if params.get("force", False) is None:
336
+ raise StyxValidationError("`force` must not be None")
337
+ if not isinstance(params["force"], bool):
338
+ raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
339
+ if params.get("nthreads", None) is not None:
340
+ if not isinstance(params["nthreads"], int):
341
+ raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
342
+ if params.get("config", None) is not None:
343
+ if not isinstance(params["config"], list):
344
+ raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[DirstatConfigParamsDict] | None`')
345
+ for e in params["config"]:
346
+ dirstat_config_validate(e)
347
+ if params.get("help", False) is None:
348
+ raise StyxValidationError("`help` must not be None")
349
+ if not isinstance(params["help"], bool):
350
+ raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
351
+ if params.get("version", False) is None:
352
+ raise StyxValidationError("`version` must not be None")
353
+ if not isinstance(params["version"], bool):
354
+ raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
355
+ if params.get("dirs", None) is None:
356
+ raise StyxValidationError("`dirs` must not be None")
357
+ if not isinstance(params["dirs"], (pathlib.Path, str)):
358
+ raise StyxValidationError(f'`dirs` has the wrong type: Received `{type(params.get("dirs", None))}` expected `InputPathType`')
359
+
360
+
361
+ def dirstat_cargs(
362
+ params: DirstatParamsDict,
363
+ execution: Execution,
364
+ ) -> list[str]:
365
+ """
366
+ Build command-line arguments from parameters.
367
+
368
+ Args:
369
+ params: The parameters.
370
+ execution: The execution object for resolving input paths.
371
+ Returns:
372
+ Command-line arguments.
373
+ """
374
+ cargs = []
375
+ cargs.append("dirstat")
376
+ if params.get("output", None) is not None:
377
+ cargs.extend([
378
+ "-output",
379
+ params.get("output", None)
380
+ ])
381
+ if params.get("shells", None) is not None:
382
+ cargs.extend([
383
+ "-shells",
384
+ ",".join(map(str, params.get("shells", None)))
385
+ ])
386
+ if params.get("grad", None) is not None:
387
+ cargs.extend([
388
+ "-grad",
389
+ execution.input_file(params.get("grad", None))
390
+ ])
391
+ if params.get("fslgrad", None) is not None:
392
+ cargs.extend(dirstat_fslgrad_cargs(params.get("fslgrad", None), execution))
393
+ if params.get("info", False):
394
+ cargs.append("-info")
395
+ if params.get("quiet", False):
396
+ cargs.append("-quiet")
397
+ if params.get("debug", False):
398
+ cargs.append("-debug")
399
+ if params.get("force", False):
400
+ cargs.append("-force")
401
+ if params.get("nthreads", None) is not None:
402
+ cargs.extend([
403
+ "-nthreads",
404
+ str(params.get("nthreads", None))
405
+ ])
406
+ if params.get("config", None) is not None:
407
+ cargs.extend([a for c in [dirstat_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
408
+ if params.get("help", False):
409
+ cargs.append("-help")
410
+ if params.get("version", False):
411
+ cargs.append("-version")
412
+ cargs.append(execution.input_file(params.get("dirs", None)))
413
+ return cargs
414
+
415
+
416
+ def dirstat_outputs(
417
+ params: DirstatParamsDict,
418
+ execution: Execution,
419
+ ) -> DirstatOutputs:
420
+ """
421
+ Build outputs object containing output file paths and possibly stdout/stderr.
422
+
423
+ Args:
424
+ params: The parameters.
425
+ execution: The execution object for resolving input paths.
426
+ Returns:
427
+ Outputs object.
428
+ """
429
+ ret = DirstatOutputs(
430
+ root=execution.output_file("."),
431
+ )
432
+ return ret
433
+
434
+
435
+ def dirstat_execute(
436
+ params: DirstatParamsDict,
437
+ runner: Runner | None = None,
438
+ ) -> DirstatOutputs:
439
+ """
440
+ dirstat
441
+
442
+ Report statistics on a direction set.
443
+
444
+ This command will accept as inputs:
445
+
446
+ - directions file in spherical coordinates (ASCII text, [ az el ]
447
+ space-separated values, one per line);
448
+
449
+ - directions file in Cartesian coordinates (ASCII text, [ x y z ]
450
+ space-separated values, one per line);
451
+
452
+ - DW gradient files (MRtrix format: ASCII text, [ x y z b ] space-separated
453
+ values, one per line);
454
+
455
+ - image files, using the DW gradient scheme found in the header (or provided
456
+ using the appropriate command line options below).
457
+
458
+ By default, this produces all relevant metrics for the direction set
459
+ provided. If the direction set contains multiple shells, metrics are
460
+ provided for each shell separately.
461
+
462
+ Metrics are produced assuming a unipolar or bipolar electrostatic repulsion
463
+ model, producing the potential energy (total, mean, min & max), and the
464
+ nearest-neighbour angles (mean, min & max). The condition number is also
465
+ produced for the spherical harmonic fits up to the highest harmonic order
466
+ supported by the number of volumes. Finally, the norm of the mean direction
467
+ vector is provided as a measure of the overall symmetry of the direction set
468
+ (important with respect to eddy-current resilience).
469
+
470
+ Specific metrics can also be queried independently via the "-output" option,
471
+ using these shorthands:
472
+ U/B for unipolar/bipolar model,
473
+ E/N for energy and nearest-neighbour respectively,
474
+ t/-/+ for total/min/max respectively (mean implied otherwise);
475
+ SHn for condition number of SH fit at order n (with n an even integer);
476
+ ASYM for asymmetry index (norm of mean direction vector);
477
+ N for the number of directions.
478
+
479
+ References:
480
+
481
+ .
482
+
483
+ Author: MRTrix3 Developers
484
+
485
+ URL: https://www.mrtrix.org/
486
+
487
+ Args:
488
+ params: The parameters.
489
+ runner: Command runner.
490
+ Returns:
491
+ NamedTuple of outputs (described in `DirstatOutputs`).
492
+ """
493
+ dirstat_validate(params)
494
+ runner = runner or get_global_runner()
495
+ execution = runner.start_execution(DIRSTAT_METADATA)
496
+ params = execution.params(params)
497
+ cargs = dirstat_cargs(params, execution)
498
+ ret = dirstat_outputs(params, execution)
499
+ execution.run(cargs)
500
+ return ret
501
+
502
+
503
+ def dirstat(
504
+ dirs: InputPathType,
505
+ output: str | None = None,
506
+ shells: list[float] | None = None,
507
+ grad: InputPathType | None = None,
508
+ fslgrad: DirstatFslgradParamsDict | None = None,
509
+ info: bool = False,
510
+ quiet: bool = False,
511
+ debug: bool = False,
512
+ force: bool = False,
513
+ nthreads: int | None = None,
514
+ config: list[DirstatConfigParamsDict] | None = None,
515
+ help_: bool = False,
516
+ version: bool = False,
517
+ runner: Runner | None = None,
518
+ ) -> DirstatOutputs:
519
+ """
520
+ dirstat
521
+
522
+ Report statistics on a direction set.
523
+
524
+ This command will accept as inputs:
525
+
526
+ - directions file in spherical coordinates (ASCII text, [ az el ]
527
+ space-separated values, one per line);
528
+
529
+ - directions file in Cartesian coordinates (ASCII text, [ x y z ]
530
+ space-separated values, one per line);
531
+
532
+ - DW gradient files (MRtrix format: ASCII text, [ x y z b ] space-separated
533
+ values, one per line);
534
+
535
+ - image files, using the DW gradient scheme found in the header (or provided
536
+ using the appropriate command line options below).
537
+
538
+ By default, this produces all relevant metrics for the direction set
539
+ provided. If the direction set contains multiple shells, metrics are
540
+ provided for each shell separately.
541
+
542
+ Metrics are produced assuming a unipolar or bipolar electrostatic repulsion
543
+ model, producing the potential energy (total, mean, min & max), and the
544
+ nearest-neighbour angles (mean, min & max). The condition number is also
545
+ produced for the spherical harmonic fits up to the highest harmonic order
546
+ supported by the number of volumes. Finally, the norm of the mean direction
547
+ vector is provided as a measure of the overall symmetry of the direction set
548
+ (important with respect to eddy-current resilience).
549
+
550
+ Specific metrics can also be queried independently via the "-output" option,
551
+ using these shorthands:
552
+ U/B for unipolar/bipolar model,
553
+ E/N for energy and nearest-neighbour respectively,
554
+ t/-/+ for total/min/max respectively (mean implied otherwise);
555
+ SHn for condition number of SH fit at order n (with n an even integer);
556
+ ASYM for asymmetry index (norm of mean direction vector);
557
+ N for the number of directions.
558
+
559
+ References:
560
+
561
+ .
562
+
563
+ Author: MRTrix3 Developers
564
+
565
+ URL: https://www.mrtrix.org/
566
+
567
+ Args:
568
+ dirs: the text file or image containing the directions.
569
+ output: output selected metrics as a space-delimited list, suitable for\
570
+ use in scripts. This will produce one line of values per selected\
571
+ shell. Valid metrics are as specified in the description above.
572
+ shells: specify one or more b-values to use during processing, as a\
573
+ comma-separated list of the desired approximate b-values (b-values are\
574
+ clustered to allow for small deviations). Note that some commands are\
575
+ incompatible with multiple b-values, and will report an error if more\
576
+ than one b-value is provided.\
577
+ WARNING: note that, even though the b=0 volumes are never referred\
578
+ to as shells in the literature, they still have to be explicitly\
579
+ included in the list of b-values as provided to the -shell option!\
580
+ Several algorithms which include the b=0 volumes in their\
581
+ computations may otherwise return an undesired result.
582
+ grad: Provide the diffusion-weighted gradient scheme used in the\
583
+ acquisition in a text file. This should be supplied as a 4xN text file\
584
+ with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
585
+ the direction of the applied gradient, and b gives the b-value in units\
586
+ of s/mm^2. If a diffusion gradient scheme is present in the input image\
587
+ header, the data provided with this option will be instead used.
588
+ fslgrad: Provide the diffusion-weighted gradient scheme used in the\
589
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
590
+ scheme is present in the input image header, the data provided with\
591
+ this option will be instead used.
592
+ info: display information messages.
593
+ quiet: do not display information messages or progress status;\
594
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
595
+ environment variable to a non-empty string.
596
+ debug: display debugging messages.
597
+ force: force overwrite of output files (caution: using the same file as\
598
+ input and output might cause unexpected behaviour).
599
+ nthreads: use this number of threads in multi-threaded applications\
600
+ (set to 0 to disable multi-threading).
601
+ config: temporarily set the value of an MRtrix config file entry.
602
+ help_: display this information page and exit.
603
+ version: display version information and exit.
604
+ runner: Command runner.
605
+ Returns:
606
+ NamedTuple of outputs (described in `DirstatOutputs`).
607
+ """
608
+ params = dirstat_params(
609
+ output=output,
610
+ shells=shells,
611
+ grad=grad,
612
+ fslgrad=fslgrad,
613
+ info=info,
614
+ quiet=quiet,
615
+ debug=debug,
616
+ force=force,
617
+ nthreads=nthreads,
618
+ config=config,
619
+ help_=help_,
620
+ version=version,
621
+ dirs=dirs,
622
+ )
623
+ return dirstat_execute(params, runner)
624
+
625
+
626
+ __all__ = [
627
+ "DIRSTAT_METADATA",
628
+ "DirstatConfigParamsDict",
629
+ "DirstatConfigParamsDictTagged",
630
+ "DirstatFslgradParamsDict",
631
+ "DirstatFslgradParamsDictTagged",
632
+ "DirstatOutputs",
633
+ "DirstatParamsDict",
634
+ "DirstatParamsDictTagged",
635
+ "dirstat",
636
+ "dirstat_config",
637
+ "dirstat_execute",
638
+ "dirstat_fslgrad",
639
+ "dirstat_params",
640
+ ]