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,819 @@
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
+ MRGRID_METADATA = Metadata(
9
+ id="38b5784d2ea0ffb125cf48797846326fbc4d3517.boutiques",
10
+ name="mrgrid",
11
+ package="mrtrix",
12
+ container_image_tag="mrtrix3/mrtrix3:3.0.4",
13
+ )
14
+
15
+
16
+ MrgridAxisParameters = typing.TypedDict('MrgridAxisParameters', {
17
+ "__STYX_TYPE__": typing.Literal["axis"],
18
+ "index": int,
19
+ "spec": str,
20
+ })
21
+
22
+
23
+ MrgridVariousStringParameters = typing.TypedDict('MrgridVariousStringParameters', {
24
+ "__STYX_TYPE__": typing.Literal["VariousString"],
25
+ "obj": str,
26
+ })
27
+
28
+
29
+ MrgridVariousFileParameters = typing.TypedDict('MrgridVariousFileParameters', {
30
+ "__STYX_TYPE__": typing.Literal["VariousFile"],
31
+ "obj": InputPathType,
32
+ })
33
+
34
+
35
+ MrgridConfigParameters = typing.TypedDict('MrgridConfigParameters', {
36
+ "__STYX_TYPE__": typing.Literal["config"],
37
+ "key": str,
38
+ "value": str,
39
+ })
40
+
41
+
42
+ MrgridParameters = typing.TypedDict('MrgridParameters', {
43
+ "__STYX_TYPE__": typing.Literal["mrgrid"],
44
+ "template": typing.NotRequired[InputPathType | None],
45
+ "size": typing.NotRequired[list[int] | None],
46
+ "voxel": typing.NotRequired[list[float] | None],
47
+ "scale": typing.NotRequired[list[float] | None],
48
+ "interp": typing.NotRequired[str | None],
49
+ "oversample": typing.NotRequired[list[int] | None],
50
+ "as": typing.NotRequired[InputPathType | None],
51
+ "uniform": typing.NotRequired[int | None],
52
+ "mask": typing.NotRequired[InputPathType | None],
53
+ "crop_unbound": bool,
54
+ "axis": typing.NotRequired[list[MrgridAxisParameters] | None],
55
+ "all_axes": bool,
56
+ "fill": typing.NotRequired[float | None],
57
+ "strides": typing.NotRequired[typing.Union[MrgridVariousStringParameters, MrgridVariousFileParameters] | None],
58
+ "datatype": typing.NotRequired[str | None],
59
+ "info": bool,
60
+ "quiet": bool,
61
+ "debug": bool,
62
+ "force": bool,
63
+ "nthreads": typing.NotRequired[int | None],
64
+ "config": typing.NotRequired[list[MrgridConfigParameters] | None],
65
+ "help": bool,
66
+ "version": bool,
67
+ "input": InputPathType,
68
+ "operation": str,
69
+ "output": str,
70
+ })
71
+
72
+
73
+ def dyn_cargs(
74
+ t: str,
75
+ ) -> typing.Any:
76
+ """
77
+ Get build cargs function by command type.
78
+
79
+ Args:
80
+ t: Command type.
81
+ Returns:
82
+ Build cargs function.
83
+ """
84
+ return {
85
+ "mrgrid": mrgrid_cargs,
86
+ "axis": mrgrid_axis_cargs,
87
+ "VariousString": mrgrid_various_string_cargs,
88
+ "VariousFile": mrgrid_various_file_cargs,
89
+ "config": mrgrid_config_cargs,
90
+ }.get(t)
91
+
92
+
93
+ def dyn_outputs(
94
+ t: str,
95
+ ) -> typing.Any:
96
+ """
97
+ Get build outputs function by command type.
98
+
99
+ Args:
100
+ t: Command type.
101
+ Returns:
102
+ Build outputs function.
103
+ """
104
+ return {
105
+ "mrgrid": mrgrid_outputs,
106
+ }.get(t)
107
+
108
+
109
+ def mrgrid_axis_params(
110
+ index: int,
111
+ spec: str,
112
+ ) -> MrgridAxisParameters:
113
+ """
114
+ Build parameters.
115
+
116
+ Args:
117
+ index: pad or crop the input image along the provided axis (defined by\
118
+ index). The specifier argument defines the number of voxels added or\
119
+ removed on the lower or upper end of the axis (-axis index\
120
+ delta_lower,delta_upper) or acts as a voxel selection range (-axis\
121
+ index start:stop). In both modes, values are relative to the input\
122
+ image (overriding all other extent-specifying options). Negative delta\
123
+ specifier values trigger the inverse operation (pad instead of crop and\
124
+ vice versa) and negative range specifier trigger padding. Note that the\
125
+ deprecated commands 'mrcrop' and 'mrpad' used range-based and\
126
+ delta-based -axis indices, respectively.
127
+ spec: pad or crop the input image along the provided axis (defined by\
128
+ index). The specifier argument defines the number of voxels added or\
129
+ removed on the lower or upper end of the axis (-axis index\
130
+ delta_lower,delta_upper) or acts as a voxel selection range (-axis\
131
+ index start:stop). In both modes, values are relative to the input\
132
+ image (overriding all other extent-specifying options). Negative delta\
133
+ specifier values trigger the inverse operation (pad instead of crop and\
134
+ vice versa) and negative range specifier trigger padding. Note that the\
135
+ deprecated commands 'mrcrop' and 'mrpad' used range-based and\
136
+ delta-based -axis indices, respectively.
137
+ Returns:
138
+ Parameter dictionary
139
+ """
140
+ params = {
141
+ "__STYXTYPE__": "axis",
142
+ "index": index,
143
+ "spec": spec,
144
+ }
145
+ return params
146
+
147
+
148
+ def mrgrid_axis_cargs(
149
+ params: MrgridAxisParameters,
150
+ execution: Execution,
151
+ ) -> list[str]:
152
+ """
153
+ Build command-line arguments from parameters.
154
+
155
+ Args:
156
+ params: The parameters.
157
+ execution: The execution object for resolving input paths.
158
+ Returns:
159
+ Command-line arguments.
160
+ """
161
+ cargs = []
162
+ cargs.append("-axis")
163
+ cargs.append(str(params.get("index")))
164
+ cargs.append(params.get("spec"))
165
+ return cargs
166
+
167
+
168
+ def mrgrid_various_string_params(
169
+ obj: str,
170
+ ) -> MrgridVariousStringParameters:
171
+ """
172
+ Build parameters.
173
+
174
+ Args:
175
+ obj: String object.
176
+ Returns:
177
+ Parameter dictionary
178
+ """
179
+ params = {
180
+ "__STYXTYPE__": "VariousString",
181
+ "obj": obj,
182
+ }
183
+ return params
184
+
185
+
186
+ def mrgrid_various_string_cargs(
187
+ params: MrgridVariousStringParameters,
188
+ execution: Execution,
189
+ ) -> list[str]:
190
+ """
191
+ Build command-line arguments from parameters.
192
+
193
+ Args:
194
+ params: The parameters.
195
+ execution: The execution object for resolving input paths.
196
+ Returns:
197
+ Command-line arguments.
198
+ """
199
+ cargs = []
200
+ cargs.append(params.get("obj"))
201
+ return cargs
202
+
203
+
204
+ def mrgrid_various_file_params(
205
+ obj: InputPathType,
206
+ ) -> MrgridVariousFileParameters:
207
+ """
208
+ Build parameters.
209
+
210
+ Args:
211
+ obj: File object.
212
+ Returns:
213
+ Parameter dictionary
214
+ """
215
+ params = {
216
+ "__STYXTYPE__": "VariousFile",
217
+ "obj": obj,
218
+ }
219
+ return params
220
+
221
+
222
+ def mrgrid_various_file_cargs(
223
+ params: MrgridVariousFileParameters,
224
+ execution: Execution,
225
+ ) -> list[str]:
226
+ """
227
+ Build command-line arguments from parameters.
228
+
229
+ Args:
230
+ params: The parameters.
231
+ execution: The execution object for resolving input paths.
232
+ Returns:
233
+ Command-line arguments.
234
+ """
235
+ cargs = []
236
+ cargs.append(execution.input_file(params.get("obj")))
237
+ return cargs
238
+
239
+
240
+ def mrgrid_config_params(
241
+ key: str,
242
+ value: str,
243
+ ) -> MrgridConfigParameters:
244
+ """
245
+ Build parameters.
246
+
247
+ Args:
248
+ key: temporarily set the value of an MRtrix config file entry.
249
+ value: temporarily set the value of an MRtrix config file entry.
250
+ Returns:
251
+ Parameter dictionary
252
+ """
253
+ params = {
254
+ "__STYXTYPE__": "config",
255
+ "key": key,
256
+ "value": value,
257
+ }
258
+ return params
259
+
260
+
261
+ def mrgrid_config_cargs(
262
+ params: MrgridConfigParameters,
263
+ execution: Execution,
264
+ ) -> list[str]:
265
+ """
266
+ Build command-line arguments from parameters.
267
+
268
+ Args:
269
+ params: The parameters.
270
+ execution: The execution object for resolving input paths.
271
+ Returns:
272
+ Command-line arguments.
273
+ """
274
+ cargs = []
275
+ cargs.append("-config")
276
+ cargs.append(params.get("key"))
277
+ cargs.append(params.get("value"))
278
+ return cargs
279
+
280
+
281
+ class MrgridOutputs(typing.NamedTuple):
282
+ """
283
+ Output object returned when calling `mrgrid(...)`.
284
+ """
285
+ root: OutputPathType
286
+ """Output root folder. This is the root folder for all outputs."""
287
+ output: OutputPathType
288
+ """the output image."""
289
+
290
+
291
+ def mrgrid_params(
292
+ input_: InputPathType,
293
+ operation: str,
294
+ output: str,
295
+ template: InputPathType | None = None,
296
+ size: list[int] | None = None,
297
+ voxel: list[float] | None = None,
298
+ scale: list[float] | None = None,
299
+ interp: str | None = None,
300
+ oversample: list[int] | None = None,
301
+ as_: InputPathType | None = None,
302
+ uniform: int | None = None,
303
+ mask: InputPathType | None = None,
304
+ crop_unbound: bool = False,
305
+ axis: list[MrgridAxisParameters] | None = None,
306
+ all_axes: bool = False,
307
+ fill: float | None = None,
308
+ strides: typing.Union[MrgridVariousStringParameters, MrgridVariousFileParameters] | None = None,
309
+ datatype: str | None = None,
310
+ info: bool = False,
311
+ quiet: bool = False,
312
+ debug: bool = False,
313
+ force: bool = False,
314
+ nthreads: int | None = None,
315
+ config: list[MrgridConfigParameters] | None = None,
316
+ help_: bool = False,
317
+ version: bool = False,
318
+ ) -> MrgridParameters:
319
+ """
320
+ Build parameters.
321
+
322
+ Args:
323
+ input_: input image to be regridded.
324
+ operation: the operation to be performed, one of: regrid, crop, pad.
325
+ output: the output image.
326
+ template: match the input image grid (voxel spacing, image size, header\
327
+ transformation) to that of a reference image. The image resolution\
328
+ relative to the template image can be changed with one of -size,\
329
+ -voxel, -scale.
330
+ size: define the size (number of voxels) in each spatial dimension for\
331
+ the output image. This should be specified as a comma-separated list.
332
+ voxel: define the new voxel size for the output image. This can be\
333
+ specified either as a single value to be used for all spatial\
334
+ dimensions, or as a comma-separated list of the size for each voxel\
335
+ dimension.
336
+ scale: scale the image resolution by the supplied factor. This can be\
337
+ specified either as a single value to be used for all dimensions, or as\
338
+ a comma-separated list of scale factors for each dimension.
339
+ interp: set the interpolation method to use when reslicing (choices:\
340
+ nearest, linear, cubic, sinc. Default: cubic).
341
+ oversample: set the amount of over-sampling (in the target space) to\
342
+ perform when regridding. This is particularly relevant when downsamping\
343
+ a high-resolution image to a low-resolution image, to avoid aliasing\
344
+ artefacts. This can consist of a single integer, or a comma-separated\
345
+ list of 3 integers if different oversampling factors are desired along\
346
+ the different axes. Default is determined from ratio of voxel\
347
+ dimensions (disabled for nearest-neighbour interpolation).
348
+ as_: pad or crop the input image on the upper bound to match the\
349
+ specified reference image grid. This operation ignores differences in\
350
+ image transformation between input and reference image.
351
+ uniform: pad or crop the input image by a uniform number of voxels on\
352
+ all sides.
353
+ mask: crop the input image according to the spatial extent of a mask\
354
+ image. The mask must share a common voxel grid with the input image but\
355
+ differences in image transformations are ignored. Note that even though\
356
+ only 3 dimensions are cropped when using a mask, the bounds are\
357
+ computed by checking the extent for all dimensions. Note that by\
358
+ default a gap of 1 voxel is left at all edges of the image to allow\
359
+ valid trilinear interpolation. This gap can be modified with the\
360
+ -uniform option but by default it does not extend beyond the FOV unless\
361
+ -crop_unbound is used.
362
+ crop_unbound: Allow padding beyond the original FOV when cropping.
363
+ axis: pad or crop the input image along the provided axis (defined by\
364
+ index). The specifier argument defines the number of voxels added or\
365
+ removed on the lower or upper end of the axis (-axis index\
366
+ delta_lower,delta_upper) or acts as a voxel selection range (-axis\
367
+ index start:stop). In both modes, values are relative to the input\
368
+ image (overriding all other extent-specifying options). Negative delta\
369
+ specifier values trigger the inverse operation (pad instead of crop and\
370
+ vice versa) and negative range specifier trigger padding. Note that the\
371
+ deprecated commands 'mrcrop' and 'mrpad' used range-based and\
372
+ delta-based -axis indices, respectively.
373
+ all_axes: Crop or pad all, not just spatial axes.
374
+ fill: Use number as the out of bounds value. nan, inf and -inf are\
375
+ valid arguments. (Default: 0.0).
376
+ strides: specify the strides of the output data in memory; either as a\
377
+ comma-separated list of (signed) integers, or as a template image from\
378
+ which the strides shall be extracted and used. The actual strides\
379
+ produced will depend on whether the output image format can support it.
380
+ datatype: specify output image data type. Valid choices are: float32,\
381
+ float32le, float32be, float64, float64le, float64be, int64, uint64,\
382
+ int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
383
+ int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
384
+ cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
385
+ int8, uint8, bit.
386
+ info: display information messages.
387
+ quiet: do not display information messages or progress status;\
388
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
389
+ environment variable to a non-empty string.
390
+ debug: display debugging messages.
391
+ force: force overwrite of output files (caution: using the same file as\
392
+ input and output might cause unexpected behaviour).
393
+ nthreads: use this number of threads in multi-threaded applications\
394
+ (set to 0 to disable multi-threading).
395
+ config: temporarily set the value of an MRtrix config file entry.
396
+ help_: display this information page and exit.
397
+ version: display version information and exit.
398
+ Returns:
399
+ Parameter dictionary
400
+ """
401
+ params = {
402
+ "__STYXTYPE__": "mrgrid",
403
+ "crop_unbound": crop_unbound,
404
+ "all_axes": all_axes,
405
+ "info": info,
406
+ "quiet": quiet,
407
+ "debug": debug,
408
+ "force": force,
409
+ "help": help_,
410
+ "version": version,
411
+ "input": input_,
412
+ "operation": operation,
413
+ "output": output,
414
+ }
415
+ if template is not None:
416
+ params["template"] = template
417
+ if size is not None:
418
+ params["size"] = size
419
+ if voxel is not None:
420
+ params["voxel"] = voxel
421
+ if scale is not None:
422
+ params["scale"] = scale
423
+ if interp is not None:
424
+ params["interp"] = interp
425
+ if oversample is not None:
426
+ params["oversample"] = oversample
427
+ if as_ is not None:
428
+ params["as"] = as_
429
+ if uniform is not None:
430
+ params["uniform"] = uniform
431
+ if mask is not None:
432
+ params["mask"] = mask
433
+ if axis is not None:
434
+ params["axis"] = axis
435
+ if fill is not None:
436
+ params["fill"] = fill
437
+ if strides is not None:
438
+ params["strides"] = strides
439
+ if datatype is not None:
440
+ params["datatype"] = datatype
441
+ if nthreads is not None:
442
+ params["nthreads"] = nthreads
443
+ if config is not None:
444
+ params["config"] = config
445
+ return params
446
+
447
+
448
+ def mrgrid_cargs(
449
+ params: MrgridParameters,
450
+ execution: Execution,
451
+ ) -> list[str]:
452
+ """
453
+ Build command-line arguments from parameters.
454
+
455
+ Args:
456
+ params: The parameters.
457
+ execution: The execution object for resolving input paths.
458
+ Returns:
459
+ Command-line arguments.
460
+ """
461
+ cargs = []
462
+ cargs.append("mrgrid")
463
+ if params.get("template") is not None:
464
+ cargs.extend([
465
+ "-template",
466
+ execution.input_file(params.get("template"))
467
+ ])
468
+ if params.get("size") is not None:
469
+ cargs.extend([
470
+ "-size",
471
+ ",".join(map(str, params.get("size")))
472
+ ])
473
+ if params.get("voxel") is not None:
474
+ cargs.extend([
475
+ "-voxel",
476
+ ",".join(map(str, params.get("voxel")))
477
+ ])
478
+ if params.get("scale") is not None:
479
+ cargs.extend([
480
+ "-scale",
481
+ ",".join(map(str, params.get("scale")))
482
+ ])
483
+ if params.get("interp") is not None:
484
+ cargs.extend([
485
+ "-interp",
486
+ params.get("interp")
487
+ ])
488
+ if params.get("oversample") is not None:
489
+ cargs.extend([
490
+ "-oversample",
491
+ ",".join(map(str, params.get("oversample")))
492
+ ])
493
+ if params.get("as") is not None:
494
+ cargs.extend([
495
+ "-as",
496
+ execution.input_file(params.get("as"))
497
+ ])
498
+ if params.get("uniform") is not None:
499
+ cargs.extend([
500
+ "-uniform",
501
+ str(params.get("uniform"))
502
+ ])
503
+ if params.get("mask") is not None:
504
+ cargs.extend([
505
+ "-mask",
506
+ execution.input_file(params.get("mask"))
507
+ ])
508
+ if params.get("crop_unbound"):
509
+ cargs.append("-crop_unbound")
510
+ if params.get("axis") is not None:
511
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("axis")] for a in c])
512
+ if params.get("all_axes"):
513
+ cargs.append("-all_axes")
514
+ if params.get("fill") is not None:
515
+ cargs.extend([
516
+ "-fill",
517
+ str(params.get("fill"))
518
+ ])
519
+ if params.get("strides") is not None:
520
+ cargs.extend([
521
+ "-strides",
522
+ *dyn_cargs(params.get("strides")["__STYXTYPE__"])(params.get("strides"), execution)
523
+ ])
524
+ if params.get("datatype") is not None:
525
+ cargs.extend([
526
+ "-datatype",
527
+ params.get("datatype")
528
+ ])
529
+ if params.get("info"):
530
+ cargs.append("-info")
531
+ if params.get("quiet"):
532
+ cargs.append("-quiet")
533
+ if params.get("debug"):
534
+ cargs.append("-debug")
535
+ if params.get("force"):
536
+ cargs.append("-force")
537
+ if params.get("nthreads") is not None:
538
+ cargs.extend([
539
+ "-nthreads",
540
+ str(params.get("nthreads"))
541
+ ])
542
+ if params.get("config") is not None:
543
+ cargs.extend([a for c in [dyn_cargs(s["__STYXTYPE__"])(s, execution) for s in params.get("config")] for a in c])
544
+ if params.get("help"):
545
+ cargs.append("-help")
546
+ if params.get("version"):
547
+ cargs.append("-version")
548
+ cargs.append(execution.input_file(params.get("input")))
549
+ cargs.append(params.get("operation"))
550
+ cargs.append(params.get("output"))
551
+ return cargs
552
+
553
+
554
+ def mrgrid_outputs(
555
+ params: MrgridParameters,
556
+ execution: Execution,
557
+ ) -> MrgridOutputs:
558
+ """
559
+ Build outputs object containing output file paths and possibly stdout/stderr.
560
+
561
+ Args:
562
+ params: The parameters.
563
+ execution: The execution object for resolving input paths.
564
+ Returns:
565
+ Outputs object.
566
+ """
567
+ ret = MrgridOutputs(
568
+ root=execution.output_file("."),
569
+ output=execution.output_file(params.get("output")),
570
+ )
571
+ return ret
572
+
573
+
574
+ def mrgrid_execute(
575
+ params: MrgridParameters,
576
+ execution: Execution,
577
+ ) -> MrgridOutputs:
578
+ """
579
+ Modify the grid of an image without interpolation (cropping or padding) or by
580
+ regridding to an image grid with modified orientation, location and or
581
+ resolution. The image content remains in place in real world coordinates..
582
+
583
+ - regrid: This operation performs changes of the voxel grid that require
584
+ interpolation of the image such as changing the resolution or location and
585
+ orientation of the voxel grid. If the image is down-sampled, the appropriate
586
+ smoothing is automatically applied using Gaussian smoothing unless nearest
587
+ neighbour interpolation is selected or oversample is changed explicitly. The
588
+ resolution can only be changed for spatial dimensions.
589
+
590
+ - crop: The image extent after cropping, can be specified either manually
591
+ for each axis dimensions, or via a mask or reference image. The image can be
592
+ cropped to the extent of a mask. This is useful for axially-acquired brain
593
+ images, where the image size can be reduced by a factor of 2 by removing the
594
+ empty space on either side of the brain. Note that cropping does not extend
595
+ the image beyond the original FOV unless explicitly specified (via
596
+ -crop_unbound or negative -axis extent).
597
+
598
+ - pad: Analogously to cropping, padding increases the FOV of an image
599
+ without image interpolation. Pad and crop can be performed simultaneously by
600
+ specifying signed specifier argument values to the -axis option.
601
+
602
+ This command encapsulates and extends the functionality of the superseded
603
+ commands 'mrpad', 'mrcrop' and 'mrresize'. Note the difference in -axis
604
+ convention used for 'mrcrop' and 'mrpad' (see -axis option description).
605
+
606
+ References:
607
+
608
+ .
609
+
610
+ Author: MRTrix3 Developers
611
+
612
+ URL: https://www.mrtrix.org/
613
+
614
+ Args:
615
+ params: The parameters.
616
+ execution: The execution object.
617
+ Returns:
618
+ NamedTuple of outputs (described in `MrgridOutputs`).
619
+ """
620
+ params = execution.params(params)
621
+ cargs = mrgrid_cargs(params, execution)
622
+ ret = mrgrid_outputs(params, execution)
623
+ execution.run(cargs)
624
+ return ret
625
+
626
+
627
+ def mrgrid(
628
+ input_: InputPathType,
629
+ operation: str,
630
+ output: str,
631
+ template: InputPathType | None = None,
632
+ size: list[int] | None = None,
633
+ voxel: list[float] | None = None,
634
+ scale: list[float] | None = None,
635
+ interp: str | None = None,
636
+ oversample: list[int] | None = None,
637
+ as_: InputPathType | None = None,
638
+ uniform: int | None = None,
639
+ mask: InputPathType | None = None,
640
+ crop_unbound: bool = False,
641
+ axis: list[MrgridAxisParameters] | None = None,
642
+ all_axes: bool = False,
643
+ fill: float | None = None,
644
+ strides: typing.Union[MrgridVariousStringParameters, MrgridVariousFileParameters] | None = None,
645
+ datatype: str | None = None,
646
+ info: bool = False,
647
+ quiet: bool = False,
648
+ debug: bool = False,
649
+ force: bool = False,
650
+ nthreads: int | None = None,
651
+ config: list[MrgridConfigParameters] | None = None,
652
+ help_: bool = False,
653
+ version: bool = False,
654
+ runner: Runner | None = None,
655
+ ) -> MrgridOutputs:
656
+ """
657
+ Modify the grid of an image without interpolation (cropping or padding) or by
658
+ regridding to an image grid with modified orientation, location and or
659
+ resolution. The image content remains in place in real world coordinates..
660
+
661
+ - regrid: This operation performs changes of the voxel grid that require
662
+ interpolation of the image such as changing the resolution or location and
663
+ orientation of the voxel grid. If the image is down-sampled, the appropriate
664
+ smoothing is automatically applied using Gaussian smoothing unless nearest
665
+ neighbour interpolation is selected or oversample is changed explicitly. The
666
+ resolution can only be changed for spatial dimensions.
667
+
668
+ - crop: The image extent after cropping, can be specified either manually
669
+ for each axis dimensions, or via a mask or reference image. The image can be
670
+ cropped to the extent of a mask. This is useful for axially-acquired brain
671
+ images, where the image size can be reduced by a factor of 2 by removing the
672
+ empty space on either side of the brain. Note that cropping does not extend
673
+ the image beyond the original FOV unless explicitly specified (via
674
+ -crop_unbound or negative -axis extent).
675
+
676
+ - pad: Analogously to cropping, padding increases the FOV of an image
677
+ without image interpolation. Pad and crop can be performed simultaneously by
678
+ specifying signed specifier argument values to the -axis option.
679
+
680
+ This command encapsulates and extends the functionality of the superseded
681
+ commands 'mrpad', 'mrcrop' and 'mrresize'. Note the difference in -axis
682
+ convention used for 'mrcrop' and 'mrpad' (see -axis option description).
683
+
684
+ References:
685
+
686
+ .
687
+
688
+ Author: MRTrix3 Developers
689
+
690
+ URL: https://www.mrtrix.org/
691
+
692
+ Args:
693
+ input_: input image to be regridded.
694
+ operation: the operation to be performed, one of: regrid, crop, pad.
695
+ output: the output image.
696
+ template: match the input image grid (voxel spacing, image size, header\
697
+ transformation) to that of a reference image. The image resolution\
698
+ relative to the template image can be changed with one of -size,\
699
+ -voxel, -scale.
700
+ size: define the size (number of voxels) in each spatial dimension for\
701
+ the output image. This should be specified as a comma-separated list.
702
+ voxel: define the new voxel size for the output image. This can be\
703
+ specified either as a single value to be used for all spatial\
704
+ dimensions, or as a comma-separated list of the size for each voxel\
705
+ dimension.
706
+ scale: scale the image resolution by the supplied factor. This can be\
707
+ specified either as a single value to be used for all dimensions, or as\
708
+ a comma-separated list of scale factors for each dimension.
709
+ interp: set the interpolation method to use when reslicing (choices:\
710
+ nearest, linear, cubic, sinc. Default: cubic).
711
+ oversample: set the amount of over-sampling (in the target space) to\
712
+ perform when regridding. This is particularly relevant when downsamping\
713
+ a high-resolution image to a low-resolution image, to avoid aliasing\
714
+ artefacts. This can consist of a single integer, or a comma-separated\
715
+ list of 3 integers if different oversampling factors are desired along\
716
+ the different axes. Default is determined from ratio of voxel\
717
+ dimensions (disabled for nearest-neighbour interpolation).
718
+ as_: pad or crop the input image on the upper bound to match the\
719
+ specified reference image grid. This operation ignores differences in\
720
+ image transformation between input and reference image.
721
+ uniform: pad or crop the input image by a uniform number of voxels on\
722
+ all sides.
723
+ mask: crop the input image according to the spatial extent of a mask\
724
+ image. The mask must share a common voxel grid with the input image but\
725
+ differences in image transformations are ignored. Note that even though\
726
+ only 3 dimensions are cropped when using a mask, the bounds are\
727
+ computed by checking the extent for all dimensions. Note that by\
728
+ default a gap of 1 voxel is left at all edges of the image to allow\
729
+ valid trilinear interpolation. This gap can be modified with the\
730
+ -uniform option but by default it does not extend beyond the FOV unless\
731
+ -crop_unbound is used.
732
+ crop_unbound: Allow padding beyond the original FOV when cropping.
733
+ axis: pad or crop the input image along the provided axis (defined by\
734
+ index). The specifier argument defines the number of voxels added or\
735
+ removed on the lower or upper end of the axis (-axis index\
736
+ delta_lower,delta_upper) or acts as a voxel selection range (-axis\
737
+ index start:stop). In both modes, values are relative to the input\
738
+ image (overriding all other extent-specifying options). Negative delta\
739
+ specifier values trigger the inverse operation (pad instead of crop and\
740
+ vice versa) and negative range specifier trigger padding. Note that the\
741
+ deprecated commands 'mrcrop' and 'mrpad' used range-based and\
742
+ delta-based -axis indices, respectively.
743
+ all_axes: Crop or pad all, not just spatial axes.
744
+ fill: Use number as the out of bounds value. nan, inf and -inf are\
745
+ valid arguments. (Default: 0.0).
746
+ strides: specify the strides of the output data in memory; either as a\
747
+ comma-separated list of (signed) integers, or as a template image from\
748
+ which the strides shall be extracted and used. The actual strides\
749
+ produced will depend on whether the output image format can support it.
750
+ datatype: specify output image data type. Valid choices are: float32,\
751
+ float32le, float32be, float64, float64le, float64be, int64, uint64,\
752
+ int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
753
+ int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
754
+ cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
755
+ int8, uint8, bit.
756
+ info: display information messages.
757
+ quiet: do not display information messages or progress status;\
758
+ alternatively, this can be achieved by setting the MRTRIX_QUIET\
759
+ environment variable to a non-empty string.
760
+ debug: display debugging messages.
761
+ force: force overwrite of output files (caution: using the same file as\
762
+ input and output might cause unexpected behaviour).
763
+ nthreads: use this number of threads in multi-threaded applications\
764
+ (set to 0 to disable multi-threading).
765
+ config: temporarily set the value of an MRtrix config file entry.
766
+ help_: display this information page and exit.
767
+ version: display version information and exit.
768
+ runner: Command runner.
769
+ Returns:
770
+ NamedTuple of outputs (described in `MrgridOutputs`).
771
+ """
772
+ runner = runner or get_global_runner()
773
+ execution = runner.start_execution(MRGRID_METADATA)
774
+ params = mrgrid_params(
775
+ template=template,
776
+ size=size,
777
+ voxel=voxel,
778
+ scale=scale,
779
+ interp=interp,
780
+ oversample=oversample,
781
+ as_=as_,
782
+ uniform=uniform,
783
+ mask=mask,
784
+ crop_unbound=crop_unbound,
785
+ axis=axis,
786
+ all_axes=all_axes,
787
+ fill=fill,
788
+ strides=strides,
789
+ datatype=datatype,
790
+ info=info,
791
+ quiet=quiet,
792
+ debug=debug,
793
+ force=force,
794
+ nthreads=nthreads,
795
+ config=config,
796
+ help_=help_,
797
+ version=version,
798
+ input_=input_,
799
+ operation=operation,
800
+ output=output,
801
+ )
802
+ return mrgrid_execute(params, execution)
803
+
804
+
805
+ __all__ = [
806
+ "MRGRID_METADATA",
807
+ "MrgridAxisParameters",
808
+ "MrgridConfigParameters",
809
+ "MrgridOutputs",
810
+ "MrgridParameters",
811
+ "MrgridVariousFileParameters",
812
+ "MrgridVariousStringParameters",
813
+ "mrgrid",
814
+ "mrgrid_axis_params",
815
+ "mrgrid_config_params",
816
+ "mrgrid_params",
817
+ "mrgrid_various_file_params",
818
+ "mrgrid_various_string_params",
819
+ ]