niwrap-mrtrix 0.5.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.

Potentially problematic release.


This version of niwrap-mrtrix might be problematic. Click here for more details.

Files changed (119) hide show
  1. niwrap_mrtrix/mrtrix/__init__.py +130 -0
  2. niwrap_mrtrix/mrtrix/afdconnectivity.py +445 -0
  3. niwrap_mrtrix/mrtrix/amp2response.py +453 -0
  4. niwrap_mrtrix/mrtrix/amp2sh.py +656 -0
  5. niwrap_mrtrix/mrtrix/connectome2tck.py +470 -0
  6. niwrap_mrtrix/mrtrix/connectomeedit.py +338 -0
  7. niwrap_mrtrix/mrtrix/connectomestats.py +767 -0
  8. niwrap_mrtrix/mrtrix/dcmedit.py +440 -0
  9. niwrap_mrtrix/mrtrix/dcminfo.py +416 -0
  10. niwrap_mrtrix/mrtrix/dirflip.py +362 -0
  11. niwrap_mrtrix/mrtrix/dirgen.py +423 -0
  12. niwrap_mrtrix/mrtrix/dirmerge.py +365 -0
  13. niwrap_mrtrix/mrtrix/dirorder.py +347 -0
  14. niwrap_mrtrix/mrtrix/dirsplit.py +358 -0
  15. niwrap_mrtrix/mrtrix/dirstat.py +530 -0
  16. niwrap_mrtrix/mrtrix/dwi2adc.py +428 -0
  17. niwrap_mrtrix/mrtrix/dwi2fod.py +879 -0
  18. niwrap_mrtrix/mrtrix/dwi2mask.py +463 -0
  19. niwrap_mrtrix/mrtrix/dwi2response.py +1295 -0
  20. niwrap_mrtrix/mrtrix/dwi2tensor.py +587 -0
  21. niwrap_mrtrix/mrtrix/dwibiascorrect.py +467 -0
  22. niwrap_mrtrix/mrtrix/dwidenoise.py +478 -0
  23. niwrap_mrtrix/mrtrix/dwiextract.py +825 -0
  24. niwrap_mrtrix/mrtrix/dwigradcheck.py +534 -0
  25. niwrap_mrtrix/mrtrix/fixel2peaks.py +452 -0
  26. niwrap_mrtrix/mrtrix/fixel2sh.py +357 -0
  27. niwrap_mrtrix/mrtrix/fixel2tsf.py +357 -0
  28. niwrap_mrtrix/mrtrix/fixel2voxel.py +437 -0
  29. niwrap_mrtrix/mrtrix/fixelcfestats.py +893 -0
  30. niwrap_mrtrix/mrtrix/fixelconnectivity.py +391 -0
  31. niwrap_mrtrix/mrtrix/fixelconvert.py +588 -0
  32. niwrap_mrtrix/mrtrix/fixelcorrespondence.py +371 -0
  33. niwrap_mrtrix/mrtrix/fixelcrop.py +348 -0
  34. niwrap_mrtrix/mrtrix/fixelfilter.py +616 -0
  35. niwrap_mrtrix/mrtrix/fixelreorient.py +361 -0
  36. niwrap_mrtrix/mrtrix/fod2dec.py +469 -0
  37. niwrap_mrtrix/mrtrix/fod2fixel.py +530 -0
  38. niwrap_mrtrix/mrtrix/label2colour.py +351 -0
  39. niwrap_mrtrix/mrtrix/label2mesh.py +343 -0
  40. niwrap_mrtrix/mrtrix/labelconvert.py +377 -0
  41. niwrap_mrtrix/mrtrix/labelstats.py +344 -0
  42. niwrap_mrtrix/mrtrix/maskdump.py +336 -0
  43. niwrap_mrtrix/mrtrix/maskfilter.py +537 -0
  44. niwrap_mrtrix/mrtrix/mesh2voxel.py +348 -0
  45. niwrap_mrtrix/mrtrix/meshconvert.py +410 -0
  46. niwrap_mrtrix/mrtrix/meshfilter.py +370 -0
  47. niwrap_mrtrix/mrtrix/mraverageheader.py +396 -0
  48. niwrap_mrtrix/mrtrix/mrcalc.py +3047 -0
  49. niwrap_mrtrix/mrtrix/mrcat.py +382 -0
  50. niwrap_mrtrix/mrtrix/mrcentroid.py +344 -0
  51. niwrap_mrtrix/mrtrix/mrcheckerboardmask.py +363 -0
  52. niwrap_mrtrix/mrtrix/mrclusterstats.py +736 -0
  53. niwrap_mrtrix/mrtrix/mrcolour.py +401 -0
  54. niwrap_mrtrix/mrtrix/mrconvert.py +1423 -0
  55. niwrap_mrtrix/mrtrix/mrdegibbs.py +443 -0
  56. niwrap_mrtrix/mrtrix/mrdump.py +351 -0
  57. niwrap_mrtrix/mrtrix/mredit.py +546 -0
  58. niwrap_mrtrix/mrtrix/mrfilter.py +716 -0
  59. niwrap_mrtrix/mrtrix/mrgrid.py +819 -0
  60. niwrap_mrtrix/mrtrix/mrhistmatch.py +403 -0
  61. niwrap_mrtrix/mrtrix/mrhistogram.py +393 -0
  62. niwrap_mrtrix/mrtrix/mrinfo.py +990 -0
  63. niwrap_mrtrix/mrtrix/mrmath.py +413 -0
  64. niwrap_mrtrix/mrtrix/mrmetric.py +425 -0
  65. niwrap_mrtrix/mrtrix/mrregister.py +1676 -0
  66. niwrap_mrtrix/mrtrix/mrstats.py +427 -0
  67. niwrap_mrtrix/mrtrix/mrthreshold.py +549 -0
  68. niwrap_mrtrix/mrtrix/mrtransform.py +1061 -0
  69. niwrap_mrtrix/mrtrix/mtnormalise.py +596 -0
  70. niwrap_mrtrix/mrtrix/peaks2amp.py +334 -0
  71. niwrap_mrtrix/mrtrix/peaks2fixel.py +349 -0
  72. niwrap_mrtrix/mrtrix/responsemean.py +316 -0
  73. niwrap_mrtrix/mrtrix/sh2amp.py +640 -0
  74. niwrap_mrtrix/mrtrix/sh2peaks.py +505 -0
  75. niwrap_mrtrix/mrtrix/sh2power.py +353 -0
  76. niwrap_mrtrix/mrtrix/sh2response.py +394 -0
  77. niwrap_mrtrix/mrtrix/shbasis.py +373 -0
  78. niwrap_mrtrix/mrtrix/shconv.py +498 -0
  79. niwrap_mrtrix/mrtrix/tck2connectome.py +580 -0
  80. niwrap_mrtrix/mrtrix/tck2fixel.py +363 -0
  81. niwrap_mrtrix/mrtrix/tckconvert.py +580 -0
  82. niwrap_mrtrix/mrtrix/tckdfc.py +551 -0
  83. niwrap_mrtrix/mrtrix/tckedit.py +1003 -0
  84. niwrap_mrtrix/mrtrix/tckgen.py +1983 -0
  85. niwrap_mrtrix/mrtrix/tckglobal.py +758 -0
  86. niwrap_mrtrix/mrtrix/tckinfo.py +329 -0
  87. niwrap_mrtrix/mrtrix/tckmap.py +772 -0
  88. niwrap_mrtrix/mrtrix/tckresample.py +580 -0
  89. niwrap_mrtrix/mrtrix/tcksample.py +404 -0
  90. niwrap_mrtrix/mrtrix/tcksift.py +592 -0
  91. niwrap_mrtrix/mrtrix/tcksift2.py +730 -0
  92. niwrap_mrtrix/mrtrix/tckstats.py +441 -0
  93. niwrap_mrtrix/mrtrix/tcktransform.py +340 -0
  94. niwrap_mrtrix/mrtrix/tensor2metric.py +544 -0
  95. niwrap_mrtrix/mrtrix/transformcalc.py +344 -0
  96. niwrap_mrtrix/mrtrix/transformcompose.py +465 -0
  97. niwrap_mrtrix/mrtrix/transformconvert.py +346 -0
  98. niwrap_mrtrix/mrtrix/tsfdivide.py +340 -0
  99. niwrap_mrtrix/mrtrix/tsfinfo.py +344 -0
  100. niwrap_mrtrix/mrtrix/tsfmult.py +340 -0
  101. niwrap_mrtrix/mrtrix/tsfsmooth.py +347 -0
  102. niwrap_mrtrix/mrtrix/tsfthreshold.py +349 -0
  103. niwrap_mrtrix/mrtrix/tsfvalidate.py +328 -0
  104. niwrap_mrtrix/mrtrix/v_5tt2gmwmi.py +359 -0
  105. niwrap_mrtrix/mrtrix/v_5tt2vis.py +412 -0
  106. niwrap_mrtrix/mrtrix/v_5ttcheck.py +337 -0
  107. niwrap_mrtrix/mrtrix/v_5ttedit.py +420 -0
  108. niwrap_mrtrix/mrtrix/v_5ttgen.py +816 -0
  109. niwrap_mrtrix/mrtrix/vectorstats.py +585 -0
  110. niwrap_mrtrix/mrtrix/voxel2fixel.py +350 -0
  111. niwrap_mrtrix/mrtrix/voxel2mesh.py +376 -0
  112. niwrap_mrtrix/mrtrix/warp2metric.py +449 -0
  113. niwrap_mrtrix/mrtrix/warpconvert.py +411 -0
  114. niwrap_mrtrix/mrtrix/warpcorrect.py +368 -0
  115. niwrap_mrtrix/mrtrix/warpinit.py +356 -0
  116. niwrap_mrtrix/mrtrix/warpinvert.py +370 -0
  117. niwrap_mrtrix-0.5.0.dist-info/METADATA +8 -0
  118. niwrap_mrtrix-0.5.0.dist-info/RECORD +119 -0
  119. niwrap_mrtrix-0.5.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,1983 @@
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="5b475b82cef330ab1e3018809589d1f9c95a6a94.boutiques",
10
+ name="tckgen",
11
+ package="mrtrix",
12
+ container_image_tag="mrtrix3/mrtrix3:3.0.4",
13
+ )
14
+
15
+
16
+ TckgenSeedImageParameters = typing.TypedDict('TckgenSeedImageParameters', {
17
+ "__STYX_TYPE__": typing.Literal["seed_image"],
18
+ "image": InputPathType,
19
+ })
20
+
21
+
22
+ TckgenSeedSphereParameters = typing.TypedDict('TckgenSeedSphereParameters', {
23
+ "__STYX_TYPE__": typing.Literal["seed_sphere"],
24
+ "spec": list[float],
25
+ })
26
+
27
+
28
+ TckgenSeedRandomPerVoxelParameters = typing.TypedDict('TckgenSeedRandomPerVoxelParameters', {
29
+ "__STYX_TYPE__": typing.Literal["seed_random_per_voxel"],
30
+ "image": InputPathType,
31
+ "num_per_voxel": int,
32
+ })
33
+
34
+
35
+ TckgenSeedGridPerVoxelParameters = typing.TypedDict('TckgenSeedGridPerVoxelParameters', {
36
+ "__STYX_TYPE__": typing.Literal["seed_grid_per_voxel"],
37
+ "image": InputPathType,
38
+ "grid_size": int,
39
+ })
40
+
41
+
42
+ TckgenSeedRejectionParameters = typing.TypedDict('TckgenSeedRejectionParameters', {
43
+ "__STYX_TYPE__": typing.Literal["seed_rejection"],
44
+ "image": InputPathType,
45
+ })
46
+
47
+
48
+ TckgenSeedGmwmiParameters = typing.TypedDict('TckgenSeedGmwmiParameters', {
49
+ "__STYX_TYPE__": typing.Literal["seed_gmwmi"],
50
+ "image": InputPathType,
51
+ })
52
+
53
+
54
+ TckgenVariousStringParameters = typing.TypedDict('TckgenVariousStringParameters', {
55
+ "__STYX_TYPE__": typing.Literal["VariousString"],
56
+ "obj": str,
57
+ })
58
+
59
+
60
+ TckgenVariousFileParameters = typing.TypedDict('TckgenVariousFileParameters', {
61
+ "__STYX_TYPE__": typing.Literal["VariousFile"],
62
+ "obj": InputPathType,
63
+ })
64
+
65
+
66
+ TckgenIncludeParameters = typing.TypedDict('TckgenIncludeParameters', {
67
+ "__STYX_TYPE__": typing.Literal["include"],
68
+ "spec": typing.Union[TckgenVariousStringParameters, TckgenVariousFileParameters],
69
+ })
70
+
71
+
72
+ TckgenIncludeOrderedParameters = typing.TypedDict('TckgenIncludeOrderedParameters', {
73
+ "__STYX_TYPE__": typing.Literal["include_ordered"],
74
+ "image": str,
75
+ })
76
+
77
+
78
+ TckgenVariousString1Parameters = typing.TypedDict('TckgenVariousString1Parameters', {
79
+ "__STYX_TYPE__": typing.Literal["VariousString_1"],
80
+ "obj": str,
81
+ })
82
+
83
+
84
+ TckgenVariousFile1Parameters = typing.TypedDict('TckgenVariousFile1Parameters', {
85
+ "__STYX_TYPE__": typing.Literal["VariousFile_1"],
86
+ "obj": InputPathType,
87
+ })
88
+
89
+
90
+ TckgenExcludeParameters = typing.TypedDict('TckgenExcludeParameters', {
91
+ "__STYX_TYPE__": typing.Literal["exclude"],
92
+ "spec": typing.Union[TckgenVariousString1Parameters, TckgenVariousFile1Parameters],
93
+ })
94
+
95
+
96
+ TckgenVariousString2Parameters = typing.TypedDict('TckgenVariousString2Parameters', {
97
+ "__STYX_TYPE__": typing.Literal["VariousString_2"],
98
+ "obj": str,
99
+ })
100
+
101
+
102
+ TckgenVariousFile2Parameters = typing.TypedDict('TckgenVariousFile2Parameters', {
103
+ "__STYX_TYPE__": typing.Literal["VariousFile_2"],
104
+ "obj": InputPathType,
105
+ })
106
+
107
+
108
+ TckgenMaskParameters = typing.TypedDict('TckgenMaskParameters', {
109
+ "__STYX_TYPE__": typing.Literal["mask"],
110
+ "spec": typing.Union[TckgenVariousString2Parameters, TckgenVariousFile2Parameters],
111
+ })
112
+
113
+
114
+ TckgenFslgradParameters = typing.TypedDict('TckgenFslgradParameters', {
115
+ "__STYX_TYPE__": typing.Literal["fslgrad"],
116
+ "bvecs": InputPathType,
117
+ "bvals": InputPathType,
118
+ })
119
+
120
+
121
+ TckgenConfigParameters = typing.TypedDict('TckgenConfigParameters', {
122
+ "__STYX_TYPE__": typing.Literal["config"],
123
+ "key": str,
124
+ "value": str,
125
+ })
126
+
127
+
128
+ TckgenParameters = typing.TypedDict('TckgenParameters', {
129
+ "__STYX_TYPE__": typing.Literal["tckgen"],
130
+ "algorithm": typing.NotRequired[str | None],
131
+ "select": typing.NotRequired[int | None],
132
+ "step": typing.NotRequired[float | None],
133
+ "angle": typing.NotRequired[float | None],
134
+ "minlength": typing.NotRequired[float | None],
135
+ "maxlength": typing.NotRequired[float | None],
136
+ "cutoff": typing.NotRequired[float | None],
137
+ "trials": typing.NotRequired[int | None],
138
+ "noprecomputed": bool,
139
+ "rk4": bool,
140
+ "stop": bool,
141
+ "downsample": typing.NotRequired[int | None],
142
+ "seed_image": typing.NotRequired[list[TckgenSeedImageParameters] | None],
143
+ "seed_sphere": typing.NotRequired[list[TckgenSeedSphereParameters] | None],
144
+ "seed_random_per_voxel": typing.NotRequired[list[TckgenSeedRandomPerVoxelParameters] | None],
145
+ "seed_grid_per_voxel": typing.NotRequired[list[TckgenSeedGridPerVoxelParameters] | None],
146
+ "seed_rejection": typing.NotRequired[list[TckgenSeedRejectionParameters] | None],
147
+ "seed_gmwmi": typing.NotRequired[list[TckgenSeedGmwmiParameters] | None],
148
+ "seed_dynamic": typing.NotRequired[InputPathType | None],
149
+ "seeds": typing.NotRequired[int | None],
150
+ "max_attempts_per_seed": typing.NotRequired[int | None],
151
+ "seed_cutoff": typing.NotRequired[float | None],
152
+ "seed_unidirectional": bool,
153
+ "seed_direction": typing.NotRequired[list[float] | None],
154
+ "output_seeds": typing.NotRequired[str | None],
155
+ "include": typing.NotRequired[list[TckgenIncludeParameters] | None],
156
+ "include_ordered": typing.NotRequired[list[TckgenIncludeOrderedParameters] | None],
157
+ "exclude": typing.NotRequired[list[TckgenExcludeParameters] | None],
158
+ "mask": typing.NotRequired[list[TckgenMaskParameters] | None],
159
+ "act": typing.NotRequired[InputPathType | None],
160
+ "backtrack": bool,
161
+ "crop_at_gmwmi": bool,
162
+ "power": typing.NotRequired[float | None],
163
+ "samples": typing.NotRequired[int | None],
164
+ "grad": typing.NotRequired[InputPathType | None],
165
+ "fslgrad": typing.NotRequired[TckgenFslgradParameters | None],
166
+ "info": bool,
167
+ "quiet": bool,
168
+ "debug": bool,
169
+ "force": bool,
170
+ "nthreads": typing.NotRequired[int | None],
171
+ "config": typing.NotRequired[list[TckgenConfigParameters] | None],
172
+ "help": bool,
173
+ "version": bool,
174
+ "source": InputPathType,
175
+ "tracks": str,
176
+ })
177
+
178
+
179
+ def dyn_cargs(
180
+ t: str,
181
+ ) -> typing.Any:
182
+ """
183
+ Get build cargs function by command type.
184
+
185
+ Args:
186
+ t: Command type.
187
+ Returns:
188
+ Build cargs function.
189
+ """
190
+ return {
191
+ "tckgen": tckgen_cargs,
192
+ "seed_image": tckgen_seed_image_cargs,
193
+ "seed_sphere": tckgen_seed_sphere_cargs,
194
+ "seed_random_per_voxel": tckgen_seed_random_per_voxel_cargs,
195
+ "seed_grid_per_voxel": tckgen_seed_grid_per_voxel_cargs,
196
+ "seed_rejection": tckgen_seed_rejection_cargs,
197
+ "seed_gmwmi": tckgen_seed_gmwmi_cargs,
198
+ "include": tckgen_include_cargs,
199
+ "VariousString": tckgen_various_string_cargs,
200
+ "VariousFile": tckgen_various_file_cargs,
201
+ "include_ordered": tckgen_include_ordered_cargs,
202
+ "exclude": tckgen_exclude_cargs,
203
+ "VariousString_1": tckgen_various_string_1_cargs,
204
+ "VariousFile_1": tckgen_various_file_1_cargs,
205
+ "mask": tckgen_mask_cargs,
206
+ "VariousString_2": tckgen_various_string_2_cargs,
207
+ "VariousFile_2": tckgen_various_file_2_cargs,
208
+ "fslgrad": tckgen_fslgrad_cargs,
209
+ "config": tckgen_config_cargs,
210
+ }.get(t)
211
+
212
+
213
+ def dyn_outputs(
214
+ t: str,
215
+ ) -> typing.Any:
216
+ """
217
+ Get build outputs function by command type.
218
+
219
+ Args:
220
+ t: Command type.
221
+ Returns:
222
+ Build outputs function.
223
+ """
224
+ return {
225
+ "tckgen": tckgen_outputs,
226
+ }.get(t)
227
+
228
+
229
+ def tckgen_seed_image_params(
230
+ image: InputPathType,
231
+ ) -> TckgenSeedImageParameters:
232
+ """
233
+ Build parameters.
234
+
235
+ Args:
236
+ image: seed streamlines entirely at random within a mask image.
237
+ Returns:
238
+ Parameter dictionary
239
+ """
240
+ params = {
241
+ "__STYXTYPE__": "seed_image",
242
+ "image": image,
243
+ }
244
+ return params
245
+
246
+
247
+ def tckgen_seed_image_cargs(
248
+ params: TckgenSeedImageParameters,
249
+ execution: Execution,
250
+ ) -> list[str]:
251
+ """
252
+ Build command-line arguments from parameters.
253
+
254
+ Args:
255
+ params: The parameters.
256
+ execution: The execution object for resolving input paths.
257
+ Returns:
258
+ Command-line arguments.
259
+ """
260
+ cargs = []
261
+ cargs.append("-seed_image")
262
+ cargs.append(execution.input_file(params.get("image")))
263
+ return cargs
264
+
265
+
266
+ def tckgen_seed_sphere_params(
267
+ spec: list[float],
268
+ ) -> TckgenSeedSphereParameters:
269
+ """
270
+ Build parameters.
271
+
272
+ Args:
273
+ spec: spherical seed as four comma-separated values (XYZ position and\
274
+ radius).
275
+ Returns:
276
+ Parameter dictionary
277
+ """
278
+ params = {
279
+ "__STYXTYPE__": "seed_sphere",
280
+ "spec": spec,
281
+ }
282
+ return params
283
+
284
+
285
+ def tckgen_seed_sphere_cargs(
286
+ params: TckgenSeedSphereParameters,
287
+ execution: Execution,
288
+ ) -> list[str]:
289
+ """
290
+ Build command-line arguments from parameters.
291
+
292
+ Args:
293
+ params: The parameters.
294
+ execution: The execution object for resolving input paths.
295
+ Returns:
296
+ Command-line arguments.
297
+ """
298
+ cargs = []
299
+ cargs.append("-seed_sphere")
300
+ cargs.append(",".join(map(str, params.get("spec"))))
301
+ return cargs
302
+
303
+
304
+ def tckgen_seed_random_per_voxel_params(
305
+ image: InputPathType,
306
+ num_per_voxel: int,
307
+ ) -> TckgenSeedRandomPerVoxelParameters:
308
+ """
309
+ Build parameters.
310
+
311
+ Args:
312
+ image: seed a fixed number of streamlines per voxel in a mask image;\
313
+ random placement of seeds in each voxel.
314
+ num_per_voxel: seed a fixed number of streamlines per voxel in a mask\
315
+ image; random placement of seeds in each voxel.
316
+ Returns:
317
+ Parameter dictionary
318
+ """
319
+ params = {
320
+ "__STYXTYPE__": "seed_random_per_voxel",
321
+ "image": image,
322
+ "num_per_voxel": num_per_voxel,
323
+ }
324
+ return params
325
+
326
+
327
+ def tckgen_seed_random_per_voxel_cargs(
328
+ params: TckgenSeedRandomPerVoxelParameters,
329
+ execution: Execution,
330
+ ) -> list[str]:
331
+ """
332
+ Build command-line arguments from parameters.
333
+
334
+ Args:
335
+ params: The parameters.
336
+ execution: The execution object for resolving input paths.
337
+ Returns:
338
+ Command-line arguments.
339
+ """
340
+ cargs = []
341
+ cargs.append("-seed_random_per_voxel")
342
+ cargs.append(execution.input_file(params.get("image")))
343
+ cargs.append(str(params.get("num_per_voxel")))
344
+ return cargs
345
+
346
+
347
+ def tckgen_seed_grid_per_voxel_params(
348
+ image: InputPathType,
349
+ grid_size: int,
350
+ ) -> TckgenSeedGridPerVoxelParameters:
351
+ """
352
+ Build parameters.
353
+
354
+ Args:
355
+ image: seed a fixed number of streamlines per voxel in a mask image;\
356
+ place seeds on a 3D mesh grid (grid_size argument is per axis; so a\
357
+ grid_size of 3 results in 27 seeds per voxel).
358
+ grid_size: seed a fixed number of streamlines per voxel in a mask\
359
+ image; place seeds on a 3D mesh grid (grid_size argument is per axis;\
360
+ so a grid_size of 3 results in 27 seeds per voxel).
361
+ Returns:
362
+ Parameter dictionary
363
+ """
364
+ params = {
365
+ "__STYXTYPE__": "seed_grid_per_voxel",
366
+ "image": image,
367
+ "grid_size": grid_size,
368
+ }
369
+ return params
370
+
371
+
372
+ def tckgen_seed_grid_per_voxel_cargs(
373
+ params: TckgenSeedGridPerVoxelParameters,
374
+ execution: Execution,
375
+ ) -> list[str]:
376
+ """
377
+ Build command-line arguments from parameters.
378
+
379
+ Args:
380
+ params: The parameters.
381
+ execution: The execution object for resolving input paths.
382
+ Returns:
383
+ Command-line arguments.
384
+ """
385
+ cargs = []
386
+ cargs.append("-seed_grid_per_voxel")
387
+ cargs.append(execution.input_file(params.get("image")))
388
+ cargs.append(str(params.get("grid_size")))
389
+ return cargs
390
+
391
+
392
+ def tckgen_seed_rejection_params(
393
+ image: InputPathType,
394
+ ) -> TckgenSeedRejectionParameters:
395
+ """
396
+ Build parameters.
397
+
398
+ Args:
399
+ image: seed from an image using rejection sampling (higher values =\
400
+ more probable to seed from).
401
+ Returns:
402
+ Parameter dictionary
403
+ """
404
+ params = {
405
+ "__STYXTYPE__": "seed_rejection",
406
+ "image": image,
407
+ }
408
+ return params
409
+
410
+
411
+ def tckgen_seed_rejection_cargs(
412
+ params: TckgenSeedRejectionParameters,
413
+ execution: Execution,
414
+ ) -> list[str]:
415
+ """
416
+ Build command-line arguments from parameters.
417
+
418
+ Args:
419
+ params: The parameters.
420
+ execution: The execution object for resolving input paths.
421
+ Returns:
422
+ Command-line arguments.
423
+ """
424
+ cargs = []
425
+ cargs.append("-seed_rejection")
426
+ cargs.append(execution.input_file(params.get("image")))
427
+ return cargs
428
+
429
+
430
+ def tckgen_seed_gmwmi_params(
431
+ image: InputPathType,
432
+ ) -> TckgenSeedGmwmiParameters:
433
+ """
434
+ Build parameters.
435
+
436
+ Args:
437
+ image: seed from the grey matter - white matter interface (only valid\
438
+ if using ACT framework). Input image should be a 3D seeding volume;\
439
+ seeds drawn within this image will be optimised to the interface using\
440
+ the 5TT image provided using the -act option.
441
+ Returns:
442
+ Parameter dictionary
443
+ """
444
+ params = {
445
+ "__STYXTYPE__": "seed_gmwmi",
446
+ "image": image,
447
+ }
448
+ return params
449
+
450
+
451
+ def tckgen_seed_gmwmi_cargs(
452
+ params: TckgenSeedGmwmiParameters,
453
+ execution: Execution,
454
+ ) -> list[str]:
455
+ """
456
+ Build command-line arguments from parameters.
457
+
458
+ Args:
459
+ params: The parameters.
460
+ execution: The execution object for resolving input paths.
461
+ Returns:
462
+ Command-line arguments.
463
+ """
464
+ cargs = []
465
+ cargs.append("-seed_gmwmi")
466
+ cargs.append(execution.input_file(params.get("image")))
467
+ return cargs
468
+
469
+
470
+ def tckgen_various_string_params(
471
+ obj: str,
472
+ ) -> TckgenVariousStringParameters:
473
+ """
474
+ Build parameters.
475
+
476
+ Args:
477
+ obj: String object.
478
+ Returns:
479
+ Parameter dictionary
480
+ """
481
+ params = {
482
+ "__STYXTYPE__": "VariousString",
483
+ "obj": obj,
484
+ }
485
+ return params
486
+
487
+
488
+ def tckgen_various_string_cargs(
489
+ params: TckgenVariousStringParameters,
490
+ execution: Execution,
491
+ ) -> list[str]:
492
+ """
493
+ Build command-line arguments from parameters.
494
+
495
+ Args:
496
+ params: The parameters.
497
+ execution: The execution object for resolving input paths.
498
+ Returns:
499
+ Command-line arguments.
500
+ """
501
+ cargs = []
502
+ cargs.append(params.get("obj"))
503
+ return cargs
504
+
505
+
506
+ def tckgen_various_file_params(
507
+ obj: InputPathType,
508
+ ) -> TckgenVariousFileParameters:
509
+ """
510
+ Build parameters.
511
+
512
+ Args:
513
+ obj: File object.
514
+ Returns:
515
+ Parameter dictionary
516
+ """
517
+ params = {
518
+ "__STYXTYPE__": "VariousFile",
519
+ "obj": obj,
520
+ }
521
+ return params
522
+
523
+
524
+ def tckgen_various_file_cargs(
525
+ params: TckgenVariousFileParameters,
526
+ execution: Execution,
527
+ ) -> list[str]:
528
+ """
529
+ Build command-line arguments from parameters.
530
+
531
+ Args:
532
+ params: The parameters.
533
+ execution: The execution object for resolving input paths.
534
+ Returns:
535
+ Command-line arguments.
536
+ """
537
+ cargs = []
538
+ cargs.append(execution.input_file(params.get("obj")))
539
+ return cargs
540
+
541
+
542
+ def tckgen_include_params(
543
+ spec: typing.Union[TckgenVariousStringParameters, TckgenVariousFileParameters],
544
+ ) -> TckgenIncludeParameters:
545
+ """
546
+ Build parameters.
547
+
548
+ Args:
549
+ spec: specify an inclusion region of interest, as either a binary mask\
550
+ image, or as a sphere using 4 comma-separared values (x,y,z,radius).\
551
+ Streamlines must traverse ALL inclusion regions to be accepted.
552
+ Returns:
553
+ Parameter dictionary
554
+ """
555
+ params = {
556
+ "__STYXTYPE__": "include",
557
+ "spec": spec,
558
+ }
559
+ return params
560
+
561
+
562
+ def tckgen_include_cargs(
563
+ params: TckgenIncludeParameters,
564
+ execution: Execution,
565
+ ) -> list[str]:
566
+ """
567
+ Build command-line arguments from parameters.
568
+
569
+ Args:
570
+ params: The parameters.
571
+ execution: The execution object for resolving input paths.
572
+ Returns:
573
+ Command-line arguments.
574
+ """
575
+ cargs = []
576
+ cargs.append("-include")
577
+ cargs.extend(dyn_cargs(params.get("spec")["__STYXTYPE__"])(params.get("spec"), execution))
578
+ return cargs
579
+
580
+
581
+ def tckgen_include_ordered_params(
582
+ image: str,
583
+ ) -> TckgenIncludeOrderedParameters:
584
+ """
585
+ Build parameters.
586
+
587
+ Args:
588
+ image: specify an inclusion region of interest, as either a binary mask\
589
+ image, or as a sphere using 4 comma-separared values (x,y,z,radius).\
590
+ Streamlines must traverse ALL inclusion_ordered regions in the order\
591
+ they are specified in order to be accepted.
592
+ Returns:
593
+ Parameter dictionary
594
+ """
595
+ params = {
596
+ "__STYXTYPE__": "include_ordered",
597
+ "image": image,
598
+ }
599
+ return params
600
+
601
+
602
+ def tckgen_include_ordered_cargs(
603
+ params: TckgenIncludeOrderedParameters,
604
+ execution: Execution,
605
+ ) -> list[str]:
606
+ """
607
+ Build command-line arguments from parameters.
608
+
609
+ Args:
610
+ params: The parameters.
611
+ execution: The execution object for resolving input paths.
612
+ Returns:
613
+ Command-line arguments.
614
+ """
615
+ cargs = []
616
+ cargs.append("-include_ordered")
617
+ cargs.append(params.get("image"))
618
+ return cargs
619
+
620
+
621
+ def tckgen_various_string_1_params(
622
+ obj: str,
623
+ ) -> TckgenVariousString1Parameters:
624
+ """
625
+ Build parameters.
626
+
627
+ Args:
628
+ obj: String object.
629
+ Returns:
630
+ Parameter dictionary
631
+ """
632
+ params = {
633
+ "__STYXTYPE__": "VariousString_1",
634
+ "obj": obj,
635
+ }
636
+ return params
637
+
638
+
639
+ def tckgen_various_string_1_cargs(
640
+ params: TckgenVariousString1Parameters,
641
+ execution: Execution,
642
+ ) -> list[str]:
643
+ """
644
+ Build command-line arguments from parameters.
645
+
646
+ Args:
647
+ params: The parameters.
648
+ execution: The execution object for resolving input paths.
649
+ Returns:
650
+ Command-line arguments.
651
+ """
652
+ cargs = []
653
+ cargs.append(params.get("obj"))
654
+ return cargs
655
+
656
+
657
+ def tckgen_various_file_1_params(
658
+ obj: InputPathType,
659
+ ) -> TckgenVariousFile1Parameters:
660
+ """
661
+ Build parameters.
662
+
663
+ Args:
664
+ obj: File object.
665
+ Returns:
666
+ Parameter dictionary
667
+ """
668
+ params = {
669
+ "__STYXTYPE__": "VariousFile_1",
670
+ "obj": obj,
671
+ }
672
+ return params
673
+
674
+
675
+ def tckgen_various_file_1_cargs(
676
+ params: TckgenVariousFile1Parameters,
677
+ execution: Execution,
678
+ ) -> list[str]:
679
+ """
680
+ Build command-line arguments from parameters.
681
+
682
+ Args:
683
+ params: The parameters.
684
+ execution: The execution object for resolving input paths.
685
+ Returns:
686
+ Command-line arguments.
687
+ """
688
+ cargs = []
689
+ cargs.append(execution.input_file(params.get("obj")))
690
+ return cargs
691
+
692
+
693
+ def tckgen_exclude_params(
694
+ spec: typing.Union[TckgenVariousString1Parameters, TckgenVariousFile1Parameters],
695
+ ) -> TckgenExcludeParameters:
696
+ """
697
+ Build parameters.
698
+
699
+ Args:
700
+ spec: specify an exclusion region of interest, as either a binary mask\
701
+ image, or as a sphere using 4 comma-separared values (x,y,z,radius).\
702
+ Streamlines that enter ANY exclude region will be discarded.
703
+ Returns:
704
+ Parameter dictionary
705
+ """
706
+ params = {
707
+ "__STYXTYPE__": "exclude",
708
+ "spec": spec,
709
+ }
710
+ return params
711
+
712
+
713
+ def tckgen_exclude_cargs(
714
+ params: TckgenExcludeParameters,
715
+ execution: Execution,
716
+ ) -> list[str]:
717
+ """
718
+ Build command-line arguments from parameters.
719
+
720
+ Args:
721
+ params: The parameters.
722
+ execution: The execution object for resolving input paths.
723
+ Returns:
724
+ Command-line arguments.
725
+ """
726
+ cargs = []
727
+ cargs.append("-exclude")
728
+ cargs.extend(dyn_cargs(params.get("spec")["__STYXTYPE__"])(params.get("spec"), execution))
729
+ return cargs
730
+
731
+
732
+ def tckgen_various_string_2_params(
733
+ obj: str,
734
+ ) -> TckgenVariousString2Parameters:
735
+ """
736
+ Build parameters.
737
+
738
+ Args:
739
+ obj: String object.
740
+ Returns:
741
+ Parameter dictionary
742
+ """
743
+ params = {
744
+ "__STYXTYPE__": "VariousString_2",
745
+ "obj": obj,
746
+ }
747
+ return params
748
+
749
+
750
+ def tckgen_various_string_2_cargs(
751
+ params: TckgenVariousString2Parameters,
752
+ execution: Execution,
753
+ ) -> list[str]:
754
+ """
755
+ Build command-line arguments from parameters.
756
+
757
+ Args:
758
+ params: The parameters.
759
+ execution: The execution object for resolving input paths.
760
+ Returns:
761
+ Command-line arguments.
762
+ """
763
+ cargs = []
764
+ cargs.append(params.get("obj"))
765
+ return cargs
766
+
767
+
768
+ def tckgen_various_file_2_params(
769
+ obj: InputPathType,
770
+ ) -> TckgenVariousFile2Parameters:
771
+ """
772
+ Build parameters.
773
+
774
+ Args:
775
+ obj: File object.
776
+ Returns:
777
+ Parameter dictionary
778
+ """
779
+ params = {
780
+ "__STYXTYPE__": "VariousFile_2",
781
+ "obj": obj,
782
+ }
783
+ return params
784
+
785
+
786
+ def tckgen_various_file_2_cargs(
787
+ params: TckgenVariousFile2Parameters,
788
+ execution: Execution,
789
+ ) -> list[str]:
790
+ """
791
+ Build command-line arguments from parameters.
792
+
793
+ Args:
794
+ params: The parameters.
795
+ execution: The execution object for resolving input paths.
796
+ Returns:
797
+ Command-line arguments.
798
+ """
799
+ cargs = []
800
+ cargs.append(execution.input_file(params.get("obj")))
801
+ return cargs
802
+
803
+
804
+ def tckgen_mask_params(
805
+ spec: typing.Union[TckgenVariousString2Parameters, TckgenVariousFile2Parameters],
806
+ ) -> TckgenMaskParameters:
807
+ """
808
+ Build parameters.
809
+
810
+ Args:
811
+ spec: specify a masking region of interest, as either a binary mask\
812
+ image, or as a sphere using 4 comma-separared values (x,y,z,radius). If\
813
+ defined, streamlines exiting the mask will be truncated.
814
+ Returns:
815
+ Parameter dictionary
816
+ """
817
+ params = {
818
+ "__STYXTYPE__": "mask",
819
+ "spec": spec,
820
+ }
821
+ return params
822
+
823
+
824
+ def tckgen_mask_cargs(
825
+ params: TckgenMaskParameters,
826
+ execution: Execution,
827
+ ) -> list[str]:
828
+ """
829
+ Build command-line arguments from parameters.
830
+
831
+ Args:
832
+ params: The parameters.
833
+ execution: The execution object for resolving input paths.
834
+ Returns:
835
+ Command-line arguments.
836
+ """
837
+ cargs = []
838
+ cargs.append("-mask")
839
+ cargs.extend(dyn_cargs(params.get("spec")["__STYXTYPE__"])(params.get("spec"), execution))
840
+ return cargs
841
+
842
+
843
+ def tckgen_fslgrad_params(
844
+ bvecs: InputPathType,
845
+ bvals: InputPathType,
846
+ ) -> TckgenFslgradParameters:
847
+ """
848
+ Build parameters.
849
+
850
+ Args:
851
+ bvecs: Provide the diffusion-weighted gradient scheme used in the\
852
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
853
+ scheme is present in the input image header, the data provided with\
854
+ this option will be instead used.
855
+ bvals: Provide the diffusion-weighted gradient scheme used in the\
856
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
857
+ scheme is present in the input image header, the data provided with\
858
+ this option will be instead used.
859
+ Returns:
860
+ Parameter dictionary
861
+ """
862
+ params = {
863
+ "__STYXTYPE__": "fslgrad",
864
+ "bvecs": bvecs,
865
+ "bvals": bvals,
866
+ }
867
+ return params
868
+
869
+
870
+ def tckgen_fslgrad_cargs(
871
+ params: TckgenFslgradParameters,
872
+ execution: Execution,
873
+ ) -> list[str]:
874
+ """
875
+ Build command-line arguments from parameters.
876
+
877
+ Args:
878
+ params: The parameters.
879
+ execution: The execution object for resolving input paths.
880
+ Returns:
881
+ Command-line arguments.
882
+ """
883
+ cargs = []
884
+ cargs.append("-fslgrad")
885
+ cargs.append(execution.input_file(params.get("bvecs")))
886
+ cargs.append(execution.input_file(params.get("bvals")))
887
+ return cargs
888
+
889
+
890
+ def tckgen_config_params(
891
+ key: str,
892
+ value: str,
893
+ ) -> TckgenConfigParameters:
894
+ """
895
+ Build parameters.
896
+
897
+ Args:
898
+ key: temporarily set the value of an MRtrix config file entry.
899
+ value: temporarily set the value of an MRtrix config file entry.
900
+ Returns:
901
+ Parameter dictionary
902
+ """
903
+ params = {
904
+ "__STYXTYPE__": "config",
905
+ "key": key,
906
+ "value": value,
907
+ }
908
+ return params
909
+
910
+
911
+ def tckgen_config_cargs(
912
+ params: TckgenConfigParameters,
913
+ execution: Execution,
914
+ ) -> list[str]:
915
+ """
916
+ Build command-line arguments from parameters.
917
+
918
+ Args:
919
+ params: The parameters.
920
+ execution: The execution object for resolving input paths.
921
+ Returns:
922
+ Command-line arguments.
923
+ """
924
+ cargs = []
925
+ cargs.append("-config")
926
+ cargs.append(params.get("key"))
927
+ cargs.append(params.get("value"))
928
+ return cargs
929
+
930
+
931
+ class TckgenOutputs(typing.NamedTuple):
932
+ """
933
+ Output object returned when calling `tckgen(...)`.
934
+ """
935
+ root: OutputPathType
936
+ """Output root folder. This is the root folder for all outputs."""
937
+ tracks: OutputPathType
938
+ """the output file containing the tracks generated."""
939
+ output_seeds: OutputPathType | None
940
+ """output the seed location of all successful streamlines to a file """
941
+
942
+
943
+ def tckgen_params(
944
+ source: InputPathType,
945
+ tracks: str,
946
+ algorithm: str | None = None,
947
+ select_: int | None = None,
948
+ step: float | None = None,
949
+ angle: float | None = None,
950
+ minlength: float | None = None,
951
+ maxlength: float | None = None,
952
+ cutoff: float | None = None,
953
+ trials: int | None = None,
954
+ noprecomputed: bool = False,
955
+ rk4: bool = False,
956
+ stop: bool = False,
957
+ downsample: int | None = None,
958
+ seed_image: list[TckgenSeedImageParameters] | None = None,
959
+ seed_sphere: list[TckgenSeedSphereParameters] | None = None,
960
+ seed_random_per_voxel: list[TckgenSeedRandomPerVoxelParameters] | None = None,
961
+ seed_grid_per_voxel: list[TckgenSeedGridPerVoxelParameters] | None = None,
962
+ seed_rejection: list[TckgenSeedRejectionParameters] | None = None,
963
+ seed_gmwmi: list[TckgenSeedGmwmiParameters] | None = None,
964
+ seed_dynamic: InputPathType | None = None,
965
+ seeds: int | None = None,
966
+ max_attempts_per_seed: int | None = None,
967
+ seed_cutoff: float | None = None,
968
+ seed_unidirectional: bool = False,
969
+ seed_direction: list[float] | None = None,
970
+ output_seeds: str | None = None,
971
+ include: list[TckgenIncludeParameters] | None = None,
972
+ include_ordered: list[TckgenIncludeOrderedParameters] | None = None,
973
+ exclude: list[TckgenExcludeParameters] | None = None,
974
+ mask: list[TckgenMaskParameters] | None = None,
975
+ act: InputPathType | None = None,
976
+ backtrack: bool = False,
977
+ crop_at_gmwmi: bool = False,
978
+ power: float | None = None,
979
+ samples: int | None = None,
980
+ grad: InputPathType | None = None,
981
+ fslgrad: TckgenFslgradParameters | None = None,
982
+ info: bool = False,
983
+ quiet: bool = False,
984
+ debug: bool = False,
985
+ force: bool = False,
986
+ nthreads: int | None = None,
987
+ config: list[TckgenConfigParameters] | None = None,
988
+ help_: bool = False,
989
+ version: bool = False,
990
+ ) -> TckgenParameters:
991
+ """
992
+ Build parameters.
993
+
994
+ Args:
995
+ source: The image containing the source data. The type of image data\
996
+ required depends on the algorithm used (see Description section).
997
+ tracks: the output file containing the tracks generated.
998
+ algorithm: specify the tractography algorithm to use. Valid choices\
999
+ are: FACT, iFOD1, iFOD2, Nulldist1, Nulldist2, SD_Stream, Seedtest,\
1000
+ Tensor_Det, Tensor_Prob (default: iFOD2).
1001
+ select_: set the desired number of streamlines to be selected by\
1002
+ tckgen, after all selection criteria have been applied (i.e.\
1003
+ inclusion/exclusion ROIs, min/max length, etc). tckgen will keep\
1004
+ seeding streamlines until this number of streamlines have been\
1005
+ selected, or the maximum allowed number of seeds has been exceeded (see\
1006
+ -seeds option). By default, 5000 streamlines are to be selected. Set to\
1007
+ zero to disable, which will result in streamlines being seeded until\
1008
+ the number specified by -seeds has been reached.
1009
+ step: set the step size of the algorithm in mm (defaults: for\
1010
+ first-order algorithms, 0.1 x voxelsize; if using RK4, 0.25 x\
1011
+ voxelsize; for iFOD2: 0.5 x voxelsize).
1012
+ angle: set the maximum angle in degrees between successive steps\
1013
+ (defaults: 60 for deterministic algorithms; 15 for iFOD1 / nulldist1;\
1014
+ 45 for iFOD2 / nulldist2).
1015
+ minlength: set the minimum length of any track in mm (defaults: without\
1016
+ ACT, 5 x voxelsize; with ACT, 2 x voxelsize).
1017
+ maxlength: set the maximum length of any track in mm (default: 100 x\
1018
+ voxelsize).
1019
+ cutoff: set the FOD amplitude / fixel size / tensor FA cutoff for\
1020
+ terminating tracks (defaults: 0.1 for FOD-based algorithms; 0.1 for\
1021
+ fixel-based algorithms; 0.1 for tensor-based algorithms; threshold\
1022
+ multiplied by 0.5 when using ACT).
1023
+ trials: set the maximum number of sampling trials at each point (only\
1024
+ used for iFOD1 / iFOD2) (default: 1000).
1025
+ noprecomputed: do NOT pre-compute legendre polynomial values. Warning:\
1026
+ this will slow down the algorithm by a factor of approximately 4.
1027
+ rk4: use 4th-order Runge-Kutta integration (slower, but eliminates\
1028
+ curvature overshoot in 1st-order deterministic methods).
1029
+ stop: stop propagating a streamline once it has traversed all include\
1030
+ regions.
1031
+ downsample: downsample the generated streamlines to reduce output file\
1032
+ size (default is (samples-1) for iFOD2, no downsampling for all other\
1033
+ algorithms).
1034
+ seed_image: seed streamlines entirely at random within a mask image.
1035
+ seed_sphere: spherical seed as four comma-separated values (XYZ\
1036
+ position and radius).
1037
+ seed_random_per_voxel: seed a fixed number of streamlines per voxel in\
1038
+ a mask image; random placement of seeds in each voxel.
1039
+ seed_grid_per_voxel: seed a fixed number of streamlines per voxel in a\
1040
+ mask image; place seeds on a 3D mesh grid (grid_size argument is per\
1041
+ axis; so a grid_size of 3 results in 27 seeds per voxel).
1042
+ seed_rejection: seed from an image using rejection sampling (higher\
1043
+ values = more probable to seed from).
1044
+ seed_gmwmi: seed from the grey matter - white matter interface (only\
1045
+ valid if using ACT framework). Input image should be a 3D seeding\
1046
+ volume; seeds drawn within this image will be optimised to the\
1047
+ interface using the 5TT image provided using the -act option.
1048
+ seed_dynamic: determine seed points dynamically using the SIFT model\
1049
+ (must not provide any other seeding mechanism). Note that while this\
1050
+ seeding mechanism improves the distribution of reconstructed\
1051
+ streamlines density, it should NOT be used as a substitute for the SIFT\
1052
+ method itself.
1053
+ seeds: set the number of seeds that tckgen will attempt to track from.\
1054
+ If this option is NOT provided, the default number of seeds is set to\
1055
+ 1000× the number of selected streamlines. If -select is NOT also\
1056
+ specified, tckgen will continue tracking until this number of seeds has\
1057
+ been attempted. However, if -select is also specified, tckgen will stop\
1058
+ when the number of seeds attempted reaches the number specified here,\
1059
+ OR when the number of streamlines selected reaches the number requested\
1060
+ with the -select option. This can be used to prevent the program from\
1061
+ running indefinitely when no or very few streamlines can be found that\
1062
+ match the selection criteria. Setting this to zero will cause tckgen to\
1063
+ keep attempting seeds until the number specified by -select has been\
1064
+ reached.
1065
+ max_attempts_per_seed: set the maximum number of times that the\
1066
+ tracking algorithm should attempt to find an appropriate tracking\
1067
+ direction from a given seed point. This should be set high enough to\
1068
+ ensure that an actual plausible seed point is not discarded prematurely\
1069
+ as being unable to initiate tracking from. Higher settings may affect\
1070
+ performance if many seeds are genuinely impossible to track from, as\
1071
+ many attempts will still be made in vain for such seeds. (default:\
1072
+ 1000).
1073
+ seed_cutoff: set the minimum FA or FOD amplitude for seeding tracks\
1074
+ (default is the same as the normal -cutoff).
1075
+ seed_unidirectional: track from the seed point in one direction only\
1076
+ (default is to track in both directions).
1077
+ seed_direction: specify a seeding direction for the tracking (this\
1078
+ should be supplied as a vector of 3 comma-separated values.
1079
+ output_seeds: output the seed location of all successful streamlines to\
1080
+ a file.
1081
+ include: specify an inclusion region of interest, as either a binary\
1082
+ mask image, or as a sphere using 4 comma-separared values\
1083
+ (x,y,z,radius). Streamlines must traverse ALL inclusion regions to be\
1084
+ accepted.
1085
+ include_ordered: specify an inclusion region of interest, as either a\
1086
+ binary mask image, or as a sphere using 4 comma-separared values\
1087
+ (x,y,z,radius). Streamlines must traverse ALL inclusion_ordered regions\
1088
+ in the order they are specified in order to be accepted.
1089
+ exclude: specify an exclusion region of interest, as either a binary\
1090
+ mask image, or as a sphere using 4 comma-separared values\
1091
+ (x,y,z,radius). Streamlines that enter ANY exclude region will be\
1092
+ discarded.
1093
+ mask: specify a masking region of interest, as either a binary mask\
1094
+ image, or as a sphere using 4 comma-separared values (x,y,z,radius). If\
1095
+ defined, streamlines exiting the mask will be truncated.
1096
+ act: use the Anatomically-Constrained Tractography framework during\
1097
+ tracking; provided image must be in the 5TT (five-tissue-type) format.
1098
+ backtrack: allow tracks to be truncated and re-tracked if a poor\
1099
+ structural termination is encountered.
1100
+ crop_at_gmwmi: crop streamline endpoints more precisely as they cross\
1101
+ the GM-WM interface.
1102
+ power: raise the FOD to the power specified (defaults are: 1.0 for\
1103
+ iFOD1; 1.0/nsamples for iFOD2).
1104
+ samples: set the number of FOD samples to take per step (Default: 4).
1105
+ grad: Provide the diffusion-weighted gradient scheme used in the\
1106
+ acquisition in a text file. This should be supplied as a 4xN text file\
1107
+ with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
1108
+ the direction of the applied gradient, and b gives the b-value in units\
1109
+ of s/mm^2. If a diffusion gradient scheme is present in the input image\
1110
+ header, the data provided with this option will be instead used.
1111
+ fslgrad: Provide the diffusion-weighted gradient scheme used in the\
1112
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
1113
+ scheme is present in the input image header, the data provided with\
1114
+ this option will be instead used.
1115
+ info: display information messages.
1116
+ quiet: do not display information messages or progress status;\
1117
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
1118
+ environment variable to a non-empty string.
1119
+ debug: display debugging messages.
1120
+ force: force overwrite of output files (caution: using the same file as\
1121
+ input and output might cause unexpected behaviour).
1122
+ nthreads: use this number of threads in multi-threaded applications\
1123
+ (set to 0 to disable multi-threading).
1124
+ config: temporarily set the value of an MRtrix config file entry.
1125
+ help_: display this information page and exit.
1126
+ version: display version information and exit.
1127
+ Returns:
1128
+ Parameter dictionary
1129
+ """
1130
+ params = {
1131
+ "__STYXTYPE__": "tckgen",
1132
+ "noprecomputed": noprecomputed,
1133
+ "rk4": rk4,
1134
+ "stop": stop,
1135
+ "seed_unidirectional": seed_unidirectional,
1136
+ "backtrack": backtrack,
1137
+ "crop_at_gmwmi": crop_at_gmwmi,
1138
+ "info": info,
1139
+ "quiet": quiet,
1140
+ "debug": debug,
1141
+ "force": force,
1142
+ "help": help_,
1143
+ "version": version,
1144
+ "source": source,
1145
+ "tracks": tracks,
1146
+ }
1147
+ if algorithm is not None:
1148
+ params["algorithm"] = algorithm
1149
+ if select_ is not None:
1150
+ params["select"] = select_
1151
+ if step is not None:
1152
+ params["step"] = step
1153
+ if angle is not None:
1154
+ params["angle"] = angle
1155
+ if minlength is not None:
1156
+ params["minlength"] = minlength
1157
+ if maxlength is not None:
1158
+ params["maxlength"] = maxlength
1159
+ if cutoff is not None:
1160
+ params["cutoff"] = cutoff
1161
+ if trials is not None:
1162
+ params["trials"] = trials
1163
+ if downsample is not None:
1164
+ params["downsample"] = downsample
1165
+ if seed_image is not None:
1166
+ params["seed_image"] = seed_image
1167
+ if seed_sphere is not None:
1168
+ params["seed_sphere"] = seed_sphere
1169
+ if seed_random_per_voxel is not None:
1170
+ params["seed_random_per_voxel"] = seed_random_per_voxel
1171
+ if seed_grid_per_voxel is not None:
1172
+ params["seed_grid_per_voxel"] = seed_grid_per_voxel
1173
+ if seed_rejection is not None:
1174
+ params["seed_rejection"] = seed_rejection
1175
+ if seed_gmwmi is not None:
1176
+ params["seed_gmwmi"] = seed_gmwmi
1177
+ if seed_dynamic is not None:
1178
+ params["seed_dynamic"] = seed_dynamic
1179
+ if seeds is not None:
1180
+ params["seeds"] = seeds
1181
+ if max_attempts_per_seed is not None:
1182
+ params["max_attempts_per_seed"] = max_attempts_per_seed
1183
+ if seed_cutoff is not None:
1184
+ params["seed_cutoff"] = seed_cutoff
1185
+ if seed_direction is not None:
1186
+ params["seed_direction"] = seed_direction
1187
+ if output_seeds is not None:
1188
+ params["output_seeds"] = output_seeds
1189
+ if include is not None:
1190
+ params["include"] = include
1191
+ if include_ordered is not None:
1192
+ params["include_ordered"] = include_ordered
1193
+ if exclude is not None:
1194
+ params["exclude"] = exclude
1195
+ if mask is not None:
1196
+ params["mask"] = mask
1197
+ if act is not None:
1198
+ params["act"] = act
1199
+ if power is not None:
1200
+ params["power"] = power
1201
+ if samples is not None:
1202
+ params["samples"] = samples
1203
+ if grad is not None:
1204
+ params["grad"] = grad
1205
+ if fslgrad is not None:
1206
+ params["fslgrad"] = fslgrad
1207
+ if nthreads is not None:
1208
+ params["nthreads"] = nthreads
1209
+ if config is not None:
1210
+ params["config"] = config
1211
+ return params
1212
+
1213
+
1214
+ def tckgen_cargs(
1215
+ params: TckgenParameters,
1216
+ execution: Execution,
1217
+ ) -> list[str]:
1218
+ """
1219
+ Build command-line arguments from parameters.
1220
+
1221
+ Args:
1222
+ params: The parameters.
1223
+ execution: The execution object for resolving input paths.
1224
+ Returns:
1225
+ Command-line arguments.
1226
+ """
1227
+ cargs = []
1228
+ cargs.append("tckgen")
1229
+ if params.get("algorithm") is not None:
1230
+ cargs.extend([
1231
+ "-algorithm",
1232
+ params.get("algorithm")
1233
+ ])
1234
+ if params.get("select") is not None:
1235
+ cargs.extend([
1236
+ "-select",
1237
+ str(params.get("select"))
1238
+ ])
1239
+ if params.get("step") is not None:
1240
+ cargs.extend([
1241
+ "-step",
1242
+ str(params.get("step"))
1243
+ ])
1244
+ if params.get("angle") is not None:
1245
+ cargs.extend([
1246
+ "-angle",
1247
+ str(params.get("angle"))
1248
+ ])
1249
+ if params.get("minlength") is not None:
1250
+ cargs.extend([
1251
+ "-minlength",
1252
+ str(params.get("minlength"))
1253
+ ])
1254
+ if params.get("maxlength") is not None:
1255
+ cargs.extend([
1256
+ "-maxlength",
1257
+ str(params.get("maxlength"))
1258
+ ])
1259
+ if params.get("cutoff") is not None:
1260
+ cargs.extend([
1261
+ "-cutoff",
1262
+ str(params.get("cutoff"))
1263
+ ])
1264
+ if params.get("trials") is not None:
1265
+ cargs.extend([
1266
+ "-trials",
1267
+ str(params.get("trials"))
1268
+ ])
1269
+ if params.get("noprecomputed"):
1270
+ cargs.append("-noprecomputed")
1271
+ if params.get("rk4"):
1272
+ cargs.append("-rk4")
1273
+ if params.get("stop"):
1274
+ cargs.append("-stop")
1275
+ if params.get("downsample") is not None:
1276
+ cargs.extend([
1277
+ "-downsample",
1278
+ str(params.get("downsample"))
1279
+ ])
1280
+ if params.get("seed_image") is not None:
1281
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("seed_image")] for a in c])
1282
+ if params.get("seed_sphere") is not None:
1283
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("seed_sphere")] for a in c])
1284
+ if params.get("seed_random_per_voxel") is not None:
1285
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("seed_random_per_voxel")] for a in c])
1286
+ if params.get("seed_grid_per_voxel") is not None:
1287
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("seed_grid_per_voxel")] for a in c])
1288
+ if params.get("seed_rejection") is not None:
1289
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("seed_rejection")] for a in c])
1290
+ if params.get("seed_gmwmi") is not None:
1291
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("seed_gmwmi")] for a in c])
1292
+ if params.get("seed_dynamic") is not None:
1293
+ cargs.extend([
1294
+ "-seed_dynamic",
1295
+ execution.input_file(params.get("seed_dynamic"))
1296
+ ])
1297
+ if params.get("seeds") is not None:
1298
+ cargs.extend([
1299
+ "-seeds",
1300
+ str(params.get("seeds"))
1301
+ ])
1302
+ if params.get("max_attempts_per_seed") is not None:
1303
+ cargs.extend([
1304
+ "-max_attempts_per_seed",
1305
+ str(params.get("max_attempts_per_seed"))
1306
+ ])
1307
+ if params.get("seed_cutoff") is not None:
1308
+ cargs.extend([
1309
+ "-seed_cutoff",
1310
+ str(params.get("seed_cutoff"))
1311
+ ])
1312
+ if params.get("seed_unidirectional"):
1313
+ cargs.append("-seed_unidirectional")
1314
+ if params.get("seed_direction") is not None:
1315
+ cargs.extend([
1316
+ "-seed_direction",
1317
+ ",".join(map(str, params.get("seed_direction")))
1318
+ ])
1319
+ if params.get("output_seeds") is not None:
1320
+ cargs.extend([
1321
+ "-output_seeds",
1322
+ params.get("output_seeds")
1323
+ ])
1324
+ if params.get("include") is not None:
1325
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("include")] for a in c])
1326
+ if params.get("include_ordered") is not None:
1327
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("include_ordered")] for a in c])
1328
+ if params.get("exclude") is not None:
1329
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("exclude")] for a in c])
1330
+ if params.get("mask") is not None:
1331
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("mask")] for a in c])
1332
+ if params.get("act") is not None:
1333
+ cargs.extend([
1334
+ "-act",
1335
+ execution.input_file(params.get("act"))
1336
+ ])
1337
+ if params.get("backtrack"):
1338
+ cargs.append("-backtrack")
1339
+ if params.get("crop_at_gmwmi"):
1340
+ cargs.append("-crop_at_gmwmi")
1341
+ if params.get("power") is not None:
1342
+ cargs.extend([
1343
+ "-power",
1344
+ str(params.get("power"))
1345
+ ])
1346
+ if params.get("samples") is not None:
1347
+ cargs.extend([
1348
+ "-samples",
1349
+ str(params.get("samples"))
1350
+ ])
1351
+ if params.get("grad") is not None:
1352
+ cargs.extend([
1353
+ "-grad",
1354
+ execution.input_file(params.get("grad"))
1355
+ ])
1356
+ if params.get("fslgrad") is not None:
1357
+ cargs.extend(dyn_cargs(params.get("fslgrad")["__STYXTYPE__"])(params.get("fslgrad"), execution))
1358
+ if params.get("info"):
1359
+ cargs.append("-info")
1360
+ if params.get("quiet"):
1361
+ cargs.append("-quiet")
1362
+ if params.get("debug"):
1363
+ cargs.append("-debug")
1364
+ if params.get("force"):
1365
+ cargs.append("-force")
1366
+ if params.get("nthreads") is not None:
1367
+ cargs.extend([
1368
+ "-nthreads",
1369
+ str(params.get("nthreads"))
1370
+ ])
1371
+ if params.get("config") is not None:
1372
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("config")] for a in c])
1373
+ if params.get("help"):
1374
+ cargs.append("-help")
1375
+ if params.get("version"):
1376
+ cargs.append("-version")
1377
+ cargs.append(execution.input_file(params.get("source")))
1378
+ cargs.append(params.get("tracks"))
1379
+ return cargs
1380
+
1381
+
1382
+ def tckgen_outputs(
1383
+ params: TckgenParameters,
1384
+ execution: Execution,
1385
+ ) -> TckgenOutputs:
1386
+ """
1387
+ Build outputs object containing output file paths and possibly stdout/stderr.
1388
+
1389
+ Args:
1390
+ params: The parameters.
1391
+ execution: The execution object for resolving input paths.
1392
+ Returns:
1393
+ Outputs object.
1394
+ """
1395
+ ret = TckgenOutputs(
1396
+ root=execution.output_file("."),
1397
+ tracks=execution.output_file(params.get("tracks")),
1398
+ output_seeds=execution.output_file(params.get("output_seeds")) if (params.get("output_seeds") is not None) else None,
1399
+ )
1400
+ return ret
1401
+
1402
+
1403
+ def tckgen_execute(
1404
+ params: TckgenParameters,
1405
+ execution: Execution,
1406
+ ) -> TckgenOutputs:
1407
+ """
1408
+ Perform streamlines tractography.
1409
+
1410
+ By default, tckgen produces a fixed number of streamlines, by attempting to
1411
+ seed from new random locations until the target number of streamlines have
1412
+ been selected (in other words, after all inclusion & exclusion criteria have
1413
+ been applied), or the maximum number of seeds has been exceeded (by default,
1414
+ this is 1000 x the desired number of selected streamlines). Use the -select
1415
+ and/or -seeds options to modify as required. See also the Seeding options
1416
+ section for alternative seeding strategies.
1417
+
1418
+ Below is a list of available tracking algorithms, the input image data that
1419
+ they require, and a brief description of their behaviour:
1420
+
1421
+ - FACT: Fiber Assigned by Continuous Tracking. A deterministic algorithm
1422
+ that takes as input a 4D image, with 3xN volumes, where N is the maximum
1423
+ number of fiber orientations in a voxel. Each triplet of volumes represents
1424
+ a 3D vector corresponding to a fiber orientation; the length of the vector
1425
+ additionally indicates some measure of density or anisotropy. As streamlines
1426
+ move from one voxel to another, the fiber orientation most collinear with
1427
+ the streamline orientation is selected (i.e. there is no intra-voxel
1428
+ interpolation).
1429
+
1430
+ - iFOD1: First-order Integration over Fiber Orientation Distributions. A
1431
+ probabilistic algorithm that takes as input a Fiber Orientation Distribution
1432
+ (FOD) image represented in the Spherical Harmonic (SH) basis. At each
1433
+ streamline step, random samples from the local (trilinear interpolated) FOD
1434
+ are taken. A streamline is more probable to follow orientations where the
1435
+ FOD amplitude is large; but it may also rarely traverse orientations with
1436
+ small FOD amplitude.
1437
+
1438
+ - iFOD2 (default): Second-order Integration over Fiber Orientation
1439
+ Distributions. A probabilistic algorithm that takes as input a Fiber
1440
+ Orientation Distribution (FOD) image represented in the Spherical Harmonic
1441
+ (SH) basis. Candidate streamline paths (based on short curved "arcs") are
1442
+ drawn, and the underlying (trilinear-interpolated) FOD amplitudes along
1443
+ those arcs are sampled. A streamline is more probable to follow a path where
1444
+ the FOD amplitudes along that path are large; but it may also rarely
1445
+ traverse orientations where the FOD amplitudes are small, as long as the
1446
+ amplitude remains above the FOD amplitude threshold along the entire path.
1447
+
1448
+ - NullDist1 / NullDist2: Null Distribution tracking algorithms. These
1449
+ probabilistic algorithms expect as input the same image that was used when
1450
+ invoking the corresponding algorithm for which the null distribution is
1451
+ sought. These algorithms generate streamlines based on random orientation
1452
+ samples; that is, no image information relating to fiber orientations is
1453
+ used, and streamlines trajectories are determined entirely from random
1454
+ sampling. The NullDist2 algorithm is designed to be used in conjunction with
1455
+ iFOD2; NullDist1 should be used in conjunction with any first-order
1456
+ algorithm.
1457
+
1458
+ - SD_STREAM: Streamlines tractography based on Spherical Deconvolution (SD).
1459
+ A deterministic algorithm that takes as input a Fiber Orientation
1460
+ Distribution (FOD) image represented in the Spherical Harmonic (SH) basis.
1461
+ At each streamline step, the local (trilinear-interpolated) FOD is sampled,
1462
+ and from the current streamline tangent orientation, a Newton optimisation
1463
+ on the sphere is performed in order to locate the orientation of the nearest
1464
+ FOD amplitude peak.
1465
+
1466
+ - SeedTest: A dummy streamlines algorithm used for testing streamline
1467
+ seeding mechanisms. Any image can be used as input; the image will not be
1468
+ used in any way. For each seed point generated by the seeding mechanism(s),
1469
+ a streamline containing a single point corresponding to that seed location
1470
+ will be written to the output track file.
1471
+
1472
+ - Tensor_Det: A deterministic algorithm that takes as input a 4D
1473
+ diffusion-weighted image (DWI) series. At each streamline step, the
1474
+ diffusion tensor is fitted to the local (trilinear-interpolated) diffusion
1475
+ data, and the streamline trajectory is determined as the principal
1476
+ eigenvector of that tensor.
1477
+
1478
+ - Tensor_Prob: A probabilistic algorithm that takes as input a 4D
1479
+ diffusion-weighted image (DWI) series. Within each image voxel, a residual
1480
+ bootstrap is performed to obtain a unique realisation of the DWI data in
1481
+ that voxel for each streamline. These data are then sampled via trilinear
1482
+ interpolation at each streamline step, the diffusion tensor model is fitted,
1483
+ and the streamline follows the orientation of the principal eigenvector of
1484
+ that tensor.
1485
+
1486
+ Note that the behaviour of the -angle option varies slightly depending on
1487
+ the order of integration: for any first-order method, this angle corresponds
1488
+ to the deviation in streamline trajectory per step; for higher-order
1489
+ methods, this corresponds to the change in underlying fibre orientation
1490
+ between the start and end points of each step.
1491
+
1492
+ References:
1493
+
1494
+ References based on streamlines algorithm used:
1495
+
1496
+ * FACT:
1497
+ Mori, S.; Crain, B. J.; Chacko, V. P. & van Zijl, P. C. M. Three-dimensional
1498
+ tracking of axonal projections in the brain by magnetic resonance imaging.
1499
+ Annals of Neurology, 1999, 45, 265-269
1500
+
1501
+ * iFOD1 or SD_STREAM:
1502
+ Tournier, J.-D.; Calamante, F. & Connelly, A. MRtrix: Diffusion tractography
1503
+ in crossing fiber regions. Int. J. Imaging Syst. Technol., 2012, 22, 53-66
1504
+
1505
+ * iFOD2:
1506
+ Tournier, J.-D.; Calamante, F. & Connelly, A. Improved probabilistic
1507
+ streamlines tractography by 2nd order integration over fibre orientation
1508
+ distributions. Proceedings of the International Society for Magnetic
1509
+ Resonance in Medicine, 2010, 1670
1510
+
1511
+ * Nulldist1 / Nulldist2:
1512
+ Morris, D. M.; Embleton, K. V. & Parker, G. J. Probabilistic fibre tracking:
1513
+ Differentiation of connections from chance events. NeuroImage, 2008, 42,
1514
+ 1329-1339
1515
+
1516
+ * Tensor_Det:
1517
+ Basser, P. J.; Pajevic, S.; Pierpaoli, C.; Duda, J. & Aldroubi, A. In vivo
1518
+ fiber tractography using DT-MRI data. Magnetic Resonance in Medicine, 2000,
1519
+ 44, 625-632
1520
+
1521
+ * Tensor_Prob:
1522
+ Jones, D. Tractography Gone Wild: Probabilistic Fibre Tracking Using the
1523
+ Wild Bootstrap With Diffusion Tensor MRI. IEEE Transactions on Medical
1524
+ Imaging, 2008, 27, 1268-1274
1525
+
1526
+ References based on command-line options:
1527
+
1528
+ * -rk4:
1529
+ Basser, P. J.; Pajevic, S.; Pierpaoli, C.; Duda, J. & Aldroubi, A. In vivo
1530
+ fiber tractography using DT-MRI data. Magnetic Resonance in Medicine, 2000,
1531
+ 44, 625-632
1532
+
1533
+ * -act, -backtrack, -seed_gmwmi:
1534
+ Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A.
1535
+ Anatomically-constrained tractography: Improved diffusion MRI streamlines
1536
+ tractography through effective use of anatomical information. NeuroImage,
1537
+ 2012, 62, 1924-1938
1538
+
1539
+ * -seed_dynamic:
1540
+ Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A. SIFT2: Enabling
1541
+ dense quantitative assessment of brain white matter connectivity using
1542
+ streamlines tractography. NeuroImage, 2015, 119, 338-351.
1543
+
1544
+ Author: MRTrix3 Developers
1545
+
1546
+ URL: https://www.mrtrix.org/
1547
+
1548
+ Args:
1549
+ params: The parameters.
1550
+ execution: The execution object.
1551
+ Returns:
1552
+ NamedTuple of outputs (described in `TckgenOutputs`).
1553
+ """
1554
+ params = execution.params(params)
1555
+ cargs = tckgen_cargs(params, execution)
1556
+ ret = tckgen_outputs(params, execution)
1557
+ execution.run(cargs)
1558
+ return ret
1559
+
1560
+
1561
+ def tckgen(
1562
+ source: InputPathType,
1563
+ tracks: str,
1564
+ algorithm: str | None = None,
1565
+ select_: int | None = None,
1566
+ step: float | None = None,
1567
+ angle: float | None = None,
1568
+ minlength: float | None = None,
1569
+ maxlength: float | None = None,
1570
+ cutoff: float | None = None,
1571
+ trials: int | None = None,
1572
+ noprecomputed: bool = False,
1573
+ rk4: bool = False,
1574
+ stop: bool = False,
1575
+ downsample: int | None = None,
1576
+ seed_image: list[TckgenSeedImageParameters] | None = None,
1577
+ seed_sphere: list[TckgenSeedSphereParameters] | None = None,
1578
+ seed_random_per_voxel: list[TckgenSeedRandomPerVoxelParameters] | None = None,
1579
+ seed_grid_per_voxel: list[TckgenSeedGridPerVoxelParameters] | None = None,
1580
+ seed_rejection: list[TckgenSeedRejectionParameters] | None = None,
1581
+ seed_gmwmi: list[TckgenSeedGmwmiParameters] | None = None,
1582
+ seed_dynamic: InputPathType | None = None,
1583
+ seeds: int | None = None,
1584
+ max_attempts_per_seed: int | None = None,
1585
+ seed_cutoff: float | None = None,
1586
+ seed_unidirectional: bool = False,
1587
+ seed_direction: list[float] | None = None,
1588
+ output_seeds: str | None = None,
1589
+ include: list[TckgenIncludeParameters] | None = None,
1590
+ include_ordered: list[TckgenIncludeOrderedParameters] | None = None,
1591
+ exclude: list[TckgenExcludeParameters] | None = None,
1592
+ mask: list[TckgenMaskParameters] | None = None,
1593
+ act: InputPathType | None = None,
1594
+ backtrack: bool = False,
1595
+ crop_at_gmwmi: bool = False,
1596
+ power: float | None = None,
1597
+ samples: int | None = None,
1598
+ grad: InputPathType | None = None,
1599
+ fslgrad: TckgenFslgradParameters | None = None,
1600
+ info: bool = False,
1601
+ quiet: bool = False,
1602
+ debug: bool = False,
1603
+ force: bool = False,
1604
+ nthreads: int | None = None,
1605
+ config: list[TckgenConfigParameters] | None = None,
1606
+ help_: bool = False,
1607
+ version: bool = False,
1608
+ runner: Runner | None = None,
1609
+ ) -> TckgenOutputs:
1610
+ """
1611
+ Perform streamlines tractography.
1612
+
1613
+ By default, tckgen produces a fixed number of streamlines, by attempting to
1614
+ seed from new random locations until the target number of streamlines have
1615
+ been selected (in other words, after all inclusion & exclusion criteria have
1616
+ been applied), or the maximum number of seeds has been exceeded (by default,
1617
+ this is 1000 x the desired number of selected streamlines). Use the -select
1618
+ and/or -seeds options to modify as required. See also the Seeding options
1619
+ section for alternative seeding strategies.
1620
+
1621
+ Below is a list of available tracking algorithms, the input image data that
1622
+ they require, and a brief description of their behaviour:
1623
+
1624
+ - FACT: Fiber Assigned by Continuous Tracking. A deterministic algorithm
1625
+ that takes as input a 4D image, with 3xN volumes, where N is the maximum
1626
+ number of fiber orientations in a voxel. Each triplet of volumes represents
1627
+ a 3D vector corresponding to a fiber orientation; the length of the vector
1628
+ additionally indicates some measure of density or anisotropy. As streamlines
1629
+ move from one voxel to another, the fiber orientation most collinear with
1630
+ the streamline orientation is selected (i.e. there is no intra-voxel
1631
+ interpolation).
1632
+
1633
+ - iFOD1: First-order Integration over Fiber Orientation Distributions. A
1634
+ probabilistic algorithm that takes as input a Fiber Orientation Distribution
1635
+ (FOD) image represented in the Spherical Harmonic (SH) basis. At each
1636
+ streamline step, random samples from the local (trilinear interpolated) FOD
1637
+ are taken. A streamline is more probable to follow orientations where the
1638
+ FOD amplitude is large; but it may also rarely traverse orientations with
1639
+ small FOD amplitude.
1640
+
1641
+ - iFOD2 (default): Second-order Integration over Fiber Orientation
1642
+ Distributions. A probabilistic algorithm that takes as input a Fiber
1643
+ Orientation Distribution (FOD) image represented in the Spherical Harmonic
1644
+ (SH) basis. Candidate streamline paths (based on short curved "arcs") are
1645
+ drawn, and the underlying (trilinear-interpolated) FOD amplitudes along
1646
+ those arcs are sampled. A streamline is more probable to follow a path where
1647
+ the FOD amplitudes along that path are large; but it may also rarely
1648
+ traverse orientations where the FOD amplitudes are small, as long as the
1649
+ amplitude remains above the FOD amplitude threshold along the entire path.
1650
+
1651
+ - NullDist1 / NullDist2: Null Distribution tracking algorithms. These
1652
+ probabilistic algorithms expect as input the same image that was used when
1653
+ invoking the corresponding algorithm for which the null distribution is
1654
+ sought. These algorithms generate streamlines based on random orientation
1655
+ samples; that is, no image information relating to fiber orientations is
1656
+ used, and streamlines trajectories are determined entirely from random
1657
+ sampling. The NullDist2 algorithm is designed to be used in conjunction with
1658
+ iFOD2; NullDist1 should be used in conjunction with any first-order
1659
+ algorithm.
1660
+
1661
+ - SD_STREAM: Streamlines tractography based on Spherical Deconvolution (SD).
1662
+ A deterministic algorithm that takes as input a Fiber Orientation
1663
+ Distribution (FOD) image represented in the Spherical Harmonic (SH) basis.
1664
+ At each streamline step, the local (trilinear-interpolated) FOD is sampled,
1665
+ and from the current streamline tangent orientation, a Newton optimisation
1666
+ on the sphere is performed in order to locate the orientation of the nearest
1667
+ FOD amplitude peak.
1668
+
1669
+ - SeedTest: A dummy streamlines algorithm used for testing streamline
1670
+ seeding mechanisms. Any image can be used as input; the image will not be
1671
+ used in any way. For each seed point generated by the seeding mechanism(s),
1672
+ a streamline containing a single point corresponding to that seed location
1673
+ will be written to the output track file.
1674
+
1675
+ - Tensor_Det: A deterministic algorithm that takes as input a 4D
1676
+ diffusion-weighted image (DWI) series. At each streamline step, the
1677
+ diffusion tensor is fitted to the local (trilinear-interpolated) diffusion
1678
+ data, and the streamline trajectory is determined as the principal
1679
+ eigenvector of that tensor.
1680
+
1681
+ - Tensor_Prob: A probabilistic algorithm that takes as input a 4D
1682
+ diffusion-weighted image (DWI) series. Within each image voxel, a residual
1683
+ bootstrap is performed to obtain a unique realisation of the DWI data in
1684
+ that voxel for each streamline. These data are then sampled via trilinear
1685
+ interpolation at each streamline step, the diffusion tensor model is fitted,
1686
+ and the streamline follows the orientation of the principal eigenvector of
1687
+ that tensor.
1688
+
1689
+ Note that the behaviour of the -angle option varies slightly depending on
1690
+ the order of integration: for any first-order method, this angle corresponds
1691
+ to the deviation in streamline trajectory per step; for higher-order
1692
+ methods, this corresponds to the change in underlying fibre orientation
1693
+ between the start and end points of each step.
1694
+
1695
+ References:
1696
+
1697
+ References based on streamlines algorithm used:
1698
+
1699
+ * FACT:
1700
+ Mori, S.; Crain, B. J.; Chacko, V. P. & van Zijl, P. C. M. Three-dimensional
1701
+ tracking of axonal projections in the brain by magnetic resonance imaging.
1702
+ Annals of Neurology, 1999, 45, 265-269
1703
+
1704
+ * iFOD1 or SD_STREAM:
1705
+ Tournier, J.-D.; Calamante, F. & Connelly, A. MRtrix: Diffusion tractography
1706
+ in crossing fiber regions. Int. J. Imaging Syst. Technol., 2012, 22, 53-66
1707
+
1708
+ * iFOD2:
1709
+ Tournier, J.-D.; Calamante, F. & Connelly, A. Improved probabilistic
1710
+ streamlines tractography by 2nd order integration over fibre orientation
1711
+ distributions. Proceedings of the International Society for Magnetic
1712
+ Resonance in Medicine, 2010, 1670
1713
+
1714
+ * Nulldist1 / Nulldist2:
1715
+ Morris, D. M.; Embleton, K. V. & Parker, G. J. Probabilistic fibre tracking:
1716
+ Differentiation of connections from chance events. NeuroImage, 2008, 42,
1717
+ 1329-1339
1718
+
1719
+ * Tensor_Det:
1720
+ Basser, P. J.; Pajevic, S.; Pierpaoli, C.; Duda, J. & Aldroubi, A. In vivo
1721
+ fiber tractography using DT-MRI data. Magnetic Resonance in Medicine, 2000,
1722
+ 44, 625-632
1723
+
1724
+ * Tensor_Prob:
1725
+ Jones, D. Tractography Gone Wild: Probabilistic Fibre Tracking Using the
1726
+ Wild Bootstrap With Diffusion Tensor MRI. IEEE Transactions on Medical
1727
+ Imaging, 2008, 27, 1268-1274
1728
+
1729
+ References based on command-line options:
1730
+
1731
+ * -rk4:
1732
+ Basser, P. J.; Pajevic, S.; Pierpaoli, C.; Duda, J. & Aldroubi, A. In vivo
1733
+ fiber tractography using DT-MRI data. Magnetic Resonance in Medicine, 2000,
1734
+ 44, 625-632
1735
+
1736
+ * -act, -backtrack, -seed_gmwmi:
1737
+ Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A.
1738
+ Anatomically-constrained tractography: Improved diffusion MRI streamlines
1739
+ tractography through effective use of anatomical information. NeuroImage,
1740
+ 2012, 62, 1924-1938
1741
+
1742
+ * -seed_dynamic:
1743
+ Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A. SIFT2: Enabling
1744
+ dense quantitative assessment of brain white matter connectivity using
1745
+ streamlines tractography. NeuroImage, 2015, 119, 338-351.
1746
+
1747
+ Author: MRTrix3 Developers
1748
+
1749
+ URL: https://www.mrtrix.org/
1750
+
1751
+ Args:
1752
+ source: The image containing the source data. The type of image data\
1753
+ required depends on the algorithm used (see Description section).
1754
+ tracks: the output file containing the tracks generated.
1755
+ algorithm: specify the tractography algorithm to use. Valid choices\
1756
+ are: FACT, iFOD1, iFOD2, Nulldist1, Nulldist2, SD_Stream, Seedtest,\
1757
+ Tensor_Det, Tensor_Prob (default: iFOD2).
1758
+ select_: set the desired number of streamlines to be selected by\
1759
+ tckgen, after all selection criteria have been applied (i.e.\
1760
+ inclusion/exclusion ROIs, min/max length, etc). tckgen will keep\
1761
+ seeding streamlines until this number of streamlines have been\
1762
+ selected, or the maximum allowed number of seeds has been exceeded (see\
1763
+ -seeds option). By default, 5000 streamlines are to be selected. Set to\
1764
+ zero to disable, which will result in streamlines being seeded until\
1765
+ the number specified by -seeds has been reached.
1766
+ step: set the step size of the algorithm in mm (defaults: for\
1767
+ first-order algorithms, 0.1 x voxelsize; if using RK4, 0.25 x\
1768
+ voxelsize; for iFOD2: 0.5 x voxelsize).
1769
+ angle: set the maximum angle in degrees between successive steps\
1770
+ (defaults: 60 for deterministic algorithms; 15 for iFOD1 / nulldist1;\
1771
+ 45 for iFOD2 / nulldist2).
1772
+ minlength: set the minimum length of any track in mm (defaults: without\
1773
+ ACT, 5 x voxelsize; with ACT, 2 x voxelsize).
1774
+ maxlength: set the maximum length of any track in mm (default: 100 x\
1775
+ voxelsize).
1776
+ cutoff: set the FOD amplitude / fixel size / tensor FA cutoff for\
1777
+ terminating tracks (defaults: 0.1 for FOD-based algorithms; 0.1 for\
1778
+ fixel-based algorithms; 0.1 for tensor-based algorithms; threshold\
1779
+ multiplied by 0.5 when using ACT).
1780
+ trials: set the maximum number of sampling trials at each point (only\
1781
+ used for iFOD1 / iFOD2) (default: 1000).
1782
+ noprecomputed: do NOT pre-compute legendre polynomial values. Warning:\
1783
+ this will slow down the algorithm by a factor of approximately 4.
1784
+ rk4: use 4th-order Runge-Kutta integration (slower, but eliminates\
1785
+ curvature overshoot in 1st-order deterministic methods).
1786
+ stop: stop propagating a streamline once it has traversed all include\
1787
+ regions.
1788
+ downsample: downsample the generated streamlines to reduce output file\
1789
+ size (default is (samples-1) for iFOD2, no downsampling for all other\
1790
+ algorithms).
1791
+ seed_image: seed streamlines entirely at random within a mask image.
1792
+ seed_sphere: spherical seed as four comma-separated values (XYZ\
1793
+ position and radius).
1794
+ seed_random_per_voxel: seed a fixed number of streamlines per voxel in\
1795
+ a mask image; random placement of seeds in each voxel.
1796
+ seed_grid_per_voxel: seed a fixed number of streamlines per voxel in a\
1797
+ mask image; place seeds on a 3D mesh grid (grid_size argument is per\
1798
+ axis; so a grid_size of 3 results in 27 seeds per voxel).
1799
+ seed_rejection: seed from an image using rejection sampling (higher\
1800
+ values = more probable to seed from).
1801
+ seed_gmwmi: seed from the grey matter - white matter interface (only\
1802
+ valid if using ACT framework). Input image should be a 3D seeding\
1803
+ volume; seeds drawn within this image will be optimised to the\
1804
+ interface using the 5TT image provided using the -act option.
1805
+ seed_dynamic: determine seed points dynamically using the SIFT model\
1806
+ (must not provide any other seeding mechanism). Note that while this\
1807
+ seeding mechanism improves the distribution of reconstructed\
1808
+ streamlines density, it should NOT be used as a substitute for the SIFT\
1809
+ method itself.
1810
+ seeds: set the number of seeds that tckgen will attempt to track from.\
1811
+ If this option is NOT provided, the default number of seeds is set to\
1812
+ 1000× the number of selected streamlines. If -select is NOT also\
1813
+ specified, tckgen will continue tracking until this number of seeds has\
1814
+ been attempted. However, if -select is also specified, tckgen will stop\
1815
+ when the number of seeds attempted reaches the number specified here,\
1816
+ OR when the number of streamlines selected reaches the number requested\
1817
+ with the -select option. This can be used to prevent the program from\
1818
+ running indefinitely when no or very few streamlines can be found that\
1819
+ match the selection criteria. Setting this to zero will cause tckgen to\
1820
+ keep attempting seeds until the number specified by -select has been\
1821
+ reached.
1822
+ max_attempts_per_seed: set the maximum number of times that the\
1823
+ tracking algorithm should attempt to find an appropriate tracking\
1824
+ direction from a given seed point. This should be set high enough to\
1825
+ ensure that an actual plausible seed point is not discarded prematurely\
1826
+ as being unable to initiate tracking from. Higher settings may affect\
1827
+ performance if many seeds are genuinely impossible to track from, as\
1828
+ many attempts will still be made in vain for such seeds. (default:\
1829
+ 1000).
1830
+ seed_cutoff: set the minimum FA or FOD amplitude for seeding tracks\
1831
+ (default is the same as the normal -cutoff).
1832
+ seed_unidirectional: track from the seed point in one direction only\
1833
+ (default is to track in both directions).
1834
+ seed_direction: specify a seeding direction for the tracking (this\
1835
+ should be supplied as a vector of 3 comma-separated values.
1836
+ output_seeds: output the seed location of all successful streamlines to\
1837
+ a file.
1838
+ include: specify an inclusion region of interest, as either a binary\
1839
+ mask image, or as a sphere using 4 comma-separared values\
1840
+ (x,y,z,radius). Streamlines must traverse ALL inclusion regions to be\
1841
+ accepted.
1842
+ include_ordered: specify an inclusion region of interest, as either a\
1843
+ binary mask image, or as a sphere using 4 comma-separared values\
1844
+ (x,y,z,radius). Streamlines must traverse ALL inclusion_ordered regions\
1845
+ in the order they are specified in order to be accepted.
1846
+ exclude: specify an exclusion region of interest, as either a binary\
1847
+ mask image, or as a sphere using 4 comma-separared values\
1848
+ (x,y,z,radius). Streamlines that enter ANY exclude region will be\
1849
+ discarded.
1850
+ mask: specify a masking region of interest, as either a binary mask\
1851
+ image, or as a sphere using 4 comma-separared values (x,y,z,radius). If\
1852
+ defined, streamlines exiting the mask will be truncated.
1853
+ act: use the Anatomically-Constrained Tractography framework during\
1854
+ tracking; provided image must be in the 5TT (five-tissue-type) format.
1855
+ backtrack: allow tracks to be truncated and re-tracked if a poor\
1856
+ structural termination is encountered.
1857
+ crop_at_gmwmi: crop streamline endpoints more precisely as they cross\
1858
+ the GM-WM interface.
1859
+ power: raise the FOD to the power specified (defaults are: 1.0 for\
1860
+ iFOD1; 1.0/nsamples for iFOD2).
1861
+ samples: set the number of FOD samples to take per step (Default: 4).
1862
+ grad: Provide the diffusion-weighted gradient scheme used in the\
1863
+ acquisition in a text file. This should be supplied as a 4xN text file\
1864
+ with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
1865
+ the direction of the applied gradient, and b gives the b-value in units\
1866
+ of s/mm^2. If a diffusion gradient scheme is present in the input image\
1867
+ header, the data provided with this option will be instead used.
1868
+ fslgrad: Provide the diffusion-weighted gradient scheme used in the\
1869
+ acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
1870
+ scheme is present in the input image header, the data provided with\
1871
+ this option will be instead used.
1872
+ info: display information messages.
1873
+ quiet: do not display information messages or progress status;\
1874
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
1875
+ environment variable to a non-empty string.
1876
+ debug: display debugging messages.
1877
+ force: force overwrite of output files (caution: using the same file as\
1878
+ input and output might cause unexpected behaviour).
1879
+ nthreads: use this number of threads in multi-threaded applications\
1880
+ (set to 0 to disable multi-threading).
1881
+ config: temporarily set the value of an MRtrix config file entry.
1882
+ help_: display this information page and exit.
1883
+ version: display version information and exit.
1884
+ runner: Command runner.
1885
+ Returns:
1886
+ NamedTuple of outputs (described in `TckgenOutputs`).
1887
+ """
1888
+ runner = runner or get_global_runner()
1889
+ execution = runner.start_execution(TCKGEN_METADATA)
1890
+ params = tckgen_params(
1891
+ algorithm=algorithm,
1892
+ select_=select_,
1893
+ step=step,
1894
+ angle=angle,
1895
+ minlength=minlength,
1896
+ maxlength=maxlength,
1897
+ cutoff=cutoff,
1898
+ trials=trials,
1899
+ noprecomputed=noprecomputed,
1900
+ rk4=rk4,
1901
+ stop=stop,
1902
+ downsample=downsample,
1903
+ seed_image=seed_image,
1904
+ seed_sphere=seed_sphere,
1905
+ seed_random_per_voxel=seed_random_per_voxel,
1906
+ seed_grid_per_voxel=seed_grid_per_voxel,
1907
+ seed_rejection=seed_rejection,
1908
+ seed_gmwmi=seed_gmwmi,
1909
+ seed_dynamic=seed_dynamic,
1910
+ seeds=seeds,
1911
+ max_attempts_per_seed=max_attempts_per_seed,
1912
+ seed_cutoff=seed_cutoff,
1913
+ seed_unidirectional=seed_unidirectional,
1914
+ seed_direction=seed_direction,
1915
+ output_seeds=output_seeds,
1916
+ include=include,
1917
+ include_ordered=include_ordered,
1918
+ exclude=exclude,
1919
+ mask=mask,
1920
+ act=act,
1921
+ backtrack=backtrack,
1922
+ crop_at_gmwmi=crop_at_gmwmi,
1923
+ power=power,
1924
+ samples=samples,
1925
+ grad=grad,
1926
+ fslgrad=fslgrad,
1927
+ info=info,
1928
+ quiet=quiet,
1929
+ debug=debug,
1930
+ force=force,
1931
+ nthreads=nthreads,
1932
+ config=config,
1933
+ help_=help_,
1934
+ version=version,
1935
+ source=source,
1936
+ tracks=tracks,
1937
+ )
1938
+ return tckgen_execute(params, execution)
1939
+
1940
+
1941
+ __all__ = [
1942
+ "TCKGEN_METADATA",
1943
+ "TckgenConfigParameters",
1944
+ "TckgenExcludeParameters",
1945
+ "TckgenFslgradParameters",
1946
+ "TckgenIncludeOrderedParameters",
1947
+ "TckgenIncludeParameters",
1948
+ "TckgenMaskParameters",
1949
+ "TckgenOutputs",
1950
+ "TckgenParameters",
1951
+ "TckgenSeedGmwmiParameters",
1952
+ "TckgenSeedGridPerVoxelParameters",
1953
+ "TckgenSeedImageParameters",
1954
+ "TckgenSeedRandomPerVoxelParameters",
1955
+ "TckgenSeedRejectionParameters",
1956
+ "TckgenSeedSphereParameters",
1957
+ "TckgenVariousFile1Parameters",
1958
+ "TckgenVariousFile2Parameters",
1959
+ "TckgenVariousFileParameters",
1960
+ "TckgenVariousString1Parameters",
1961
+ "TckgenVariousString2Parameters",
1962
+ "TckgenVariousStringParameters",
1963
+ "tckgen",
1964
+ "tckgen_config_params",
1965
+ "tckgen_exclude_params",
1966
+ "tckgen_fslgrad_params",
1967
+ "tckgen_include_ordered_params",
1968
+ "tckgen_include_params",
1969
+ "tckgen_mask_params",
1970
+ "tckgen_params",
1971
+ "tckgen_seed_gmwmi_params",
1972
+ "tckgen_seed_grid_per_voxel_params",
1973
+ "tckgen_seed_image_params",
1974
+ "tckgen_seed_random_per_voxel_params",
1975
+ "tckgen_seed_rejection_params",
1976
+ "tckgen_seed_sphere_params",
1977
+ "tckgen_various_file_1_params",
1978
+ "tckgen_various_file_2_params",
1979
+ "tckgen_various_file_params",
1980
+ "tckgen_various_string_1_params",
1981
+ "tckgen_various_string_2_params",
1982
+ "tckgen_various_string_params",
1983
+ ]