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,739 @@
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
+ TCKSIFT_METADATA = Metadata(
9
+ id="7ab67267156023e9057e22433c919ff074901975.boutiques",
10
+ name="tcksift",
11
+ package="mrtrix",
12
+ container_image_tag="mrtrix3/mrtrix3:3.0.4",
13
+ )
14
+
15
+
16
+ _TcksiftConfigParamsDictNoTag = typing.TypedDict('_TcksiftConfigParamsDictNoTag', {
17
+ "key": str,
18
+ "value": str,
19
+ })
20
+ TcksiftConfigParamsDictTagged = typing.TypedDict('TcksiftConfigParamsDictTagged', {
21
+ "@type": typing.Literal["config"],
22
+ "key": str,
23
+ "value": str,
24
+ })
25
+ TcksiftConfigParamsDict = _TcksiftConfigParamsDictNoTag | TcksiftConfigParamsDictTagged
26
+
27
+
28
+ _TcksiftParamsDictNoTag = typing.TypedDict('_TcksiftParamsDictNoTag', {
29
+ "nofilter": bool,
30
+ "output_at_counts": typing.NotRequired[list[int] | None],
31
+ "proc_mask": typing.NotRequired[InputPathType | None],
32
+ "act": typing.NotRequired[InputPathType | None],
33
+ "fd_scale_gm": bool,
34
+ "no_dilate_lut": bool,
35
+ "make_null_lobes": bool,
36
+ "remove_untracked": bool,
37
+ "fd_thresh": typing.NotRequired[float | None],
38
+ "csv": typing.NotRequired[str | None],
39
+ "out_mu": typing.NotRequired[str | None],
40
+ "output_debug": bool,
41
+ "out_selection": typing.NotRequired[str | None],
42
+ "term_number": typing.NotRequired[int | None],
43
+ "term_ratio": typing.NotRequired[float | None],
44
+ "term_mu": typing.NotRequired[float | None],
45
+ "info": bool,
46
+ "quiet": bool,
47
+ "debug": bool,
48
+ "force": bool,
49
+ "nthreads": typing.NotRequired[int | None],
50
+ "config": typing.NotRequired[list[TcksiftConfigParamsDict] | None],
51
+ "help": bool,
52
+ "version": bool,
53
+ "in_tracks": InputPathType,
54
+ "in_fod": InputPathType,
55
+ "out_tracks": str,
56
+ })
57
+ TcksiftParamsDictTagged = typing.TypedDict('TcksiftParamsDictTagged', {
58
+ "@type": typing.Literal["mrtrix/tcksift"],
59
+ "nofilter": bool,
60
+ "output_at_counts": typing.NotRequired[list[int] | None],
61
+ "proc_mask": typing.NotRequired[InputPathType | None],
62
+ "act": typing.NotRequired[InputPathType | None],
63
+ "fd_scale_gm": bool,
64
+ "no_dilate_lut": bool,
65
+ "make_null_lobes": bool,
66
+ "remove_untracked": bool,
67
+ "fd_thresh": typing.NotRequired[float | None],
68
+ "csv": typing.NotRequired[str | None],
69
+ "out_mu": typing.NotRequired[str | None],
70
+ "output_debug": bool,
71
+ "out_selection": typing.NotRequired[str | None],
72
+ "term_number": typing.NotRequired[int | None],
73
+ "term_ratio": typing.NotRequired[float | None],
74
+ "term_mu": typing.NotRequired[float | None],
75
+ "info": bool,
76
+ "quiet": bool,
77
+ "debug": bool,
78
+ "force": bool,
79
+ "nthreads": typing.NotRequired[int | None],
80
+ "config": typing.NotRequired[list[TcksiftConfigParamsDict] | None],
81
+ "help": bool,
82
+ "version": bool,
83
+ "in_tracks": InputPathType,
84
+ "in_fod": InputPathType,
85
+ "out_tracks": str,
86
+ })
87
+ TcksiftParamsDict = _TcksiftParamsDictNoTag | TcksiftParamsDictTagged
88
+
89
+
90
+ def tcksift_config(
91
+ key: str,
92
+ value: str,
93
+ ) -> TcksiftConfigParamsDictTagged:
94
+ """
95
+ Build parameters.
96
+
97
+ Args:
98
+ key: temporarily set the value of an MRtrix config file entry.
99
+ value: temporarily set the value of an MRtrix config file entry.
100
+ Returns:
101
+ Parameter dictionary
102
+ """
103
+ params = {
104
+ "@type": "config",
105
+ "key": key,
106
+ "value": value,
107
+ }
108
+ return params
109
+
110
+
111
+ def tcksift_config_validate(
112
+ params: typing.Any,
113
+ ) -> None:
114
+ """
115
+ Validate parameters. Throws an error if `params` is not a valid
116
+ `TcksiftConfigParamsDict` object.
117
+
118
+ Args:
119
+ params: The parameters object to validate.
120
+ """
121
+ if params is None or not isinstance(params, dict):
122
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
123
+ if params.get("key", None) is None:
124
+ raise StyxValidationError("`key` must not be None")
125
+ if not isinstance(params["key"], str):
126
+ raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
127
+ if params.get("value", None) is None:
128
+ raise StyxValidationError("`value` must not be None")
129
+ if not isinstance(params["value"], str):
130
+ raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')
131
+
132
+
133
+ def tcksift_config_cargs(
134
+ params: TcksiftConfigParamsDict,
135
+ execution: Execution,
136
+ ) -> list[str]:
137
+ """
138
+ Build command-line arguments from parameters.
139
+
140
+ Args:
141
+ params: The parameters.
142
+ execution: The execution object for resolving input paths.
143
+ Returns:
144
+ Command-line arguments.
145
+ """
146
+ cargs = []
147
+ cargs.append("-config")
148
+ cargs.append(params.get("key", None))
149
+ cargs.append(params.get("value", None))
150
+ return cargs
151
+
152
+
153
+ class TcksiftOutputs(typing.NamedTuple):
154
+ """
155
+ Output object returned when calling `TcksiftParamsDict(...)`.
156
+ """
157
+ root: OutputPathType
158
+ """Output root folder. This is the root folder for all outputs."""
159
+ out_tracks: OutputPathType
160
+ """the output filtered tracks file"""
161
+ csv_: OutputPathType | None
162
+ """output statistics of execution per iteration to a .csv file """
163
+ out_mu: OutputPathType | None
164
+ """output the final value of SIFT proportionality coefficient mu to a text
165
+ file """
166
+ out_selection: OutputPathType | None
167
+ """output a text file containing the binary selection of streamlines """
168
+
169
+
170
+ def tcksift_params(
171
+ in_tracks: InputPathType,
172
+ in_fod: InputPathType,
173
+ out_tracks: str,
174
+ nofilter: bool = False,
175
+ output_at_counts: list[int] | None = None,
176
+ proc_mask: InputPathType | None = None,
177
+ act: InputPathType | None = None,
178
+ fd_scale_gm: bool = False,
179
+ no_dilate_lut: bool = False,
180
+ make_null_lobes: bool = False,
181
+ remove_untracked: bool = False,
182
+ fd_thresh: float | None = None,
183
+ csv_: str | None = None,
184
+ out_mu: str | None = None,
185
+ output_debug: bool = False,
186
+ out_selection: str | None = None,
187
+ term_number: int | None = None,
188
+ term_ratio: float | None = None,
189
+ term_mu: float | None = None,
190
+ info: bool = False,
191
+ quiet: bool = False,
192
+ debug: bool = False,
193
+ force: bool = False,
194
+ nthreads: int | None = None,
195
+ config: list[TcksiftConfigParamsDict] | None = None,
196
+ help_: bool = False,
197
+ version: bool = False,
198
+ ) -> TcksiftParamsDictTagged:
199
+ """
200
+ Build parameters.
201
+
202
+ Args:
203
+ in_tracks: the input track file.
204
+ in_fod: input image containing the spherical harmonics of the fibre\
205
+ orientation distributions.
206
+ out_tracks: the output filtered tracks file.
207
+ nofilter: do NOT perform track filtering - just construct the model in\
208
+ order to provide output debugging images.
209
+ output_at_counts: output filtered track files (and optionally debugging\
210
+ images if -output_debug is specified) at specific numbers of remaining\
211
+ streamlines; provide as comma-separated list of integers.
212
+ proc_mask: provide an image containing the processing mask weights for\
213
+ the model; image spatial dimensions must match the fixel image.
214
+ act: use an ACT five-tissue-type segmented anatomical image to derive\
215
+ the processing mask.
216
+ fd_scale_gm: provide this option (in conjunction with -act) to\
217
+ heuristically downsize the fibre density estimates based on the\
218
+ presence of GM in the voxel. This can assist in reducing tissue\
219
+ interface effects when using a single-tissue deconvolution algorithm.
220
+ no_dilate_lut: do NOT dilate FOD lobe lookup tables; only map\
221
+ streamlines to FOD lobes if the precise tangent lies within the angular\
222
+ spread of that lobe.
223
+ make_null_lobes: add an additional FOD lobe to each voxel, with zero\
224
+ integral, that covers all directions with zero / negative FOD\
225
+ amplitudes.
226
+ remove_untracked: remove FOD lobes that do not have any streamline\
227
+ density attributed to them; this improves filtering slightly, at the\
228
+ expense of longer computation time (and you can no longer do\
229
+ quantitative comparisons between reconstructions if this is enabled).
230
+ fd_thresh: fibre density threshold; exclude an FOD lobe from filtering\
231
+ processing if its integral is less than this amount (streamlines will\
232
+ still be mapped to it, but it will not contribute to the cost function\
233
+ or the filtering).
234
+ csv_: output statistics of execution per iteration to a .csv file.
235
+ out_mu: output the final value of SIFT proportionality coefficient mu\
236
+ to a text file.
237
+ output_debug: provide various output images for assessing & debugging\
238
+ performance etc.
239
+ out_selection: output a text file containing the binary selection of\
240
+ streamlines.
241
+ term_number: number of streamlines - continue filtering until this\
242
+ number of streamlines remain.
243
+ term_ratio: termination ratio - defined as the ratio between reduction\
244
+ in cost function, and reduction in density of streamlines.\
245
+ Smaller values result in more streamlines being filtered out.
246
+ term_mu: terminate filtering once the SIFT proportionality coefficient\
247
+ reaches a given value.
248
+ info: display information messages.
249
+ quiet: do not display information messages or progress status;\
250
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
251
+ environment variable to a non-empty string.
252
+ debug: display debugging messages.
253
+ force: force overwrite of output files (caution: using the same file as\
254
+ input and output might cause unexpected behaviour).
255
+ nthreads: use this number of threads in multi-threaded applications\
256
+ (set to 0 to disable multi-threading).
257
+ config: temporarily set the value of an MRtrix config file entry.
258
+ help_: display this information page and exit.
259
+ version: display version information and exit.
260
+ Returns:
261
+ Parameter dictionary
262
+ """
263
+ params = {
264
+ "@type": "mrtrix/tcksift",
265
+ "nofilter": nofilter,
266
+ "fd_scale_gm": fd_scale_gm,
267
+ "no_dilate_lut": no_dilate_lut,
268
+ "make_null_lobes": make_null_lobes,
269
+ "remove_untracked": remove_untracked,
270
+ "output_debug": output_debug,
271
+ "info": info,
272
+ "quiet": quiet,
273
+ "debug": debug,
274
+ "force": force,
275
+ "help": help_,
276
+ "version": version,
277
+ "in_tracks": in_tracks,
278
+ "in_fod": in_fod,
279
+ "out_tracks": out_tracks,
280
+ }
281
+ if output_at_counts is not None:
282
+ params["output_at_counts"] = output_at_counts
283
+ if proc_mask is not None:
284
+ params["proc_mask"] = proc_mask
285
+ if act is not None:
286
+ params["act"] = act
287
+ if fd_thresh is not None:
288
+ params["fd_thresh"] = fd_thresh
289
+ if csv_ is not None:
290
+ params["csv"] = csv_
291
+ if out_mu is not None:
292
+ params["out_mu"] = out_mu
293
+ if out_selection is not None:
294
+ params["out_selection"] = out_selection
295
+ if term_number is not None:
296
+ params["term_number"] = term_number
297
+ if term_ratio is not None:
298
+ params["term_ratio"] = term_ratio
299
+ if term_mu is not None:
300
+ params["term_mu"] = term_mu
301
+ if nthreads is not None:
302
+ params["nthreads"] = nthreads
303
+ if config is not None:
304
+ params["config"] = config
305
+ return params
306
+
307
+
308
+ def tcksift_validate(
309
+ params: typing.Any,
310
+ ) -> None:
311
+ """
312
+ Validate parameters. Throws an error if `params` is not a valid
313
+ `TcksiftParamsDict` object.
314
+
315
+ Args:
316
+ params: The parameters object to validate.
317
+ """
318
+ if params is None or not isinstance(params, dict):
319
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
320
+ if params.get("nofilter", False) is None:
321
+ raise StyxValidationError("`nofilter` must not be None")
322
+ if not isinstance(params["nofilter"], bool):
323
+ raise StyxValidationError(f'`nofilter` has the wrong type: Received `{type(params.get("nofilter", False))}` expected `bool`')
324
+ if params.get("output_at_counts", None) is not None:
325
+ if not isinstance(params["output_at_counts"], list):
326
+ raise StyxValidationError(f'`output_at_counts` has the wrong type: Received `{type(params.get("output_at_counts", None))}` expected `list[int] | None`')
327
+ for e in params["output_at_counts"]:
328
+ if not isinstance(e, int):
329
+ raise StyxValidationError(f'`output_at_counts` has the wrong type: Received `{type(params.get("output_at_counts", None))}` expected `list[int] | None`')
330
+ if params.get("proc_mask", None) is not None:
331
+ if not isinstance(params["proc_mask"], (pathlib.Path, str)):
332
+ raise StyxValidationError(f'`proc_mask` has the wrong type: Received `{type(params.get("proc_mask", None))}` expected `InputPathType | None`')
333
+ if params.get("act", None) is not None:
334
+ if not isinstance(params["act"], (pathlib.Path, str)):
335
+ raise StyxValidationError(f'`act` has the wrong type: Received `{type(params.get("act", None))}` expected `InputPathType | None`')
336
+ if params.get("fd_scale_gm", False) is None:
337
+ raise StyxValidationError("`fd_scale_gm` must not be None")
338
+ if not isinstance(params["fd_scale_gm"], bool):
339
+ raise StyxValidationError(f'`fd_scale_gm` has the wrong type: Received `{type(params.get("fd_scale_gm", False))}` expected `bool`')
340
+ if params.get("no_dilate_lut", False) is None:
341
+ raise StyxValidationError("`no_dilate_lut` must not be None")
342
+ if not isinstance(params["no_dilate_lut"], bool):
343
+ raise StyxValidationError(f'`no_dilate_lut` has the wrong type: Received `{type(params.get("no_dilate_lut", False))}` expected `bool`')
344
+ if params.get("make_null_lobes", False) is None:
345
+ raise StyxValidationError("`make_null_lobes` must not be None")
346
+ if not isinstance(params["make_null_lobes"], bool):
347
+ raise StyxValidationError(f'`make_null_lobes` has the wrong type: Received `{type(params.get("make_null_lobes", False))}` expected `bool`')
348
+ if params.get("remove_untracked", False) is None:
349
+ raise StyxValidationError("`remove_untracked` must not be None")
350
+ if not isinstance(params["remove_untracked"], bool):
351
+ raise StyxValidationError(f'`remove_untracked` has the wrong type: Received `{type(params.get("remove_untracked", False))}` expected `bool`')
352
+ if params.get("fd_thresh", None) is not None:
353
+ if not isinstance(params["fd_thresh"], (float, int)):
354
+ raise StyxValidationError(f'`fd_thresh` has the wrong type: Received `{type(params.get("fd_thresh", None))}` expected `float | None`')
355
+ if params.get("csv", None) is not None:
356
+ if not isinstance(params["csv"], str):
357
+ raise StyxValidationError(f'`csv` has the wrong type: Received `{type(params.get("csv", None))}` expected `str | None`')
358
+ if params.get("out_mu", None) is not None:
359
+ if not isinstance(params["out_mu"], str):
360
+ raise StyxValidationError(f'`out_mu` has the wrong type: Received `{type(params.get("out_mu", None))}` expected `str | None`')
361
+ if params.get("output_debug", False) is None:
362
+ raise StyxValidationError("`output_debug` must not be None")
363
+ if not isinstance(params["output_debug"], bool):
364
+ raise StyxValidationError(f'`output_debug` has the wrong type: Received `{type(params.get("output_debug", False))}` expected `bool`')
365
+ if params.get("out_selection", None) is not None:
366
+ if not isinstance(params["out_selection"], str):
367
+ raise StyxValidationError(f'`out_selection` has the wrong type: Received `{type(params.get("out_selection", None))}` expected `str | None`')
368
+ if params.get("term_number", None) is not None:
369
+ if not isinstance(params["term_number"], int):
370
+ raise StyxValidationError(f'`term_number` has the wrong type: Received `{type(params.get("term_number", None))}` expected `int | None`')
371
+ if params.get("term_ratio", None) is not None:
372
+ if not isinstance(params["term_ratio"], (float, int)):
373
+ raise StyxValidationError(f'`term_ratio` has the wrong type: Received `{type(params.get("term_ratio", None))}` expected `float | None`')
374
+ if params.get("term_mu", None) is not None:
375
+ if not isinstance(params["term_mu"], (float, int)):
376
+ raise StyxValidationError(f'`term_mu` has the wrong type: Received `{type(params.get("term_mu", None))}` expected `float | None`')
377
+ if params.get("info", False) is None:
378
+ raise StyxValidationError("`info` must not be None")
379
+ if not isinstance(params["info"], bool):
380
+ raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
381
+ if params.get("quiet", False) is None:
382
+ raise StyxValidationError("`quiet` must not be None")
383
+ if not isinstance(params["quiet"], bool):
384
+ raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
385
+ if params.get("debug", False) is None:
386
+ raise StyxValidationError("`debug` must not be None")
387
+ if not isinstance(params["debug"], bool):
388
+ raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
389
+ if params.get("force", False) is None:
390
+ raise StyxValidationError("`force` must not be None")
391
+ if not isinstance(params["force"], bool):
392
+ raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
393
+ if params.get("nthreads", None) is not None:
394
+ if not isinstance(params["nthreads"], int):
395
+ raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
396
+ if params.get("config", None) is not None:
397
+ if not isinstance(params["config"], list):
398
+ raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[TcksiftConfigParamsDict] | None`')
399
+ for e in params["config"]:
400
+ tcksift_config_validate(e)
401
+ if params.get("help", False) is None:
402
+ raise StyxValidationError("`help` must not be None")
403
+ if not isinstance(params["help"], bool):
404
+ raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
405
+ if params.get("version", False) is None:
406
+ raise StyxValidationError("`version` must not be None")
407
+ if not isinstance(params["version"], bool):
408
+ raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
409
+ if params.get("in_tracks", None) is None:
410
+ raise StyxValidationError("`in_tracks` must not be None")
411
+ if not isinstance(params["in_tracks"], (pathlib.Path, str)):
412
+ raise StyxValidationError(f'`in_tracks` has the wrong type: Received `{type(params.get("in_tracks", None))}` expected `InputPathType`')
413
+ if params.get("in_fod", None) is None:
414
+ raise StyxValidationError("`in_fod` must not be None")
415
+ if not isinstance(params["in_fod"], (pathlib.Path, str)):
416
+ raise StyxValidationError(f'`in_fod` has the wrong type: Received `{type(params.get("in_fod", None))}` expected `InputPathType`')
417
+ if params.get("out_tracks", None) is None:
418
+ raise StyxValidationError("`out_tracks` must not be None")
419
+ if not isinstance(params["out_tracks"], str):
420
+ raise StyxValidationError(f'`out_tracks` has the wrong type: Received `{type(params.get("out_tracks", None))}` expected `str`')
421
+
422
+
423
+ def tcksift_cargs(
424
+ params: TcksiftParamsDict,
425
+ execution: Execution,
426
+ ) -> list[str]:
427
+ """
428
+ Build command-line arguments from parameters.
429
+
430
+ Args:
431
+ params: The parameters.
432
+ execution: The execution object for resolving input paths.
433
+ Returns:
434
+ Command-line arguments.
435
+ """
436
+ cargs = []
437
+ cargs.append("tcksift")
438
+ if params.get("nofilter", False):
439
+ cargs.append("-nofilter")
440
+ if params.get("output_at_counts", None) is not None:
441
+ cargs.extend([
442
+ "-output_at_counts",
443
+ ",".join(map(str, params.get("output_at_counts", None)))
444
+ ])
445
+ if params.get("proc_mask", None) is not None:
446
+ cargs.extend([
447
+ "-proc_mask",
448
+ execution.input_file(params.get("proc_mask", None))
449
+ ])
450
+ if params.get("act", None) is not None:
451
+ cargs.extend([
452
+ "-act",
453
+ execution.input_file(params.get("act", None))
454
+ ])
455
+ if params.get("fd_scale_gm", False):
456
+ cargs.append("-fd_scale_gm")
457
+ if params.get("no_dilate_lut", False):
458
+ cargs.append("-no_dilate_lut")
459
+ if params.get("make_null_lobes", False):
460
+ cargs.append("-make_null_lobes")
461
+ if params.get("remove_untracked", False):
462
+ cargs.append("-remove_untracked")
463
+ if params.get("fd_thresh", None) is not None:
464
+ cargs.extend([
465
+ "-fd_thresh",
466
+ str(params.get("fd_thresh", None))
467
+ ])
468
+ if params.get("csv", None) is not None:
469
+ cargs.extend([
470
+ "-csv",
471
+ params.get("csv", None)
472
+ ])
473
+ if params.get("out_mu", None) is not None:
474
+ cargs.extend([
475
+ "-out_mu",
476
+ params.get("out_mu", None)
477
+ ])
478
+ if params.get("output_debug", False):
479
+ cargs.append("-output_debug")
480
+ if params.get("out_selection", None) is not None:
481
+ cargs.extend([
482
+ "-out_selection",
483
+ params.get("out_selection", None)
484
+ ])
485
+ if params.get("term_number", None) is not None:
486
+ cargs.extend([
487
+ "-term_number",
488
+ str(params.get("term_number", None))
489
+ ])
490
+ if params.get("term_ratio", None) is not None:
491
+ cargs.extend([
492
+ "-term_ratio",
493
+ str(params.get("term_ratio", None))
494
+ ])
495
+ if params.get("term_mu", None) is not None:
496
+ cargs.extend([
497
+ "-term_mu",
498
+ str(params.get("term_mu", None))
499
+ ])
500
+ if params.get("info", False):
501
+ cargs.append("-info")
502
+ if params.get("quiet", False):
503
+ cargs.append("-quiet")
504
+ if params.get("debug", False):
505
+ cargs.append("-debug")
506
+ if params.get("force", False):
507
+ cargs.append("-force")
508
+ if params.get("nthreads", None) is not None:
509
+ cargs.extend([
510
+ "-nthreads",
511
+ str(params.get("nthreads", None))
512
+ ])
513
+ if params.get("config", None) is not None:
514
+ cargs.extend([a for c in [tcksift_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
515
+ if params.get("help", False):
516
+ cargs.append("-help")
517
+ if params.get("version", False):
518
+ cargs.append("-version")
519
+ cargs.append(execution.input_file(params.get("in_tracks", None)))
520
+ cargs.append(execution.input_file(params.get("in_fod", None)))
521
+ cargs.append(params.get("out_tracks", None))
522
+ return cargs
523
+
524
+
525
+ def tcksift_outputs(
526
+ params: TcksiftParamsDict,
527
+ execution: Execution,
528
+ ) -> TcksiftOutputs:
529
+ """
530
+ Build outputs object containing output file paths and possibly stdout/stderr.
531
+
532
+ Args:
533
+ params: The parameters.
534
+ execution: The execution object for resolving input paths.
535
+ Returns:
536
+ Outputs object.
537
+ """
538
+ ret = TcksiftOutputs(
539
+ root=execution.output_file("."),
540
+ out_tracks=execution.output_file(params.get("out_tracks", None)),
541
+ csv_=execution.output_file(params.get("csv", None)) if (params.get("csv") is not None) else None,
542
+ out_mu=execution.output_file(params.get("out_mu", None)) if (params.get("out_mu") is not None) else None,
543
+ out_selection=execution.output_file(params.get("out_selection", None)) if (params.get("out_selection") is not None) else None,
544
+ )
545
+ return ret
546
+
547
+
548
+ def tcksift_execute(
549
+ params: TcksiftParamsDict,
550
+ runner: Runner | None = None,
551
+ ) -> TcksiftOutputs:
552
+ """
553
+ tcksift
554
+
555
+ Filter a whole-brain fibre-tracking data set such that the streamline
556
+ densities match the FOD lobe integrals.
557
+
558
+
559
+
560
+ References:
561
+
562
+ Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A. SIFT:
563
+ Spherical-deconvolution informed filtering of tractograms. NeuroImage, 2013,
564
+ 67, 298-312.
565
+
566
+ Author: MRTrix3 Developers
567
+
568
+ URL: https://www.mrtrix.org/
569
+
570
+ Args:
571
+ params: The parameters.
572
+ runner: Command runner.
573
+ Returns:
574
+ NamedTuple of outputs (described in `TcksiftOutputs`).
575
+ """
576
+ tcksift_validate(params)
577
+ runner = runner or get_global_runner()
578
+ execution = runner.start_execution(TCKSIFT_METADATA)
579
+ params = execution.params(params)
580
+ cargs = tcksift_cargs(params, execution)
581
+ ret = tcksift_outputs(params, execution)
582
+ execution.run(cargs)
583
+ return ret
584
+
585
+
586
+ def tcksift(
587
+ in_tracks: InputPathType,
588
+ in_fod: InputPathType,
589
+ out_tracks: str,
590
+ nofilter: bool = False,
591
+ output_at_counts: list[int] | None = None,
592
+ proc_mask: InputPathType | None = None,
593
+ act: InputPathType | None = None,
594
+ fd_scale_gm: bool = False,
595
+ no_dilate_lut: bool = False,
596
+ make_null_lobes: bool = False,
597
+ remove_untracked: bool = False,
598
+ fd_thresh: float | None = None,
599
+ csv_: str | None = None,
600
+ out_mu: str | None = None,
601
+ output_debug: bool = False,
602
+ out_selection: str | None = None,
603
+ term_number: int | None = None,
604
+ term_ratio: float | None = None,
605
+ term_mu: float | None = None,
606
+ info: bool = False,
607
+ quiet: bool = False,
608
+ debug: bool = False,
609
+ force: bool = False,
610
+ nthreads: int | None = None,
611
+ config: list[TcksiftConfigParamsDict] | None = None,
612
+ help_: bool = False,
613
+ version: bool = False,
614
+ runner: Runner | None = None,
615
+ ) -> TcksiftOutputs:
616
+ """
617
+ tcksift
618
+
619
+ Filter a whole-brain fibre-tracking data set such that the streamline
620
+ densities match the FOD lobe integrals.
621
+
622
+
623
+
624
+ References:
625
+
626
+ Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A. SIFT:
627
+ Spherical-deconvolution informed filtering of tractograms. NeuroImage, 2013,
628
+ 67, 298-312.
629
+
630
+ Author: MRTrix3 Developers
631
+
632
+ URL: https://www.mrtrix.org/
633
+
634
+ Args:
635
+ in_tracks: the input track file.
636
+ in_fod: input image containing the spherical harmonics of the fibre\
637
+ orientation distributions.
638
+ out_tracks: the output filtered tracks file.
639
+ nofilter: do NOT perform track filtering - just construct the model in\
640
+ order to provide output debugging images.
641
+ output_at_counts: output filtered track files (and optionally debugging\
642
+ images if -output_debug is specified) at specific numbers of remaining\
643
+ streamlines; provide as comma-separated list of integers.
644
+ proc_mask: provide an image containing the processing mask weights for\
645
+ the model; image spatial dimensions must match the fixel image.
646
+ act: use an ACT five-tissue-type segmented anatomical image to derive\
647
+ the processing mask.
648
+ fd_scale_gm: provide this option (in conjunction with -act) to\
649
+ heuristically downsize the fibre density estimates based on the\
650
+ presence of GM in the voxel. This can assist in reducing tissue\
651
+ interface effects when using a single-tissue deconvolution algorithm.
652
+ no_dilate_lut: do NOT dilate FOD lobe lookup tables; only map\
653
+ streamlines to FOD lobes if the precise tangent lies within the angular\
654
+ spread of that lobe.
655
+ make_null_lobes: add an additional FOD lobe to each voxel, with zero\
656
+ integral, that covers all directions with zero / negative FOD\
657
+ amplitudes.
658
+ remove_untracked: remove FOD lobes that do not have any streamline\
659
+ density attributed to them; this improves filtering slightly, at the\
660
+ expense of longer computation time (and you can no longer do\
661
+ quantitative comparisons between reconstructions if this is enabled).
662
+ fd_thresh: fibre density threshold; exclude an FOD lobe from filtering\
663
+ processing if its integral is less than this amount (streamlines will\
664
+ still be mapped to it, but it will not contribute to the cost function\
665
+ or the filtering).
666
+ csv_: output statistics of execution per iteration to a .csv file.
667
+ out_mu: output the final value of SIFT proportionality coefficient mu\
668
+ to a text file.
669
+ output_debug: provide various output images for assessing & debugging\
670
+ performance etc.
671
+ out_selection: output a text file containing the binary selection of\
672
+ streamlines.
673
+ term_number: number of streamlines - continue filtering until this\
674
+ number of streamlines remain.
675
+ term_ratio: termination ratio - defined as the ratio between reduction\
676
+ in cost function, and reduction in density of streamlines.\
677
+ Smaller values result in more streamlines being filtered out.
678
+ term_mu: terminate filtering once the SIFT proportionality coefficient\
679
+ reaches a given value.
680
+ info: display information messages.
681
+ quiet: do not display information messages or progress status;\
682
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
683
+ environment variable to a non-empty string.
684
+ debug: display debugging messages.
685
+ force: force overwrite of output files (caution: using the same file as\
686
+ input and output might cause unexpected behaviour).
687
+ nthreads: use this number of threads in multi-threaded applications\
688
+ (set to 0 to disable multi-threading).
689
+ config: temporarily set the value of an MRtrix config file entry.
690
+ help_: display this information page and exit.
691
+ version: display version information and exit.
692
+ runner: Command runner.
693
+ Returns:
694
+ NamedTuple of outputs (described in `TcksiftOutputs`).
695
+ """
696
+ params = tcksift_params(
697
+ nofilter=nofilter,
698
+ output_at_counts=output_at_counts,
699
+ proc_mask=proc_mask,
700
+ act=act,
701
+ fd_scale_gm=fd_scale_gm,
702
+ no_dilate_lut=no_dilate_lut,
703
+ make_null_lobes=make_null_lobes,
704
+ remove_untracked=remove_untracked,
705
+ fd_thresh=fd_thresh,
706
+ csv_=csv_,
707
+ out_mu=out_mu,
708
+ output_debug=output_debug,
709
+ out_selection=out_selection,
710
+ term_number=term_number,
711
+ term_ratio=term_ratio,
712
+ term_mu=term_mu,
713
+ info=info,
714
+ quiet=quiet,
715
+ debug=debug,
716
+ force=force,
717
+ nthreads=nthreads,
718
+ config=config,
719
+ help_=help_,
720
+ version=version,
721
+ in_tracks=in_tracks,
722
+ in_fod=in_fod,
723
+ out_tracks=out_tracks,
724
+ )
725
+ return tcksift_execute(params, runner)
726
+
727
+
728
+ __all__ = [
729
+ "TCKSIFT_METADATA",
730
+ "TcksiftConfigParamsDict",
731
+ "TcksiftConfigParamsDictTagged",
732
+ "TcksiftOutputs",
733
+ "TcksiftParamsDict",
734
+ "TcksiftParamsDictTagged",
735
+ "tcksift",
736
+ "tcksift_config",
737
+ "tcksift_execute",
738
+ "tcksift_params",
739
+ ]