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,844 @@
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
+ SH2AMP_METADATA = Metadata(
9
+ id="845bbdcb825f577d4f4e931e8e0dd0e1f1f2de94.boutiques",
10
+ name="sh2amp",
11
+ package="mrtrix",
12
+ container_image_tag="mrtrix3/mrtrix3:3.0.4",
13
+ )
14
+
15
+
16
+ _Sh2ampFslgradParamsDictNoTag = typing.TypedDict('_Sh2ampFslgradParamsDictNoTag', {
17
+ "bvecs": InputPathType,
18
+ "bvals": InputPathType,
19
+ })
20
+ Sh2ampFslgradParamsDictTagged = typing.TypedDict('Sh2ampFslgradParamsDictTagged', {
21
+ "@type": typing.Literal["fslgrad"],
22
+ "bvecs": InputPathType,
23
+ "bvals": InputPathType,
24
+ })
25
+ Sh2ampFslgradParamsDict = _Sh2ampFslgradParamsDictNoTag | Sh2ampFslgradParamsDictTagged
26
+
27
+
28
+ _Sh2ampVariousStringParamsDictNoTag = typing.TypedDict('_Sh2ampVariousStringParamsDictNoTag', {
29
+ "obj": str,
30
+ })
31
+ Sh2ampVariousStringParamsDictTagged = typing.TypedDict('Sh2ampVariousStringParamsDictTagged', {
32
+ "@type": typing.Literal["VariousString"],
33
+ "obj": str,
34
+ })
35
+ Sh2ampVariousStringParamsDict = _Sh2ampVariousStringParamsDictNoTag | Sh2ampVariousStringParamsDictTagged
36
+
37
+
38
+ _Sh2ampVariousFileParamsDictNoTag = typing.TypedDict('_Sh2ampVariousFileParamsDictNoTag', {
39
+ "obj": InputPathType,
40
+ })
41
+ Sh2ampVariousFileParamsDictTagged = typing.TypedDict('Sh2ampVariousFileParamsDictTagged', {
42
+ "@type": typing.Literal["VariousFile"],
43
+ "obj": InputPathType,
44
+ })
45
+ Sh2ampVariousFileParamsDict = _Sh2ampVariousFileParamsDictNoTag | Sh2ampVariousFileParamsDictTagged
46
+
47
+
48
+ _Sh2ampConfigParamsDictNoTag = typing.TypedDict('_Sh2ampConfigParamsDictNoTag', {
49
+ "key": str,
50
+ "value": str,
51
+ })
52
+ Sh2ampConfigParamsDictTagged = typing.TypedDict('Sh2ampConfigParamsDictTagged', {
53
+ "@type": typing.Literal["config"],
54
+ "key": str,
55
+ "value": str,
56
+ })
57
+ Sh2ampConfigParamsDict = _Sh2ampConfigParamsDictNoTag | Sh2ampConfigParamsDictTagged
58
+
59
+
60
+ _Sh2ampParamsDictNoTag = typing.TypedDict('_Sh2ampParamsDictNoTag', {
61
+ "nonnegative": bool,
62
+ "grad": typing.NotRequired[InputPathType | None],
63
+ "fslgrad": typing.NotRequired[Sh2ampFslgradParamsDict | None],
64
+ "strides": typing.NotRequired[typing.Union[Sh2ampVariousStringParamsDictTagged, Sh2ampVariousFileParamsDictTagged] | None],
65
+ "datatype": typing.NotRequired[str | None],
66
+ "info": bool,
67
+ "quiet": bool,
68
+ "debug": bool,
69
+ "force": bool,
70
+ "nthreads": typing.NotRequired[int | None],
71
+ "config": typing.NotRequired[list[Sh2ampConfigParamsDict] | None],
72
+ "help": bool,
73
+ "version": bool,
74
+ "input": InputPathType,
75
+ "directions": InputPathType,
76
+ "output": str,
77
+ })
78
+ Sh2ampParamsDictTagged = typing.TypedDict('Sh2ampParamsDictTagged', {
79
+ "@type": typing.Literal["mrtrix/sh2amp"],
80
+ "nonnegative": bool,
81
+ "grad": typing.NotRequired[InputPathType | None],
82
+ "fslgrad": typing.NotRequired[Sh2ampFslgradParamsDict | None],
83
+ "strides": typing.NotRequired[typing.Union[Sh2ampVariousStringParamsDictTagged, Sh2ampVariousFileParamsDictTagged] | None],
84
+ "datatype": typing.NotRequired[str | None],
85
+ "info": bool,
86
+ "quiet": bool,
87
+ "debug": bool,
88
+ "force": bool,
89
+ "nthreads": typing.NotRequired[int | None],
90
+ "config": typing.NotRequired[list[Sh2ampConfigParamsDict] | None],
91
+ "help": bool,
92
+ "version": bool,
93
+ "input": InputPathType,
94
+ "directions": InputPathType,
95
+ "output": str,
96
+ })
97
+ Sh2ampParamsDict = _Sh2ampParamsDictNoTag | Sh2ampParamsDictTagged
98
+
99
+
100
+ def sh2amp_strides_cargs_dyn_fn(
101
+ t: str,
102
+ ) -> typing.Any:
103
+ """
104
+ Get build cargs function by command type.
105
+
106
+ Args:
107
+ t: Command type.
108
+ Returns:
109
+ Build cargs function.
110
+ """
111
+ return {
112
+ "VariousString": sh2amp_various_string_cargs,
113
+ "VariousFile": sh2amp_various_file_cargs,
114
+ }.get(t)
115
+
116
+
117
+ def sh2amp_strides_validate_dyn_fn(
118
+ t: str,
119
+ ) -> typing.Any:
120
+ """
121
+ Get validate params function by command type.
122
+
123
+ Args:
124
+ t: Command type.
125
+ Returns:
126
+ Validate params function.
127
+ """
128
+ return {
129
+ "VariousString": sh2amp_various_string_validate,
130
+ "VariousFile": sh2amp_various_file_validate,
131
+ }.get(t)
132
+
133
+
134
+ def sh2amp_fslgrad(
135
+ bvecs: InputPathType,
136
+ bvals: InputPathType,
137
+ ) -> Sh2ampFslgradParamsDictTagged:
138
+ """
139
+ Build parameters.
140
+
141
+ Args:
142
+ bvecs: Provide the diffusion-weighted gradient scheme used in the\
143
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
144
+ scheme is present in the input image header, the data provided with\
145
+ this option will be instead used.
146
+ bvals: Provide the diffusion-weighted gradient scheme used in the\
147
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
148
+ scheme is present in the input image header, the data provided with\
149
+ this option will be instead used.
150
+ Returns:
151
+ Parameter dictionary
152
+ """
153
+ params = {
154
+ "@type": "fslgrad",
155
+ "bvecs": bvecs,
156
+ "bvals": bvals,
157
+ }
158
+ return params
159
+
160
+
161
+ def sh2amp_fslgrad_validate(
162
+ params: typing.Any,
163
+ ) -> None:
164
+ """
165
+ Validate parameters. Throws an error if `params` is not a valid
166
+ `Sh2ampFslgradParamsDict` object.
167
+
168
+ Args:
169
+ params: The parameters object to validate.
170
+ """
171
+ if params is None or not isinstance(params, dict):
172
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
173
+ if params.get("bvecs", None) is None:
174
+ raise StyxValidationError("`bvecs` must not be None")
175
+ if not isinstance(params["bvecs"], (pathlib.Path, str)):
176
+ raise StyxValidationError(f'`bvecs` has the wrong type: Received `{type(params.get("bvecs", None))}` expected `InputPathType`')
177
+ if params.get("bvals", None) is None:
178
+ raise StyxValidationError("`bvals` must not be None")
179
+ if not isinstance(params["bvals"], (pathlib.Path, str)):
180
+ raise StyxValidationError(f'`bvals` has the wrong type: Received `{type(params.get("bvals", None))}` expected `InputPathType`')
181
+
182
+
183
+ def sh2amp_fslgrad_cargs(
184
+ params: Sh2ampFslgradParamsDict,
185
+ execution: Execution,
186
+ ) -> list[str]:
187
+ """
188
+ Build command-line arguments from parameters.
189
+
190
+ Args:
191
+ params: The parameters.
192
+ execution: The execution object for resolving input paths.
193
+ Returns:
194
+ Command-line arguments.
195
+ """
196
+ cargs = []
197
+ cargs.append("-fslgrad")
198
+ cargs.append(execution.input_file(params.get("bvecs", None)))
199
+ cargs.append(execution.input_file(params.get("bvals", None)))
200
+ return cargs
201
+
202
+
203
+ def sh2amp_various_string(
204
+ obj: str,
205
+ ) -> Sh2ampVariousStringParamsDictTagged:
206
+ """
207
+ Build parameters.
208
+
209
+ Args:
210
+ obj: String object.
211
+ Returns:
212
+ Parameter dictionary
213
+ """
214
+ params = {
215
+ "@type": "VariousString",
216
+ "obj": obj,
217
+ }
218
+ return params
219
+
220
+
221
+ def sh2amp_various_string_validate(
222
+ params: typing.Any,
223
+ ) -> None:
224
+ """
225
+ Validate parameters. Throws an error if `params` is not a valid
226
+ `Sh2ampVariousStringParamsDict` object.
227
+
228
+ Args:
229
+ params: The parameters object to validate.
230
+ """
231
+ if params is None or not isinstance(params, dict):
232
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
233
+ if params.get("obj", None) is None:
234
+ raise StyxValidationError("`obj` must not be None")
235
+ if not isinstance(params["obj"], str):
236
+ raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `str`')
237
+
238
+
239
+ def sh2amp_various_string_cargs(
240
+ params: Sh2ampVariousStringParamsDict,
241
+ execution: Execution,
242
+ ) -> list[str]:
243
+ """
244
+ Build command-line arguments from parameters.
245
+
246
+ Args:
247
+ params: The parameters.
248
+ execution: The execution object for resolving input paths.
249
+ Returns:
250
+ Command-line arguments.
251
+ """
252
+ cargs = []
253
+ cargs.append(params.get("obj", None))
254
+ return cargs
255
+
256
+
257
+ def sh2amp_various_file(
258
+ obj: InputPathType,
259
+ ) -> Sh2ampVariousFileParamsDictTagged:
260
+ """
261
+ Build parameters.
262
+
263
+ Args:
264
+ obj: File object.
265
+ Returns:
266
+ Parameter dictionary
267
+ """
268
+ params = {
269
+ "@type": "VariousFile",
270
+ "obj": obj,
271
+ }
272
+ return params
273
+
274
+
275
+ def sh2amp_various_file_validate(
276
+ params: typing.Any,
277
+ ) -> None:
278
+ """
279
+ Validate parameters. Throws an error if `params` is not a valid
280
+ `Sh2ampVariousFileParamsDict` object.
281
+
282
+ Args:
283
+ params: The parameters object to validate.
284
+ """
285
+ if params is None or not isinstance(params, dict):
286
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
287
+ if params.get("obj", None) is None:
288
+ raise StyxValidationError("`obj` must not be None")
289
+ if not isinstance(params["obj"], (pathlib.Path, str)):
290
+ raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `InputPathType`')
291
+
292
+
293
+ def sh2amp_various_file_cargs(
294
+ params: Sh2ampVariousFileParamsDict,
295
+ execution: Execution,
296
+ ) -> list[str]:
297
+ """
298
+ Build command-line arguments from parameters.
299
+
300
+ Args:
301
+ params: The parameters.
302
+ execution: The execution object for resolving input paths.
303
+ Returns:
304
+ Command-line arguments.
305
+ """
306
+ cargs = []
307
+ cargs.append(execution.input_file(params.get("obj", None)))
308
+ return cargs
309
+
310
+
311
+ def sh2amp_config(
312
+ key: str,
313
+ value: str,
314
+ ) -> Sh2ampConfigParamsDictTagged:
315
+ """
316
+ Build parameters.
317
+
318
+ Args:
319
+ key: temporarily set the value of an MRtrix config file entry.
320
+ value: temporarily set the value of an MRtrix config file entry.
321
+ Returns:
322
+ Parameter dictionary
323
+ """
324
+ params = {
325
+ "@type": "config",
326
+ "key": key,
327
+ "value": value,
328
+ }
329
+ return params
330
+
331
+
332
+ def sh2amp_config_validate(
333
+ params: typing.Any,
334
+ ) -> None:
335
+ """
336
+ Validate parameters. Throws an error if `params` is not a valid
337
+ `Sh2ampConfigParamsDict` object.
338
+
339
+ Args:
340
+ params: The parameters object to validate.
341
+ """
342
+ if params is None or not isinstance(params, dict):
343
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
344
+ if params.get("key", None) is None:
345
+ raise StyxValidationError("`key` must not be None")
346
+ if not isinstance(params["key"], str):
347
+ raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
348
+ if params.get("value", None) is None:
349
+ raise StyxValidationError("`value` must not be None")
350
+ if not isinstance(params["value"], str):
351
+ raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')
352
+
353
+
354
+ def sh2amp_config_cargs(
355
+ params: Sh2ampConfigParamsDict,
356
+ execution: Execution,
357
+ ) -> list[str]:
358
+ """
359
+ Build command-line arguments from parameters.
360
+
361
+ Args:
362
+ params: The parameters.
363
+ execution: The execution object for resolving input paths.
364
+ Returns:
365
+ Command-line arguments.
366
+ """
367
+ cargs = []
368
+ cargs.append("-config")
369
+ cargs.append(params.get("key", None))
370
+ cargs.append(params.get("value", None))
371
+ return cargs
372
+
373
+
374
+ class Sh2ampOutputs(typing.NamedTuple):
375
+ """
376
+ Output object returned when calling `Sh2ampParamsDict(...)`.
377
+ """
378
+ root: OutputPathType
379
+ """Output root folder. This is the root folder for all outputs."""
380
+ output: OutputPathType
381
+ """the output image consisting of the amplitude of the SH functions along
382
+ the specified directions."""
383
+
384
+
385
+ def sh2amp_params(
386
+ input_: InputPathType,
387
+ directions: InputPathType,
388
+ output: str,
389
+ nonnegative: bool = False,
390
+ grad: InputPathType | None = None,
391
+ fslgrad: Sh2ampFslgradParamsDict | None = None,
392
+ strides: typing.Union[Sh2ampVariousStringParamsDictTagged, Sh2ampVariousFileParamsDictTagged] | None = None,
393
+ datatype: str | None = None,
394
+ info: bool = False,
395
+ quiet: bool = False,
396
+ debug: bool = False,
397
+ force: bool = False,
398
+ nthreads: int | None = None,
399
+ config: list[Sh2ampConfigParamsDict] | None = None,
400
+ help_: bool = False,
401
+ version: bool = False,
402
+ ) -> Sh2ampParamsDictTagged:
403
+ """
404
+ Build parameters.
405
+
406
+ Args:
407
+ input_: the input image consisting of spherical harmonic (SH)\
408
+ coefficients.
409
+ directions: the list of directions along which the SH functions will be\
410
+ sampled, generated using the dirgen command.
411
+ output: the output image consisting of the amplitude of the SH\
412
+ functions along the specified directions.
413
+ nonnegative: cap all negative amplitudes to zero.
414
+ grad: Provide the diffusion-weighted gradient scheme used in the\
415
+ acquisition in a text file. This should be supplied as a 4xN text file\
416
+ with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
417
+ the direction of the applied gradient, and b gives the b-value in units\
418
+ of s/mm^2. If a diffusion gradient scheme is present in the input image\
419
+ header, the data provided with this option will be instead used.
420
+ fslgrad: Provide the diffusion-weighted gradient scheme used in the\
421
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
422
+ scheme is present in the input image header, the data provided with\
423
+ this option will be instead used.
424
+ strides: specify the strides of the output data in memory; either as a\
425
+ comma-separated list of (signed) integers, or as a template image from\
426
+ which the strides shall be extracted and used. The actual strides\
427
+ produced will depend on whether the output image format can support it.
428
+ datatype: specify output image data type. Valid choices are: float32,\
429
+ float32le, float32be, float64, float64le, float64be, int64, uint64,\
430
+ int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
431
+ int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
432
+ cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
433
+ int8, uint8, bit.
434
+ info: display information messages.
435
+ quiet: do not display information messages or progress status;\
436
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
437
+ environment variable to a non-empty string.
438
+ debug: display debugging messages.
439
+ force: force overwrite of output files (caution: using the same file as\
440
+ input and output might cause unexpected behaviour).
441
+ nthreads: use this number of threads in multi-threaded applications\
442
+ (set to 0 to disable multi-threading).
443
+ config: temporarily set the value of an MRtrix config file entry.
444
+ help_: display this information page and exit.
445
+ version: display version information and exit.
446
+ Returns:
447
+ Parameter dictionary
448
+ """
449
+ params = {
450
+ "@type": "mrtrix/sh2amp",
451
+ "nonnegative": nonnegative,
452
+ "info": info,
453
+ "quiet": quiet,
454
+ "debug": debug,
455
+ "force": force,
456
+ "help": help_,
457
+ "version": version,
458
+ "input": input_,
459
+ "directions": directions,
460
+ "output": output,
461
+ }
462
+ if grad is not None:
463
+ params["grad"] = grad
464
+ if fslgrad is not None:
465
+ params["fslgrad"] = fslgrad
466
+ if strides is not None:
467
+ params["strides"] = strides
468
+ if datatype is not None:
469
+ params["datatype"] = datatype
470
+ if nthreads is not None:
471
+ params["nthreads"] = nthreads
472
+ if config is not None:
473
+ params["config"] = config
474
+ return params
475
+
476
+
477
+ def sh2amp_validate(
478
+ params: typing.Any,
479
+ ) -> None:
480
+ """
481
+ Validate parameters. Throws an error if `params` is not a valid
482
+ `Sh2ampParamsDict` object.
483
+
484
+ Args:
485
+ params: The parameters object to validate.
486
+ """
487
+ if params is None or not isinstance(params, dict):
488
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
489
+ if params.get("nonnegative", False) is None:
490
+ raise StyxValidationError("`nonnegative` must not be None")
491
+ if not isinstance(params["nonnegative"], bool):
492
+ raise StyxValidationError(f'`nonnegative` has the wrong type: Received `{type(params.get("nonnegative", False))}` expected `bool`')
493
+ if params.get("grad", None) is not None:
494
+ if not isinstance(params["grad"], (pathlib.Path, str)):
495
+ raise StyxValidationError(f'`grad` has the wrong type: Received `{type(params.get("grad", None))}` expected `InputPathType | None`')
496
+ if params.get("fslgrad", None) is not None:
497
+ sh2amp_fslgrad_validate(params["fslgrad"])
498
+ if params.get("strides", None) is not None:
499
+ if not isinstance(params["strides"], dict):
500
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params["strides"])}\'')
501
+ if "@type" not in params["strides"]:
502
+ raise StyxValidationError("Params object is missing `@type`")
503
+ if params["strides"]["@type"] not in ["VariousString", "VariousFile"]:
504
+ raise StyxValidationError("Parameter `strides`s `@type` must be one of [\"VariousString\", \"VariousFile\"]")
505
+ sh2amp_strides_validate_dyn_fn(params["strides"]["@type"])(params["strides"])
506
+ if params.get("datatype", None) is not None:
507
+ if not isinstance(params["datatype"], str):
508
+ raise StyxValidationError(f'`datatype` has the wrong type: Received `{type(params.get("datatype", None))}` expected `str | None`')
509
+ if params.get("info", False) is None:
510
+ raise StyxValidationError("`info` must not be None")
511
+ if not isinstance(params["info"], bool):
512
+ raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
513
+ if params.get("quiet", False) is None:
514
+ raise StyxValidationError("`quiet` must not be None")
515
+ if not isinstance(params["quiet"], bool):
516
+ raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
517
+ if params.get("debug", False) is None:
518
+ raise StyxValidationError("`debug` must not be None")
519
+ if not isinstance(params["debug"], bool):
520
+ raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
521
+ if params.get("force", False) is None:
522
+ raise StyxValidationError("`force` must not be None")
523
+ if not isinstance(params["force"], bool):
524
+ raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
525
+ if params.get("nthreads", None) is not None:
526
+ if not isinstance(params["nthreads"], int):
527
+ raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
528
+ if params.get("config", None) is not None:
529
+ if not isinstance(params["config"], list):
530
+ raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[Sh2ampConfigParamsDict] | None`')
531
+ for e in params["config"]:
532
+ sh2amp_config_validate(e)
533
+ if params.get("help", False) is None:
534
+ raise StyxValidationError("`help` must not be None")
535
+ if not isinstance(params["help"], bool):
536
+ raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
537
+ if params.get("version", False) is None:
538
+ raise StyxValidationError("`version` must not be None")
539
+ if not isinstance(params["version"], bool):
540
+ raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
541
+ if params.get("input", None) is None:
542
+ raise StyxValidationError("`input` must not be None")
543
+ if not isinstance(params["input"], (pathlib.Path, str)):
544
+ raise StyxValidationError(f'`input` has the wrong type: Received `{type(params.get("input", None))}` expected `InputPathType`')
545
+ if params.get("directions", None) is None:
546
+ raise StyxValidationError("`directions` must not be None")
547
+ if not isinstance(params["directions"], (pathlib.Path, str)):
548
+ raise StyxValidationError(f'`directions` has the wrong type: Received `{type(params.get("directions", None))}` expected `InputPathType`')
549
+ if params.get("output", None) is None:
550
+ raise StyxValidationError("`output` must not be None")
551
+ if not isinstance(params["output"], str):
552
+ raise StyxValidationError(f'`output` has the wrong type: Received `{type(params.get("output", None))}` expected `str`')
553
+
554
+
555
+ def sh2amp_cargs(
556
+ params: Sh2ampParamsDict,
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("sh2amp")
570
+ if params.get("nonnegative", False):
571
+ cargs.append("-nonnegative")
572
+ if params.get("grad", None) is not None:
573
+ cargs.extend([
574
+ "-grad",
575
+ execution.input_file(params.get("grad", None))
576
+ ])
577
+ if params.get("fslgrad", None) is not None:
578
+ cargs.extend(sh2amp_fslgrad_cargs(params.get("fslgrad", None), execution))
579
+ if params.get("strides", None) is not None:
580
+ cargs.extend([
581
+ "-strides",
582
+ *sh2amp_strides_cargs_dyn_fn(params.get("strides", None)["@type"])(params.get("strides", None), execution)
583
+ ])
584
+ if params.get("datatype", None) is not None:
585
+ cargs.extend([
586
+ "-datatype",
587
+ params.get("datatype", None)
588
+ ])
589
+ if params.get("info", False):
590
+ cargs.append("-info")
591
+ if params.get("quiet", False):
592
+ cargs.append("-quiet")
593
+ if params.get("debug", False):
594
+ cargs.append("-debug")
595
+ if params.get("force", False):
596
+ cargs.append("-force")
597
+ if params.get("nthreads", None) is not None:
598
+ cargs.extend([
599
+ "-nthreads",
600
+ str(params.get("nthreads", None))
601
+ ])
602
+ if params.get("config", None) is not None:
603
+ cargs.extend([a for c in [sh2amp_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
604
+ if params.get("help", False):
605
+ cargs.append("-help")
606
+ if params.get("version", False):
607
+ cargs.append("-version")
608
+ cargs.append(execution.input_file(params.get("input", None)))
609
+ cargs.append(execution.input_file(params.get("directions", None)))
610
+ cargs.append(params.get("output", None))
611
+ return cargs
612
+
613
+
614
+ def sh2amp_outputs(
615
+ params: Sh2ampParamsDict,
616
+ execution: Execution,
617
+ ) -> Sh2ampOutputs:
618
+ """
619
+ Build outputs object containing output file paths and possibly stdout/stderr.
620
+
621
+ Args:
622
+ params: The parameters.
623
+ execution: The execution object for resolving input paths.
624
+ Returns:
625
+ Outputs object.
626
+ """
627
+ ret = Sh2ampOutputs(
628
+ root=execution.output_file("."),
629
+ output=execution.output_file(params.get("output", None)),
630
+ )
631
+ return ret
632
+
633
+
634
+ def sh2amp_execute(
635
+ params: Sh2ampParamsDict,
636
+ runner: Runner | None = None,
637
+ ) -> Sh2ampOutputs:
638
+ """
639
+ sh2amp
640
+
641
+ Evaluate the amplitude of an image of spherical harmonic functions along
642
+ specified directions.
643
+
644
+ The input image should consist of a 4D or 5D image, with SH coefficients
645
+ along the 4th dimension according to the convention below. If 4D (or size 1
646
+ along the 5th dimension), the program expects to be provided with a single
647
+ shell of directions. If 5D, each set of coefficients along the 5th dimension
648
+ is understood to correspond to a different shell.
649
+
650
+ The directions can be provided as:
651
+ - a 2-column ASCII text file contained azimuth / elevation pairs (as
652
+ produced by dirgen)
653
+ - a 3-column ASCII text file containing x, y, z Cartesian direction vectors
654
+ (as produced by dirgen -cart)
655
+ - a 4-column ASCII text file containing the x, y, z, b components of a full
656
+ DW encoding scheme (in MRtrix format, see main documentation for details).
657
+ - an image file whose header contains a valid DW encoding scheme
658
+
659
+ If a full DW encoding is provided, the number of shells needs to match those
660
+ found in the input image of coefficients (i.e. its size along the 5th
661
+ dimension). If needed, the -shell option can be used to pick out the
662
+ specific shell(s) of interest.
663
+
664
+ If the input image contains multiple shells (its size along the 5th
665
+ dimension is greater than one), the program will expect the direction set to
666
+ contain multiple shells, which can only be provided as a full DW encodings
667
+ (the last two options in the list above).
668
+
669
+ The spherical harmonic coefficients are stored according the conventions
670
+ described the main documentation, which can be found at the following link:
671
+ https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
672
+
673
+ References:
674
+
675
+ .
676
+
677
+ Author: MRTrix3 Developers
678
+
679
+ URL: https://www.mrtrix.org/
680
+
681
+ Args:
682
+ params: The parameters.
683
+ runner: Command runner.
684
+ Returns:
685
+ NamedTuple of outputs (described in `Sh2ampOutputs`).
686
+ """
687
+ sh2amp_validate(params)
688
+ runner = runner or get_global_runner()
689
+ execution = runner.start_execution(SH2AMP_METADATA)
690
+ params = execution.params(params)
691
+ cargs = sh2amp_cargs(params, execution)
692
+ ret = sh2amp_outputs(params, execution)
693
+ execution.run(cargs)
694
+ return ret
695
+
696
+
697
+ def sh2amp(
698
+ input_: InputPathType,
699
+ directions: InputPathType,
700
+ output: str,
701
+ nonnegative: bool = False,
702
+ grad: InputPathType | None = None,
703
+ fslgrad: Sh2ampFslgradParamsDict | None = None,
704
+ strides: typing.Union[Sh2ampVariousStringParamsDictTagged, Sh2ampVariousFileParamsDictTagged] | None = None,
705
+ datatype: str | None = None,
706
+ info: bool = False,
707
+ quiet: bool = False,
708
+ debug: bool = False,
709
+ force: bool = False,
710
+ nthreads: int | None = None,
711
+ config: list[Sh2ampConfigParamsDict] | None = None,
712
+ help_: bool = False,
713
+ version: bool = False,
714
+ runner: Runner | None = None,
715
+ ) -> Sh2ampOutputs:
716
+ """
717
+ sh2amp
718
+
719
+ Evaluate the amplitude of an image of spherical harmonic functions along
720
+ specified directions.
721
+
722
+ The input image should consist of a 4D or 5D image, with SH coefficients
723
+ along the 4th dimension according to the convention below. If 4D (or size 1
724
+ along the 5th dimension), the program expects to be provided with a single
725
+ shell of directions. If 5D, each set of coefficients along the 5th dimension
726
+ is understood to correspond to a different shell.
727
+
728
+ The directions can be provided as:
729
+ - a 2-column ASCII text file contained azimuth / elevation pairs (as
730
+ produced by dirgen)
731
+ - a 3-column ASCII text file containing x, y, z Cartesian direction vectors
732
+ (as produced by dirgen -cart)
733
+ - a 4-column ASCII text file containing the x, y, z, b components of a full
734
+ DW encoding scheme (in MRtrix format, see main documentation for details).
735
+ - an image file whose header contains a valid DW encoding scheme
736
+
737
+ If a full DW encoding is provided, the number of shells needs to match those
738
+ found in the input image of coefficients (i.e. its size along the 5th
739
+ dimension). If needed, the -shell option can be used to pick out the
740
+ specific shell(s) of interest.
741
+
742
+ If the input image contains multiple shells (its size along the 5th
743
+ dimension is greater than one), the program will expect the direction set to
744
+ contain multiple shells, which can only be provided as a full DW encodings
745
+ (the last two options in the list above).
746
+
747
+ The spherical harmonic coefficients are stored according the conventions
748
+ described the main documentation, which can be found at the following link:
749
+ https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
750
+
751
+ References:
752
+
753
+ .
754
+
755
+ Author: MRTrix3 Developers
756
+
757
+ URL: https://www.mrtrix.org/
758
+
759
+ Args:
760
+ input_: the input image consisting of spherical harmonic (SH)\
761
+ coefficients.
762
+ directions: the list of directions along which the SH functions will be\
763
+ sampled, generated using the dirgen command.
764
+ output: the output image consisting of the amplitude of the SH\
765
+ functions along the specified directions.
766
+ nonnegative: cap all negative amplitudes to zero.
767
+ grad: Provide the diffusion-weighted gradient scheme used in the\
768
+ acquisition in a text file. This should be supplied as a 4xN text file\
769
+ with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
770
+ the direction of the applied gradient, and b gives the b-value in units\
771
+ of s/mm^2. If a diffusion gradient scheme is present in the input image\
772
+ header, the data provided with this option will be instead used.
773
+ fslgrad: Provide the diffusion-weighted gradient scheme used in the\
774
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
775
+ scheme is present in the input image header, the data provided with\
776
+ this option will be instead used.
777
+ strides: specify the strides of the output data in memory; either as a\
778
+ comma-separated list of (signed) integers, or as a template image from\
779
+ which the strides shall be extracted and used. The actual strides\
780
+ produced will depend on whether the output image format can support it.
781
+ datatype: specify output image data type. Valid choices are: float32,\
782
+ float32le, float32be, float64, float64le, float64be, int64, uint64,\
783
+ int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
784
+ int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
785
+ cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
786
+ int8, uint8, bit.
787
+ info: display information messages.
788
+ quiet: do not display information messages or progress status;\
789
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
790
+ environment variable to a non-empty string.
791
+ debug: display debugging messages.
792
+ force: force overwrite of output files (caution: using the same file as\
793
+ input and output might cause unexpected behaviour).
794
+ nthreads: use this number of threads in multi-threaded applications\
795
+ (set to 0 to disable multi-threading).
796
+ config: temporarily set the value of an MRtrix config file entry.
797
+ help_: display this information page and exit.
798
+ version: display version information and exit.
799
+ runner: Command runner.
800
+ Returns:
801
+ NamedTuple of outputs (described in `Sh2ampOutputs`).
802
+ """
803
+ params = sh2amp_params(
804
+ nonnegative=nonnegative,
805
+ grad=grad,
806
+ fslgrad=fslgrad,
807
+ strides=strides,
808
+ datatype=datatype,
809
+ info=info,
810
+ quiet=quiet,
811
+ debug=debug,
812
+ force=force,
813
+ nthreads=nthreads,
814
+ config=config,
815
+ help_=help_,
816
+ version=version,
817
+ input_=input_,
818
+ directions=directions,
819
+ output=output,
820
+ )
821
+ return sh2amp_execute(params, runner)
822
+
823
+
824
+ __all__ = [
825
+ "SH2AMP_METADATA",
826
+ "Sh2ampConfigParamsDict",
827
+ "Sh2ampConfigParamsDictTagged",
828
+ "Sh2ampFslgradParamsDict",
829
+ "Sh2ampFslgradParamsDictTagged",
830
+ "Sh2ampOutputs",
831
+ "Sh2ampParamsDict",
832
+ "Sh2ampParamsDictTagged",
833
+ "Sh2ampVariousFileParamsDict",
834
+ "Sh2ampVariousFileParamsDictTagged",
835
+ "Sh2ampVariousStringParamsDict",
836
+ "Sh2ampVariousStringParamsDictTagged",
837
+ "sh2amp",
838
+ "sh2amp_config",
839
+ "sh2amp_execute",
840
+ "sh2amp_fslgrad",
841
+ "sh2amp_params",
842
+ "sh2amp_various_file",
843
+ "sh2amp_various_string",
844
+ ]