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.
- niwrap_mrtrix/mrtrix/__init__.py +263 -0
- niwrap_mrtrix/mrtrix/afdconnectivity.py +527 -0
- niwrap_mrtrix/mrtrix/amp2response.py +560 -0
- niwrap_mrtrix/mrtrix/amp2sh.py +870 -0
- niwrap_mrtrix/mrtrix/connectome2tck.py +583 -0
- niwrap_mrtrix/mrtrix/connectomeedit.py +413 -0
- niwrap_mrtrix/mrtrix/connectomestats.py +956 -0
- niwrap_mrtrix/mrtrix/dcmedit.py +552 -0
- niwrap_mrtrix/mrtrix/dcminfo.py +529 -0
- niwrap_mrtrix/mrtrix/dirflip.py +440 -0
- niwrap_mrtrix/mrtrix/dirgen.py +514 -0
- niwrap_mrtrix/mrtrix/dirmerge.py +446 -0
- niwrap_mrtrix/mrtrix/dirorder.py +421 -0
- niwrap_mrtrix/mrtrix/dirsplit.py +436 -0
- niwrap_mrtrix/mrtrix/dirstat.py +640 -0
- niwrap_mrtrix/mrtrix/dwi2adc.py +531 -0
- niwrap_mrtrix/mrtrix/dwi2fod.py +1156 -0
- niwrap_mrtrix/mrtrix/dwi2mask.py +570 -0
- niwrap_mrtrix/mrtrix/dwi2response.py +1774 -0
- niwrap_mrtrix/mrtrix/dwi2tensor.py +715 -0
- niwrap_mrtrix/mrtrix/dwibiascorrect.py +673 -0
- niwrap_mrtrix/mrtrix/dwidenoise.py +570 -0
- niwrap_mrtrix/mrtrix/dwiextract.py +1111 -0
- niwrap_mrtrix/mrtrix/dwigradcheck.py +665 -0
- niwrap_mrtrix/mrtrix/fixel2peaks.py +613 -0
- niwrap_mrtrix/mrtrix/fixel2sh.py +430 -0
- niwrap_mrtrix/mrtrix/fixel2tsf.py +435 -0
- niwrap_mrtrix/mrtrix/fixel2voxel.py +523 -0
- niwrap_mrtrix/mrtrix/fixelcfestats.py +1179 -0
- niwrap_mrtrix/mrtrix/fixelconnectivity.py +477 -0
- niwrap_mrtrix/mrtrix/fixelconvert.py +850 -0
- niwrap_mrtrix/mrtrix/fixelcorrespondence.py +455 -0
- niwrap_mrtrix/mrtrix/fixelcrop.py +422 -0
- niwrap_mrtrix/mrtrix/fixelfilter.py +882 -0
- niwrap_mrtrix/mrtrix/fixelreorient.py +435 -0
- niwrap_mrtrix/mrtrix/fod2dec.py +571 -0
- niwrap_mrtrix/mrtrix/fod2fixel.py +646 -0
- niwrap_mrtrix/mrtrix/label2colour.py +426 -0
- niwrap_mrtrix/mrtrix/label2mesh.py +417 -0
- niwrap_mrtrix/mrtrix/labelconvert.py +460 -0
- niwrap_mrtrix/mrtrix/labelstats.py +418 -0
- niwrap_mrtrix/mrtrix/maskdump.py +404 -0
- niwrap_mrtrix/mrtrix/maskfilter.py +730 -0
- niwrap_mrtrix/mrtrix/mesh2voxel.py +422 -0
- niwrap_mrtrix/mrtrix/meshconvert.py +514 -0
- niwrap_mrtrix/mrtrix/meshfilter.py +452 -0
- niwrap_mrtrix/mrtrix/mraverageheader.py +485 -0
- niwrap_mrtrix/mrtrix/mrcalc.py +4302 -0
- niwrap_mrtrix/mrtrix/mrcat.py +467 -0
- niwrap_mrtrix/mrtrix/mrcentroid.py +418 -0
- niwrap_mrtrix/mrtrix/mrcheckerboardmask.py +446 -0
- niwrap_mrtrix/mrtrix/mrclusterstats.py +930 -0
- niwrap_mrtrix/mrtrix/mrcolour.py +490 -0
- niwrap_mrtrix/mrtrix/mrconvert.py +1967 -0
- niwrap_mrtrix/mrtrix/mrdegibbs.py +535 -0
- niwrap_mrtrix/mrtrix/mrdump.py +423 -0
- niwrap_mrtrix/mrtrix/mredit.py +737 -0
- niwrap_mrtrix/mrtrix/mrfilter.py +971 -0
- niwrap_mrtrix/mrtrix/mrgrid.py +1079 -0
- niwrap_mrtrix/mrtrix/mrhistmatch.py +494 -0
- niwrap_mrtrix/mrtrix/mrhistogram.py +484 -0
- niwrap_mrtrix/mrtrix/mrinfo.py +1282 -0
- niwrap_mrtrix/mrtrix/mrmath.py +503 -0
- niwrap_mrtrix/mrtrix/mrmetric.py +525 -0
- niwrap_mrtrix/mrtrix/mrregister.py +2098 -0
- niwrap_mrtrix/mrtrix/mrstats.py +534 -0
- niwrap_mrtrix/mrtrix/mrthreshold.py +666 -0
- niwrap_mrtrix/mrtrix/mrtransform.py +1372 -0
- niwrap_mrtrix/mrtrix/mtnormalise.py +725 -0
- niwrap_mrtrix/mrtrix/peaks2amp.py +403 -0
- niwrap_mrtrix/mrtrix/peaks2fixel.py +422 -0
- niwrap_mrtrix/mrtrix/responsemean.py +385 -0
- niwrap_mrtrix/mrtrix/sh2amp.py +844 -0
- niwrap_mrtrix/mrtrix/sh2peaks.py +632 -0
- niwrap_mrtrix/mrtrix/sh2power.py +427 -0
- niwrap_mrtrix/mrtrix/sh2response.py +481 -0
- niwrap_mrtrix/mrtrix/shbasis.py +445 -0
- niwrap_mrtrix/mrtrix/shconv.py +661 -0
- niwrap_mrtrix/mrtrix/tck2connectome.py +727 -0
- niwrap_mrtrix/mrtrix/tck2fixel.py +447 -0
- niwrap_mrtrix/mrtrix/tckconvert.py +775 -0
- niwrap_mrtrix/mrtrix/tckdfc.py +684 -0
- niwrap_mrtrix/mrtrix/tckedit.py +1478 -0
- niwrap_mrtrix/mrtrix/tckgen.py +2733 -0
- niwrap_mrtrix/mrtrix/tckglobal.py +944 -0
- niwrap_mrtrix/mrtrix/tckinfo.py +402 -0
- niwrap_mrtrix/mrtrix/tckmap.py +1004 -0
- niwrap_mrtrix/mrtrix/tckresample.py +760 -0
- niwrap_mrtrix/mrtrix/tcksample.py +497 -0
- niwrap_mrtrix/mrtrix/tcksift.py +739 -0
- niwrap_mrtrix/mrtrix/tcksift2.py +902 -0
- niwrap_mrtrix/mrtrix/tckstats.py +550 -0
- niwrap_mrtrix/mrtrix/tcktransform.py +414 -0
- niwrap_mrtrix/mrtrix/tensor2metric.py +659 -0
- niwrap_mrtrix/mrtrix/transformcalc.py +421 -0
- niwrap_mrtrix/mrtrix/transformcompose.py +625 -0
- niwrap_mrtrix/mrtrix/transformconvert.py +423 -0
- niwrap_mrtrix/mrtrix/tsfdivide.py +414 -0
- niwrap_mrtrix/mrtrix/tsfinfo.py +421 -0
- niwrap_mrtrix/mrtrix/tsfmult.py +401 -0
- niwrap_mrtrix/mrtrix/tsfsmooth.py +420 -0
- niwrap_mrtrix/mrtrix/tsfthreshold.py +428 -0
- niwrap_mrtrix/mrtrix/tsfvalidate.py +398 -0
- niwrap_mrtrix/mrtrix/v_5tt2gmwmi.py +432 -0
- niwrap_mrtrix/mrtrix/v_5tt2vis.py +505 -0
- niwrap_mrtrix/mrtrix/v_5ttcheck.py +409 -0
- niwrap_mrtrix/mrtrix/v_5ttedit.py +513 -0
- niwrap_mrtrix/mrtrix/v_5ttgen.py +1107 -0
- niwrap_mrtrix/mrtrix/vectorstats.py +736 -0
- niwrap_mrtrix/mrtrix/voxel2fixel.py +430 -0
- niwrap_mrtrix/mrtrix/voxel2mesh.py +454 -0
- niwrap_mrtrix/mrtrix/warp2metric.py +556 -0
- niwrap_mrtrix/mrtrix/warpconvert.py +498 -0
- niwrap_mrtrix/mrtrix/warpcorrect.py +448 -0
- niwrap_mrtrix/mrtrix/warpinit.py +425 -0
- niwrap_mrtrix/mrtrix/warpinvert.py +448 -0
- niwrap_mrtrix-0.8.0.dist-info/METADATA +8 -0
- niwrap_mrtrix-0.8.0.dist-info/RECORD +119 -0
- niwrap_mrtrix-0.8.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,661 @@
|
|
|
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
|
+
SHCONV_METADATA = Metadata(
|
|
9
|
+
id="b17c6209ec80f04a818c3feb05bf3e7580772b75.boutiques",
|
|
10
|
+
name="shconv",
|
|
11
|
+
package="mrtrix",
|
|
12
|
+
container_image_tag="mrtrix3/mrtrix3:3.0.4",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
_ShconvVariousStringParamsDictNoTag = typing.TypedDict('_ShconvVariousStringParamsDictNoTag', {
|
|
17
|
+
"obj": str,
|
|
18
|
+
})
|
|
19
|
+
ShconvVariousStringParamsDictTagged = typing.TypedDict('ShconvVariousStringParamsDictTagged', {
|
|
20
|
+
"@type": typing.Literal["VariousString"],
|
|
21
|
+
"obj": str,
|
|
22
|
+
})
|
|
23
|
+
ShconvVariousStringParamsDict = _ShconvVariousStringParamsDictNoTag | ShconvVariousStringParamsDictTagged
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
_ShconvVariousFileParamsDictNoTag = typing.TypedDict('_ShconvVariousFileParamsDictNoTag', {
|
|
27
|
+
"obj": InputPathType,
|
|
28
|
+
})
|
|
29
|
+
ShconvVariousFileParamsDictTagged = typing.TypedDict('ShconvVariousFileParamsDictTagged', {
|
|
30
|
+
"@type": typing.Literal["VariousFile"],
|
|
31
|
+
"obj": InputPathType,
|
|
32
|
+
})
|
|
33
|
+
ShconvVariousFileParamsDict = _ShconvVariousFileParamsDictNoTag | ShconvVariousFileParamsDictTagged
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
_ShconvConfigParamsDictNoTag = typing.TypedDict('_ShconvConfigParamsDictNoTag', {
|
|
37
|
+
"key": str,
|
|
38
|
+
"value": str,
|
|
39
|
+
})
|
|
40
|
+
ShconvConfigParamsDictTagged = typing.TypedDict('ShconvConfigParamsDictTagged', {
|
|
41
|
+
"@type": typing.Literal["config"],
|
|
42
|
+
"key": str,
|
|
43
|
+
"value": str,
|
|
44
|
+
})
|
|
45
|
+
ShconvConfigParamsDict = _ShconvConfigParamsDictNoTag | ShconvConfigParamsDictTagged
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
_ShconvParamsDictNoTag = typing.TypedDict('_ShconvParamsDictNoTag', {
|
|
49
|
+
"datatype": typing.NotRequired[str | None],
|
|
50
|
+
"strides": typing.NotRequired[typing.Union[ShconvVariousStringParamsDictTagged, ShconvVariousFileParamsDictTagged] | None],
|
|
51
|
+
"info": bool,
|
|
52
|
+
"quiet": bool,
|
|
53
|
+
"debug": bool,
|
|
54
|
+
"force": bool,
|
|
55
|
+
"nthreads": typing.NotRequired[int | None],
|
|
56
|
+
"config": typing.NotRequired[list[ShconvConfigParamsDict] | None],
|
|
57
|
+
"help": bool,
|
|
58
|
+
"version": bool,
|
|
59
|
+
"odf_response": list[str],
|
|
60
|
+
"SH_out": str,
|
|
61
|
+
})
|
|
62
|
+
ShconvParamsDictTagged = typing.TypedDict('ShconvParamsDictTagged', {
|
|
63
|
+
"@type": typing.Literal["mrtrix/shconv"],
|
|
64
|
+
"datatype": typing.NotRequired[str | None],
|
|
65
|
+
"strides": typing.NotRequired[typing.Union[ShconvVariousStringParamsDictTagged, ShconvVariousFileParamsDictTagged] | None],
|
|
66
|
+
"info": bool,
|
|
67
|
+
"quiet": bool,
|
|
68
|
+
"debug": bool,
|
|
69
|
+
"force": bool,
|
|
70
|
+
"nthreads": typing.NotRequired[int | None],
|
|
71
|
+
"config": typing.NotRequired[list[ShconvConfigParamsDict] | None],
|
|
72
|
+
"help": bool,
|
|
73
|
+
"version": bool,
|
|
74
|
+
"odf_response": list[str],
|
|
75
|
+
"SH_out": str,
|
|
76
|
+
})
|
|
77
|
+
ShconvParamsDict = _ShconvParamsDictNoTag | ShconvParamsDictTagged
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def shconv_strides_cargs_dyn_fn(
|
|
81
|
+
t: str,
|
|
82
|
+
) -> typing.Any:
|
|
83
|
+
"""
|
|
84
|
+
Get build cargs function by command type.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
t: Command type.
|
|
88
|
+
Returns:
|
|
89
|
+
Build cargs function.
|
|
90
|
+
"""
|
|
91
|
+
return {
|
|
92
|
+
"VariousString": shconv_various_string_cargs,
|
|
93
|
+
"VariousFile": shconv_various_file_cargs,
|
|
94
|
+
}.get(t)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def shconv_strides_validate_dyn_fn(
|
|
98
|
+
t: str,
|
|
99
|
+
) -> typing.Any:
|
|
100
|
+
"""
|
|
101
|
+
Get validate params function by command type.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
t: Command type.
|
|
105
|
+
Returns:
|
|
106
|
+
Validate params function.
|
|
107
|
+
"""
|
|
108
|
+
return {
|
|
109
|
+
"VariousString": shconv_various_string_validate,
|
|
110
|
+
"VariousFile": shconv_various_file_validate,
|
|
111
|
+
}.get(t)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def shconv_various_string(
|
|
115
|
+
obj: str,
|
|
116
|
+
) -> ShconvVariousStringParamsDictTagged:
|
|
117
|
+
"""
|
|
118
|
+
Build parameters.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
obj: String object.
|
|
122
|
+
Returns:
|
|
123
|
+
Parameter dictionary
|
|
124
|
+
"""
|
|
125
|
+
params = {
|
|
126
|
+
"@type": "VariousString",
|
|
127
|
+
"obj": obj,
|
|
128
|
+
}
|
|
129
|
+
return params
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def shconv_various_string_validate(
|
|
133
|
+
params: typing.Any,
|
|
134
|
+
) -> None:
|
|
135
|
+
"""
|
|
136
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
137
|
+
`ShconvVariousStringParamsDict` object.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
params: The parameters object to validate.
|
|
141
|
+
"""
|
|
142
|
+
if params is None or not isinstance(params, dict):
|
|
143
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
144
|
+
if params.get("obj", None) is None:
|
|
145
|
+
raise StyxValidationError("`obj` must not be None")
|
|
146
|
+
if not isinstance(params["obj"], str):
|
|
147
|
+
raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `str`')
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def shconv_various_string_cargs(
|
|
151
|
+
params: ShconvVariousStringParamsDict,
|
|
152
|
+
execution: Execution,
|
|
153
|
+
) -> list[str]:
|
|
154
|
+
"""
|
|
155
|
+
Build command-line arguments from parameters.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
params: The parameters.
|
|
159
|
+
execution: The execution object for resolving input paths.
|
|
160
|
+
Returns:
|
|
161
|
+
Command-line arguments.
|
|
162
|
+
"""
|
|
163
|
+
cargs = []
|
|
164
|
+
cargs.append(params.get("obj", None))
|
|
165
|
+
return cargs
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def shconv_various_file(
|
|
169
|
+
obj: InputPathType,
|
|
170
|
+
) -> ShconvVariousFileParamsDictTagged:
|
|
171
|
+
"""
|
|
172
|
+
Build parameters.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
obj: File object.
|
|
176
|
+
Returns:
|
|
177
|
+
Parameter dictionary
|
|
178
|
+
"""
|
|
179
|
+
params = {
|
|
180
|
+
"@type": "VariousFile",
|
|
181
|
+
"obj": obj,
|
|
182
|
+
}
|
|
183
|
+
return params
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def shconv_various_file_validate(
|
|
187
|
+
params: typing.Any,
|
|
188
|
+
) -> None:
|
|
189
|
+
"""
|
|
190
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
191
|
+
`ShconvVariousFileParamsDict` object.
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
params: The parameters object to validate.
|
|
195
|
+
"""
|
|
196
|
+
if params is None or not isinstance(params, dict):
|
|
197
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
198
|
+
if params.get("obj", None) is None:
|
|
199
|
+
raise StyxValidationError("`obj` must not be None")
|
|
200
|
+
if not isinstance(params["obj"], (pathlib.Path, str)):
|
|
201
|
+
raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `InputPathType`')
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def shconv_various_file_cargs(
|
|
205
|
+
params: ShconvVariousFileParamsDict,
|
|
206
|
+
execution: Execution,
|
|
207
|
+
) -> list[str]:
|
|
208
|
+
"""
|
|
209
|
+
Build command-line arguments from parameters.
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
params: The parameters.
|
|
213
|
+
execution: The execution object for resolving input paths.
|
|
214
|
+
Returns:
|
|
215
|
+
Command-line arguments.
|
|
216
|
+
"""
|
|
217
|
+
cargs = []
|
|
218
|
+
cargs.append(execution.input_file(params.get("obj", None)))
|
|
219
|
+
return cargs
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def shconv_config(
|
|
223
|
+
key: str,
|
|
224
|
+
value: str,
|
|
225
|
+
) -> ShconvConfigParamsDictTagged:
|
|
226
|
+
"""
|
|
227
|
+
Build parameters.
|
|
228
|
+
|
|
229
|
+
Args:
|
|
230
|
+
key: temporarily set the value of an MRtrix config file entry.
|
|
231
|
+
value: temporarily set the value of an MRtrix config file entry.
|
|
232
|
+
Returns:
|
|
233
|
+
Parameter dictionary
|
|
234
|
+
"""
|
|
235
|
+
params = {
|
|
236
|
+
"@type": "config",
|
|
237
|
+
"key": key,
|
|
238
|
+
"value": value,
|
|
239
|
+
}
|
|
240
|
+
return params
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def shconv_config_validate(
|
|
244
|
+
params: typing.Any,
|
|
245
|
+
) -> None:
|
|
246
|
+
"""
|
|
247
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
248
|
+
`ShconvConfigParamsDict` object.
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
params: The parameters object to validate.
|
|
252
|
+
"""
|
|
253
|
+
if params is None or not isinstance(params, dict):
|
|
254
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
255
|
+
if params.get("key", None) is None:
|
|
256
|
+
raise StyxValidationError("`key` must not be None")
|
|
257
|
+
if not isinstance(params["key"], str):
|
|
258
|
+
raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
|
|
259
|
+
if params.get("value", None) is None:
|
|
260
|
+
raise StyxValidationError("`value` must not be None")
|
|
261
|
+
if not isinstance(params["value"], str):
|
|
262
|
+
raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def shconv_config_cargs(
|
|
266
|
+
params: ShconvConfigParamsDict,
|
|
267
|
+
execution: Execution,
|
|
268
|
+
) -> list[str]:
|
|
269
|
+
"""
|
|
270
|
+
Build command-line arguments from parameters.
|
|
271
|
+
|
|
272
|
+
Args:
|
|
273
|
+
params: The parameters.
|
|
274
|
+
execution: The execution object for resolving input paths.
|
|
275
|
+
Returns:
|
|
276
|
+
Command-line arguments.
|
|
277
|
+
"""
|
|
278
|
+
cargs = []
|
|
279
|
+
cargs.append("-config")
|
|
280
|
+
cargs.append(params.get("key", None))
|
|
281
|
+
cargs.append(params.get("value", None))
|
|
282
|
+
return cargs
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
class ShconvOutputs(typing.NamedTuple):
|
|
286
|
+
"""
|
|
287
|
+
Output object returned when calling `ShconvParamsDict(...)`.
|
|
288
|
+
"""
|
|
289
|
+
root: OutputPathType
|
|
290
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
291
|
+
sh_out: OutputPathType
|
|
292
|
+
"""the output spherical harmonics coefficients image."""
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def shconv_params(
|
|
296
|
+
odf_response: list[str],
|
|
297
|
+
sh_out: str,
|
|
298
|
+
datatype: str | None = None,
|
|
299
|
+
strides: typing.Union[ShconvVariousStringParamsDictTagged, ShconvVariousFileParamsDictTagged] | None = None,
|
|
300
|
+
info: bool = False,
|
|
301
|
+
quiet: bool = False,
|
|
302
|
+
debug: bool = False,
|
|
303
|
+
force: bool = False,
|
|
304
|
+
nthreads: int | None = None,
|
|
305
|
+
config: list[ShconvConfigParamsDict] | None = None,
|
|
306
|
+
help_: bool = False,
|
|
307
|
+
version: bool = False,
|
|
308
|
+
) -> ShconvParamsDictTagged:
|
|
309
|
+
"""
|
|
310
|
+
Build parameters.
|
|
311
|
+
|
|
312
|
+
Args:
|
|
313
|
+
odf_response: pairs of input ODF image and corresponding responses.
|
|
314
|
+
sh_out: the output spherical harmonics coefficients image.
|
|
315
|
+
datatype: specify output image data type. Valid choices are: float32,\
|
|
316
|
+
float32le, float32be, float64, float64le, float64be, int64, uint64,\
|
|
317
|
+
int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
|
|
318
|
+
int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
|
|
319
|
+
cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
|
|
320
|
+
int8, uint8, bit.
|
|
321
|
+
strides: specify the strides of the output data in memory; either as a\
|
|
322
|
+
comma-separated list of (signed) integers, or as a template image from\
|
|
323
|
+
which the strides shall be extracted and used. The actual strides\
|
|
324
|
+
produced will depend on whether the output image format can support it.
|
|
325
|
+
info: display information messages.
|
|
326
|
+
quiet: do not display information messages or progress status;\
|
|
327
|
+
alternatively, this can be achieved by setting the MRTRIX_QUIET\
|
|
328
|
+
environment variable to a non-empty string.
|
|
329
|
+
debug: display debugging messages.
|
|
330
|
+
force: force overwrite of output files (caution: using the same file as\
|
|
331
|
+
input and output might cause unexpected behaviour).
|
|
332
|
+
nthreads: use this number of threads in multi-threaded applications\
|
|
333
|
+
(set to 0 to disable multi-threading).
|
|
334
|
+
config: temporarily set the value of an MRtrix config file entry.
|
|
335
|
+
help_: display this information page and exit.
|
|
336
|
+
version: display version information and exit.
|
|
337
|
+
Returns:
|
|
338
|
+
Parameter dictionary
|
|
339
|
+
"""
|
|
340
|
+
params = {
|
|
341
|
+
"@type": "mrtrix/shconv",
|
|
342
|
+
"info": info,
|
|
343
|
+
"quiet": quiet,
|
|
344
|
+
"debug": debug,
|
|
345
|
+
"force": force,
|
|
346
|
+
"help": help_,
|
|
347
|
+
"version": version,
|
|
348
|
+
"odf_response": odf_response,
|
|
349
|
+
"SH_out": sh_out,
|
|
350
|
+
}
|
|
351
|
+
if datatype is not None:
|
|
352
|
+
params["datatype"] = datatype
|
|
353
|
+
if strides is not None:
|
|
354
|
+
params["strides"] = strides
|
|
355
|
+
if nthreads is not None:
|
|
356
|
+
params["nthreads"] = nthreads
|
|
357
|
+
if config is not None:
|
|
358
|
+
params["config"] = config
|
|
359
|
+
return params
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
def shconv_validate(
|
|
363
|
+
params: typing.Any,
|
|
364
|
+
) -> None:
|
|
365
|
+
"""
|
|
366
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
367
|
+
`ShconvParamsDict` object.
|
|
368
|
+
|
|
369
|
+
Args:
|
|
370
|
+
params: The parameters object to validate.
|
|
371
|
+
"""
|
|
372
|
+
if params is None or not isinstance(params, dict):
|
|
373
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
374
|
+
if params.get("datatype", None) is not None:
|
|
375
|
+
if not isinstance(params["datatype"], str):
|
|
376
|
+
raise StyxValidationError(f'`datatype` has the wrong type: Received `{type(params.get("datatype", None))}` expected `str | None`')
|
|
377
|
+
if params.get("strides", None) is not None:
|
|
378
|
+
if not isinstance(params["strides"], dict):
|
|
379
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params["strides"])}\'')
|
|
380
|
+
if "@type" not in params["strides"]:
|
|
381
|
+
raise StyxValidationError("Params object is missing `@type`")
|
|
382
|
+
if params["strides"]["@type"] not in ["VariousString", "VariousFile"]:
|
|
383
|
+
raise StyxValidationError("Parameter `strides`s `@type` must be one of [\"VariousString\", \"VariousFile\"]")
|
|
384
|
+
shconv_strides_validate_dyn_fn(params["strides"]["@type"])(params["strides"])
|
|
385
|
+
if params.get("info", False) is None:
|
|
386
|
+
raise StyxValidationError("`info` must not be None")
|
|
387
|
+
if not isinstance(params["info"], bool):
|
|
388
|
+
raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
|
|
389
|
+
if params.get("quiet", False) is None:
|
|
390
|
+
raise StyxValidationError("`quiet` must not be None")
|
|
391
|
+
if not isinstance(params["quiet"], bool):
|
|
392
|
+
raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
|
|
393
|
+
if params.get("debug", False) is None:
|
|
394
|
+
raise StyxValidationError("`debug` must not be None")
|
|
395
|
+
if not isinstance(params["debug"], bool):
|
|
396
|
+
raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
|
|
397
|
+
if params.get("force", False) is None:
|
|
398
|
+
raise StyxValidationError("`force` must not be None")
|
|
399
|
+
if not isinstance(params["force"], bool):
|
|
400
|
+
raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
|
|
401
|
+
if params.get("nthreads", None) is not None:
|
|
402
|
+
if not isinstance(params["nthreads"], int):
|
|
403
|
+
raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
|
|
404
|
+
if params.get("config", None) is not None:
|
|
405
|
+
if not isinstance(params["config"], list):
|
|
406
|
+
raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[ShconvConfigParamsDict] | None`')
|
|
407
|
+
for e in params["config"]:
|
|
408
|
+
shconv_config_validate(e)
|
|
409
|
+
if params.get("help", False) is None:
|
|
410
|
+
raise StyxValidationError("`help` must not be None")
|
|
411
|
+
if not isinstance(params["help"], bool):
|
|
412
|
+
raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
|
|
413
|
+
if params.get("version", False) is None:
|
|
414
|
+
raise StyxValidationError("`version` must not be None")
|
|
415
|
+
if not isinstance(params["version"], bool):
|
|
416
|
+
raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
|
|
417
|
+
if params.get("odf_response", None) is None:
|
|
418
|
+
raise StyxValidationError("`odf_response` must not be None")
|
|
419
|
+
if not isinstance(params["odf_response"], list):
|
|
420
|
+
raise StyxValidationError(f'`odf_response` has the wrong type: Received `{type(params.get("odf_response", None))}` expected `list[str]`')
|
|
421
|
+
for e in params["odf_response"]:
|
|
422
|
+
if not isinstance(e, str):
|
|
423
|
+
raise StyxValidationError(f'`odf_response` has the wrong type: Received `{type(params.get("odf_response", None))}` expected `list[str]`')
|
|
424
|
+
if params.get("SH_out", None) is None:
|
|
425
|
+
raise StyxValidationError("`SH_out` must not be None")
|
|
426
|
+
if not isinstance(params["SH_out"], str):
|
|
427
|
+
raise StyxValidationError(f'`SH_out` has the wrong type: Received `{type(params.get("SH_out", None))}` expected `str`')
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
def shconv_cargs(
|
|
431
|
+
params: ShconvParamsDict,
|
|
432
|
+
execution: Execution,
|
|
433
|
+
) -> list[str]:
|
|
434
|
+
"""
|
|
435
|
+
Build command-line arguments from parameters.
|
|
436
|
+
|
|
437
|
+
Args:
|
|
438
|
+
params: The parameters.
|
|
439
|
+
execution: The execution object for resolving input paths.
|
|
440
|
+
Returns:
|
|
441
|
+
Command-line arguments.
|
|
442
|
+
"""
|
|
443
|
+
cargs = []
|
|
444
|
+
cargs.append("shconv")
|
|
445
|
+
if params.get("datatype", None) is not None:
|
|
446
|
+
cargs.extend([
|
|
447
|
+
"-datatype",
|
|
448
|
+
params.get("datatype", None)
|
|
449
|
+
])
|
|
450
|
+
if params.get("strides", None) is not None:
|
|
451
|
+
cargs.extend([
|
|
452
|
+
"-strides",
|
|
453
|
+
*shconv_strides_cargs_dyn_fn(params.get("strides", None)["@type"])(params.get("strides", None), execution)
|
|
454
|
+
])
|
|
455
|
+
if params.get("info", False):
|
|
456
|
+
cargs.append("-info")
|
|
457
|
+
if params.get("quiet", False):
|
|
458
|
+
cargs.append("-quiet")
|
|
459
|
+
if params.get("debug", False):
|
|
460
|
+
cargs.append("-debug")
|
|
461
|
+
if params.get("force", False):
|
|
462
|
+
cargs.append("-force")
|
|
463
|
+
if params.get("nthreads", None) is not None:
|
|
464
|
+
cargs.extend([
|
|
465
|
+
"-nthreads",
|
|
466
|
+
str(params.get("nthreads", None))
|
|
467
|
+
])
|
|
468
|
+
if params.get("config", None) is not None:
|
|
469
|
+
cargs.extend([a for c in [shconv_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
|
|
470
|
+
if params.get("help", False):
|
|
471
|
+
cargs.append("-help")
|
|
472
|
+
if params.get("version", False):
|
|
473
|
+
cargs.append("-version")
|
|
474
|
+
cargs.extend(params.get("odf_response", None))
|
|
475
|
+
cargs.append(params.get("SH_out", None))
|
|
476
|
+
return cargs
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
def shconv_outputs(
|
|
480
|
+
params: ShconvParamsDict,
|
|
481
|
+
execution: Execution,
|
|
482
|
+
) -> ShconvOutputs:
|
|
483
|
+
"""
|
|
484
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
485
|
+
|
|
486
|
+
Args:
|
|
487
|
+
params: The parameters.
|
|
488
|
+
execution: The execution object for resolving input paths.
|
|
489
|
+
Returns:
|
|
490
|
+
Outputs object.
|
|
491
|
+
"""
|
|
492
|
+
ret = ShconvOutputs(
|
|
493
|
+
root=execution.output_file("."),
|
|
494
|
+
sh_out=execution.output_file(params.get("SH_out", None)),
|
|
495
|
+
)
|
|
496
|
+
return ret
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
def shconv_execute(
|
|
500
|
+
params: ShconvParamsDict,
|
|
501
|
+
runner: Runner | None = None,
|
|
502
|
+
) -> ShconvOutputs:
|
|
503
|
+
"""
|
|
504
|
+
shconv
|
|
505
|
+
|
|
506
|
+
Perform spherical convolution.
|
|
507
|
+
|
|
508
|
+
Provided with matching pairs of response function and ODF images (containing
|
|
509
|
+
SH coefficients), perform spherical convolution to provide the corresponding
|
|
510
|
+
SH coefficients of the signal.
|
|
511
|
+
|
|
512
|
+
If multiple pairs of inputs are provided, their contributions will be summed
|
|
513
|
+
into a single output.
|
|
514
|
+
|
|
515
|
+
If the responses are multi-shell (with one line of coefficients per shell),
|
|
516
|
+
the output will be a 5-dimensional image, with the SH coefficients of the
|
|
517
|
+
signal in each shell stored at different indices along the 5th dimension.
|
|
518
|
+
|
|
519
|
+
The spherical harmonic coefficients are stored according the conventions
|
|
520
|
+
described the main documentation, which can be found at the following link:
|
|
521
|
+
https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
|
|
522
|
+
|
|
523
|
+
The spherical harmonic coefficients are stored according the conventions
|
|
524
|
+
described the main documentation, which can be found at the following link:
|
|
525
|
+
https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
|
|
526
|
+
|
|
527
|
+
References:
|
|
528
|
+
|
|
529
|
+
.
|
|
530
|
+
|
|
531
|
+
Author: MRTrix3 Developers
|
|
532
|
+
|
|
533
|
+
URL: https://www.mrtrix.org/
|
|
534
|
+
|
|
535
|
+
Args:
|
|
536
|
+
params: The parameters.
|
|
537
|
+
runner: Command runner.
|
|
538
|
+
Returns:
|
|
539
|
+
NamedTuple of outputs (described in `ShconvOutputs`).
|
|
540
|
+
"""
|
|
541
|
+
shconv_validate(params)
|
|
542
|
+
runner = runner or get_global_runner()
|
|
543
|
+
execution = runner.start_execution(SHCONV_METADATA)
|
|
544
|
+
params = execution.params(params)
|
|
545
|
+
cargs = shconv_cargs(params, execution)
|
|
546
|
+
ret = shconv_outputs(params, execution)
|
|
547
|
+
execution.run(cargs)
|
|
548
|
+
return ret
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
def shconv(
|
|
552
|
+
odf_response: list[str],
|
|
553
|
+
sh_out: str,
|
|
554
|
+
datatype: str | None = None,
|
|
555
|
+
strides: typing.Union[ShconvVariousStringParamsDictTagged, ShconvVariousFileParamsDictTagged] | None = None,
|
|
556
|
+
info: bool = False,
|
|
557
|
+
quiet: bool = False,
|
|
558
|
+
debug: bool = False,
|
|
559
|
+
force: bool = False,
|
|
560
|
+
nthreads: int | None = None,
|
|
561
|
+
config: list[ShconvConfigParamsDict] | None = None,
|
|
562
|
+
help_: bool = False,
|
|
563
|
+
version: bool = False,
|
|
564
|
+
runner: Runner | None = None,
|
|
565
|
+
) -> ShconvOutputs:
|
|
566
|
+
"""
|
|
567
|
+
shconv
|
|
568
|
+
|
|
569
|
+
Perform spherical convolution.
|
|
570
|
+
|
|
571
|
+
Provided with matching pairs of response function and ODF images (containing
|
|
572
|
+
SH coefficients), perform spherical convolution to provide the corresponding
|
|
573
|
+
SH coefficients of the signal.
|
|
574
|
+
|
|
575
|
+
If multiple pairs of inputs are provided, their contributions will be summed
|
|
576
|
+
into a single output.
|
|
577
|
+
|
|
578
|
+
If the responses are multi-shell (with one line of coefficients per shell),
|
|
579
|
+
the output will be a 5-dimensional image, with the SH coefficients of the
|
|
580
|
+
signal in each shell stored at different indices along the 5th dimension.
|
|
581
|
+
|
|
582
|
+
The spherical harmonic coefficients are stored according the conventions
|
|
583
|
+
described the main documentation, which can be found at the following link:
|
|
584
|
+
https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
|
|
585
|
+
|
|
586
|
+
The spherical harmonic coefficients are stored according the conventions
|
|
587
|
+
described the main documentation, which can be found at the following link:
|
|
588
|
+
https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
|
|
589
|
+
|
|
590
|
+
References:
|
|
591
|
+
|
|
592
|
+
.
|
|
593
|
+
|
|
594
|
+
Author: MRTrix3 Developers
|
|
595
|
+
|
|
596
|
+
URL: https://www.mrtrix.org/
|
|
597
|
+
|
|
598
|
+
Args:
|
|
599
|
+
odf_response: pairs of input ODF image and corresponding responses.
|
|
600
|
+
sh_out: the output spherical harmonics coefficients image.
|
|
601
|
+
datatype: specify output image data type. Valid choices are: float32,\
|
|
602
|
+
float32le, float32be, float64, float64le, float64be, int64, uint64,\
|
|
603
|
+
int64le, uint64le, int64be, uint64be, int32, uint32, int32le, uint32le,\
|
|
604
|
+
int32be, uint32be, int16, uint16, int16le, uint16le, int16be, uint16be,\
|
|
605
|
+
cfloat32, cfloat32le, cfloat32be, cfloat64, cfloat64le, cfloat64be,\
|
|
606
|
+
int8, uint8, bit.
|
|
607
|
+
strides: specify the strides of the output data in memory; either as a\
|
|
608
|
+
comma-separated list of (signed) integers, or as a template image from\
|
|
609
|
+
which the strides shall be extracted and used. The actual strides\
|
|
610
|
+
produced will depend on whether the output image format can support it.
|
|
611
|
+
info: display information messages.
|
|
612
|
+
quiet: do not display information messages or progress status;\
|
|
613
|
+
alternatively, this can be achieved by setting the MRTRIX_QUIET\
|
|
614
|
+
environment variable to a non-empty string.
|
|
615
|
+
debug: display debugging messages.
|
|
616
|
+
force: force overwrite of output files (caution: using the same file as\
|
|
617
|
+
input and output might cause unexpected behaviour).
|
|
618
|
+
nthreads: use this number of threads in multi-threaded applications\
|
|
619
|
+
(set to 0 to disable multi-threading).
|
|
620
|
+
config: temporarily set the value of an MRtrix config file entry.
|
|
621
|
+
help_: display this information page and exit.
|
|
622
|
+
version: display version information and exit.
|
|
623
|
+
runner: Command runner.
|
|
624
|
+
Returns:
|
|
625
|
+
NamedTuple of outputs (described in `ShconvOutputs`).
|
|
626
|
+
"""
|
|
627
|
+
params = shconv_params(
|
|
628
|
+
datatype=datatype,
|
|
629
|
+
strides=strides,
|
|
630
|
+
info=info,
|
|
631
|
+
quiet=quiet,
|
|
632
|
+
debug=debug,
|
|
633
|
+
force=force,
|
|
634
|
+
nthreads=nthreads,
|
|
635
|
+
config=config,
|
|
636
|
+
help_=help_,
|
|
637
|
+
version=version,
|
|
638
|
+
odf_response=odf_response,
|
|
639
|
+
sh_out=sh_out,
|
|
640
|
+
)
|
|
641
|
+
return shconv_execute(params, runner)
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
__all__ = [
|
|
645
|
+
"SHCONV_METADATA",
|
|
646
|
+
"ShconvConfigParamsDict",
|
|
647
|
+
"ShconvConfigParamsDictTagged",
|
|
648
|
+
"ShconvOutputs",
|
|
649
|
+
"ShconvParamsDict",
|
|
650
|
+
"ShconvParamsDictTagged",
|
|
651
|
+
"ShconvVariousFileParamsDict",
|
|
652
|
+
"ShconvVariousFileParamsDictTagged",
|
|
653
|
+
"ShconvVariousStringParamsDict",
|
|
654
|
+
"ShconvVariousStringParamsDictTagged",
|
|
655
|
+
"shconv",
|
|
656
|
+
"shconv_config",
|
|
657
|
+
"shconv_execute",
|
|
658
|
+
"shconv_params",
|
|
659
|
+
"shconv_various_file",
|
|
660
|
+
"shconv_various_string",
|
|
661
|
+
]
|