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,2733 @@
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
+ TCKGEN_METADATA = Metadata(
9
+ id="49bb9108a82b9af72391f635d21ece29154ff9f6.boutiques",
10
+ name="tckgen",
11
+ package="mrtrix",
12
+ container_image_tag="mrtrix3/mrtrix3:3.0.4",
13
+ )
14
+
15
+
16
+ _TckgenSeedImageParamsDictNoTag = typing.TypedDict('_TckgenSeedImageParamsDictNoTag', {
17
+ "image": InputPathType,
18
+ })
19
+ TckgenSeedImageParamsDictTagged = typing.TypedDict('TckgenSeedImageParamsDictTagged', {
20
+ "@type": typing.Literal["seed_image"],
21
+ "image": InputPathType,
22
+ })
23
+ TckgenSeedImageParamsDict = _TckgenSeedImageParamsDictNoTag | TckgenSeedImageParamsDictTagged
24
+
25
+
26
+ _TckgenSeedSphereParamsDictNoTag = typing.TypedDict('_TckgenSeedSphereParamsDictNoTag', {
27
+ "spec": list[float],
28
+ })
29
+ TckgenSeedSphereParamsDictTagged = typing.TypedDict('TckgenSeedSphereParamsDictTagged', {
30
+ "@type": typing.Literal["seed_sphere"],
31
+ "spec": list[float],
32
+ })
33
+ TckgenSeedSphereParamsDict = _TckgenSeedSphereParamsDictNoTag | TckgenSeedSphereParamsDictTagged
34
+
35
+
36
+ _TckgenSeedRandomPerVoxelParamsDictNoTag = typing.TypedDict('_TckgenSeedRandomPerVoxelParamsDictNoTag', {
37
+ "image": InputPathType,
38
+ "num_per_voxel": int,
39
+ })
40
+ TckgenSeedRandomPerVoxelParamsDictTagged = typing.TypedDict('TckgenSeedRandomPerVoxelParamsDictTagged', {
41
+ "@type": typing.Literal["seed_random_per_voxel"],
42
+ "image": InputPathType,
43
+ "num_per_voxel": int,
44
+ })
45
+ TckgenSeedRandomPerVoxelParamsDict = _TckgenSeedRandomPerVoxelParamsDictNoTag | TckgenSeedRandomPerVoxelParamsDictTagged
46
+
47
+
48
+ _TckgenSeedGridPerVoxelParamsDictNoTag = typing.TypedDict('_TckgenSeedGridPerVoxelParamsDictNoTag', {
49
+ "image": InputPathType,
50
+ "grid_size": int,
51
+ })
52
+ TckgenSeedGridPerVoxelParamsDictTagged = typing.TypedDict('TckgenSeedGridPerVoxelParamsDictTagged', {
53
+ "@type": typing.Literal["seed_grid_per_voxel"],
54
+ "image": InputPathType,
55
+ "grid_size": int,
56
+ })
57
+ TckgenSeedGridPerVoxelParamsDict = _TckgenSeedGridPerVoxelParamsDictNoTag | TckgenSeedGridPerVoxelParamsDictTagged
58
+
59
+
60
+ _TckgenSeedRejectionParamsDictNoTag = typing.TypedDict('_TckgenSeedRejectionParamsDictNoTag', {
61
+ "image": InputPathType,
62
+ })
63
+ TckgenSeedRejectionParamsDictTagged = typing.TypedDict('TckgenSeedRejectionParamsDictTagged', {
64
+ "@type": typing.Literal["seed_rejection"],
65
+ "image": InputPathType,
66
+ })
67
+ TckgenSeedRejectionParamsDict = _TckgenSeedRejectionParamsDictNoTag | TckgenSeedRejectionParamsDictTagged
68
+
69
+
70
+ _TckgenSeedGmwmiParamsDictNoTag = typing.TypedDict('_TckgenSeedGmwmiParamsDictNoTag', {
71
+ "image": InputPathType,
72
+ })
73
+ TckgenSeedGmwmiParamsDictTagged = typing.TypedDict('TckgenSeedGmwmiParamsDictTagged', {
74
+ "@type": typing.Literal["seed_gmwmi"],
75
+ "image": InputPathType,
76
+ })
77
+ TckgenSeedGmwmiParamsDict = _TckgenSeedGmwmiParamsDictNoTag | TckgenSeedGmwmiParamsDictTagged
78
+
79
+
80
+ _TckgenVariousStringParamsDictNoTag = typing.TypedDict('_TckgenVariousStringParamsDictNoTag', {
81
+ "obj": str,
82
+ })
83
+ TckgenVariousStringParamsDictTagged = typing.TypedDict('TckgenVariousStringParamsDictTagged', {
84
+ "@type": typing.Literal["VariousString"],
85
+ "obj": str,
86
+ })
87
+ TckgenVariousStringParamsDict = _TckgenVariousStringParamsDictNoTag | TckgenVariousStringParamsDictTagged
88
+
89
+
90
+ _TckgenVariousFileParamsDictNoTag = typing.TypedDict('_TckgenVariousFileParamsDictNoTag', {
91
+ "obj": InputPathType,
92
+ })
93
+ TckgenVariousFileParamsDictTagged = typing.TypedDict('TckgenVariousFileParamsDictTagged', {
94
+ "@type": typing.Literal["VariousFile"],
95
+ "obj": InputPathType,
96
+ })
97
+ TckgenVariousFileParamsDict = _TckgenVariousFileParamsDictNoTag | TckgenVariousFileParamsDictTagged
98
+
99
+
100
+ _TckgenIncludeParamsDictNoTag = typing.TypedDict('_TckgenIncludeParamsDictNoTag', {
101
+ "spec": typing.Union[TckgenVariousStringParamsDictTagged, TckgenVariousFileParamsDictTagged],
102
+ })
103
+ TckgenIncludeParamsDictTagged = typing.TypedDict('TckgenIncludeParamsDictTagged', {
104
+ "@type": typing.Literal["include"],
105
+ "spec": typing.Union[TckgenVariousStringParamsDictTagged, TckgenVariousFileParamsDictTagged],
106
+ })
107
+ TckgenIncludeParamsDict = _TckgenIncludeParamsDictNoTag | TckgenIncludeParamsDictTagged
108
+
109
+
110
+ _TckgenIncludeOrderedParamsDictNoTag = typing.TypedDict('_TckgenIncludeOrderedParamsDictNoTag', {
111
+ "image": str,
112
+ })
113
+ TckgenIncludeOrderedParamsDictTagged = typing.TypedDict('TckgenIncludeOrderedParamsDictTagged', {
114
+ "@type": typing.Literal["include_ordered"],
115
+ "image": str,
116
+ })
117
+ TckgenIncludeOrderedParamsDict = _TckgenIncludeOrderedParamsDictNoTag | TckgenIncludeOrderedParamsDictTagged
118
+
119
+
120
+ _TckgenVariousString1ParamsDictNoTag = typing.TypedDict('_TckgenVariousString1ParamsDictNoTag', {
121
+ "obj": str,
122
+ })
123
+ TckgenVariousString1ParamsDictTagged = typing.TypedDict('TckgenVariousString1ParamsDictTagged', {
124
+ "@type": typing.Literal["VariousString_1"],
125
+ "obj": str,
126
+ })
127
+ TckgenVariousString1ParamsDict = _TckgenVariousString1ParamsDictNoTag | TckgenVariousString1ParamsDictTagged
128
+
129
+
130
+ _TckgenVariousFile1ParamsDictNoTag = typing.TypedDict('_TckgenVariousFile1ParamsDictNoTag', {
131
+ "obj": InputPathType,
132
+ })
133
+ TckgenVariousFile1ParamsDictTagged = typing.TypedDict('TckgenVariousFile1ParamsDictTagged', {
134
+ "@type": typing.Literal["VariousFile_1"],
135
+ "obj": InputPathType,
136
+ })
137
+ TckgenVariousFile1ParamsDict = _TckgenVariousFile1ParamsDictNoTag | TckgenVariousFile1ParamsDictTagged
138
+
139
+
140
+ _TckgenExcludeParamsDictNoTag = typing.TypedDict('_TckgenExcludeParamsDictNoTag', {
141
+ "spec": typing.Union[TckgenVariousString1ParamsDictTagged, TckgenVariousFile1ParamsDictTagged],
142
+ })
143
+ TckgenExcludeParamsDictTagged = typing.TypedDict('TckgenExcludeParamsDictTagged', {
144
+ "@type": typing.Literal["exclude"],
145
+ "spec": typing.Union[TckgenVariousString1ParamsDictTagged, TckgenVariousFile1ParamsDictTagged],
146
+ })
147
+ TckgenExcludeParamsDict = _TckgenExcludeParamsDictNoTag | TckgenExcludeParamsDictTagged
148
+
149
+
150
+ _TckgenVariousString2ParamsDictNoTag = typing.TypedDict('_TckgenVariousString2ParamsDictNoTag', {
151
+ "obj": str,
152
+ })
153
+ TckgenVariousString2ParamsDictTagged = typing.TypedDict('TckgenVariousString2ParamsDictTagged', {
154
+ "@type": typing.Literal["VariousString_2"],
155
+ "obj": str,
156
+ })
157
+ TckgenVariousString2ParamsDict = _TckgenVariousString2ParamsDictNoTag | TckgenVariousString2ParamsDictTagged
158
+
159
+
160
+ _TckgenVariousFile2ParamsDictNoTag = typing.TypedDict('_TckgenVariousFile2ParamsDictNoTag', {
161
+ "obj": InputPathType,
162
+ })
163
+ TckgenVariousFile2ParamsDictTagged = typing.TypedDict('TckgenVariousFile2ParamsDictTagged', {
164
+ "@type": typing.Literal["VariousFile_2"],
165
+ "obj": InputPathType,
166
+ })
167
+ TckgenVariousFile2ParamsDict = _TckgenVariousFile2ParamsDictNoTag | TckgenVariousFile2ParamsDictTagged
168
+
169
+
170
+ _TckgenMaskParamsDictNoTag = typing.TypedDict('_TckgenMaskParamsDictNoTag', {
171
+ "spec": typing.Union[TckgenVariousString2ParamsDictTagged, TckgenVariousFile2ParamsDictTagged],
172
+ })
173
+ TckgenMaskParamsDictTagged = typing.TypedDict('TckgenMaskParamsDictTagged', {
174
+ "@type": typing.Literal["mask"],
175
+ "spec": typing.Union[TckgenVariousString2ParamsDictTagged, TckgenVariousFile2ParamsDictTagged],
176
+ })
177
+ TckgenMaskParamsDict = _TckgenMaskParamsDictNoTag | TckgenMaskParamsDictTagged
178
+
179
+
180
+ _TckgenFslgradParamsDictNoTag = typing.TypedDict('_TckgenFslgradParamsDictNoTag', {
181
+ "bvecs": InputPathType,
182
+ "bvals": InputPathType,
183
+ })
184
+ TckgenFslgradParamsDictTagged = typing.TypedDict('TckgenFslgradParamsDictTagged', {
185
+ "@type": typing.Literal["fslgrad"],
186
+ "bvecs": InputPathType,
187
+ "bvals": InputPathType,
188
+ })
189
+ TckgenFslgradParamsDict = _TckgenFslgradParamsDictNoTag | TckgenFslgradParamsDictTagged
190
+
191
+
192
+ _TckgenConfigParamsDictNoTag = typing.TypedDict('_TckgenConfigParamsDictNoTag', {
193
+ "key": str,
194
+ "value": str,
195
+ })
196
+ TckgenConfigParamsDictTagged = typing.TypedDict('TckgenConfigParamsDictTagged', {
197
+ "@type": typing.Literal["config"],
198
+ "key": str,
199
+ "value": str,
200
+ })
201
+ TckgenConfigParamsDict = _TckgenConfigParamsDictNoTag | TckgenConfigParamsDictTagged
202
+
203
+
204
+ _TckgenParamsDictNoTag = typing.TypedDict('_TckgenParamsDictNoTag', {
205
+ "algorithm": typing.NotRequired[str | None],
206
+ "select": typing.NotRequired[int | None],
207
+ "step": typing.NotRequired[float | None],
208
+ "angle": typing.NotRequired[float | None],
209
+ "minlength": typing.NotRequired[float | None],
210
+ "maxlength": typing.NotRequired[float | None],
211
+ "cutoff": typing.NotRequired[float | None],
212
+ "trials": typing.NotRequired[int | None],
213
+ "noprecomputed": bool,
214
+ "rk4": bool,
215
+ "stop": bool,
216
+ "downsample": typing.NotRequired[int | None],
217
+ "seed_image": typing.NotRequired[list[TckgenSeedImageParamsDict] | None],
218
+ "seed_sphere": typing.NotRequired[list[TckgenSeedSphereParamsDict] | None],
219
+ "seed_random_per_voxel": typing.NotRequired[list[TckgenSeedRandomPerVoxelParamsDict] | None],
220
+ "seed_grid_per_voxel": typing.NotRequired[list[TckgenSeedGridPerVoxelParamsDict] | None],
221
+ "seed_rejection": typing.NotRequired[list[TckgenSeedRejectionParamsDict] | None],
222
+ "seed_gmwmi": typing.NotRequired[list[TckgenSeedGmwmiParamsDict] | None],
223
+ "seed_dynamic": typing.NotRequired[InputPathType | None],
224
+ "seeds": typing.NotRequired[int | None],
225
+ "max_attempts_per_seed": typing.NotRequired[int | None],
226
+ "seed_cutoff": typing.NotRequired[float | None],
227
+ "seed_unidirectional": bool,
228
+ "seed_direction": typing.NotRequired[list[float] | None],
229
+ "output_seeds": typing.NotRequired[str | None],
230
+ "include": typing.NotRequired[list[TckgenIncludeParamsDict] | None],
231
+ "include_ordered": typing.NotRequired[list[TckgenIncludeOrderedParamsDict] | None],
232
+ "exclude": typing.NotRequired[list[TckgenExcludeParamsDict] | None],
233
+ "mask": typing.NotRequired[list[TckgenMaskParamsDict] | None],
234
+ "act": typing.NotRequired[InputPathType | None],
235
+ "backtrack": bool,
236
+ "crop_at_gmwmi": bool,
237
+ "power": typing.NotRequired[float | None],
238
+ "samples": typing.NotRequired[int | None],
239
+ "grad": typing.NotRequired[InputPathType | None],
240
+ "fslgrad": typing.NotRequired[TckgenFslgradParamsDict | None],
241
+ "info": bool,
242
+ "quiet": bool,
243
+ "debug": bool,
244
+ "force": bool,
245
+ "nthreads": typing.NotRequired[int | None],
246
+ "config": typing.NotRequired[list[TckgenConfigParamsDict] | None],
247
+ "help": bool,
248
+ "version": bool,
249
+ "source": InputPathType,
250
+ "tracks": str,
251
+ })
252
+ TckgenParamsDictTagged = typing.TypedDict('TckgenParamsDictTagged', {
253
+ "@type": typing.Literal["mrtrix/tckgen"],
254
+ "algorithm": typing.NotRequired[str | None],
255
+ "select": typing.NotRequired[int | None],
256
+ "step": typing.NotRequired[float | None],
257
+ "angle": typing.NotRequired[float | None],
258
+ "minlength": typing.NotRequired[float | None],
259
+ "maxlength": typing.NotRequired[float | None],
260
+ "cutoff": typing.NotRequired[float | None],
261
+ "trials": typing.NotRequired[int | None],
262
+ "noprecomputed": bool,
263
+ "rk4": bool,
264
+ "stop": bool,
265
+ "downsample": typing.NotRequired[int | None],
266
+ "seed_image": typing.NotRequired[list[TckgenSeedImageParamsDict] | None],
267
+ "seed_sphere": typing.NotRequired[list[TckgenSeedSphereParamsDict] | None],
268
+ "seed_random_per_voxel": typing.NotRequired[list[TckgenSeedRandomPerVoxelParamsDict] | None],
269
+ "seed_grid_per_voxel": typing.NotRequired[list[TckgenSeedGridPerVoxelParamsDict] | None],
270
+ "seed_rejection": typing.NotRequired[list[TckgenSeedRejectionParamsDict] | None],
271
+ "seed_gmwmi": typing.NotRequired[list[TckgenSeedGmwmiParamsDict] | None],
272
+ "seed_dynamic": typing.NotRequired[InputPathType | None],
273
+ "seeds": typing.NotRequired[int | None],
274
+ "max_attempts_per_seed": typing.NotRequired[int | None],
275
+ "seed_cutoff": typing.NotRequired[float | None],
276
+ "seed_unidirectional": bool,
277
+ "seed_direction": typing.NotRequired[list[float] | None],
278
+ "output_seeds": typing.NotRequired[str | None],
279
+ "include": typing.NotRequired[list[TckgenIncludeParamsDict] | None],
280
+ "include_ordered": typing.NotRequired[list[TckgenIncludeOrderedParamsDict] | None],
281
+ "exclude": typing.NotRequired[list[TckgenExcludeParamsDict] | None],
282
+ "mask": typing.NotRequired[list[TckgenMaskParamsDict] | None],
283
+ "act": typing.NotRequired[InputPathType | None],
284
+ "backtrack": bool,
285
+ "crop_at_gmwmi": bool,
286
+ "power": typing.NotRequired[float | None],
287
+ "samples": typing.NotRequired[int | None],
288
+ "grad": typing.NotRequired[InputPathType | None],
289
+ "fslgrad": typing.NotRequired[TckgenFslgradParamsDict | None],
290
+ "info": bool,
291
+ "quiet": bool,
292
+ "debug": bool,
293
+ "force": bool,
294
+ "nthreads": typing.NotRequired[int | None],
295
+ "config": typing.NotRequired[list[TckgenConfigParamsDict] | None],
296
+ "help": bool,
297
+ "version": bool,
298
+ "source": InputPathType,
299
+ "tracks": str,
300
+ })
301
+ TckgenParamsDict = _TckgenParamsDictNoTag | TckgenParamsDictTagged
302
+
303
+
304
+ def tckgen_spec_cargs_dyn_fn(
305
+ t: str,
306
+ ) -> typing.Any:
307
+ """
308
+ Get build cargs function by command type.
309
+
310
+ Args:
311
+ t: Command type.
312
+ Returns:
313
+ Build cargs function.
314
+ """
315
+ return {
316
+ "VariousString": tckgen_various_string_cargs,
317
+ "VariousFile": tckgen_various_file_cargs,
318
+ }.get(t)
319
+
320
+
321
+ def tckgen_spec_validate_dyn_fn(
322
+ t: str,
323
+ ) -> typing.Any:
324
+ """
325
+ Get validate params function by command type.
326
+
327
+ Args:
328
+ t: Command type.
329
+ Returns:
330
+ Validate params function.
331
+ """
332
+ return {
333
+ "VariousString": tckgen_various_string_validate,
334
+ "VariousFile": tckgen_various_file_validate,
335
+ }.get(t)
336
+
337
+
338
+ def tckgen_spec_cargs_dyn_fn_(
339
+ t: str,
340
+ ) -> typing.Any:
341
+ """
342
+ Get build cargs function by command type.
343
+
344
+ Args:
345
+ t: Command type.
346
+ Returns:
347
+ Build cargs function.
348
+ """
349
+ return {
350
+ "VariousString_1": tckgen_various_string_1_cargs,
351
+ "VariousFile_1": tckgen_various_file_1_cargs,
352
+ }.get(t)
353
+
354
+
355
+ def tckgen_spec_validate_dyn_fn_(
356
+ t: str,
357
+ ) -> typing.Any:
358
+ """
359
+ Get validate params function by command type.
360
+
361
+ Args:
362
+ t: Command type.
363
+ Returns:
364
+ Validate params function.
365
+ """
366
+ return {
367
+ "VariousString_1": tckgen_various_string_1_validate,
368
+ "VariousFile_1": tckgen_various_file_1_validate,
369
+ }.get(t)
370
+
371
+
372
+ def tckgen_spec_cargs_dyn_fn_2(
373
+ t: str,
374
+ ) -> typing.Any:
375
+ """
376
+ Get build cargs function by command type.
377
+
378
+ Args:
379
+ t: Command type.
380
+ Returns:
381
+ Build cargs function.
382
+ """
383
+ return {
384
+ "VariousString_2": tckgen_various_string_2_cargs,
385
+ "VariousFile_2": tckgen_various_file_2_cargs,
386
+ }.get(t)
387
+
388
+
389
+ def tckgen_spec_validate_dyn_fn_2(
390
+ t: str,
391
+ ) -> typing.Any:
392
+ """
393
+ Get validate params function by command type.
394
+
395
+ Args:
396
+ t: Command type.
397
+ Returns:
398
+ Validate params function.
399
+ """
400
+ return {
401
+ "VariousString_2": tckgen_various_string_2_validate,
402
+ "VariousFile_2": tckgen_various_file_2_validate,
403
+ }.get(t)
404
+
405
+
406
+ def tckgen_seed_image(
407
+ image: InputPathType,
408
+ ) -> TckgenSeedImageParamsDictTagged:
409
+ """
410
+ Build parameters.
411
+
412
+ Args:
413
+ image: seed streamlines entirely at random within a mask image.
414
+ Returns:
415
+ Parameter dictionary
416
+ """
417
+ params = {
418
+ "@type": "seed_image",
419
+ "image": image,
420
+ }
421
+ return params
422
+
423
+
424
+ def tckgen_seed_image_validate(
425
+ params: typing.Any,
426
+ ) -> None:
427
+ """
428
+ Validate parameters. Throws an error if `params` is not a valid
429
+ `TckgenSeedImageParamsDict` object.
430
+
431
+ Args:
432
+ params: The parameters object to validate.
433
+ """
434
+ if params is None or not isinstance(params, dict):
435
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
436
+ if params.get("image", None) is None:
437
+ raise StyxValidationError("`image` must not be None")
438
+ if not isinstance(params["image"], (pathlib.Path, str)):
439
+ raise StyxValidationError(f'`image` has the wrong type: Received `{type(params.get("image", None))}` expected `InputPathType`')
440
+
441
+
442
+ def tckgen_seed_image_cargs(
443
+ params: TckgenSeedImageParamsDict,
444
+ execution: Execution,
445
+ ) -> list[str]:
446
+ """
447
+ Build command-line arguments from parameters.
448
+
449
+ Args:
450
+ params: The parameters.
451
+ execution: The execution object for resolving input paths.
452
+ Returns:
453
+ Command-line arguments.
454
+ """
455
+ cargs = []
456
+ cargs.append("-seed_image")
457
+ cargs.append(execution.input_file(params.get("image", None)))
458
+ return cargs
459
+
460
+
461
+ def tckgen_seed_sphere(
462
+ spec: list[float],
463
+ ) -> TckgenSeedSphereParamsDictTagged:
464
+ """
465
+ Build parameters.
466
+
467
+ Args:
468
+ spec: spherical seed as four comma-separated values (XYZ position and\
469
+ radius).
470
+ Returns:
471
+ Parameter dictionary
472
+ """
473
+ params = {
474
+ "@type": "seed_sphere",
475
+ "spec": spec,
476
+ }
477
+ return params
478
+
479
+
480
+ def tckgen_seed_sphere_validate(
481
+ params: typing.Any,
482
+ ) -> None:
483
+ """
484
+ Validate parameters. Throws an error if `params` is not a valid
485
+ `TckgenSeedSphereParamsDict` object.
486
+
487
+ Args:
488
+ params: The parameters object to validate.
489
+ """
490
+ if params is None or not isinstance(params, dict):
491
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
492
+ if params.get("spec", None) is None:
493
+ raise StyxValidationError("`spec` must not be None")
494
+ if not isinstance(params["spec"], list):
495
+ raise StyxValidationError(f'`spec` has the wrong type: Received `{type(params.get("spec", None))}` expected `list[float]`')
496
+ for e in params["spec"]:
497
+ if not isinstance(e, (float, int)):
498
+ raise StyxValidationError(f'`spec` has the wrong type: Received `{type(params.get("spec", None))}` expected `list[float]`')
499
+
500
+
501
+ def tckgen_seed_sphere_cargs(
502
+ params: TckgenSeedSphereParamsDict,
503
+ execution: Execution,
504
+ ) -> list[str]:
505
+ """
506
+ Build command-line arguments from parameters.
507
+
508
+ Args:
509
+ params: The parameters.
510
+ execution: The execution object for resolving input paths.
511
+ Returns:
512
+ Command-line arguments.
513
+ """
514
+ cargs = []
515
+ cargs.append("-seed_sphere")
516
+ cargs.append(",".join(map(str, params.get("spec", None))))
517
+ return cargs
518
+
519
+
520
+ def tckgen_seed_random_per_voxel(
521
+ image: InputPathType,
522
+ num_per_voxel: int,
523
+ ) -> TckgenSeedRandomPerVoxelParamsDictTagged:
524
+ """
525
+ Build parameters.
526
+
527
+ Args:
528
+ image: seed a fixed number of streamlines per voxel in a mask image;\
529
+ random placement of seeds in each voxel.
530
+ num_per_voxel: seed a fixed number of streamlines per voxel in a mask\
531
+ image; random placement of seeds in each voxel.
532
+ Returns:
533
+ Parameter dictionary
534
+ """
535
+ params = {
536
+ "@type": "seed_random_per_voxel",
537
+ "image": image,
538
+ "num_per_voxel": num_per_voxel,
539
+ }
540
+ return params
541
+
542
+
543
+ def tckgen_seed_random_per_voxel_validate(
544
+ params: typing.Any,
545
+ ) -> None:
546
+ """
547
+ Validate parameters. Throws an error if `params` is not a valid
548
+ `TckgenSeedRandomPerVoxelParamsDict` object.
549
+
550
+ Args:
551
+ params: The parameters object to validate.
552
+ """
553
+ if params is None or not isinstance(params, dict):
554
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
555
+ if params.get("image", None) is None:
556
+ raise StyxValidationError("`image` must not be None")
557
+ if not isinstance(params["image"], (pathlib.Path, str)):
558
+ raise StyxValidationError(f'`image` has the wrong type: Received `{type(params.get("image", None))}` expected `InputPathType`')
559
+ if params.get("num_per_voxel", None) is None:
560
+ raise StyxValidationError("`num_per_voxel` must not be None")
561
+ if not isinstance(params["num_per_voxel"], int):
562
+ raise StyxValidationError(f'`num_per_voxel` has the wrong type: Received `{type(params.get("num_per_voxel", None))}` expected `int`')
563
+
564
+
565
+ def tckgen_seed_random_per_voxel_cargs(
566
+ params: TckgenSeedRandomPerVoxelParamsDict,
567
+ execution: Execution,
568
+ ) -> list[str]:
569
+ """
570
+ Build command-line arguments from parameters.
571
+
572
+ Args:
573
+ params: The parameters.
574
+ execution: The execution object for resolving input paths.
575
+ Returns:
576
+ Command-line arguments.
577
+ """
578
+ cargs = []
579
+ cargs.append("-seed_random_per_voxel")
580
+ cargs.append(execution.input_file(params.get("image", None)))
581
+ cargs.append(str(params.get("num_per_voxel", None)))
582
+ return cargs
583
+
584
+
585
+ def tckgen_seed_grid_per_voxel(
586
+ image: InputPathType,
587
+ grid_size: int,
588
+ ) -> TckgenSeedGridPerVoxelParamsDictTagged:
589
+ """
590
+ Build parameters.
591
+
592
+ Args:
593
+ image: seed a fixed number of streamlines per voxel in a mask image;\
594
+ place seeds on a 3D mesh grid (grid_size argument is per axis; so a\
595
+ grid_size of 3 results in 27 seeds per voxel).
596
+ grid_size: seed a fixed number of streamlines per voxel in a mask\
597
+ image; place seeds on a 3D mesh grid (grid_size argument is per axis;\
598
+ so a grid_size of 3 results in 27 seeds per voxel).
599
+ Returns:
600
+ Parameter dictionary
601
+ """
602
+ params = {
603
+ "@type": "seed_grid_per_voxel",
604
+ "image": image,
605
+ "grid_size": grid_size,
606
+ }
607
+ return params
608
+
609
+
610
+ def tckgen_seed_grid_per_voxel_validate(
611
+ params: typing.Any,
612
+ ) -> None:
613
+ """
614
+ Validate parameters. Throws an error if `params` is not a valid
615
+ `TckgenSeedGridPerVoxelParamsDict` object.
616
+
617
+ Args:
618
+ params: The parameters object to validate.
619
+ """
620
+ if params is None or not isinstance(params, dict):
621
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
622
+ if params.get("image", None) is None:
623
+ raise StyxValidationError("`image` must not be None")
624
+ if not isinstance(params["image"], (pathlib.Path, str)):
625
+ raise StyxValidationError(f'`image` has the wrong type: Received `{type(params.get("image", None))}` expected `InputPathType`')
626
+ if params.get("grid_size", None) is None:
627
+ raise StyxValidationError("`grid_size` must not be None")
628
+ if not isinstance(params["grid_size"], int):
629
+ raise StyxValidationError(f'`grid_size` has the wrong type: Received `{type(params.get("grid_size", None))}` expected `int`')
630
+
631
+
632
+ def tckgen_seed_grid_per_voxel_cargs(
633
+ params: TckgenSeedGridPerVoxelParamsDict,
634
+ execution: Execution,
635
+ ) -> list[str]:
636
+ """
637
+ Build command-line arguments from parameters.
638
+
639
+ Args:
640
+ params: The parameters.
641
+ execution: The execution object for resolving input paths.
642
+ Returns:
643
+ Command-line arguments.
644
+ """
645
+ cargs = []
646
+ cargs.append("-seed_grid_per_voxel")
647
+ cargs.append(execution.input_file(params.get("image", None)))
648
+ cargs.append(str(params.get("grid_size", None)))
649
+ return cargs
650
+
651
+
652
+ def tckgen_seed_rejection(
653
+ image: InputPathType,
654
+ ) -> TckgenSeedRejectionParamsDictTagged:
655
+ """
656
+ Build parameters.
657
+
658
+ Args:
659
+ image: seed from an image using rejection sampling (higher values =\
660
+ more probable to seed from).
661
+ Returns:
662
+ Parameter dictionary
663
+ """
664
+ params = {
665
+ "@type": "seed_rejection",
666
+ "image": image,
667
+ }
668
+ return params
669
+
670
+
671
+ def tckgen_seed_rejection_validate(
672
+ params: typing.Any,
673
+ ) -> None:
674
+ """
675
+ Validate parameters. Throws an error if `params` is not a valid
676
+ `TckgenSeedRejectionParamsDict` object.
677
+
678
+ Args:
679
+ params: The parameters object to validate.
680
+ """
681
+ if params is None or not isinstance(params, dict):
682
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
683
+ if params.get("image", None) is None:
684
+ raise StyxValidationError("`image` must not be None")
685
+ if not isinstance(params["image"], (pathlib.Path, str)):
686
+ raise StyxValidationError(f'`image` has the wrong type: Received `{type(params.get("image", None))}` expected `InputPathType`')
687
+
688
+
689
+ def tckgen_seed_rejection_cargs(
690
+ params: TckgenSeedRejectionParamsDict,
691
+ execution: Execution,
692
+ ) -> list[str]:
693
+ """
694
+ Build command-line arguments from parameters.
695
+
696
+ Args:
697
+ params: The parameters.
698
+ execution: The execution object for resolving input paths.
699
+ Returns:
700
+ Command-line arguments.
701
+ """
702
+ cargs = []
703
+ cargs.append("-seed_rejection")
704
+ cargs.append(execution.input_file(params.get("image", None)))
705
+ return cargs
706
+
707
+
708
+ def tckgen_seed_gmwmi(
709
+ image: InputPathType,
710
+ ) -> TckgenSeedGmwmiParamsDictTagged:
711
+ """
712
+ Build parameters.
713
+
714
+ Args:
715
+ image: seed from the grey matter - white matter interface (only valid\
716
+ if using ACT framework). Input image should be a 3D seeding volume;\
717
+ seeds drawn within this image will be optimised to the interface using\
718
+ the 5TT image provided using the -act option.
719
+ Returns:
720
+ Parameter dictionary
721
+ """
722
+ params = {
723
+ "@type": "seed_gmwmi",
724
+ "image": image,
725
+ }
726
+ return params
727
+
728
+
729
+ def tckgen_seed_gmwmi_validate(
730
+ params: typing.Any,
731
+ ) -> None:
732
+ """
733
+ Validate parameters. Throws an error if `params` is not a valid
734
+ `TckgenSeedGmwmiParamsDict` object.
735
+
736
+ Args:
737
+ params: The parameters object to validate.
738
+ """
739
+ if params is None or not isinstance(params, dict):
740
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
741
+ if params.get("image", None) is None:
742
+ raise StyxValidationError("`image` must not be None")
743
+ if not isinstance(params["image"], (pathlib.Path, str)):
744
+ raise StyxValidationError(f'`image` has the wrong type: Received `{type(params.get("image", None))}` expected `InputPathType`')
745
+
746
+
747
+ def tckgen_seed_gmwmi_cargs(
748
+ params: TckgenSeedGmwmiParamsDict,
749
+ execution: Execution,
750
+ ) -> list[str]:
751
+ """
752
+ Build command-line arguments from parameters.
753
+
754
+ Args:
755
+ params: The parameters.
756
+ execution: The execution object for resolving input paths.
757
+ Returns:
758
+ Command-line arguments.
759
+ """
760
+ cargs = []
761
+ cargs.append("-seed_gmwmi")
762
+ cargs.append(execution.input_file(params.get("image", None)))
763
+ return cargs
764
+
765
+
766
+ def tckgen_various_string(
767
+ obj: str,
768
+ ) -> TckgenVariousStringParamsDictTagged:
769
+ """
770
+ Build parameters.
771
+
772
+ Args:
773
+ obj: String object.
774
+ Returns:
775
+ Parameter dictionary
776
+ """
777
+ params = {
778
+ "@type": "VariousString",
779
+ "obj": obj,
780
+ }
781
+ return params
782
+
783
+
784
+ def tckgen_various_string_validate(
785
+ params: typing.Any,
786
+ ) -> None:
787
+ """
788
+ Validate parameters. Throws an error if `params` is not a valid
789
+ `TckgenVariousStringParamsDict` object.
790
+
791
+ Args:
792
+ params: The parameters object to validate.
793
+ """
794
+ if params is None or not isinstance(params, dict):
795
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
796
+ if params.get("obj", None) is None:
797
+ raise StyxValidationError("`obj` must not be None")
798
+ if not isinstance(params["obj"], str):
799
+ raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `str`')
800
+
801
+
802
+ def tckgen_various_string_cargs(
803
+ params: TckgenVariousStringParamsDict,
804
+ execution: Execution,
805
+ ) -> list[str]:
806
+ """
807
+ Build command-line arguments from parameters.
808
+
809
+ Args:
810
+ params: The parameters.
811
+ execution: The execution object for resolving input paths.
812
+ Returns:
813
+ Command-line arguments.
814
+ """
815
+ cargs = []
816
+ cargs.append(params.get("obj", None))
817
+ return cargs
818
+
819
+
820
+ def tckgen_various_file(
821
+ obj: InputPathType,
822
+ ) -> TckgenVariousFileParamsDictTagged:
823
+ """
824
+ Build parameters.
825
+
826
+ Args:
827
+ obj: File object.
828
+ Returns:
829
+ Parameter dictionary
830
+ """
831
+ params = {
832
+ "@type": "VariousFile",
833
+ "obj": obj,
834
+ }
835
+ return params
836
+
837
+
838
+ def tckgen_various_file_validate(
839
+ params: typing.Any,
840
+ ) -> None:
841
+ """
842
+ Validate parameters. Throws an error if `params` is not a valid
843
+ `TckgenVariousFileParamsDict` object.
844
+
845
+ Args:
846
+ params: The parameters object to validate.
847
+ """
848
+ if params is None or not isinstance(params, dict):
849
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
850
+ if params.get("obj", None) is None:
851
+ raise StyxValidationError("`obj` must not be None")
852
+ if not isinstance(params["obj"], (pathlib.Path, str)):
853
+ raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `InputPathType`')
854
+
855
+
856
+ def tckgen_various_file_cargs(
857
+ params: TckgenVariousFileParamsDict,
858
+ execution: Execution,
859
+ ) -> list[str]:
860
+ """
861
+ Build command-line arguments from parameters.
862
+
863
+ Args:
864
+ params: The parameters.
865
+ execution: The execution object for resolving input paths.
866
+ Returns:
867
+ Command-line arguments.
868
+ """
869
+ cargs = []
870
+ cargs.append(execution.input_file(params.get("obj", None)))
871
+ return cargs
872
+
873
+
874
+ def tckgen_include(
875
+ spec: typing.Union[TckgenVariousStringParamsDictTagged, TckgenVariousFileParamsDictTagged],
876
+ ) -> TckgenIncludeParamsDictTagged:
877
+ """
878
+ Build parameters.
879
+
880
+ Args:
881
+ spec: specify an inclusion region of interest, as either a binary mask\
882
+ image, or as a sphere using 4 comma-separared values (x,y,z,radius).\
883
+ Streamlines must traverse ALL inclusion regions to be accepted.
884
+ Returns:
885
+ Parameter dictionary
886
+ """
887
+ params = {
888
+ "@type": "include",
889
+ "spec": spec,
890
+ }
891
+ return params
892
+
893
+
894
+ def tckgen_include_validate(
895
+ params: typing.Any,
896
+ ) -> None:
897
+ """
898
+ Validate parameters. Throws an error if `params` is not a valid
899
+ `TckgenIncludeParamsDict` object.
900
+
901
+ Args:
902
+ params: The parameters object to validate.
903
+ """
904
+ if params is None or not isinstance(params, dict):
905
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
906
+ if params.get("spec", None) is None:
907
+ raise StyxValidationError("`spec` must not be None")
908
+ if not isinstance(params["spec"], dict):
909
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params["spec"])}\'')
910
+ if "@type" not in params["spec"]:
911
+ raise StyxValidationError("Params object is missing `@type`")
912
+ if params["spec"]["@type"] not in ["VariousString", "VariousFile"]:
913
+ raise StyxValidationError("Parameter `spec`s `@type` must be one of [\"VariousString\", \"VariousFile\"]")
914
+ tckgen_spec_validate_dyn_fn(params["spec"]["@type"])(params["spec"])
915
+
916
+
917
+ def tckgen_include_cargs(
918
+ params: TckgenIncludeParamsDict,
919
+ execution: Execution,
920
+ ) -> list[str]:
921
+ """
922
+ Build command-line arguments from parameters.
923
+
924
+ Args:
925
+ params: The parameters.
926
+ execution: The execution object for resolving input paths.
927
+ Returns:
928
+ Command-line arguments.
929
+ """
930
+ cargs = []
931
+ cargs.append("-include")
932
+ cargs.extend(tckgen_spec_cargs_dyn_fn(params.get("spec", None)["@type"])(params.get("spec", None), execution))
933
+ return cargs
934
+
935
+
936
+ def tckgen_include_ordered(
937
+ image: str,
938
+ ) -> TckgenIncludeOrderedParamsDictTagged:
939
+ """
940
+ Build parameters.
941
+
942
+ Args:
943
+ image: specify an inclusion region of interest, as either a binary mask\
944
+ image, or as a sphere using 4 comma-separared values (x,y,z,radius).\
945
+ Streamlines must traverse ALL inclusion_ordered regions in the order\
946
+ they are specified in order to be accepted.
947
+ Returns:
948
+ Parameter dictionary
949
+ """
950
+ params = {
951
+ "@type": "include_ordered",
952
+ "image": image,
953
+ }
954
+ return params
955
+
956
+
957
+ def tckgen_include_ordered_validate(
958
+ params: typing.Any,
959
+ ) -> None:
960
+ """
961
+ Validate parameters. Throws an error if `params` is not a valid
962
+ `TckgenIncludeOrderedParamsDict` object.
963
+
964
+ Args:
965
+ params: The parameters object to validate.
966
+ """
967
+ if params is None or not isinstance(params, dict):
968
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
969
+ if params.get("image", None) is None:
970
+ raise StyxValidationError("`image` must not be None")
971
+ if not isinstance(params["image"], str):
972
+ raise StyxValidationError(f'`image` has the wrong type: Received `{type(params.get("image", None))}` expected `str`')
973
+
974
+
975
+ def tckgen_include_ordered_cargs(
976
+ params: TckgenIncludeOrderedParamsDict,
977
+ execution: Execution,
978
+ ) -> list[str]:
979
+ """
980
+ Build command-line arguments from parameters.
981
+
982
+ Args:
983
+ params: The parameters.
984
+ execution: The execution object for resolving input paths.
985
+ Returns:
986
+ Command-line arguments.
987
+ """
988
+ cargs = []
989
+ cargs.append("-include_ordered")
990
+ cargs.append(params.get("image", None))
991
+ return cargs
992
+
993
+
994
+ def tckgen_various_string_1(
995
+ obj: str,
996
+ ) -> TckgenVariousString1ParamsDictTagged:
997
+ """
998
+ Build parameters.
999
+
1000
+ Args:
1001
+ obj: String object.
1002
+ Returns:
1003
+ Parameter dictionary
1004
+ """
1005
+ params = {
1006
+ "@type": "VariousString_1",
1007
+ "obj": obj,
1008
+ }
1009
+ return params
1010
+
1011
+
1012
+ def tckgen_various_string_1_validate(
1013
+ params: typing.Any,
1014
+ ) -> None:
1015
+ """
1016
+ Validate parameters. Throws an error if `params` is not a valid
1017
+ `TckgenVariousString1ParamsDict` object.
1018
+
1019
+ Args:
1020
+ params: The parameters object to validate.
1021
+ """
1022
+ if params is None or not isinstance(params, dict):
1023
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
1024
+ if params.get("obj", None) is None:
1025
+ raise StyxValidationError("`obj` must not be None")
1026
+ if not isinstance(params["obj"], str):
1027
+ raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `str`')
1028
+
1029
+
1030
+ def tckgen_various_string_1_cargs(
1031
+ params: TckgenVariousString1ParamsDict,
1032
+ execution: Execution,
1033
+ ) -> list[str]:
1034
+ """
1035
+ Build command-line arguments from parameters.
1036
+
1037
+ Args:
1038
+ params: The parameters.
1039
+ execution: The execution object for resolving input paths.
1040
+ Returns:
1041
+ Command-line arguments.
1042
+ """
1043
+ cargs = []
1044
+ cargs.append(params.get("obj", None))
1045
+ return cargs
1046
+
1047
+
1048
+ def tckgen_various_file_1(
1049
+ obj: InputPathType,
1050
+ ) -> TckgenVariousFile1ParamsDictTagged:
1051
+ """
1052
+ Build parameters.
1053
+
1054
+ Args:
1055
+ obj: File object.
1056
+ Returns:
1057
+ Parameter dictionary
1058
+ """
1059
+ params = {
1060
+ "@type": "VariousFile_1",
1061
+ "obj": obj,
1062
+ }
1063
+ return params
1064
+
1065
+
1066
+ def tckgen_various_file_1_validate(
1067
+ params: typing.Any,
1068
+ ) -> None:
1069
+ """
1070
+ Validate parameters. Throws an error if `params` is not a valid
1071
+ `TckgenVariousFile1ParamsDict` object.
1072
+
1073
+ Args:
1074
+ params: The parameters object to validate.
1075
+ """
1076
+ if params is None or not isinstance(params, dict):
1077
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
1078
+ if params.get("obj", None) is None:
1079
+ raise StyxValidationError("`obj` must not be None")
1080
+ if not isinstance(params["obj"], (pathlib.Path, str)):
1081
+ raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `InputPathType`')
1082
+
1083
+
1084
+ def tckgen_various_file_1_cargs(
1085
+ params: TckgenVariousFile1ParamsDict,
1086
+ execution: Execution,
1087
+ ) -> list[str]:
1088
+ """
1089
+ Build command-line arguments from parameters.
1090
+
1091
+ Args:
1092
+ params: The parameters.
1093
+ execution: The execution object for resolving input paths.
1094
+ Returns:
1095
+ Command-line arguments.
1096
+ """
1097
+ cargs = []
1098
+ cargs.append(execution.input_file(params.get("obj", None)))
1099
+ return cargs
1100
+
1101
+
1102
+ def tckgen_exclude(
1103
+ spec: typing.Union[TckgenVariousString1ParamsDictTagged, TckgenVariousFile1ParamsDictTagged],
1104
+ ) -> TckgenExcludeParamsDictTagged:
1105
+ """
1106
+ Build parameters.
1107
+
1108
+ Args:
1109
+ spec: specify an exclusion region of interest, as either a binary mask\
1110
+ image, or as a sphere using 4 comma-separared values (x,y,z,radius).\
1111
+ Streamlines that enter ANY exclude region will be discarded.
1112
+ Returns:
1113
+ Parameter dictionary
1114
+ """
1115
+ params = {
1116
+ "@type": "exclude",
1117
+ "spec": spec,
1118
+ }
1119
+ return params
1120
+
1121
+
1122
+ def tckgen_exclude_validate(
1123
+ params: typing.Any,
1124
+ ) -> None:
1125
+ """
1126
+ Validate parameters. Throws an error if `params` is not a valid
1127
+ `TckgenExcludeParamsDict` object.
1128
+
1129
+ Args:
1130
+ params: The parameters object to validate.
1131
+ """
1132
+ if params is None or not isinstance(params, dict):
1133
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
1134
+ if params.get("spec", None) is None:
1135
+ raise StyxValidationError("`spec` must not be None")
1136
+ if not isinstance(params["spec"], dict):
1137
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params["spec"])}\'')
1138
+ if "@type" not in params["spec"]:
1139
+ raise StyxValidationError("Params object is missing `@type`")
1140
+ if params["spec"]["@type"] not in ["VariousString_1", "VariousFile_1"]:
1141
+ raise StyxValidationError("Parameter `spec`s `@type` must be one of [\"VariousString_1\", \"VariousFile_1\"]")
1142
+ tckgen_spec_validate_dyn_fn_(params["spec"]["@type"])(params["spec"])
1143
+
1144
+
1145
+ def tckgen_exclude_cargs(
1146
+ params: TckgenExcludeParamsDict,
1147
+ execution: Execution,
1148
+ ) -> list[str]:
1149
+ """
1150
+ Build command-line arguments from parameters.
1151
+
1152
+ Args:
1153
+ params: The parameters.
1154
+ execution: The execution object for resolving input paths.
1155
+ Returns:
1156
+ Command-line arguments.
1157
+ """
1158
+ cargs = []
1159
+ cargs.append("-exclude")
1160
+ cargs.extend(tckgen_spec_cargs_dyn_fn_(params.get("spec", None)["@type"])(params.get("spec", None), execution))
1161
+ return cargs
1162
+
1163
+
1164
+ def tckgen_various_string_2(
1165
+ obj: str,
1166
+ ) -> TckgenVariousString2ParamsDictTagged:
1167
+ """
1168
+ Build parameters.
1169
+
1170
+ Args:
1171
+ obj: String object.
1172
+ Returns:
1173
+ Parameter dictionary
1174
+ """
1175
+ params = {
1176
+ "@type": "VariousString_2",
1177
+ "obj": obj,
1178
+ }
1179
+ return params
1180
+
1181
+
1182
+ def tckgen_various_string_2_validate(
1183
+ params: typing.Any,
1184
+ ) -> None:
1185
+ """
1186
+ Validate parameters. Throws an error if `params` is not a valid
1187
+ `TckgenVariousString2ParamsDict` object.
1188
+
1189
+ Args:
1190
+ params: The parameters object to validate.
1191
+ """
1192
+ if params is None or not isinstance(params, dict):
1193
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
1194
+ if params.get("obj", None) is None:
1195
+ raise StyxValidationError("`obj` must not be None")
1196
+ if not isinstance(params["obj"], str):
1197
+ raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `str`')
1198
+
1199
+
1200
+ def tckgen_various_string_2_cargs(
1201
+ params: TckgenVariousString2ParamsDict,
1202
+ execution: Execution,
1203
+ ) -> list[str]:
1204
+ """
1205
+ Build command-line arguments from parameters.
1206
+
1207
+ Args:
1208
+ params: The parameters.
1209
+ execution: The execution object for resolving input paths.
1210
+ Returns:
1211
+ Command-line arguments.
1212
+ """
1213
+ cargs = []
1214
+ cargs.append(params.get("obj", None))
1215
+ return cargs
1216
+
1217
+
1218
+ def tckgen_various_file_2(
1219
+ obj: InputPathType,
1220
+ ) -> TckgenVariousFile2ParamsDictTagged:
1221
+ """
1222
+ Build parameters.
1223
+
1224
+ Args:
1225
+ obj: File object.
1226
+ Returns:
1227
+ Parameter dictionary
1228
+ """
1229
+ params = {
1230
+ "@type": "VariousFile_2",
1231
+ "obj": obj,
1232
+ }
1233
+ return params
1234
+
1235
+
1236
+ def tckgen_various_file_2_validate(
1237
+ params: typing.Any,
1238
+ ) -> None:
1239
+ """
1240
+ Validate parameters. Throws an error if `params` is not a valid
1241
+ `TckgenVariousFile2ParamsDict` object.
1242
+
1243
+ Args:
1244
+ params: The parameters object to validate.
1245
+ """
1246
+ if params is None or not isinstance(params, dict):
1247
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
1248
+ if params.get("obj", None) is None:
1249
+ raise StyxValidationError("`obj` must not be None")
1250
+ if not isinstance(params["obj"], (pathlib.Path, str)):
1251
+ raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `InputPathType`')
1252
+
1253
+
1254
+ def tckgen_various_file_2_cargs(
1255
+ params: TckgenVariousFile2ParamsDict,
1256
+ execution: Execution,
1257
+ ) -> list[str]:
1258
+ """
1259
+ Build command-line arguments from parameters.
1260
+
1261
+ Args:
1262
+ params: The parameters.
1263
+ execution: The execution object for resolving input paths.
1264
+ Returns:
1265
+ Command-line arguments.
1266
+ """
1267
+ cargs = []
1268
+ cargs.append(execution.input_file(params.get("obj", None)))
1269
+ return cargs
1270
+
1271
+
1272
+ def tckgen_mask(
1273
+ spec: typing.Union[TckgenVariousString2ParamsDictTagged, TckgenVariousFile2ParamsDictTagged],
1274
+ ) -> TckgenMaskParamsDictTagged:
1275
+ """
1276
+ Build parameters.
1277
+
1278
+ Args:
1279
+ spec: specify a masking region of interest, as either a binary mask\
1280
+ image, or as a sphere using 4 comma-separared values (x,y,z,radius). If\
1281
+ defined, streamlines exiting the mask will be truncated.
1282
+ Returns:
1283
+ Parameter dictionary
1284
+ """
1285
+ params = {
1286
+ "@type": "mask",
1287
+ "spec": spec,
1288
+ }
1289
+ return params
1290
+
1291
+
1292
+ def tckgen_mask_validate(
1293
+ params: typing.Any,
1294
+ ) -> None:
1295
+ """
1296
+ Validate parameters. Throws an error if `params` is not a valid
1297
+ `TckgenMaskParamsDict` object.
1298
+
1299
+ Args:
1300
+ params: The parameters object to validate.
1301
+ """
1302
+ if params is None or not isinstance(params, dict):
1303
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
1304
+ if params.get("spec", None) is None:
1305
+ raise StyxValidationError("`spec` must not be None")
1306
+ if not isinstance(params["spec"], dict):
1307
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params["spec"])}\'')
1308
+ if "@type" not in params["spec"]:
1309
+ raise StyxValidationError("Params object is missing `@type`")
1310
+ if params["spec"]["@type"] not in ["VariousString_2", "VariousFile_2"]:
1311
+ raise StyxValidationError("Parameter `spec`s `@type` must be one of [\"VariousString_2\", \"VariousFile_2\"]")
1312
+ tckgen_spec_validate_dyn_fn_2(params["spec"]["@type"])(params["spec"])
1313
+
1314
+
1315
+ def tckgen_mask_cargs(
1316
+ params: TckgenMaskParamsDict,
1317
+ execution: Execution,
1318
+ ) -> list[str]:
1319
+ """
1320
+ Build command-line arguments from parameters.
1321
+
1322
+ Args:
1323
+ params: The parameters.
1324
+ execution: The execution object for resolving input paths.
1325
+ Returns:
1326
+ Command-line arguments.
1327
+ """
1328
+ cargs = []
1329
+ cargs.append("-mask")
1330
+ cargs.extend(tckgen_spec_cargs_dyn_fn_2(params.get("spec", None)["@type"])(params.get("spec", None), execution))
1331
+ return cargs
1332
+
1333
+
1334
+ def tckgen_fslgrad(
1335
+ bvecs: InputPathType,
1336
+ bvals: InputPathType,
1337
+ ) -> TckgenFslgradParamsDictTagged:
1338
+ """
1339
+ Build parameters.
1340
+
1341
+ Args:
1342
+ bvecs: Provide the diffusion-weighted gradient scheme used in the\
1343
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
1344
+ scheme is present in the input image header, the data provided with\
1345
+ this option will be instead used.
1346
+ bvals: Provide the diffusion-weighted gradient scheme used in the\
1347
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
1348
+ scheme is present in the input image header, the data provided with\
1349
+ this option will be instead used.
1350
+ Returns:
1351
+ Parameter dictionary
1352
+ """
1353
+ params = {
1354
+ "@type": "fslgrad",
1355
+ "bvecs": bvecs,
1356
+ "bvals": bvals,
1357
+ }
1358
+ return params
1359
+
1360
+
1361
+ def tckgen_fslgrad_validate(
1362
+ params: typing.Any,
1363
+ ) -> None:
1364
+ """
1365
+ Validate parameters. Throws an error if `params` is not a valid
1366
+ `TckgenFslgradParamsDict` object.
1367
+
1368
+ Args:
1369
+ params: The parameters object to validate.
1370
+ """
1371
+ if params is None or not isinstance(params, dict):
1372
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
1373
+ if params.get("bvecs", None) is None:
1374
+ raise StyxValidationError("`bvecs` must not be None")
1375
+ if not isinstance(params["bvecs"], (pathlib.Path, str)):
1376
+ raise StyxValidationError(f'`bvecs` has the wrong type: Received `{type(params.get("bvecs", None))}` expected `InputPathType`')
1377
+ if params.get("bvals", None) is None:
1378
+ raise StyxValidationError("`bvals` must not be None")
1379
+ if not isinstance(params["bvals"], (pathlib.Path, str)):
1380
+ raise StyxValidationError(f'`bvals` has the wrong type: Received `{type(params.get("bvals", None))}` expected `InputPathType`')
1381
+
1382
+
1383
+ def tckgen_fslgrad_cargs(
1384
+ params: TckgenFslgradParamsDict,
1385
+ execution: Execution,
1386
+ ) -> list[str]:
1387
+ """
1388
+ Build command-line arguments from parameters.
1389
+
1390
+ Args:
1391
+ params: The parameters.
1392
+ execution: The execution object for resolving input paths.
1393
+ Returns:
1394
+ Command-line arguments.
1395
+ """
1396
+ cargs = []
1397
+ cargs.append("-fslgrad")
1398
+ cargs.append(execution.input_file(params.get("bvecs", None)))
1399
+ cargs.append(execution.input_file(params.get("bvals", None)))
1400
+ return cargs
1401
+
1402
+
1403
+ def tckgen_config(
1404
+ key: str,
1405
+ value: str,
1406
+ ) -> TckgenConfigParamsDictTagged:
1407
+ """
1408
+ Build parameters.
1409
+
1410
+ Args:
1411
+ key: temporarily set the value of an MRtrix config file entry.
1412
+ value: temporarily set the value of an MRtrix config file entry.
1413
+ Returns:
1414
+ Parameter dictionary
1415
+ """
1416
+ params = {
1417
+ "@type": "config",
1418
+ "key": key,
1419
+ "value": value,
1420
+ }
1421
+ return params
1422
+
1423
+
1424
+ def tckgen_config_validate(
1425
+ params: typing.Any,
1426
+ ) -> None:
1427
+ """
1428
+ Validate parameters. Throws an error if `params` is not a valid
1429
+ `TckgenConfigParamsDict` object.
1430
+
1431
+ Args:
1432
+ params: The parameters object to validate.
1433
+ """
1434
+ if params is None or not isinstance(params, dict):
1435
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
1436
+ if params.get("key", None) is None:
1437
+ raise StyxValidationError("`key` must not be None")
1438
+ if not isinstance(params["key"], str):
1439
+ raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
1440
+ if params.get("value", None) is None:
1441
+ raise StyxValidationError("`value` must not be None")
1442
+ if not isinstance(params["value"], str):
1443
+ raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')
1444
+
1445
+
1446
+ def tckgen_config_cargs(
1447
+ params: TckgenConfigParamsDict,
1448
+ execution: Execution,
1449
+ ) -> list[str]:
1450
+ """
1451
+ Build command-line arguments from parameters.
1452
+
1453
+ Args:
1454
+ params: The parameters.
1455
+ execution: The execution object for resolving input paths.
1456
+ Returns:
1457
+ Command-line arguments.
1458
+ """
1459
+ cargs = []
1460
+ cargs.append("-config")
1461
+ cargs.append(params.get("key", None))
1462
+ cargs.append(params.get("value", None))
1463
+ return cargs
1464
+
1465
+
1466
+ class TckgenOutputs(typing.NamedTuple):
1467
+ """
1468
+ Output object returned when calling `TckgenParamsDict(...)`.
1469
+ """
1470
+ root: OutputPathType
1471
+ """Output root folder. This is the root folder for all outputs."""
1472
+ tracks: OutputPathType
1473
+ """the output file containing the tracks generated."""
1474
+ output_seeds: OutputPathType | None
1475
+ """output the seed location of all successful streamlines to a file """
1476
+
1477
+
1478
+ def tckgen_params(
1479
+ source: InputPathType,
1480
+ tracks: str,
1481
+ algorithm: str | None = None,
1482
+ select_: int | None = None,
1483
+ step: float | None = None,
1484
+ angle: float | None = None,
1485
+ minlength: float | None = None,
1486
+ maxlength: float | None = None,
1487
+ cutoff: float | None = None,
1488
+ trials: int | None = None,
1489
+ noprecomputed: bool = False,
1490
+ rk4: bool = False,
1491
+ stop: bool = False,
1492
+ downsample: int | None = None,
1493
+ seed_image: list[TckgenSeedImageParamsDict] | None = None,
1494
+ seed_sphere: list[TckgenSeedSphereParamsDict] | None = None,
1495
+ seed_random_per_voxel: list[TckgenSeedRandomPerVoxelParamsDict] | None = None,
1496
+ seed_grid_per_voxel: list[TckgenSeedGridPerVoxelParamsDict] | None = None,
1497
+ seed_rejection: list[TckgenSeedRejectionParamsDict] | None = None,
1498
+ seed_gmwmi: list[TckgenSeedGmwmiParamsDict] | None = None,
1499
+ seed_dynamic: InputPathType | None = None,
1500
+ seeds: int | None = None,
1501
+ max_attempts_per_seed: int | None = None,
1502
+ seed_cutoff: float | None = None,
1503
+ seed_unidirectional: bool = False,
1504
+ seed_direction: list[float] | None = None,
1505
+ output_seeds: str | None = None,
1506
+ include: list[TckgenIncludeParamsDict] | None = None,
1507
+ include_ordered: list[TckgenIncludeOrderedParamsDict] | None = None,
1508
+ exclude: list[TckgenExcludeParamsDict] | None = None,
1509
+ mask: list[TckgenMaskParamsDict] | None = None,
1510
+ act: InputPathType | None = None,
1511
+ backtrack: bool = False,
1512
+ crop_at_gmwmi: bool = False,
1513
+ power: float | None = None,
1514
+ samples: int | None = None,
1515
+ grad: InputPathType | None = None,
1516
+ fslgrad: TckgenFslgradParamsDict | None = None,
1517
+ info: bool = False,
1518
+ quiet: bool = False,
1519
+ debug: bool = False,
1520
+ force: bool = False,
1521
+ nthreads: int | None = None,
1522
+ config: list[TckgenConfigParamsDict] | None = None,
1523
+ help_: bool = False,
1524
+ version: bool = False,
1525
+ ) -> TckgenParamsDictTagged:
1526
+ """
1527
+ Build parameters.
1528
+
1529
+ Args:
1530
+ source: The image containing the source data. The type of image data\
1531
+ required depends on the algorithm used (see Description section).
1532
+ tracks: the output file containing the tracks generated.
1533
+ algorithm: specify the tractography algorithm to use. Valid choices\
1534
+ are: FACT, iFOD1, iFOD2, Nulldist1, Nulldist2, SD_Stream, Seedtest,\
1535
+ Tensor_Det, Tensor_Prob (default: iFOD2).
1536
+ select_: set the desired number of streamlines to be selected by\
1537
+ tckgen, after all selection criteria have been applied (i.e.\
1538
+ inclusion/exclusion ROIs, min/max length, etc). tckgen will keep\
1539
+ seeding streamlines until this number of streamlines have been\
1540
+ selected, or the maximum allowed number of seeds has been exceeded (see\
1541
+ -seeds option). By default, 5000 streamlines are to be selected. Set to\
1542
+ zero to disable, which will result in streamlines being seeded until\
1543
+ the number specified by -seeds has been reached.
1544
+ step: set the step size of the algorithm in mm (defaults: for\
1545
+ first-order algorithms, 0.1 x voxelsize; if using RK4, 0.25 x\
1546
+ voxelsize; for iFOD2: 0.5 x voxelsize).
1547
+ angle: set the maximum angle in degrees between successive steps\
1548
+ (defaults: 60 for deterministic algorithms; 15 for iFOD1 / nulldist1;\
1549
+ 45 for iFOD2 / nulldist2).
1550
+ minlength: set the minimum length of any track in mm (defaults: without\
1551
+ ACT, 5 x voxelsize; with ACT, 2 x voxelsize).
1552
+ maxlength: set the maximum length of any track in mm (default: 100 x\
1553
+ voxelsize).
1554
+ cutoff: set the FOD amplitude / fixel size / tensor FA cutoff for\
1555
+ terminating tracks (defaults: 0.1 for FOD-based algorithms; 0.1 for\
1556
+ fixel-based algorithms; 0.1 for tensor-based algorithms; threshold\
1557
+ multiplied by 0.5 when using ACT).
1558
+ trials: set the maximum number of sampling trials at each point (only\
1559
+ used for iFOD1 / iFOD2) (default: 1000).
1560
+ noprecomputed: do NOT pre-compute legendre polynomial values. Warning:\
1561
+ this will slow down the algorithm by a factor of approximately 4.
1562
+ rk4: use 4th-order Runge-Kutta integration (slower, but eliminates\
1563
+ curvature overshoot in 1st-order deterministic methods).
1564
+ stop: stop propagating a streamline once it has traversed all include\
1565
+ regions.
1566
+ downsample: downsample the generated streamlines to reduce output file\
1567
+ size (default is (samples-1) for iFOD2, no downsampling for all other\
1568
+ algorithms).
1569
+ seed_image: seed streamlines entirely at random within a mask image.
1570
+ seed_sphere: spherical seed as four comma-separated values (XYZ\
1571
+ position and radius).
1572
+ seed_random_per_voxel: seed a fixed number of streamlines per voxel in\
1573
+ a mask image; random placement of seeds in each voxel.
1574
+ seed_grid_per_voxel: seed a fixed number of streamlines per voxel in a\
1575
+ mask image; place seeds on a 3D mesh grid (grid_size argument is per\
1576
+ axis; so a grid_size of 3 results in 27 seeds per voxel).
1577
+ seed_rejection: seed from an image using rejection sampling (higher\
1578
+ values = more probable to seed from).
1579
+ seed_gmwmi: seed from the grey matter - white matter interface (only\
1580
+ valid if using ACT framework). Input image should be a 3D seeding\
1581
+ volume; seeds drawn within this image will be optimised to the\
1582
+ interface using the 5TT image provided using the -act option.
1583
+ seed_dynamic: determine seed points dynamically using the SIFT model\
1584
+ (must not provide any other seeding mechanism). Note that while this\
1585
+ seeding mechanism improves the distribution of reconstructed\
1586
+ streamlines density, it should NOT be used as a substitute for the SIFT\
1587
+ method itself.
1588
+ seeds: set the number of seeds that tckgen will attempt to track from.\
1589
+ If this option is NOT provided, the default number of seeds is set to\
1590
+ 1000× the number of selected streamlines. If -select is NOT also\
1591
+ specified, tckgen will continue tracking until this number of seeds has\
1592
+ been attempted. However, if -select is also specified, tckgen will stop\
1593
+ when the number of seeds attempted reaches the number specified here,\
1594
+ OR when the number of streamlines selected reaches the number requested\
1595
+ with the -select option. This can be used to prevent the program from\
1596
+ running indefinitely when no or very few streamlines can be found that\
1597
+ match the selection criteria. Setting this to zero will cause tckgen to\
1598
+ keep attempting seeds until the number specified by -select has been\
1599
+ reached.
1600
+ max_attempts_per_seed: set the maximum number of times that the\
1601
+ tracking algorithm should attempt to find an appropriate tracking\
1602
+ direction from a given seed point. This should be set high enough to\
1603
+ ensure that an actual plausible seed point is not discarded prematurely\
1604
+ as being unable to initiate tracking from. Higher settings may affect\
1605
+ performance if many seeds are genuinely impossible to track from, as\
1606
+ many attempts will still be made in vain for such seeds. (default:\
1607
+ 1000).
1608
+ seed_cutoff: set the minimum FA or FOD amplitude for seeding tracks\
1609
+ (default is the same as the normal -cutoff).
1610
+ seed_unidirectional: track from the seed point in one direction only\
1611
+ (default is to track in both directions).
1612
+ seed_direction: specify a seeding direction for the tracking (this\
1613
+ should be supplied as a vector of 3 comma-separated values.
1614
+ output_seeds: output the seed location of all successful streamlines to\
1615
+ a file.
1616
+ include: specify an inclusion region of interest, as either a binary\
1617
+ mask image, or as a sphere using 4 comma-separared values\
1618
+ (x,y,z,radius). Streamlines must traverse ALL inclusion regions to be\
1619
+ accepted.
1620
+ include_ordered: specify an inclusion region of interest, as either a\
1621
+ binary mask image, or as a sphere using 4 comma-separared values\
1622
+ (x,y,z,radius). Streamlines must traverse ALL inclusion_ordered regions\
1623
+ in the order they are specified in order to be accepted.
1624
+ exclude: specify an exclusion region of interest, as either a binary\
1625
+ mask image, or as a sphere using 4 comma-separared values\
1626
+ (x,y,z,radius). Streamlines that enter ANY exclude region will be\
1627
+ discarded.
1628
+ mask: specify a masking region of interest, as either a binary mask\
1629
+ image, or as a sphere using 4 comma-separared values (x,y,z,radius). If\
1630
+ defined, streamlines exiting the mask will be truncated.
1631
+ act: use the Anatomically-Constrained Tractography framework during\
1632
+ tracking; provided image must be in the 5TT (five-tissue-type) format.
1633
+ backtrack: allow tracks to be truncated and re-tracked if a poor\
1634
+ structural termination is encountered.
1635
+ crop_at_gmwmi: crop streamline endpoints more precisely as they cross\
1636
+ the GM-WM interface.
1637
+ power: raise the FOD to the power specified (defaults are: 1.0 for\
1638
+ iFOD1; 1.0/nsamples for iFOD2).
1639
+ samples: set the number of FOD samples to take per step (Default: 4).
1640
+ grad: Provide the diffusion-weighted gradient scheme used in the\
1641
+ acquisition in a text file. This should be supplied as a 4xN text file\
1642
+ with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
1643
+ the direction of the applied gradient, and b gives the b-value in units\
1644
+ of s/mm^2. If a diffusion gradient scheme is present in the input image\
1645
+ header, the data provided with this option will be instead used.
1646
+ fslgrad: Provide the diffusion-weighted gradient scheme used in the\
1647
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
1648
+ scheme is present in the input image header, the data provided with\
1649
+ this option will be instead used.
1650
+ info: display information messages.
1651
+ quiet: do not display information messages or progress status;\
1652
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
1653
+ environment variable to a non-empty string.
1654
+ debug: display debugging messages.
1655
+ force: force overwrite of output files (caution: using the same file as\
1656
+ input and output might cause unexpected behaviour).
1657
+ nthreads: use this number of threads in multi-threaded applications\
1658
+ (set to 0 to disable multi-threading).
1659
+ config: temporarily set the value of an MRtrix config file entry.
1660
+ help_: display this information page and exit.
1661
+ version: display version information and exit.
1662
+ Returns:
1663
+ Parameter dictionary
1664
+ """
1665
+ params = {
1666
+ "@type": "mrtrix/tckgen",
1667
+ "noprecomputed": noprecomputed,
1668
+ "rk4": rk4,
1669
+ "stop": stop,
1670
+ "seed_unidirectional": seed_unidirectional,
1671
+ "backtrack": backtrack,
1672
+ "crop_at_gmwmi": crop_at_gmwmi,
1673
+ "info": info,
1674
+ "quiet": quiet,
1675
+ "debug": debug,
1676
+ "force": force,
1677
+ "help": help_,
1678
+ "version": version,
1679
+ "source": source,
1680
+ "tracks": tracks,
1681
+ }
1682
+ if algorithm is not None:
1683
+ params["algorithm"] = algorithm
1684
+ if select_ is not None:
1685
+ params["select"] = select_
1686
+ if step is not None:
1687
+ params["step"] = step
1688
+ if angle is not None:
1689
+ params["angle"] = angle
1690
+ if minlength is not None:
1691
+ params["minlength"] = minlength
1692
+ if maxlength is not None:
1693
+ params["maxlength"] = maxlength
1694
+ if cutoff is not None:
1695
+ params["cutoff"] = cutoff
1696
+ if trials is not None:
1697
+ params["trials"] = trials
1698
+ if downsample is not None:
1699
+ params["downsample"] = downsample
1700
+ if seed_image is not None:
1701
+ params["seed_image"] = seed_image
1702
+ if seed_sphere is not None:
1703
+ params["seed_sphere"] = seed_sphere
1704
+ if seed_random_per_voxel is not None:
1705
+ params["seed_random_per_voxel"] = seed_random_per_voxel
1706
+ if seed_grid_per_voxel is not None:
1707
+ params["seed_grid_per_voxel"] = seed_grid_per_voxel
1708
+ if seed_rejection is not None:
1709
+ params["seed_rejection"] = seed_rejection
1710
+ if seed_gmwmi is not None:
1711
+ params["seed_gmwmi"] = seed_gmwmi
1712
+ if seed_dynamic is not None:
1713
+ params["seed_dynamic"] = seed_dynamic
1714
+ if seeds is not None:
1715
+ params["seeds"] = seeds
1716
+ if max_attempts_per_seed is not None:
1717
+ params["max_attempts_per_seed"] = max_attempts_per_seed
1718
+ if seed_cutoff is not None:
1719
+ params["seed_cutoff"] = seed_cutoff
1720
+ if seed_direction is not None:
1721
+ params["seed_direction"] = seed_direction
1722
+ if output_seeds is not None:
1723
+ params["output_seeds"] = output_seeds
1724
+ if include is not None:
1725
+ params["include"] = include
1726
+ if include_ordered is not None:
1727
+ params["include_ordered"] = include_ordered
1728
+ if exclude is not None:
1729
+ params["exclude"] = exclude
1730
+ if mask is not None:
1731
+ params["mask"] = mask
1732
+ if act is not None:
1733
+ params["act"] = act
1734
+ if power is not None:
1735
+ params["power"] = power
1736
+ if samples is not None:
1737
+ params["samples"] = samples
1738
+ if grad is not None:
1739
+ params["grad"] = grad
1740
+ if fslgrad is not None:
1741
+ params["fslgrad"] = fslgrad
1742
+ if nthreads is not None:
1743
+ params["nthreads"] = nthreads
1744
+ if config is not None:
1745
+ params["config"] = config
1746
+ return params
1747
+
1748
+
1749
+ def tckgen_validate(
1750
+ params: typing.Any,
1751
+ ) -> None:
1752
+ """
1753
+ Validate parameters. Throws an error if `params` is not a valid
1754
+ `TckgenParamsDict` object.
1755
+
1756
+ Args:
1757
+ params: The parameters object to validate.
1758
+ """
1759
+ if params is None or not isinstance(params, dict):
1760
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
1761
+ if params.get("algorithm", None) is not None:
1762
+ if not isinstance(params["algorithm"], str):
1763
+ raise StyxValidationError(f'`algorithm` has the wrong type: Received `{type(params.get("algorithm", None))}` expected `str | None`')
1764
+ if params.get("select", None) is not None:
1765
+ if not isinstance(params["select"], int):
1766
+ raise StyxValidationError(f'`select` has the wrong type: Received `{type(params.get("select", None))}` expected `int | None`')
1767
+ if params.get("step", None) is not None:
1768
+ if not isinstance(params["step"], (float, int)):
1769
+ raise StyxValidationError(f'`step` has the wrong type: Received `{type(params.get("step", None))}` expected `float | None`')
1770
+ if params.get("angle", None) is not None:
1771
+ if not isinstance(params["angle"], (float, int)):
1772
+ raise StyxValidationError(f'`angle` has the wrong type: Received `{type(params.get("angle", None))}` expected `float | None`')
1773
+ if params.get("minlength", None) is not None:
1774
+ if not isinstance(params["minlength"], (float, int)):
1775
+ raise StyxValidationError(f'`minlength` has the wrong type: Received `{type(params.get("minlength", None))}` expected `float | None`')
1776
+ if params.get("maxlength", None) is not None:
1777
+ if not isinstance(params["maxlength"], (float, int)):
1778
+ raise StyxValidationError(f'`maxlength` has the wrong type: Received `{type(params.get("maxlength", None))}` expected `float | None`')
1779
+ if params.get("cutoff", None) is not None:
1780
+ if not isinstance(params["cutoff"], (float, int)):
1781
+ raise StyxValidationError(f'`cutoff` has the wrong type: Received `{type(params.get("cutoff", None))}` expected `float | None`')
1782
+ if params.get("trials", None) is not None:
1783
+ if not isinstance(params["trials"], int):
1784
+ raise StyxValidationError(f'`trials` has the wrong type: Received `{type(params.get("trials", None))}` expected `int | None`')
1785
+ if params.get("noprecomputed", False) is None:
1786
+ raise StyxValidationError("`noprecomputed` must not be None")
1787
+ if not isinstance(params["noprecomputed"], bool):
1788
+ raise StyxValidationError(f'`noprecomputed` has the wrong type: Received `{type(params.get("noprecomputed", False))}` expected `bool`')
1789
+ if params.get("rk4", False) is None:
1790
+ raise StyxValidationError("`rk4` must not be None")
1791
+ if not isinstance(params["rk4"], bool):
1792
+ raise StyxValidationError(f'`rk4` has the wrong type: Received `{type(params.get("rk4", False))}` expected `bool`')
1793
+ if params.get("stop", False) is None:
1794
+ raise StyxValidationError("`stop` must not be None")
1795
+ if not isinstance(params["stop"], bool):
1796
+ raise StyxValidationError(f'`stop` has the wrong type: Received `{type(params.get("stop", False))}` expected `bool`')
1797
+ if params.get("downsample", None) is not None:
1798
+ if not isinstance(params["downsample"], int):
1799
+ raise StyxValidationError(f'`downsample` has the wrong type: Received `{type(params.get("downsample", None))}` expected `int | None`')
1800
+ if params.get("seed_image", None) is not None:
1801
+ if not isinstance(params["seed_image"], list):
1802
+ raise StyxValidationError(f'`seed_image` has the wrong type: Received `{type(params.get("seed_image", None))}` expected `list[TckgenSeedImageParamsDict] | None`')
1803
+ for e in params["seed_image"]:
1804
+ tckgen_seed_image_validate(e)
1805
+ if params.get("seed_sphere", None) is not None:
1806
+ if not isinstance(params["seed_sphere"], list):
1807
+ raise StyxValidationError(f'`seed_sphere` has the wrong type: Received `{type(params.get("seed_sphere", None))}` expected `list[TckgenSeedSphereParamsDict] | None`')
1808
+ for e in params["seed_sphere"]:
1809
+ tckgen_seed_sphere_validate(e)
1810
+ if params.get("seed_random_per_voxel", None) is not None:
1811
+ if not isinstance(params["seed_random_per_voxel"], list):
1812
+ raise StyxValidationError(f'`seed_random_per_voxel` has the wrong type: Received `{type(params.get("seed_random_per_voxel", None))}` expected `list[TckgenSeedRandomPerVoxelParamsDict] | None`')
1813
+ for e in params["seed_random_per_voxel"]:
1814
+ tckgen_seed_random_per_voxel_validate(e)
1815
+ if params.get("seed_grid_per_voxel", None) is not None:
1816
+ if not isinstance(params["seed_grid_per_voxel"], list):
1817
+ raise StyxValidationError(f'`seed_grid_per_voxel` has the wrong type: Received `{type(params.get("seed_grid_per_voxel", None))}` expected `list[TckgenSeedGridPerVoxelParamsDict] | None`')
1818
+ for e in params["seed_grid_per_voxel"]:
1819
+ tckgen_seed_grid_per_voxel_validate(e)
1820
+ if params.get("seed_rejection", None) is not None:
1821
+ if not isinstance(params["seed_rejection"], list):
1822
+ raise StyxValidationError(f'`seed_rejection` has the wrong type: Received `{type(params.get("seed_rejection", None))}` expected `list[TckgenSeedRejectionParamsDict] | None`')
1823
+ for e in params["seed_rejection"]:
1824
+ tckgen_seed_rejection_validate(e)
1825
+ if params.get("seed_gmwmi", None) is not None:
1826
+ if not isinstance(params["seed_gmwmi"], list):
1827
+ raise StyxValidationError(f'`seed_gmwmi` has the wrong type: Received `{type(params.get("seed_gmwmi", None))}` expected `list[TckgenSeedGmwmiParamsDict] | None`')
1828
+ for e in params["seed_gmwmi"]:
1829
+ tckgen_seed_gmwmi_validate(e)
1830
+ if params.get("seed_dynamic", None) is not None:
1831
+ if not isinstance(params["seed_dynamic"], (pathlib.Path, str)):
1832
+ raise StyxValidationError(f'`seed_dynamic` has the wrong type: Received `{type(params.get("seed_dynamic", None))}` expected `InputPathType | None`')
1833
+ if params.get("seeds", None) is not None:
1834
+ if not isinstance(params["seeds"], int):
1835
+ raise StyxValidationError(f'`seeds` has the wrong type: Received `{type(params.get("seeds", None))}` expected `int | None`')
1836
+ if params.get("max_attempts_per_seed", None) is not None:
1837
+ if not isinstance(params["max_attempts_per_seed"], int):
1838
+ raise StyxValidationError(f'`max_attempts_per_seed` has the wrong type: Received `{type(params.get("max_attempts_per_seed", None))}` expected `int | None`')
1839
+ if params.get("seed_cutoff", None) is not None:
1840
+ if not isinstance(params["seed_cutoff"], (float, int)):
1841
+ raise StyxValidationError(f'`seed_cutoff` has the wrong type: Received `{type(params.get("seed_cutoff", None))}` expected `float | None`')
1842
+ if params.get("seed_unidirectional", False) is None:
1843
+ raise StyxValidationError("`seed_unidirectional` must not be None")
1844
+ if not isinstance(params["seed_unidirectional"], bool):
1845
+ raise StyxValidationError(f'`seed_unidirectional` has the wrong type: Received `{type(params.get("seed_unidirectional", False))}` expected `bool`')
1846
+ if params.get("seed_direction", None) is not None:
1847
+ if not isinstance(params["seed_direction"], list):
1848
+ raise StyxValidationError(f'`seed_direction` has the wrong type: Received `{type(params.get("seed_direction", None))}` expected `list[float] | None`')
1849
+ for e in params["seed_direction"]:
1850
+ if not isinstance(e, (float, int)):
1851
+ raise StyxValidationError(f'`seed_direction` has the wrong type: Received `{type(params.get("seed_direction", None))}` expected `list[float] | None`')
1852
+ if params.get("output_seeds", None) is not None:
1853
+ if not isinstance(params["output_seeds"], str):
1854
+ raise StyxValidationError(f'`output_seeds` has the wrong type: Received `{type(params.get("output_seeds", None))}` expected `str | None`')
1855
+ if params.get("include", None) is not None:
1856
+ if not isinstance(params["include"], list):
1857
+ raise StyxValidationError(f'`include` has the wrong type: Received `{type(params.get("include", None))}` expected `list[TckgenIncludeParamsDict] | None`')
1858
+ for e in params["include"]:
1859
+ tckgen_include_validate(e)
1860
+ if params.get("include_ordered", None) is not None:
1861
+ if not isinstance(params["include_ordered"], list):
1862
+ raise StyxValidationError(f'`include_ordered` has the wrong type: Received `{type(params.get("include_ordered", None))}` expected `list[TckgenIncludeOrderedParamsDict] | None`')
1863
+ for e in params["include_ordered"]:
1864
+ tckgen_include_ordered_validate(e)
1865
+ if params.get("exclude", None) is not None:
1866
+ if not isinstance(params["exclude"], list):
1867
+ raise StyxValidationError(f'`exclude` has the wrong type: Received `{type(params.get("exclude", None))}` expected `list[TckgenExcludeParamsDict] | None`')
1868
+ for e in params["exclude"]:
1869
+ tckgen_exclude_validate(e)
1870
+ if params.get("mask", None) is not None:
1871
+ if not isinstance(params["mask"], list):
1872
+ raise StyxValidationError(f'`mask` has the wrong type: Received `{type(params.get("mask", None))}` expected `list[TckgenMaskParamsDict] | None`')
1873
+ for e in params["mask"]:
1874
+ tckgen_mask_validate(e)
1875
+ if params.get("act", None) is not None:
1876
+ if not isinstance(params["act"], (pathlib.Path, str)):
1877
+ raise StyxValidationError(f'`act` has the wrong type: Received `{type(params.get("act", None))}` expected `InputPathType | None`')
1878
+ if params.get("backtrack", False) is None:
1879
+ raise StyxValidationError("`backtrack` must not be None")
1880
+ if not isinstance(params["backtrack"], bool):
1881
+ raise StyxValidationError(f'`backtrack` has the wrong type: Received `{type(params.get("backtrack", False))}` expected `bool`')
1882
+ if params.get("crop_at_gmwmi", False) is None:
1883
+ raise StyxValidationError("`crop_at_gmwmi` must not be None")
1884
+ if not isinstance(params["crop_at_gmwmi"], bool):
1885
+ raise StyxValidationError(f'`crop_at_gmwmi` has the wrong type: Received `{type(params.get("crop_at_gmwmi", False))}` expected `bool`')
1886
+ if params.get("power", None) is not None:
1887
+ if not isinstance(params["power"], (float, int)):
1888
+ raise StyxValidationError(f'`power` has the wrong type: Received `{type(params.get("power", None))}` expected `float | None`')
1889
+ if params.get("samples", None) is not None:
1890
+ if not isinstance(params["samples"], int):
1891
+ raise StyxValidationError(f'`samples` has the wrong type: Received `{type(params.get("samples", None))}` expected `int | None`')
1892
+ if params.get("grad", None) is not None:
1893
+ if not isinstance(params["grad"], (pathlib.Path, str)):
1894
+ raise StyxValidationError(f'`grad` has the wrong type: Received `{type(params.get("grad", None))}` expected `InputPathType | None`')
1895
+ if params.get("fslgrad", None) is not None:
1896
+ tckgen_fslgrad_validate(params["fslgrad"])
1897
+ if params.get("info", False) is None:
1898
+ raise StyxValidationError("`info` must not be None")
1899
+ if not isinstance(params["info"], bool):
1900
+ raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
1901
+ if params.get("quiet", False) is None:
1902
+ raise StyxValidationError("`quiet` must not be None")
1903
+ if not isinstance(params["quiet"], bool):
1904
+ raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
1905
+ if params.get("debug", False) is None:
1906
+ raise StyxValidationError("`debug` must not be None")
1907
+ if not isinstance(params["debug"], bool):
1908
+ raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
1909
+ if params.get("force", False) is None:
1910
+ raise StyxValidationError("`force` must not be None")
1911
+ if not isinstance(params["force"], bool):
1912
+ raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
1913
+ if params.get("nthreads", None) is not None:
1914
+ if not isinstance(params["nthreads"], int):
1915
+ raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
1916
+ if params.get("config", None) is not None:
1917
+ if not isinstance(params["config"], list):
1918
+ raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[TckgenConfigParamsDict] | None`')
1919
+ for e in params["config"]:
1920
+ tckgen_config_validate(e)
1921
+ if params.get("help", False) is None:
1922
+ raise StyxValidationError("`help` must not be None")
1923
+ if not isinstance(params["help"], bool):
1924
+ raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
1925
+ if params.get("version", False) is None:
1926
+ raise StyxValidationError("`version` must not be None")
1927
+ if not isinstance(params["version"], bool):
1928
+ raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
1929
+ if params.get("source", None) is None:
1930
+ raise StyxValidationError("`source` must not be None")
1931
+ if not isinstance(params["source"], (pathlib.Path, str)):
1932
+ raise StyxValidationError(f'`source` has the wrong type: Received `{type(params.get("source", None))}` expected `InputPathType`')
1933
+ if params.get("tracks", None) is None:
1934
+ raise StyxValidationError("`tracks` must not be None")
1935
+ if not isinstance(params["tracks"], str):
1936
+ raise StyxValidationError(f'`tracks` has the wrong type: Received `{type(params.get("tracks", None))}` expected `str`')
1937
+
1938
+
1939
+ def tckgen_cargs(
1940
+ params: TckgenParamsDict,
1941
+ execution: Execution,
1942
+ ) -> list[str]:
1943
+ """
1944
+ Build command-line arguments from parameters.
1945
+
1946
+ Args:
1947
+ params: The parameters.
1948
+ execution: The execution object for resolving input paths.
1949
+ Returns:
1950
+ Command-line arguments.
1951
+ """
1952
+ cargs = []
1953
+ cargs.append("tckgen")
1954
+ if params.get("algorithm", None) is not None:
1955
+ cargs.extend([
1956
+ "-algorithm",
1957
+ params.get("algorithm", None)
1958
+ ])
1959
+ if params.get("select", None) is not None:
1960
+ cargs.extend([
1961
+ "-select",
1962
+ str(params.get("select", None))
1963
+ ])
1964
+ if params.get("step", None) is not None:
1965
+ cargs.extend([
1966
+ "-step",
1967
+ str(params.get("step", None))
1968
+ ])
1969
+ if params.get("angle", None) is not None:
1970
+ cargs.extend([
1971
+ "-angle",
1972
+ str(params.get("angle", None))
1973
+ ])
1974
+ if params.get("minlength", None) is not None:
1975
+ cargs.extend([
1976
+ "-minlength",
1977
+ str(params.get("minlength", None))
1978
+ ])
1979
+ if params.get("maxlength", None) is not None:
1980
+ cargs.extend([
1981
+ "-maxlength",
1982
+ str(params.get("maxlength", None))
1983
+ ])
1984
+ if params.get("cutoff", None) is not None:
1985
+ cargs.extend([
1986
+ "-cutoff",
1987
+ str(params.get("cutoff", None))
1988
+ ])
1989
+ if params.get("trials", None) is not None:
1990
+ cargs.extend([
1991
+ "-trials",
1992
+ str(params.get("trials", None))
1993
+ ])
1994
+ if params.get("noprecomputed", False):
1995
+ cargs.append("-noprecomputed")
1996
+ if params.get("rk4", False):
1997
+ cargs.append("-rk4")
1998
+ if params.get("stop", False):
1999
+ cargs.append("-stop")
2000
+ if params.get("downsample", None) is not None:
2001
+ cargs.extend([
2002
+ "-downsample",
2003
+ str(params.get("downsample", None))
2004
+ ])
2005
+ if params.get("seed_image", None) is not None:
2006
+ cargs.extend([a for c in [tckgen_seed_image_cargs(s, execution) for s in params.get("seed_image", None)] for a in c])
2007
+ if params.get("seed_sphere", None) is not None:
2008
+ cargs.extend([a for c in [tckgen_seed_sphere_cargs(s, execution) for s in params.get("seed_sphere", None)] for a in c])
2009
+ if params.get("seed_random_per_voxel", None) is not None:
2010
+ cargs.extend([a for c in [tckgen_seed_random_per_voxel_cargs(s, execution) for s in params.get("seed_random_per_voxel", None)] for a in c])
2011
+ if params.get("seed_grid_per_voxel", None) is not None:
2012
+ cargs.extend([a for c in [tckgen_seed_grid_per_voxel_cargs(s, execution) for s in params.get("seed_grid_per_voxel", None)] for a in c])
2013
+ if params.get("seed_rejection", None) is not None:
2014
+ cargs.extend([a for c in [tckgen_seed_rejection_cargs(s, execution) for s in params.get("seed_rejection", None)] for a in c])
2015
+ if params.get("seed_gmwmi", None) is not None:
2016
+ cargs.extend([a for c in [tckgen_seed_gmwmi_cargs(s, execution) for s in params.get("seed_gmwmi", None)] for a in c])
2017
+ if params.get("seed_dynamic", None) is not None:
2018
+ cargs.extend([
2019
+ "-seed_dynamic",
2020
+ execution.input_file(params.get("seed_dynamic", None))
2021
+ ])
2022
+ if params.get("seeds", None) is not None:
2023
+ cargs.extend([
2024
+ "-seeds",
2025
+ str(params.get("seeds", None))
2026
+ ])
2027
+ if params.get("max_attempts_per_seed", None) is not None:
2028
+ cargs.extend([
2029
+ "-max_attempts_per_seed",
2030
+ str(params.get("max_attempts_per_seed", None))
2031
+ ])
2032
+ if params.get("seed_cutoff", None) is not None:
2033
+ cargs.extend([
2034
+ "-seed_cutoff",
2035
+ str(params.get("seed_cutoff", None))
2036
+ ])
2037
+ if params.get("seed_unidirectional", False):
2038
+ cargs.append("-seed_unidirectional")
2039
+ if params.get("seed_direction", None) is not None:
2040
+ cargs.extend([
2041
+ "-seed_direction",
2042
+ ",".join(map(str, params.get("seed_direction", None)))
2043
+ ])
2044
+ if params.get("output_seeds", None) is not None:
2045
+ cargs.extend([
2046
+ "-output_seeds",
2047
+ params.get("output_seeds", None)
2048
+ ])
2049
+ if params.get("include", None) is not None:
2050
+ cargs.extend([a for c in [tckgen_include_cargs(s, execution) for s in params.get("include", None)] for a in c])
2051
+ if params.get("include_ordered", None) is not None:
2052
+ cargs.extend([a for c in [tckgen_include_ordered_cargs(s, execution) for s in params.get("include_ordered", None)] for a in c])
2053
+ if params.get("exclude", None) is not None:
2054
+ cargs.extend([a for c in [tckgen_exclude_cargs(s, execution) for s in params.get("exclude", None)] for a in c])
2055
+ if params.get("mask", None) is not None:
2056
+ cargs.extend([a for c in [tckgen_mask_cargs(s, execution) for s in params.get("mask", None)] for a in c])
2057
+ if params.get("act", None) is not None:
2058
+ cargs.extend([
2059
+ "-act",
2060
+ execution.input_file(params.get("act", None))
2061
+ ])
2062
+ if params.get("backtrack", False):
2063
+ cargs.append("-backtrack")
2064
+ if params.get("crop_at_gmwmi", False):
2065
+ cargs.append("-crop_at_gmwmi")
2066
+ if params.get("power", None) is not None:
2067
+ cargs.extend([
2068
+ "-power",
2069
+ str(params.get("power", None))
2070
+ ])
2071
+ if params.get("samples", None) is not None:
2072
+ cargs.extend([
2073
+ "-samples",
2074
+ str(params.get("samples", None))
2075
+ ])
2076
+ if params.get("grad", None) is not None:
2077
+ cargs.extend([
2078
+ "-grad",
2079
+ execution.input_file(params.get("grad", None))
2080
+ ])
2081
+ if params.get("fslgrad", None) is not None:
2082
+ cargs.extend(tckgen_fslgrad_cargs(params.get("fslgrad", None), execution))
2083
+ if params.get("info", False):
2084
+ cargs.append("-info")
2085
+ if params.get("quiet", False):
2086
+ cargs.append("-quiet")
2087
+ if params.get("debug", False):
2088
+ cargs.append("-debug")
2089
+ if params.get("force", False):
2090
+ cargs.append("-force")
2091
+ if params.get("nthreads", None) is not None:
2092
+ cargs.extend([
2093
+ "-nthreads",
2094
+ str(params.get("nthreads", None))
2095
+ ])
2096
+ if params.get("config", None) is not None:
2097
+ cargs.extend([a for c in [tckgen_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
2098
+ if params.get("help", False):
2099
+ cargs.append("-help")
2100
+ if params.get("version", False):
2101
+ cargs.append("-version")
2102
+ cargs.append(execution.input_file(params.get("source", None)))
2103
+ cargs.append(params.get("tracks", None))
2104
+ return cargs
2105
+
2106
+
2107
+ def tckgen_outputs(
2108
+ params: TckgenParamsDict,
2109
+ execution: Execution,
2110
+ ) -> TckgenOutputs:
2111
+ """
2112
+ Build outputs object containing output file paths and possibly stdout/stderr.
2113
+
2114
+ Args:
2115
+ params: The parameters.
2116
+ execution: The execution object for resolving input paths.
2117
+ Returns:
2118
+ Outputs object.
2119
+ """
2120
+ ret = TckgenOutputs(
2121
+ root=execution.output_file("."),
2122
+ tracks=execution.output_file(params.get("tracks", None)),
2123
+ output_seeds=execution.output_file(params.get("output_seeds", None)) if (params.get("output_seeds") is not None) else None,
2124
+ )
2125
+ return ret
2126
+
2127
+
2128
+ def tckgen_execute(
2129
+ params: TckgenParamsDict,
2130
+ runner: Runner | None = None,
2131
+ ) -> TckgenOutputs:
2132
+ """
2133
+ tckgen
2134
+
2135
+ Perform streamlines tractography.
2136
+
2137
+ By default, tckgen produces a fixed number of streamlines, by attempting to
2138
+ seed from new random locations until the target number of streamlines have
2139
+ been selected (in other words, after all inclusion & exclusion criteria have
2140
+ been applied), or the maximum number of seeds has been exceeded (by default,
2141
+ this is 1000 x the desired number of selected streamlines). Use the -select
2142
+ and/or -seeds options to modify as required. See also the Seeding options
2143
+ section for alternative seeding strategies.
2144
+
2145
+ Below is a list of available tracking algorithms, the input image data that
2146
+ they require, and a brief description of their behaviour:
2147
+
2148
+ - FACT: Fiber Assigned by Continuous Tracking. A deterministic algorithm
2149
+ that takes as input a 4D image, with 3xN volumes, where N is the maximum
2150
+ number of fiber orientations in a voxel. Each triplet of volumes represents
2151
+ a 3D vector corresponding to a fiber orientation; the length of the vector
2152
+ additionally indicates some measure of density or anisotropy. As streamlines
2153
+ move from one voxel to another, the fiber orientation most collinear with
2154
+ the streamline orientation is selected (i.e. there is no intra-voxel
2155
+ interpolation).
2156
+
2157
+ - iFOD1: First-order Integration over Fiber Orientation Distributions. A
2158
+ probabilistic algorithm that takes as input a Fiber Orientation Distribution
2159
+ (FOD) image represented in the Spherical Harmonic (SH) basis. At each
2160
+ streamline step, random samples from the local (trilinear interpolated) FOD
2161
+ are taken. A streamline is more probable to follow orientations where the
2162
+ FOD amplitude is large; but it may also rarely traverse orientations with
2163
+ small FOD amplitude.
2164
+
2165
+ - iFOD2 (default): Second-order Integration over Fiber Orientation
2166
+ Distributions. A probabilistic algorithm that takes as input a Fiber
2167
+ Orientation Distribution (FOD) image represented in the Spherical Harmonic
2168
+ (SH) basis. Candidate streamline paths (based on short curved "arcs") are
2169
+ drawn, and the underlying (trilinear-interpolated) FOD amplitudes along
2170
+ those arcs are sampled. A streamline is more probable to follow a path where
2171
+ the FOD amplitudes along that path are large; but it may also rarely
2172
+ traverse orientations where the FOD amplitudes are small, as long as the
2173
+ amplitude remains above the FOD amplitude threshold along the entire path.
2174
+
2175
+ - NullDist1 / NullDist2: Null Distribution tracking algorithms. These
2176
+ probabilistic algorithms expect as input the same image that was used when
2177
+ invoking the corresponding algorithm for which the null distribution is
2178
+ sought. These algorithms generate streamlines based on random orientation
2179
+ samples; that is, no image information relating to fiber orientations is
2180
+ used, and streamlines trajectories are determined entirely from random
2181
+ sampling. The NullDist2 algorithm is designed to be used in conjunction with
2182
+ iFOD2; NullDist1 should be used in conjunction with any first-order
2183
+ algorithm.
2184
+
2185
+ - SD_STREAM: Streamlines tractography based on Spherical Deconvolution (SD).
2186
+ A deterministic algorithm that takes as input a Fiber Orientation
2187
+ Distribution (FOD) image represented in the Spherical Harmonic (SH) basis.
2188
+ At each streamline step, the local (trilinear-interpolated) FOD is sampled,
2189
+ and from the current streamline tangent orientation, a Newton optimisation
2190
+ on the sphere is performed in order to locate the orientation of the nearest
2191
+ FOD amplitude peak.
2192
+
2193
+ - SeedTest: A dummy streamlines algorithm used for testing streamline
2194
+ seeding mechanisms. Any image can be used as input; the image will not be
2195
+ used in any way. For each seed point generated by the seeding mechanism(s),
2196
+ a streamline containing a single point corresponding to that seed location
2197
+ will be written to the output track file.
2198
+
2199
+ - Tensor_Det: A deterministic algorithm that takes as input a 4D
2200
+ diffusion-weighted image (DWI) series. At each streamline step, the
2201
+ diffusion tensor is fitted to the local (trilinear-interpolated) diffusion
2202
+ data, and the streamline trajectory is determined as the principal
2203
+ eigenvector of that tensor.
2204
+
2205
+ - Tensor_Prob: A probabilistic algorithm that takes as input a 4D
2206
+ diffusion-weighted image (DWI) series. Within each image voxel, a residual
2207
+ bootstrap is performed to obtain a unique realisation of the DWI data in
2208
+ that voxel for each streamline. These data are then sampled via trilinear
2209
+ interpolation at each streamline step, the diffusion tensor model is fitted,
2210
+ and the streamline follows the orientation of the principal eigenvector of
2211
+ that tensor.
2212
+
2213
+ Note that the behaviour of the -angle option varies slightly depending on
2214
+ the order of integration: for any first-order method, this angle corresponds
2215
+ to the deviation in streamline trajectory per step; for higher-order
2216
+ methods, this corresponds to the change in underlying fibre orientation
2217
+ between the start and end points of each step.
2218
+
2219
+ References:
2220
+
2221
+ References based on streamlines algorithm used:
2222
+
2223
+ * FACT:
2224
+ Mori, S.; Crain, B. J.; Chacko, V. P. & van Zijl, P. C. M. Three-dimensional
2225
+ tracking of axonal projections in the brain by magnetic resonance imaging.
2226
+ Annals of Neurology, 1999, 45, 265-269
2227
+
2228
+ * iFOD1 or SD_STREAM:
2229
+ Tournier, J.-D.; Calamante, F. & Connelly, A. MRtrix: Diffusion tractography
2230
+ in crossing fiber regions. Int. J. Imaging Syst. Technol., 2012, 22, 53-66
2231
+
2232
+ * iFOD2:
2233
+ Tournier, J.-D.; Calamante, F. & Connelly, A. Improved probabilistic
2234
+ streamlines tractography by 2nd order integration over fibre orientation
2235
+ distributions. Proceedings of the International Society for Magnetic
2236
+ Resonance in Medicine, 2010, 1670
2237
+
2238
+ * Nulldist1 / Nulldist2:
2239
+ Morris, D. M.; Embleton, K. V. & Parker, G. J. Probabilistic fibre tracking:
2240
+ Differentiation of connections from chance events. NeuroImage, 2008, 42,
2241
+ 1329-1339
2242
+
2243
+ * Tensor_Det:
2244
+ Basser, P. J.; Pajevic, S.; Pierpaoli, C.; Duda, J. & Aldroubi, A. In vivo
2245
+ fiber tractography using DT-MRI data. Magnetic Resonance in Medicine, 2000,
2246
+ 44, 625-632
2247
+
2248
+ * Tensor_Prob:
2249
+ Jones, D. Tractography Gone Wild: Probabilistic Fibre Tracking Using the
2250
+ Wild Bootstrap With Diffusion Tensor MRI. IEEE Transactions on Medical
2251
+ Imaging, 2008, 27, 1268-1274
2252
+
2253
+ References based on command-line options:
2254
+
2255
+ * -rk4:
2256
+ Basser, P. J.; Pajevic, S.; Pierpaoli, C.; Duda, J. & Aldroubi, A. In vivo
2257
+ fiber tractography using DT-MRI data. Magnetic Resonance in Medicine, 2000,
2258
+ 44, 625-632
2259
+
2260
+ * -act, -backtrack, -seed_gmwmi:
2261
+ Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A.
2262
+ Anatomically-constrained tractography: Improved diffusion MRI streamlines
2263
+ tractography through effective use of anatomical information. NeuroImage,
2264
+ 2012, 62, 1924-1938
2265
+
2266
+ * -seed_dynamic:
2267
+ Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A. SIFT2: Enabling
2268
+ dense quantitative assessment of brain white matter connectivity using
2269
+ streamlines tractography. NeuroImage, 2015, 119, 338-351.
2270
+
2271
+ Author: MRTrix3 Developers
2272
+
2273
+ URL: https://www.mrtrix.org/
2274
+
2275
+ Args:
2276
+ params: The parameters.
2277
+ runner: Command runner.
2278
+ Returns:
2279
+ NamedTuple of outputs (described in `TckgenOutputs`).
2280
+ """
2281
+ tckgen_validate(params)
2282
+ runner = runner or get_global_runner()
2283
+ execution = runner.start_execution(TCKGEN_METADATA)
2284
+ params = execution.params(params)
2285
+ cargs = tckgen_cargs(params, execution)
2286
+ ret = tckgen_outputs(params, execution)
2287
+ execution.run(cargs)
2288
+ return ret
2289
+
2290
+
2291
+ def tckgen(
2292
+ source: InputPathType,
2293
+ tracks: str,
2294
+ algorithm: str | None = None,
2295
+ select_: int | None = None,
2296
+ step: float | None = None,
2297
+ angle: float | None = None,
2298
+ minlength: float | None = None,
2299
+ maxlength: float | None = None,
2300
+ cutoff: float | None = None,
2301
+ trials: int | None = None,
2302
+ noprecomputed: bool = False,
2303
+ rk4: bool = False,
2304
+ stop: bool = False,
2305
+ downsample: int | None = None,
2306
+ seed_image: list[TckgenSeedImageParamsDict] | None = None,
2307
+ seed_sphere: list[TckgenSeedSphereParamsDict] | None = None,
2308
+ seed_random_per_voxel: list[TckgenSeedRandomPerVoxelParamsDict] | None = None,
2309
+ seed_grid_per_voxel: list[TckgenSeedGridPerVoxelParamsDict] | None = None,
2310
+ seed_rejection: list[TckgenSeedRejectionParamsDict] | None = None,
2311
+ seed_gmwmi: list[TckgenSeedGmwmiParamsDict] | None = None,
2312
+ seed_dynamic: InputPathType | None = None,
2313
+ seeds: int | None = None,
2314
+ max_attempts_per_seed: int | None = None,
2315
+ seed_cutoff: float | None = None,
2316
+ seed_unidirectional: bool = False,
2317
+ seed_direction: list[float] | None = None,
2318
+ output_seeds: str | None = None,
2319
+ include: list[TckgenIncludeParamsDict] | None = None,
2320
+ include_ordered: list[TckgenIncludeOrderedParamsDict] | None = None,
2321
+ exclude: list[TckgenExcludeParamsDict] | None = None,
2322
+ mask: list[TckgenMaskParamsDict] | None = None,
2323
+ act: InputPathType | None = None,
2324
+ backtrack: bool = False,
2325
+ crop_at_gmwmi: bool = False,
2326
+ power: float | None = None,
2327
+ samples: int | None = None,
2328
+ grad: InputPathType | None = None,
2329
+ fslgrad: TckgenFslgradParamsDict | None = None,
2330
+ info: bool = False,
2331
+ quiet: bool = False,
2332
+ debug: bool = False,
2333
+ force: bool = False,
2334
+ nthreads: int | None = None,
2335
+ config: list[TckgenConfigParamsDict] | None = None,
2336
+ help_: bool = False,
2337
+ version: bool = False,
2338
+ runner: Runner | None = None,
2339
+ ) -> TckgenOutputs:
2340
+ """
2341
+ tckgen
2342
+
2343
+ Perform streamlines tractography.
2344
+
2345
+ By default, tckgen produces a fixed number of streamlines, by attempting to
2346
+ seed from new random locations until the target number of streamlines have
2347
+ been selected (in other words, after all inclusion & exclusion criteria have
2348
+ been applied), or the maximum number of seeds has been exceeded (by default,
2349
+ this is 1000 x the desired number of selected streamlines). Use the -select
2350
+ and/or -seeds options to modify as required. See also the Seeding options
2351
+ section for alternative seeding strategies.
2352
+
2353
+ Below is a list of available tracking algorithms, the input image data that
2354
+ they require, and a brief description of their behaviour:
2355
+
2356
+ - FACT: Fiber Assigned by Continuous Tracking. A deterministic algorithm
2357
+ that takes as input a 4D image, with 3xN volumes, where N is the maximum
2358
+ number of fiber orientations in a voxel. Each triplet of volumes represents
2359
+ a 3D vector corresponding to a fiber orientation; the length of the vector
2360
+ additionally indicates some measure of density or anisotropy. As streamlines
2361
+ move from one voxel to another, the fiber orientation most collinear with
2362
+ the streamline orientation is selected (i.e. there is no intra-voxel
2363
+ interpolation).
2364
+
2365
+ - iFOD1: First-order Integration over Fiber Orientation Distributions. A
2366
+ probabilistic algorithm that takes as input a Fiber Orientation Distribution
2367
+ (FOD) image represented in the Spherical Harmonic (SH) basis. At each
2368
+ streamline step, random samples from the local (trilinear interpolated) FOD
2369
+ are taken. A streamline is more probable to follow orientations where the
2370
+ FOD amplitude is large; but it may also rarely traverse orientations with
2371
+ small FOD amplitude.
2372
+
2373
+ - iFOD2 (default): Second-order Integration over Fiber Orientation
2374
+ Distributions. A probabilistic algorithm that takes as input a Fiber
2375
+ Orientation Distribution (FOD) image represented in the Spherical Harmonic
2376
+ (SH) basis. Candidate streamline paths (based on short curved "arcs") are
2377
+ drawn, and the underlying (trilinear-interpolated) FOD amplitudes along
2378
+ those arcs are sampled. A streamline is more probable to follow a path where
2379
+ the FOD amplitudes along that path are large; but it may also rarely
2380
+ traverse orientations where the FOD amplitudes are small, as long as the
2381
+ amplitude remains above the FOD amplitude threshold along the entire path.
2382
+
2383
+ - NullDist1 / NullDist2: Null Distribution tracking algorithms. These
2384
+ probabilistic algorithms expect as input the same image that was used when
2385
+ invoking the corresponding algorithm for which the null distribution is
2386
+ sought. These algorithms generate streamlines based on random orientation
2387
+ samples; that is, no image information relating to fiber orientations is
2388
+ used, and streamlines trajectories are determined entirely from random
2389
+ sampling. The NullDist2 algorithm is designed to be used in conjunction with
2390
+ iFOD2; NullDist1 should be used in conjunction with any first-order
2391
+ algorithm.
2392
+
2393
+ - SD_STREAM: Streamlines tractography based on Spherical Deconvolution (SD).
2394
+ A deterministic algorithm that takes as input a Fiber Orientation
2395
+ Distribution (FOD) image represented in the Spherical Harmonic (SH) basis.
2396
+ At each streamline step, the local (trilinear-interpolated) FOD is sampled,
2397
+ and from the current streamline tangent orientation, a Newton optimisation
2398
+ on the sphere is performed in order to locate the orientation of the nearest
2399
+ FOD amplitude peak.
2400
+
2401
+ - SeedTest: A dummy streamlines algorithm used for testing streamline
2402
+ seeding mechanisms. Any image can be used as input; the image will not be
2403
+ used in any way. For each seed point generated by the seeding mechanism(s),
2404
+ a streamline containing a single point corresponding to that seed location
2405
+ will be written to the output track file.
2406
+
2407
+ - Tensor_Det: A deterministic algorithm that takes as input a 4D
2408
+ diffusion-weighted image (DWI) series. At each streamline step, the
2409
+ diffusion tensor is fitted to the local (trilinear-interpolated) diffusion
2410
+ data, and the streamline trajectory is determined as the principal
2411
+ eigenvector of that tensor.
2412
+
2413
+ - Tensor_Prob: A probabilistic algorithm that takes as input a 4D
2414
+ diffusion-weighted image (DWI) series. Within each image voxel, a residual
2415
+ bootstrap is performed to obtain a unique realisation of the DWI data in
2416
+ that voxel for each streamline. These data are then sampled via trilinear
2417
+ interpolation at each streamline step, the diffusion tensor model is fitted,
2418
+ and the streamline follows the orientation of the principal eigenvector of
2419
+ that tensor.
2420
+
2421
+ Note that the behaviour of the -angle option varies slightly depending on
2422
+ the order of integration: for any first-order method, this angle corresponds
2423
+ to the deviation in streamline trajectory per step; for higher-order
2424
+ methods, this corresponds to the change in underlying fibre orientation
2425
+ between the start and end points of each step.
2426
+
2427
+ References:
2428
+
2429
+ References based on streamlines algorithm used:
2430
+
2431
+ * FACT:
2432
+ Mori, S.; Crain, B. J.; Chacko, V. P. & van Zijl, P. C. M. Three-dimensional
2433
+ tracking of axonal projections in the brain by magnetic resonance imaging.
2434
+ Annals of Neurology, 1999, 45, 265-269
2435
+
2436
+ * iFOD1 or SD_STREAM:
2437
+ Tournier, J.-D.; Calamante, F. & Connelly, A. MRtrix: Diffusion tractography
2438
+ in crossing fiber regions. Int. J. Imaging Syst. Technol., 2012, 22, 53-66
2439
+
2440
+ * iFOD2:
2441
+ Tournier, J.-D.; Calamante, F. & Connelly, A. Improved probabilistic
2442
+ streamlines tractography by 2nd order integration over fibre orientation
2443
+ distributions. Proceedings of the International Society for Magnetic
2444
+ Resonance in Medicine, 2010, 1670
2445
+
2446
+ * Nulldist1 / Nulldist2:
2447
+ Morris, D. M.; Embleton, K. V. & Parker, G. J. Probabilistic fibre tracking:
2448
+ Differentiation of connections from chance events. NeuroImage, 2008, 42,
2449
+ 1329-1339
2450
+
2451
+ * Tensor_Det:
2452
+ Basser, P. J.; Pajevic, S.; Pierpaoli, C.; Duda, J. & Aldroubi, A. In vivo
2453
+ fiber tractography using DT-MRI data. Magnetic Resonance in Medicine, 2000,
2454
+ 44, 625-632
2455
+
2456
+ * Tensor_Prob:
2457
+ Jones, D. Tractography Gone Wild: Probabilistic Fibre Tracking Using the
2458
+ Wild Bootstrap With Diffusion Tensor MRI. IEEE Transactions on Medical
2459
+ Imaging, 2008, 27, 1268-1274
2460
+
2461
+ References based on command-line options:
2462
+
2463
+ * -rk4:
2464
+ Basser, P. J.; Pajevic, S.; Pierpaoli, C.; Duda, J. & Aldroubi, A. In vivo
2465
+ fiber tractography using DT-MRI data. Magnetic Resonance in Medicine, 2000,
2466
+ 44, 625-632
2467
+
2468
+ * -act, -backtrack, -seed_gmwmi:
2469
+ Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A.
2470
+ Anatomically-constrained tractography: Improved diffusion MRI streamlines
2471
+ tractography through effective use of anatomical information. NeuroImage,
2472
+ 2012, 62, 1924-1938
2473
+
2474
+ * -seed_dynamic:
2475
+ Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A. SIFT2: Enabling
2476
+ dense quantitative assessment of brain white matter connectivity using
2477
+ streamlines tractography. NeuroImage, 2015, 119, 338-351.
2478
+
2479
+ Author: MRTrix3 Developers
2480
+
2481
+ URL: https://www.mrtrix.org/
2482
+
2483
+ Args:
2484
+ source: The image containing the source data. The type of image data\
2485
+ required depends on the algorithm used (see Description section).
2486
+ tracks: the output file containing the tracks generated.
2487
+ algorithm: specify the tractography algorithm to use. Valid choices\
2488
+ are: FACT, iFOD1, iFOD2, Nulldist1, Nulldist2, SD_Stream, Seedtest,\
2489
+ Tensor_Det, Tensor_Prob (default: iFOD2).
2490
+ select_: set the desired number of streamlines to be selected by\
2491
+ tckgen, after all selection criteria have been applied (i.e.\
2492
+ inclusion/exclusion ROIs, min/max length, etc). tckgen will keep\
2493
+ seeding streamlines until this number of streamlines have been\
2494
+ selected, or the maximum allowed number of seeds has been exceeded (see\
2495
+ -seeds option). By default, 5000 streamlines are to be selected. Set to\
2496
+ zero to disable, which will result in streamlines being seeded until\
2497
+ the number specified by -seeds has been reached.
2498
+ step: set the step size of the algorithm in mm (defaults: for\
2499
+ first-order algorithms, 0.1 x voxelsize; if using RK4, 0.25 x\
2500
+ voxelsize; for iFOD2: 0.5 x voxelsize).
2501
+ angle: set the maximum angle in degrees between successive steps\
2502
+ (defaults: 60 for deterministic algorithms; 15 for iFOD1 / nulldist1;\
2503
+ 45 for iFOD2 / nulldist2).
2504
+ minlength: set the minimum length of any track in mm (defaults: without\
2505
+ ACT, 5 x voxelsize; with ACT, 2 x voxelsize).
2506
+ maxlength: set the maximum length of any track in mm (default: 100 x\
2507
+ voxelsize).
2508
+ cutoff: set the FOD amplitude / fixel size / tensor FA cutoff for\
2509
+ terminating tracks (defaults: 0.1 for FOD-based algorithms; 0.1 for\
2510
+ fixel-based algorithms; 0.1 for tensor-based algorithms; threshold\
2511
+ multiplied by 0.5 when using ACT).
2512
+ trials: set the maximum number of sampling trials at each point (only\
2513
+ used for iFOD1 / iFOD2) (default: 1000).
2514
+ noprecomputed: do NOT pre-compute legendre polynomial values. Warning:\
2515
+ this will slow down the algorithm by a factor of approximately 4.
2516
+ rk4: use 4th-order Runge-Kutta integration (slower, but eliminates\
2517
+ curvature overshoot in 1st-order deterministic methods).
2518
+ stop: stop propagating a streamline once it has traversed all include\
2519
+ regions.
2520
+ downsample: downsample the generated streamlines to reduce output file\
2521
+ size (default is (samples-1) for iFOD2, no downsampling for all other\
2522
+ algorithms).
2523
+ seed_image: seed streamlines entirely at random within a mask image.
2524
+ seed_sphere: spherical seed as four comma-separated values (XYZ\
2525
+ position and radius).
2526
+ seed_random_per_voxel: seed a fixed number of streamlines per voxel in\
2527
+ a mask image; random placement of seeds in each voxel.
2528
+ seed_grid_per_voxel: seed a fixed number of streamlines per voxel in a\
2529
+ mask image; place seeds on a 3D mesh grid (grid_size argument is per\
2530
+ axis; so a grid_size of 3 results in 27 seeds per voxel).
2531
+ seed_rejection: seed from an image using rejection sampling (higher\
2532
+ values = more probable to seed from).
2533
+ seed_gmwmi: seed from the grey matter - white matter interface (only\
2534
+ valid if using ACT framework). Input image should be a 3D seeding\
2535
+ volume; seeds drawn within this image will be optimised to the\
2536
+ interface using the 5TT image provided using the -act option.
2537
+ seed_dynamic: determine seed points dynamically using the SIFT model\
2538
+ (must not provide any other seeding mechanism). Note that while this\
2539
+ seeding mechanism improves the distribution of reconstructed\
2540
+ streamlines density, it should NOT be used as a substitute for the SIFT\
2541
+ method itself.
2542
+ seeds: set the number of seeds that tckgen will attempt to track from.\
2543
+ If this option is NOT provided, the default number of seeds is set to\
2544
+ 1000× the number of selected streamlines. If -select is NOT also\
2545
+ specified, tckgen will continue tracking until this number of seeds has\
2546
+ been attempted. However, if -select is also specified, tckgen will stop\
2547
+ when the number of seeds attempted reaches the number specified here,\
2548
+ OR when the number of streamlines selected reaches the number requested\
2549
+ with the -select option. This can be used to prevent the program from\
2550
+ running indefinitely when no or very few streamlines can be found that\
2551
+ match the selection criteria. Setting this to zero will cause tckgen to\
2552
+ keep attempting seeds until the number specified by -select has been\
2553
+ reached.
2554
+ max_attempts_per_seed: set the maximum number of times that the\
2555
+ tracking algorithm should attempt to find an appropriate tracking\
2556
+ direction from a given seed point. This should be set high enough to\
2557
+ ensure that an actual plausible seed point is not discarded prematurely\
2558
+ as being unable to initiate tracking from. Higher settings may affect\
2559
+ performance if many seeds are genuinely impossible to track from, as\
2560
+ many attempts will still be made in vain for such seeds. (default:\
2561
+ 1000).
2562
+ seed_cutoff: set the minimum FA or FOD amplitude for seeding tracks\
2563
+ (default is the same as the normal -cutoff).
2564
+ seed_unidirectional: track from the seed point in one direction only\
2565
+ (default is to track in both directions).
2566
+ seed_direction: specify a seeding direction for the tracking (this\
2567
+ should be supplied as a vector of 3 comma-separated values.
2568
+ output_seeds: output the seed location of all successful streamlines to\
2569
+ a file.
2570
+ include: specify an inclusion region of interest, as either a binary\
2571
+ mask image, or as a sphere using 4 comma-separared values\
2572
+ (x,y,z,radius). Streamlines must traverse ALL inclusion regions to be\
2573
+ accepted.
2574
+ include_ordered: specify an inclusion region of interest, as either a\
2575
+ binary mask image, or as a sphere using 4 comma-separared values\
2576
+ (x,y,z,radius). Streamlines must traverse ALL inclusion_ordered regions\
2577
+ in the order they are specified in order to be accepted.
2578
+ exclude: specify an exclusion region of interest, as either a binary\
2579
+ mask image, or as a sphere using 4 comma-separared values\
2580
+ (x,y,z,radius). Streamlines that enter ANY exclude region will be\
2581
+ discarded.
2582
+ mask: specify a masking region of interest, as either a binary mask\
2583
+ image, or as a sphere using 4 comma-separared values (x,y,z,radius). If\
2584
+ defined, streamlines exiting the mask will be truncated.
2585
+ act: use the Anatomically-Constrained Tractography framework during\
2586
+ tracking; provided image must be in the 5TT (five-tissue-type) format.
2587
+ backtrack: allow tracks to be truncated and re-tracked if a poor\
2588
+ structural termination is encountered.
2589
+ crop_at_gmwmi: crop streamline endpoints more precisely as they cross\
2590
+ the GM-WM interface.
2591
+ power: raise the FOD to the power specified (defaults are: 1.0 for\
2592
+ iFOD1; 1.0/nsamples for iFOD2).
2593
+ samples: set the number of FOD samples to take per step (Default: 4).
2594
+ grad: Provide the diffusion-weighted gradient scheme used in the\
2595
+ acquisition in a text file. This should be supplied as a 4xN text file\
2596
+ with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
2597
+ the direction of the applied gradient, and b gives the b-value in units\
2598
+ of s/mm^2. If a diffusion gradient scheme is present in the input image\
2599
+ header, the data provided with this option will be instead used.
2600
+ fslgrad: Provide the diffusion-weighted gradient scheme used in the\
2601
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
2602
+ scheme is present in the input image header, the data provided with\
2603
+ this option will be instead used.
2604
+ info: display information messages.
2605
+ quiet: do not display information messages or progress status;\
2606
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
2607
+ environment variable to a non-empty string.
2608
+ debug: display debugging messages.
2609
+ force: force overwrite of output files (caution: using the same file as\
2610
+ input and output might cause unexpected behaviour).
2611
+ nthreads: use this number of threads in multi-threaded applications\
2612
+ (set to 0 to disable multi-threading).
2613
+ config: temporarily set the value of an MRtrix config file entry.
2614
+ help_: display this information page and exit.
2615
+ version: display version information and exit.
2616
+ runner: Command runner.
2617
+ Returns:
2618
+ NamedTuple of outputs (described in `TckgenOutputs`).
2619
+ """
2620
+ params = tckgen_params(
2621
+ algorithm=algorithm,
2622
+ select_=select_,
2623
+ step=step,
2624
+ angle=angle,
2625
+ minlength=minlength,
2626
+ maxlength=maxlength,
2627
+ cutoff=cutoff,
2628
+ trials=trials,
2629
+ noprecomputed=noprecomputed,
2630
+ rk4=rk4,
2631
+ stop=stop,
2632
+ downsample=downsample,
2633
+ seed_image=seed_image,
2634
+ seed_sphere=seed_sphere,
2635
+ seed_random_per_voxel=seed_random_per_voxel,
2636
+ seed_grid_per_voxel=seed_grid_per_voxel,
2637
+ seed_rejection=seed_rejection,
2638
+ seed_gmwmi=seed_gmwmi,
2639
+ seed_dynamic=seed_dynamic,
2640
+ seeds=seeds,
2641
+ max_attempts_per_seed=max_attempts_per_seed,
2642
+ seed_cutoff=seed_cutoff,
2643
+ seed_unidirectional=seed_unidirectional,
2644
+ seed_direction=seed_direction,
2645
+ output_seeds=output_seeds,
2646
+ include=include,
2647
+ include_ordered=include_ordered,
2648
+ exclude=exclude,
2649
+ mask=mask,
2650
+ act=act,
2651
+ backtrack=backtrack,
2652
+ crop_at_gmwmi=crop_at_gmwmi,
2653
+ power=power,
2654
+ samples=samples,
2655
+ grad=grad,
2656
+ fslgrad=fslgrad,
2657
+ info=info,
2658
+ quiet=quiet,
2659
+ debug=debug,
2660
+ force=force,
2661
+ nthreads=nthreads,
2662
+ config=config,
2663
+ help_=help_,
2664
+ version=version,
2665
+ source=source,
2666
+ tracks=tracks,
2667
+ )
2668
+ return tckgen_execute(params, runner)
2669
+
2670
+
2671
+ __all__ = [
2672
+ "TCKGEN_METADATA",
2673
+ "TckgenConfigParamsDict",
2674
+ "TckgenConfigParamsDictTagged",
2675
+ "TckgenExcludeParamsDict",
2676
+ "TckgenExcludeParamsDictTagged",
2677
+ "TckgenFslgradParamsDict",
2678
+ "TckgenFslgradParamsDictTagged",
2679
+ "TckgenIncludeOrderedParamsDict",
2680
+ "TckgenIncludeOrderedParamsDictTagged",
2681
+ "TckgenIncludeParamsDict",
2682
+ "TckgenIncludeParamsDictTagged",
2683
+ "TckgenMaskParamsDict",
2684
+ "TckgenMaskParamsDictTagged",
2685
+ "TckgenOutputs",
2686
+ "TckgenParamsDict",
2687
+ "TckgenParamsDictTagged",
2688
+ "TckgenSeedGmwmiParamsDict",
2689
+ "TckgenSeedGmwmiParamsDictTagged",
2690
+ "TckgenSeedGridPerVoxelParamsDict",
2691
+ "TckgenSeedGridPerVoxelParamsDictTagged",
2692
+ "TckgenSeedImageParamsDict",
2693
+ "TckgenSeedImageParamsDictTagged",
2694
+ "TckgenSeedRandomPerVoxelParamsDict",
2695
+ "TckgenSeedRandomPerVoxelParamsDictTagged",
2696
+ "TckgenSeedRejectionParamsDict",
2697
+ "TckgenSeedRejectionParamsDictTagged",
2698
+ "TckgenSeedSphereParamsDict",
2699
+ "TckgenSeedSphereParamsDictTagged",
2700
+ "TckgenVariousFile1ParamsDict",
2701
+ "TckgenVariousFile1ParamsDictTagged",
2702
+ "TckgenVariousFile2ParamsDict",
2703
+ "TckgenVariousFile2ParamsDictTagged",
2704
+ "TckgenVariousFileParamsDict",
2705
+ "TckgenVariousFileParamsDictTagged",
2706
+ "TckgenVariousString1ParamsDict",
2707
+ "TckgenVariousString1ParamsDictTagged",
2708
+ "TckgenVariousString2ParamsDict",
2709
+ "TckgenVariousString2ParamsDictTagged",
2710
+ "TckgenVariousStringParamsDict",
2711
+ "TckgenVariousStringParamsDictTagged",
2712
+ "tckgen",
2713
+ "tckgen_config",
2714
+ "tckgen_exclude",
2715
+ "tckgen_execute",
2716
+ "tckgen_fslgrad",
2717
+ "tckgen_include",
2718
+ "tckgen_include_ordered",
2719
+ "tckgen_mask",
2720
+ "tckgen_params",
2721
+ "tckgen_seed_gmwmi",
2722
+ "tckgen_seed_grid_per_voxel",
2723
+ "tckgen_seed_image",
2724
+ "tckgen_seed_random_per_voxel",
2725
+ "tckgen_seed_rejection",
2726
+ "tckgen_seed_sphere",
2727
+ "tckgen_various_file",
2728
+ "tckgen_various_file_1",
2729
+ "tckgen_various_file_2",
2730
+ "tckgen_various_string",
2731
+ "tckgen_various_string_1",
2732
+ "tckgen_various_string_2",
2733
+ ]