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,725 @@
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
+ MTNORMALISE_METADATA = Metadata(
9
+ id="3bc2bbe8af34500259b7245db2d18482e852bfea.boutiques",
10
+ name="mtnormalise",
11
+ package="mrtrix",
12
+ container_image_tag="mrtrix3/mrtrix3:3.0.4",
13
+ )
14
+
15
+
16
+ _MtnormaliseConfigParamsDictNoTag = typing.TypedDict('_MtnormaliseConfigParamsDictNoTag', {
17
+ "key": str,
18
+ "value": str,
19
+ })
20
+ MtnormaliseConfigParamsDictTagged = typing.TypedDict('MtnormaliseConfigParamsDictTagged', {
21
+ "@type": typing.Literal["config"],
22
+ "key": str,
23
+ "value": str,
24
+ })
25
+ MtnormaliseConfigParamsDict = _MtnormaliseConfigParamsDictNoTag | MtnormaliseConfigParamsDictTagged
26
+
27
+
28
+ _MtnormaliseInputOutputParamsDictNoTag = typing.TypedDict('_MtnormaliseInputOutputParamsDictNoTag', {
29
+ "input": InputPathType,
30
+ "output": str,
31
+ })
32
+ MtnormaliseInputOutputParamsDictTagged = typing.TypedDict('MtnormaliseInputOutputParamsDictTagged', {
33
+ "@type": typing.Literal["input_output"],
34
+ "input": InputPathType,
35
+ "output": str,
36
+ })
37
+ MtnormaliseInputOutputParamsDict = _MtnormaliseInputOutputParamsDictNoTag | MtnormaliseInputOutputParamsDictTagged
38
+
39
+
40
+ _MtnormaliseParamsDictNoTag = typing.TypedDict('_MtnormaliseParamsDictNoTag', {
41
+ "mask": InputPathType,
42
+ "order": typing.NotRequired[str | None],
43
+ "niter": typing.NotRequired[list[int] | None],
44
+ "reference": typing.NotRequired[float | None],
45
+ "balanced": bool,
46
+ "check_norm": typing.NotRequired[str | None],
47
+ "check_mask": typing.NotRequired[str | None],
48
+ "check_factors": typing.NotRequired[str | None],
49
+ "info": bool,
50
+ "quiet": bool,
51
+ "debug": bool,
52
+ "force": bool,
53
+ "nthreads": typing.NotRequired[int | None],
54
+ "config": typing.NotRequired[list[MtnormaliseConfigParamsDict] | None],
55
+ "help": bool,
56
+ "version": bool,
57
+ "input_output": list[MtnormaliseInputOutputParamsDict],
58
+ })
59
+ MtnormaliseParamsDictTagged = typing.TypedDict('MtnormaliseParamsDictTagged', {
60
+ "@type": typing.Literal["mrtrix/mtnormalise"],
61
+ "mask": InputPathType,
62
+ "order": typing.NotRequired[str | None],
63
+ "niter": typing.NotRequired[list[int] | None],
64
+ "reference": typing.NotRequired[float | None],
65
+ "balanced": bool,
66
+ "check_norm": typing.NotRequired[str | None],
67
+ "check_mask": typing.NotRequired[str | None],
68
+ "check_factors": typing.NotRequired[str | None],
69
+ "info": bool,
70
+ "quiet": bool,
71
+ "debug": bool,
72
+ "force": bool,
73
+ "nthreads": typing.NotRequired[int | None],
74
+ "config": typing.NotRequired[list[MtnormaliseConfigParamsDict] | None],
75
+ "help": bool,
76
+ "version": bool,
77
+ "input_output": list[MtnormaliseInputOutputParamsDict],
78
+ })
79
+ MtnormaliseParamsDict = _MtnormaliseParamsDictNoTag | MtnormaliseParamsDictTagged
80
+
81
+
82
+ def mtnormalise_config(
83
+ key: str,
84
+ value: str,
85
+ ) -> MtnormaliseConfigParamsDictTagged:
86
+ """
87
+ Build parameters.
88
+
89
+ Args:
90
+ key: temporarily set the value of an MRtrix config file entry.
91
+ value: temporarily set the value of an MRtrix config file entry.
92
+ Returns:
93
+ Parameter dictionary
94
+ """
95
+ params = {
96
+ "@type": "config",
97
+ "key": key,
98
+ "value": value,
99
+ }
100
+ return params
101
+
102
+
103
+ def mtnormalise_config_validate(
104
+ params: typing.Any,
105
+ ) -> None:
106
+ """
107
+ Validate parameters. Throws an error if `params` is not a valid
108
+ `MtnormaliseConfigParamsDict` object.
109
+
110
+ Args:
111
+ params: The parameters object to validate.
112
+ """
113
+ if params is None or not isinstance(params, dict):
114
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
115
+ if params.get("key", None) is None:
116
+ raise StyxValidationError("`key` must not be None")
117
+ if not isinstance(params["key"], str):
118
+ raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
119
+ if params.get("value", None) is None:
120
+ raise StyxValidationError("`value` must not be None")
121
+ if not isinstance(params["value"], str):
122
+ raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')
123
+
124
+
125
+ def mtnormalise_config_cargs(
126
+ params: MtnormaliseConfigParamsDict,
127
+ execution: Execution,
128
+ ) -> list[str]:
129
+ """
130
+ Build command-line arguments from parameters.
131
+
132
+ Args:
133
+ params: The parameters.
134
+ execution: The execution object for resolving input paths.
135
+ Returns:
136
+ Command-line arguments.
137
+ """
138
+ cargs = []
139
+ cargs.append("-config")
140
+ cargs.append(params.get("key", None))
141
+ cargs.append(params.get("value", None))
142
+ return cargs
143
+
144
+
145
+ class MtnormaliseInputOutputOutputs(typing.NamedTuple):
146
+ """
147
+ Output object returned when calling `list[MtnormaliseInputOutputParamsDict](...)`.
148
+ """
149
+ root: OutputPathType
150
+ """Output root folder. This is the root folder for all outputs."""
151
+ output: OutputPathType
152
+ """output normalised tissue compartment image."""
153
+
154
+
155
+ def mtnormalise_input_output(
156
+ input_: InputPathType,
157
+ output: str,
158
+ ) -> MtnormaliseInputOutputParamsDictTagged:
159
+ """
160
+ Build parameters.
161
+
162
+ Args:
163
+ input_: input tissue compartment image.
164
+ output: output normalised tissue compartment image.
165
+ Returns:
166
+ Parameter dictionary
167
+ """
168
+ params = {
169
+ "@type": "input_output",
170
+ "input": input_,
171
+ "output": output,
172
+ }
173
+ return params
174
+
175
+
176
+ def mtnormalise_input_output_validate(
177
+ params: typing.Any,
178
+ ) -> None:
179
+ """
180
+ Validate parameters. Throws an error if `params` is not a valid
181
+ `MtnormaliseInputOutputParamsDict` object.
182
+
183
+ Args:
184
+ params: The parameters object to validate.
185
+ """
186
+ if params is None or not isinstance(params, dict):
187
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
188
+ if params.get("input", None) is None:
189
+ raise StyxValidationError("`input` must not be None")
190
+ if not isinstance(params["input"], (pathlib.Path, str)):
191
+ raise StyxValidationError(f'`input` has the wrong type: Received `{type(params.get("input", None))}` expected `InputPathType`')
192
+ if params.get("output", None) is None:
193
+ raise StyxValidationError("`output` must not be None")
194
+ if not isinstance(params["output"], str):
195
+ raise StyxValidationError(f'`output` has the wrong type: Received `{type(params.get("output", None))}` expected `str`')
196
+
197
+
198
+ def mtnormalise_input_output_cargs(
199
+ params: MtnormaliseInputOutputParamsDict,
200
+ execution: Execution,
201
+ ) -> list[str]:
202
+ """
203
+ Build command-line arguments from parameters.
204
+
205
+ Args:
206
+ params: The parameters.
207
+ execution: The execution object for resolving input paths.
208
+ Returns:
209
+ Command-line arguments.
210
+ """
211
+ cargs = []
212
+ cargs.append(execution.input_file(params.get("input", None)))
213
+ cargs.append(params.get("output", None))
214
+ return cargs
215
+
216
+
217
+ def mtnormalise_input_output_outputs(
218
+ params: MtnormaliseInputOutputParamsDict,
219
+ execution: Execution,
220
+ ) -> MtnormaliseInputOutputOutputs:
221
+ """
222
+ Build outputs object containing output file paths and possibly stdout/stderr.
223
+
224
+ Args:
225
+ params: The parameters.
226
+ execution: The execution object for resolving input paths.
227
+ Returns:
228
+ Outputs object.
229
+ """
230
+ ret = MtnormaliseInputOutputOutputs(
231
+ root=execution.output_file("."),
232
+ output=execution.output_file(params.get("output", None)),
233
+ )
234
+ return ret
235
+
236
+
237
+ class MtnormaliseOutputs(typing.NamedTuple):
238
+ """
239
+ Output object returned when calling `MtnormaliseParamsDict(...)`.
240
+ """
241
+ root: OutputPathType
242
+ """Output root folder. This is the root folder for all outputs."""
243
+ check_norm: OutputPathType | None
244
+ """output the final estimated spatially varying intensity level that is used
245
+ for normalisation. """
246
+ check_mask: OutputPathType | None
247
+ """output the final mask used to compute the normalisation. This mask
248
+ excludes regions identified as outliers by the optimisation process. """
249
+ check_factors: OutputPathType | None
250
+ """output the tissue balance factors computed during normalisation. """
251
+ input_output: list[MtnormaliseInputOutputOutputs]
252
+ """Outputs from `mtnormalise_input_output_outputs`.This is a list of outputs
253
+ with the same length and order as the inputs."""
254
+
255
+
256
+ def mtnormalise_params(
257
+ mask: InputPathType,
258
+ input_output: list[MtnormaliseInputOutputParamsDict],
259
+ order: str | None = None,
260
+ niter: list[int] | None = None,
261
+ reference: float | None = None,
262
+ balanced: bool = False,
263
+ check_norm: str | None = None,
264
+ check_mask: str | None = None,
265
+ check_factors: str | None = None,
266
+ info: bool = False,
267
+ quiet: bool = False,
268
+ debug: bool = False,
269
+ force: bool = False,
270
+ nthreads: int | None = None,
271
+ config: list[MtnormaliseConfigParamsDict] | None = None,
272
+ help_: bool = False,
273
+ version: bool = False,
274
+ ) -> MtnormaliseParamsDictTagged:
275
+ """
276
+ Build parameters.
277
+
278
+ Args:
279
+ mask: the mask defines the data used to compute the intensity\
280
+ normalisation. This option is mandatory.
281
+ input_output: list of all input and output tissue compartment files\
282
+ (see example usage).
283
+ order: the maximum order of the polynomial basis used to fit the\
284
+ normalisation field in the log-domain. An order of 0 is equivalent to\
285
+ not allowing spatial variance of the intensity normalisation factor.\
286
+ (default: 3).
287
+ niter: set the number of iterations. The first (and potentially only)\
288
+ entry applies to the main loop. If supplied as a comma-separated list\
289
+ of integers, the second entry applies to the inner loop to update the\
290
+ balance factors (default: 15,7).
291
+ reference: specify the (positive) reference value to which the summed\
292
+ tissue compartments will be normalised. (default: 0.282095, SH DC term\
293
+ for unit angular integral).
294
+ balanced: incorporate the per-tissue balancing factors into scaling of\
295
+ the output images (NOTE: use of this option has critical consequences\
296
+ for AFD intensity normalisation; should not be used unless these\
297
+ consequences are fully understood).
298
+ check_norm: output the final estimated spatially varying intensity\
299
+ level that is used for normalisation.
300
+ check_mask: output the final mask used to compute the normalisation.\
301
+ This mask excludes regions identified as outliers by the optimisation\
302
+ process.
303
+ check_factors: output the tissue balance factors computed during\
304
+ normalisation.
305
+ info: display information messages.
306
+ quiet: do not display information messages or progress status;\
307
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
308
+ environment variable to a non-empty string.
309
+ debug: display debugging messages.
310
+ force: force overwrite of output files (caution: using the same file as\
311
+ input and output might cause unexpected behaviour).
312
+ nthreads: use this number of threads in multi-threaded applications\
313
+ (set to 0 to disable multi-threading).
314
+ config: temporarily set the value of an MRtrix config file entry.
315
+ help_: display this information page and exit.
316
+ version: display version information and exit.
317
+ Returns:
318
+ Parameter dictionary
319
+ """
320
+ params = {
321
+ "@type": "mrtrix/mtnormalise",
322
+ "mask": mask,
323
+ "balanced": balanced,
324
+ "info": info,
325
+ "quiet": quiet,
326
+ "debug": debug,
327
+ "force": force,
328
+ "help": help_,
329
+ "version": version,
330
+ "input_output": input_output,
331
+ }
332
+ if order is not None:
333
+ params["order"] = order
334
+ if niter is not None:
335
+ params["niter"] = niter
336
+ if reference is not None:
337
+ params["reference"] = reference
338
+ if check_norm is not None:
339
+ params["check_norm"] = check_norm
340
+ if check_mask is not None:
341
+ params["check_mask"] = check_mask
342
+ if check_factors is not None:
343
+ params["check_factors"] = check_factors
344
+ if nthreads is not None:
345
+ params["nthreads"] = nthreads
346
+ if config is not None:
347
+ params["config"] = config
348
+ return params
349
+
350
+
351
+ def mtnormalise_validate(
352
+ params: typing.Any,
353
+ ) -> None:
354
+ """
355
+ Validate parameters. Throws an error if `params` is not a valid
356
+ `MtnormaliseParamsDict` object.
357
+
358
+ Args:
359
+ params: The parameters object to validate.
360
+ """
361
+ if params is None or not isinstance(params, dict):
362
+ raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
363
+ if params.get("mask", None) is None:
364
+ raise StyxValidationError("`mask` must not be None")
365
+ if not isinstance(params["mask"], (pathlib.Path, str)):
366
+ raise StyxValidationError(f'`mask` has the wrong type: Received `{type(params.get("mask", None))}` expected `InputPathType`')
367
+ if params.get("order", None) is not None:
368
+ if not isinstance(params["order"], str):
369
+ raise StyxValidationError(f'`order` has the wrong type: Received `{type(params.get("order", None))}` expected `str | None`')
370
+ if params.get("niter", None) is not None:
371
+ if not isinstance(params["niter"], list):
372
+ raise StyxValidationError(f'`niter` has the wrong type: Received `{type(params.get("niter", None))}` expected `list[int] | None`')
373
+ for e in params["niter"]:
374
+ if not isinstance(e, int):
375
+ raise StyxValidationError(f'`niter` has the wrong type: Received `{type(params.get("niter", None))}` expected `list[int] | None`')
376
+ if params.get("reference", None) is not None:
377
+ if not isinstance(params["reference"], (float, int)):
378
+ raise StyxValidationError(f'`reference` has the wrong type: Received `{type(params.get("reference", None))}` expected `float | None`')
379
+ if params.get("balanced", False) is None:
380
+ raise StyxValidationError("`balanced` must not be None")
381
+ if not isinstance(params["balanced"], bool):
382
+ raise StyxValidationError(f'`balanced` has the wrong type: Received `{type(params.get("balanced", False))}` expected `bool`')
383
+ if params.get("check_norm", None) is not None:
384
+ if not isinstance(params["check_norm"], str):
385
+ raise StyxValidationError(f'`check_norm` has the wrong type: Received `{type(params.get("check_norm", None))}` expected `str | None`')
386
+ if params.get("check_mask", None) is not None:
387
+ if not isinstance(params["check_mask"], str):
388
+ raise StyxValidationError(f'`check_mask` has the wrong type: Received `{type(params.get("check_mask", None))}` expected `str | None`')
389
+ if params.get("check_factors", None) is not None:
390
+ if not isinstance(params["check_factors"], str):
391
+ raise StyxValidationError(f'`check_factors` has the wrong type: Received `{type(params.get("check_factors", None))}` expected `str | None`')
392
+ if params.get("info", False) is None:
393
+ raise StyxValidationError("`info` must not be None")
394
+ if not isinstance(params["info"], bool):
395
+ raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
396
+ if params.get("quiet", False) is None:
397
+ raise StyxValidationError("`quiet` must not be None")
398
+ if not isinstance(params["quiet"], bool):
399
+ raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
400
+ if params.get("debug", False) is None:
401
+ raise StyxValidationError("`debug` must not be None")
402
+ if not isinstance(params["debug"], bool):
403
+ raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
404
+ if params.get("force", False) is None:
405
+ raise StyxValidationError("`force` must not be None")
406
+ if not isinstance(params["force"], bool):
407
+ raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
408
+ if params.get("nthreads", None) is not None:
409
+ if not isinstance(params["nthreads"], int):
410
+ raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
411
+ if params.get("config", None) is not None:
412
+ if not isinstance(params["config"], list):
413
+ raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[MtnormaliseConfigParamsDict] | None`')
414
+ for e in params["config"]:
415
+ mtnormalise_config_validate(e)
416
+ if params.get("help", False) is None:
417
+ raise StyxValidationError("`help` must not be None")
418
+ if not isinstance(params["help"], bool):
419
+ raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
420
+ if params.get("version", False) is None:
421
+ raise StyxValidationError("`version` must not be None")
422
+ if not isinstance(params["version"], bool):
423
+ raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
424
+ if params.get("input_output", None) is None:
425
+ raise StyxValidationError("`input_output` must not be None")
426
+ if not isinstance(params["input_output"], list):
427
+ raise StyxValidationError(f'`input_output` has the wrong type: Received `{type(params.get("input_output", None))}` expected `list[MtnormaliseInputOutputParamsDict]`')
428
+ for e in params["input_output"]:
429
+ mtnormalise_input_output_validate(e)
430
+
431
+
432
+ def mtnormalise_cargs(
433
+ params: MtnormaliseParamsDict,
434
+ execution: Execution,
435
+ ) -> list[str]:
436
+ """
437
+ Build command-line arguments from parameters.
438
+
439
+ Args:
440
+ params: The parameters.
441
+ execution: The execution object for resolving input paths.
442
+ Returns:
443
+ Command-line arguments.
444
+ """
445
+ cargs = []
446
+ cargs.append("mtnormalise")
447
+ cargs.extend([
448
+ "-mask",
449
+ execution.input_file(params.get("mask", None))
450
+ ])
451
+ if params.get("order", None) is not None:
452
+ cargs.extend([
453
+ "-order",
454
+ params.get("order", None)
455
+ ])
456
+ if params.get("niter", None) is not None:
457
+ cargs.extend([
458
+ "-niter",
459
+ ",".join(map(str, params.get("niter", None)))
460
+ ])
461
+ if params.get("reference", None) is not None:
462
+ cargs.extend([
463
+ "-reference",
464
+ str(params.get("reference", None))
465
+ ])
466
+ if params.get("balanced", False):
467
+ cargs.append("-balanced")
468
+ if params.get("check_norm", None) is not None:
469
+ cargs.extend([
470
+ "-check_norm",
471
+ params.get("check_norm", None)
472
+ ])
473
+ if params.get("check_mask", None) is not None:
474
+ cargs.extend([
475
+ "-check_mask",
476
+ params.get("check_mask", None)
477
+ ])
478
+ if params.get("check_factors", None) is not None:
479
+ cargs.extend([
480
+ "-check_factors",
481
+ params.get("check_factors", None)
482
+ ])
483
+ if params.get("info", False):
484
+ cargs.append("-info")
485
+ if params.get("quiet", False):
486
+ cargs.append("-quiet")
487
+ if params.get("debug", False):
488
+ cargs.append("-debug")
489
+ if params.get("force", False):
490
+ cargs.append("-force")
491
+ if params.get("nthreads", None) is not None:
492
+ cargs.extend([
493
+ "-nthreads",
494
+ str(params.get("nthreads", None))
495
+ ])
496
+ if params.get("config", None) is not None:
497
+ cargs.extend([a for c in [mtnormalise_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
498
+ if params.get("help", False):
499
+ cargs.append("-help")
500
+ if params.get("version", False):
501
+ cargs.append("-version")
502
+ cargs.extend([a for c in [mtnormalise_input_output_cargs(s, execution) for s in params.get("input_output", None)] for a in c])
503
+ return cargs
504
+
505
+
506
+ def mtnormalise_outputs(
507
+ params: MtnormaliseParamsDict,
508
+ execution: Execution,
509
+ ) -> MtnormaliseOutputs:
510
+ """
511
+ Build outputs object containing output file paths and possibly stdout/stderr.
512
+
513
+ Args:
514
+ params: The parameters.
515
+ execution: The execution object for resolving input paths.
516
+ Returns:
517
+ Outputs object.
518
+ """
519
+ ret = MtnormaliseOutputs(
520
+ root=execution.output_file("."),
521
+ check_norm=execution.output_file(params.get("check_norm", None)) if (params.get("check_norm") is not None) else None,
522
+ check_mask=execution.output_file(params.get("check_mask", None)) if (params.get("check_mask") is not None) else None,
523
+ check_factors=execution.output_file(params.get("check_factors", None)) if (params.get("check_factors") is not None) else None,
524
+ input_output=[mtnormalise_input_output_outputs(i, execution) if mtnormalise_input_output_outputs else None for i in params.get("input_output")],
525
+ )
526
+ return ret
527
+
528
+
529
+ def mtnormalise_execute(
530
+ params: MtnormaliseParamsDict,
531
+ runner: Runner | None = None,
532
+ ) -> MtnormaliseOutputs:
533
+ """
534
+ mtnormalise
535
+
536
+ Multi-tissue informed log-domain intensity normalisation.
537
+
538
+ This command takes as input any number of tissue components (e.g. from
539
+ multi-tissue CSD) and outputs corresponding normalised tissue components
540
+ corrected for the effects of (residual) intensity inhomogeneities. Intensity
541
+ normalisation is performed by optimising the voxel-wise sum of all tissue
542
+ compartments towards a constant value, under constraints of spatial
543
+ smoothness (polynomial basis of a given order). Different to the Raffelt et
544
+ al. 2017 abstract, this algorithm performs this task in the log-domain
545
+ instead, with added gradual outlier rejection, different handling of the
546
+ balancing factors between tissue compartments and a different iteration
547
+ structure.
548
+
549
+ The -mask option is mandatory and is optimally provided with a brain mask
550
+ (such as the one obtained from dwi2mask earlier in the processing pipeline).
551
+ Outlier areas with exceptionally low or high combined tissue contributions
552
+ are accounted for and reoptimised as the intensity inhomogeneity estimation
553
+ becomes more accurate.
554
+
555
+ References:
556
+
557
+ Raffelt, D.; Dhollander, T.; Tournier, J.-D.; Tabbara, R.; Smith, R. E.;
558
+ Pierre, E. & Connelly, A. Bias Field Correction and Intensity Normalisation
559
+ for Quantitative Analysis of Apparent Fibre Density. In Proc. ISMRM, 2017,
560
+ 26, 3541
561
+
562
+ Dhollander, T.; Tabbara, R.; Rosnarho-Tornstrand, J.; Tournier, J.-D.;
563
+ Raffelt, D. & Connelly, A. Multi-tissue log-domain intensity and
564
+ inhomogeneity normalisation for quantitative apparent fibre density. In
565
+ Proc. ISMRM, 2021, 29, 2472.
566
+
567
+ Author: MRTrix3 Developers
568
+
569
+ URL: https://www.mrtrix.org/
570
+
571
+ Args:
572
+ params: The parameters.
573
+ runner: Command runner.
574
+ Returns:
575
+ NamedTuple of outputs (described in `MtnormaliseOutputs`).
576
+ """
577
+ mtnormalise_validate(params)
578
+ runner = runner or get_global_runner()
579
+ execution = runner.start_execution(MTNORMALISE_METADATA)
580
+ params = execution.params(params)
581
+ cargs = mtnormalise_cargs(params, execution)
582
+ ret = mtnormalise_outputs(params, execution)
583
+ execution.run(cargs)
584
+ return ret
585
+
586
+
587
+ def mtnormalise(
588
+ mask: InputPathType,
589
+ input_output: list[MtnormaliseInputOutputParamsDict],
590
+ order: str | None = None,
591
+ niter: list[int] | None = None,
592
+ reference: float | None = None,
593
+ balanced: bool = False,
594
+ check_norm: str | None = None,
595
+ check_mask: str | None = None,
596
+ check_factors: str | None = None,
597
+ info: bool = False,
598
+ quiet: bool = False,
599
+ debug: bool = False,
600
+ force: bool = False,
601
+ nthreads: int | None = None,
602
+ config: list[MtnormaliseConfigParamsDict] | None = None,
603
+ help_: bool = False,
604
+ version: bool = False,
605
+ runner: Runner | None = None,
606
+ ) -> MtnormaliseOutputs:
607
+ """
608
+ mtnormalise
609
+
610
+ Multi-tissue informed log-domain intensity normalisation.
611
+
612
+ This command takes as input any number of tissue components (e.g. from
613
+ multi-tissue CSD) and outputs corresponding normalised tissue components
614
+ corrected for the effects of (residual) intensity inhomogeneities. Intensity
615
+ normalisation is performed by optimising the voxel-wise sum of all tissue
616
+ compartments towards a constant value, under constraints of spatial
617
+ smoothness (polynomial basis of a given order). Different to the Raffelt et
618
+ al. 2017 abstract, this algorithm performs this task in the log-domain
619
+ instead, with added gradual outlier rejection, different handling of the
620
+ balancing factors between tissue compartments and a different iteration
621
+ structure.
622
+
623
+ The -mask option is mandatory and is optimally provided with a brain mask
624
+ (such as the one obtained from dwi2mask earlier in the processing pipeline).
625
+ Outlier areas with exceptionally low or high combined tissue contributions
626
+ are accounted for and reoptimised as the intensity inhomogeneity estimation
627
+ becomes more accurate.
628
+
629
+ References:
630
+
631
+ Raffelt, D.; Dhollander, T.; Tournier, J.-D.; Tabbara, R.; Smith, R. E.;
632
+ Pierre, E. & Connelly, A. Bias Field Correction and Intensity Normalisation
633
+ for Quantitative Analysis of Apparent Fibre Density. In Proc. ISMRM, 2017,
634
+ 26, 3541
635
+
636
+ Dhollander, T.; Tabbara, R.; Rosnarho-Tornstrand, J.; Tournier, J.-D.;
637
+ Raffelt, D. & Connelly, A. Multi-tissue log-domain intensity and
638
+ inhomogeneity normalisation for quantitative apparent fibre density. In
639
+ Proc. ISMRM, 2021, 29, 2472.
640
+
641
+ Author: MRTrix3 Developers
642
+
643
+ URL: https://www.mrtrix.org/
644
+
645
+ Args:
646
+ mask: the mask defines the data used to compute the intensity\
647
+ normalisation. This option is mandatory.
648
+ input_output: list of all input and output tissue compartment files\
649
+ (see example usage).
650
+ order: the maximum order of the polynomial basis used to fit the\
651
+ normalisation field in the log-domain. An order of 0 is equivalent to\
652
+ not allowing spatial variance of the intensity normalisation factor.\
653
+ (default: 3).
654
+ niter: set the number of iterations. The first (and potentially only)\
655
+ entry applies to the main loop. If supplied as a comma-separated list\
656
+ of integers, the second entry applies to the inner loop to update the\
657
+ balance factors (default: 15,7).
658
+ reference: specify the (positive) reference value to which the summed\
659
+ tissue compartments will be normalised. (default: 0.282095, SH DC term\
660
+ for unit angular integral).
661
+ balanced: incorporate the per-tissue balancing factors into scaling of\
662
+ the output images (NOTE: use of this option has critical consequences\
663
+ for AFD intensity normalisation; should not be used unless these\
664
+ consequences are fully understood).
665
+ check_norm: output the final estimated spatially varying intensity\
666
+ level that is used for normalisation.
667
+ check_mask: output the final mask used to compute the normalisation.\
668
+ This mask excludes regions identified as outliers by the optimisation\
669
+ process.
670
+ check_factors: output the tissue balance factors computed during\
671
+ normalisation.
672
+ info: display information messages.
673
+ quiet: do not display information messages or progress status;\
674
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
675
+ environment variable to a non-empty string.
676
+ debug: display debugging messages.
677
+ force: force overwrite of output files (caution: using the same file as\
678
+ input and output might cause unexpected behaviour).
679
+ nthreads: use this number of threads in multi-threaded applications\
680
+ (set to 0 to disable multi-threading).
681
+ config: temporarily set the value of an MRtrix config file entry.
682
+ help_: display this information page and exit.
683
+ version: display version information and exit.
684
+ runner: Command runner.
685
+ Returns:
686
+ NamedTuple of outputs (described in `MtnormaliseOutputs`).
687
+ """
688
+ params = mtnormalise_params(
689
+ mask=mask,
690
+ order=order,
691
+ niter=niter,
692
+ reference=reference,
693
+ balanced=balanced,
694
+ check_norm=check_norm,
695
+ check_mask=check_mask,
696
+ check_factors=check_factors,
697
+ info=info,
698
+ quiet=quiet,
699
+ debug=debug,
700
+ force=force,
701
+ nthreads=nthreads,
702
+ config=config,
703
+ help_=help_,
704
+ version=version,
705
+ input_output=input_output,
706
+ )
707
+ return mtnormalise_execute(params, runner)
708
+
709
+
710
+ __all__ = [
711
+ "MTNORMALISE_METADATA",
712
+ "MtnormaliseConfigParamsDict",
713
+ "MtnormaliseConfigParamsDictTagged",
714
+ "MtnormaliseInputOutputOutputs",
715
+ "MtnormaliseInputOutputParamsDict",
716
+ "MtnormaliseInputOutputParamsDictTagged",
717
+ "MtnormaliseOutputs",
718
+ "MtnormaliseParamsDict",
719
+ "MtnormaliseParamsDictTagged",
720
+ "mtnormalise",
721
+ "mtnormalise_config",
722
+ "mtnormalise_execute",
723
+ "mtnormalise_input_output",
724
+ "mtnormalise_params",
725
+ ]