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,870 @@
|
|
|
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
|
+
AMP2SH_METADATA = Metadata(
|
|
9
|
+
id="b1deae186542fe482c4a2e51622f124fe000c4fc.boutiques",
|
|
10
|
+
name="amp2sh",
|
|
11
|
+
package="mrtrix",
|
|
12
|
+
container_image_tag="mrtrix3/mrtrix3:3.0.4",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
_Amp2shFslgradParamsDictNoTag = typing.TypedDict('_Amp2shFslgradParamsDictNoTag', {
|
|
17
|
+
"bvecs": InputPathType,
|
|
18
|
+
"bvals": InputPathType,
|
|
19
|
+
})
|
|
20
|
+
Amp2shFslgradParamsDictTagged = typing.TypedDict('Amp2shFslgradParamsDictTagged', {
|
|
21
|
+
"@type": typing.Literal["fslgrad"],
|
|
22
|
+
"bvecs": InputPathType,
|
|
23
|
+
"bvals": InputPathType,
|
|
24
|
+
})
|
|
25
|
+
Amp2shFslgradParamsDict = _Amp2shFslgradParamsDictNoTag | Amp2shFslgradParamsDictTagged
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
_Amp2shVariousStringParamsDictNoTag = typing.TypedDict('_Amp2shVariousStringParamsDictNoTag', {
|
|
29
|
+
"obj": str,
|
|
30
|
+
})
|
|
31
|
+
Amp2shVariousStringParamsDictTagged = typing.TypedDict('Amp2shVariousStringParamsDictTagged', {
|
|
32
|
+
"@type": typing.Literal["VariousString"],
|
|
33
|
+
"obj": str,
|
|
34
|
+
})
|
|
35
|
+
Amp2shVariousStringParamsDict = _Amp2shVariousStringParamsDictNoTag | Amp2shVariousStringParamsDictTagged
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
_Amp2shVariousFileParamsDictNoTag = typing.TypedDict('_Amp2shVariousFileParamsDictNoTag', {
|
|
39
|
+
"obj": InputPathType,
|
|
40
|
+
})
|
|
41
|
+
Amp2shVariousFileParamsDictTagged = typing.TypedDict('Amp2shVariousFileParamsDictTagged', {
|
|
42
|
+
"@type": typing.Literal["VariousFile"],
|
|
43
|
+
"obj": InputPathType,
|
|
44
|
+
})
|
|
45
|
+
Amp2shVariousFileParamsDict = _Amp2shVariousFileParamsDictNoTag | Amp2shVariousFileParamsDictTagged
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
_Amp2shConfigParamsDictNoTag = typing.TypedDict('_Amp2shConfigParamsDictNoTag', {
|
|
49
|
+
"key": str,
|
|
50
|
+
"value": str,
|
|
51
|
+
})
|
|
52
|
+
Amp2shConfigParamsDictTagged = typing.TypedDict('Amp2shConfigParamsDictTagged', {
|
|
53
|
+
"@type": typing.Literal["config"],
|
|
54
|
+
"key": str,
|
|
55
|
+
"value": str,
|
|
56
|
+
})
|
|
57
|
+
Amp2shConfigParamsDict = _Amp2shConfigParamsDictNoTag | Amp2shConfigParamsDictTagged
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
_Amp2shParamsDictNoTag = typing.TypedDict('_Amp2shParamsDictNoTag', {
|
|
61
|
+
"lmax": typing.NotRequired[int | None],
|
|
62
|
+
"normalise": bool,
|
|
63
|
+
"directions": typing.NotRequired[InputPathType | None],
|
|
64
|
+
"rician": typing.NotRequired[InputPathType | None],
|
|
65
|
+
"grad": typing.NotRequired[InputPathType | None],
|
|
66
|
+
"fslgrad": typing.NotRequired[Amp2shFslgradParamsDict | None],
|
|
67
|
+
"shells": typing.NotRequired[list[float] | None],
|
|
68
|
+
"strides": typing.NotRequired[typing.Union[Amp2shVariousStringParamsDictTagged, Amp2shVariousFileParamsDictTagged] | None],
|
|
69
|
+
"info": bool,
|
|
70
|
+
"quiet": bool,
|
|
71
|
+
"debug": bool,
|
|
72
|
+
"force": bool,
|
|
73
|
+
"nthreads": typing.NotRequired[int | None],
|
|
74
|
+
"config": typing.NotRequired[list[Amp2shConfigParamsDict] | None],
|
|
75
|
+
"help": bool,
|
|
76
|
+
"version": bool,
|
|
77
|
+
"amp": InputPathType,
|
|
78
|
+
"SH": str,
|
|
79
|
+
})
|
|
80
|
+
Amp2shParamsDictTagged = typing.TypedDict('Amp2shParamsDictTagged', {
|
|
81
|
+
"@type": typing.Literal["mrtrix/amp2sh"],
|
|
82
|
+
"lmax": typing.NotRequired[int | None],
|
|
83
|
+
"normalise": bool,
|
|
84
|
+
"directions": typing.NotRequired[InputPathType | None],
|
|
85
|
+
"rician": typing.NotRequired[InputPathType | None],
|
|
86
|
+
"grad": typing.NotRequired[InputPathType | None],
|
|
87
|
+
"fslgrad": typing.NotRequired[Amp2shFslgradParamsDict | None],
|
|
88
|
+
"shells": typing.NotRequired[list[float] | None],
|
|
89
|
+
"strides": typing.NotRequired[typing.Union[Amp2shVariousStringParamsDictTagged, Amp2shVariousFileParamsDictTagged] | None],
|
|
90
|
+
"info": bool,
|
|
91
|
+
"quiet": bool,
|
|
92
|
+
"debug": bool,
|
|
93
|
+
"force": bool,
|
|
94
|
+
"nthreads": typing.NotRequired[int | None],
|
|
95
|
+
"config": typing.NotRequired[list[Amp2shConfigParamsDict] | None],
|
|
96
|
+
"help": bool,
|
|
97
|
+
"version": bool,
|
|
98
|
+
"amp": InputPathType,
|
|
99
|
+
"SH": str,
|
|
100
|
+
})
|
|
101
|
+
Amp2shParamsDict = _Amp2shParamsDictNoTag | Amp2shParamsDictTagged
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def amp2sh_strides_cargs_dyn_fn(
|
|
105
|
+
t: str,
|
|
106
|
+
) -> typing.Any:
|
|
107
|
+
"""
|
|
108
|
+
Get build cargs function by command type.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
t: Command type.
|
|
112
|
+
Returns:
|
|
113
|
+
Build cargs function.
|
|
114
|
+
"""
|
|
115
|
+
return {
|
|
116
|
+
"VariousString": amp2sh_various_string_cargs,
|
|
117
|
+
"VariousFile": amp2sh_various_file_cargs,
|
|
118
|
+
}.get(t)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def amp2sh_strides_validate_dyn_fn(
|
|
122
|
+
t: str,
|
|
123
|
+
) -> typing.Any:
|
|
124
|
+
"""
|
|
125
|
+
Get validate params function by command type.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
t: Command type.
|
|
129
|
+
Returns:
|
|
130
|
+
Validate params function.
|
|
131
|
+
"""
|
|
132
|
+
return {
|
|
133
|
+
"VariousString": amp2sh_various_string_validate,
|
|
134
|
+
"VariousFile": amp2sh_various_file_validate,
|
|
135
|
+
}.get(t)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def amp2sh_fslgrad(
|
|
139
|
+
bvecs: InputPathType,
|
|
140
|
+
bvals: InputPathType,
|
|
141
|
+
) -> Amp2shFslgradParamsDictTagged:
|
|
142
|
+
"""
|
|
143
|
+
Build parameters.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
bvecs: Provide the diffusion-weighted gradient scheme used in the\
|
|
147
|
+
acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
|
|
148
|
+
scheme is present in the input image header, the data provided with\
|
|
149
|
+
this option will be instead used.
|
|
150
|
+
bvals: Provide the diffusion-weighted gradient scheme used in the\
|
|
151
|
+
acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
|
|
152
|
+
scheme is present in the input image header, the data provided with\
|
|
153
|
+
this option will be instead used.
|
|
154
|
+
Returns:
|
|
155
|
+
Parameter dictionary
|
|
156
|
+
"""
|
|
157
|
+
params = {
|
|
158
|
+
"@type": "fslgrad",
|
|
159
|
+
"bvecs": bvecs,
|
|
160
|
+
"bvals": bvals,
|
|
161
|
+
}
|
|
162
|
+
return params
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def amp2sh_fslgrad_validate(
|
|
166
|
+
params: typing.Any,
|
|
167
|
+
) -> None:
|
|
168
|
+
"""
|
|
169
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
170
|
+
`Amp2shFslgradParamsDict` object.
|
|
171
|
+
|
|
172
|
+
Args:
|
|
173
|
+
params: The parameters object to validate.
|
|
174
|
+
"""
|
|
175
|
+
if params is None or not isinstance(params, dict):
|
|
176
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
177
|
+
if params.get("bvecs", None) is None:
|
|
178
|
+
raise StyxValidationError("`bvecs` must not be None")
|
|
179
|
+
if not isinstance(params["bvecs"], (pathlib.Path, str)):
|
|
180
|
+
raise StyxValidationError(f'`bvecs` has the wrong type: Received `{type(params.get("bvecs", None))}` expected `InputPathType`')
|
|
181
|
+
if params.get("bvals", None) is None:
|
|
182
|
+
raise StyxValidationError("`bvals` must not be None")
|
|
183
|
+
if not isinstance(params["bvals"], (pathlib.Path, str)):
|
|
184
|
+
raise StyxValidationError(f'`bvals` has the wrong type: Received `{type(params.get("bvals", None))}` expected `InputPathType`')
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def amp2sh_fslgrad_cargs(
|
|
188
|
+
params: Amp2shFslgradParamsDict,
|
|
189
|
+
execution: Execution,
|
|
190
|
+
) -> list[str]:
|
|
191
|
+
"""
|
|
192
|
+
Build command-line arguments from parameters.
|
|
193
|
+
|
|
194
|
+
Args:
|
|
195
|
+
params: The parameters.
|
|
196
|
+
execution: The execution object for resolving input paths.
|
|
197
|
+
Returns:
|
|
198
|
+
Command-line arguments.
|
|
199
|
+
"""
|
|
200
|
+
cargs = []
|
|
201
|
+
cargs.append("-fslgrad")
|
|
202
|
+
cargs.append(execution.input_file(params.get("bvecs", None)))
|
|
203
|
+
cargs.append(execution.input_file(params.get("bvals", None)))
|
|
204
|
+
return cargs
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def amp2sh_various_string(
|
|
208
|
+
obj: str,
|
|
209
|
+
) -> Amp2shVariousStringParamsDictTagged:
|
|
210
|
+
"""
|
|
211
|
+
Build parameters.
|
|
212
|
+
|
|
213
|
+
Args:
|
|
214
|
+
obj: String object.
|
|
215
|
+
Returns:
|
|
216
|
+
Parameter dictionary
|
|
217
|
+
"""
|
|
218
|
+
params = {
|
|
219
|
+
"@type": "VariousString",
|
|
220
|
+
"obj": obj,
|
|
221
|
+
}
|
|
222
|
+
return params
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def amp2sh_various_string_validate(
|
|
226
|
+
params: typing.Any,
|
|
227
|
+
) -> None:
|
|
228
|
+
"""
|
|
229
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
230
|
+
`Amp2shVariousStringParamsDict` object.
|
|
231
|
+
|
|
232
|
+
Args:
|
|
233
|
+
params: The parameters object to validate.
|
|
234
|
+
"""
|
|
235
|
+
if params is None or not isinstance(params, dict):
|
|
236
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
237
|
+
if params.get("obj", None) is None:
|
|
238
|
+
raise StyxValidationError("`obj` must not be None")
|
|
239
|
+
if not isinstance(params["obj"], str):
|
|
240
|
+
raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `str`')
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def amp2sh_various_string_cargs(
|
|
244
|
+
params: Amp2shVariousStringParamsDict,
|
|
245
|
+
execution: Execution,
|
|
246
|
+
) -> list[str]:
|
|
247
|
+
"""
|
|
248
|
+
Build command-line arguments from parameters.
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
params: The parameters.
|
|
252
|
+
execution: The execution object for resolving input paths.
|
|
253
|
+
Returns:
|
|
254
|
+
Command-line arguments.
|
|
255
|
+
"""
|
|
256
|
+
cargs = []
|
|
257
|
+
cargs.append(params.get("obj", None))
|
|
258
|
+
return cargs
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def amp2sh_various_file(
|
|
262
|
+
obj: InputPathType,
|
|
263
|
+
) -> Amp2shVariousFileParamsDictTagged:
|
|
264
|
+
"""
|
|
265
|
+
Build parameters.
|
|
266
|
+
|
|
267
|
+
Args:
|
|
268
|
+
obj: File object.
|
|
269
|
+
Returns:
|
|
270
|
+
Parameter dictionary
|
|
271
|
+
"""
|
|
272
|
+
params = {
|
|
273
|
+
"@type": "VariousFile",
|
|
274
|
+
"obj": obj,
|
|
275
|
+
}
|
|
276
|
+
return params
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def amp2sh_various_file_validate(
|
|
280
|
+
params: typing.Any,
|
|
281
|
+
) -> None:
|
|
282
|
+
"""
|
|
283
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
284
|
+
`Amp2shVariousFileParamsDict` object.
|
|
285
|
+
|
|
286
|
+
Args:
|
|
287
|
+
params: The parameters object to validate.
|
|
288
|
+
"""
|
|
289
|
+
if params is None or not isinstance(params, dict):
|
|
290
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
291
|
+
if params.get("obj", None) is None:
|
|
292
|
+
raise StyxValidationError("`obj` must not be None")
|
|
293
|
+
if not isinstance(params["obj"], (pathlib.Path, str)):
|
|
294
|
+
raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `InputPathType`')
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def amp2sh_various_file_cargs(
|
|
298
|
+
params: Amp2shVariousFileParamsDict,
|
|
299
|
+
execution: Execution,
|
|
300
|
+
) -> list[str]:
|
|
301
|
+
"""
|
|
302
|
+
Build command-line arguments from parameters.
|
|
303
|
+
|
|
304
|
+
Args:
|
|
305
|
+
params: The parameters.
|
|
306
|
+
execution: The execution object for resolving input paths.
|
|
307
|
+
Returns:
|
|
308
|
+
Command-line arguments.
|
|
309
|
+
"""
|
|
310
|
+
cargs = []
|
|
311
|
+
cargs.append(execution.input_file(params.get("obj", None)))
|
|
312
|
+
return cargs
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
def amp2sh_config(
|
|
316
|
+
key: str,
|
|
317
|
+
value: str,
|
|
318
|
+
) -> Amp2shConfigParamsDictTagged:
|
|
319
|
+
"""
|
|
320
|
+
Build parameters.
|
|
321
|
+
|
|
322
|
+
Args:
|
|
323
|
+
key: temporarily set the value of an MRtrix config file entry.
|
|
324
|
+
value: temporarily set the value of an MRtrix config file entry.
|
|
325
|
+
Returns:
|
|
326
|
+
Parameter dictionary
|
|
327
|
+
"""
|
|
328
|
+
params = {
|
|
329
|
+
"@type": "config",
|
|
330
|
+
"key": key,
|
|
331
|
+
"value": value,
|
|
332
|
+
}
|
|
333
|
+
return params
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def amp2sh_config_validate(
|
|
337
|
+
params: typing.Any,
|
|
338
|
+
) -> None:
|
|
339
|
+
"""
|
|
340
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
341
|
+
`Amp2shConfigParamsDict` object.
|
|
342
|
+
|
|
343
|
+
Args:
|
|
344
|
+
params: The parameters object to validate.
|
|
345
|
+
"""
|
|
346
|
+
if params is None or not isinstance(params, dict):
|
|
347
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
348
|
+
if params.get("key", None) is None:
|
|
349
|
+
raise StyxValidationError("`key` must not be None")
|
|
350
|
+
if not isinstance(params["key"], str):
|
|
351
|
+
raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
|
|
352
|
+
if params.get("value", None) is None:
|
|
353
|
+
raise StyxValidationError("`value` must not be None")
|
|
354
|
+
if not isinstance(params["value"], str):
|
|
355
|
+
raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def amp2sh_config_cargs(
|
|
359
|
+
params: Amp2shConfigParamsDict,
|
|
360
|
+
execution: Execution,
|
|
361
|
+
) -> list[str]:
|
|
362
|
+
"""
|
|
363
|
+
Build command-line arguments from parameters.
|
|
364
|
+
|
|
365
|
+
Args:
|
|
366
|
+
params: The parameters.
|
|
367
|
+
execution: The execution object for resolving input paths.
|
|
368
|
+
Returns:
|
|
369
|
+
Command-line arguments.
|
|
370
|
+
"""
|
|
371
|
+
cargs = []
|
|
372
|
+
cargs.append("-config")
|
|
373
|
+
cargs.append(params.get("key", None))
|
|
374
|
+
cargs.append(params.get("value", None))
|
|
375
|
+
return cargs
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
class Amp2shOutputs(typing.NamedTuple):
|
|
379
|
+
"""
|
|
380
|
+
Output object returned when calling `Amp2shParamsDict(...)`.
|
|
381
|
+
"""
|
|
382
|
+
root: OutputPathType
|
|
383
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
384
|
+
sh: OutputPathType
|
|
385
|
+
"""the output spherical harmonics coefficients image."""
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
def amp2sh_params(
|
|
389
|
+
amp: InputPathType,
|
|
390
|
+
sh: str,
|
|
391
|
+
lmax: int | None = None,
|
|
392
|
+
normalise: bool = False,
|
|
393
|
+
directions: InputPathType | None = None,
|
|
394
|
+
rician: InputPathType | None = None,
|
|
395
|
+
grad: InputPathType | None = None,
|
|
396
|
+
fslgrad: Amp2shFslgradParamsDict | None = None,
|
|
397
|
+
shells: list[float] | None = None,
|
|
398
|
+
strides: typing.Union[Amp2shVariousStringParamsDictTagged, Amp2shVariousFileParamsDictTagged] | None = None,
|
|
399
|
+
info: bool = False,
|
|
400
|
+
quiet: bool = False,
|
|
401
|
+
debug: bool = False,
|
|
402
|
+
force: bool = False,
|
|
403
|
+
nthreads: int | None = None,
|
|
404
|
+
config: list[Amp2shConfigParamsDict] | None = None,
|
|
405
|
+
help_: bool = False,
|
|
406
|
+
version: bool = False,
|
|
407
|
+
) -> Amp2shParamsDictTagged:
|
|
408
|
+
"""
|
|
409
|
+
Build parameters.
|
|
410
|
+
|
|
411
|
+
Args:
|
|
412
|
+
amp: the input amplitude image.
|
|
413
|
+
sh: the output spherical harmonics coefficients image.
|
|
414
|
+
lmax: set the maximum harmonic order for the output series. By default,\
|
|
415
|
+
the program will use the highest possible lmax given the number of\
|
|
416
|
+
diffusion-weighted images, up to a maximum of 8.
|
|
417
|
+
normalise: normalise the DW signal to the b=0 image.
|
|
418
|
+
directions: the directions corresponding to the input amplitude image\
|
|
419
|
+
used to sample AFD. By default this option is not required providing\
|
|
420
|
+
the direction set is supplied in the amplitude image. This should be\
|
|
421
|
+
supplied as a list of directions [az el], as generated using the dirgen\
|
|
422
|
+
command, or as a list of [ x y z ] Cartesian coordinates.
|
|
423
|
+
rician: correct for Rician noise induced bias, using noise map supplied.
|
|
424
|
+
grad: Provide the diffusion-weighted gradient scheme used in the\
|
|
425
|
+
acquisition in a text file. This should be supplied as a 4xN text file\
|
|
426
|
+
with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
|
|
427
|
+
the direction of the applied gradient, and b gives the b-value in units\
|
|
428
|
+
of s/mm^2. If a diffusion gradient scheme is present in the input image\
|
|
429
|
+
header, the data provided with this option will be instead used.
|
|
430
|
+
fslgrad: Provide the diffusion-weighted gradient scheme used in the\
|
|
431
|
+
acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
|
|
432
|
+
scheme is present in the input image header, the data provided with\
|
|
433
|
+
this option will be instead used.
|
|
434
|
+
shells: specify one or more b-values to use during processing, as a\
|
|
435
|
+
comma-separated list of the desired approximate b-values (b-values are\
|
|
436
|
+
clustered to allow for small deviations). Note that some commands are\
|
|
437
|
+
incompatible with multiple b-values, and will report an error if more\
|
|
438
|
+
than one b-value is provided.\
|
|
439
|
+
WARNING: note that, even though the b=0 volumes are never referred\
|
|
440
|
+
to as shells in the literature, they still have to be explicitly\
|
|
441
|
+
included in the list of b-values as provided to the -shell option!\
|
|
442
|
+
Several algorithms which include the b=0 volumes in their\
|
|
443
|
+
computations may otherwise return an undesired result.
|
|
444
|
+
strides: specify the strides of the output data in memory; either as a\
|
|
445
|
+
comma-separated list of (signed) integers, or as a template image from\
|
|
446
|
+
which the strides shall be extracted and used. The actual strides\
|
|
447
|
+
produced will depend on whether the output image format can support it.
|
|
448
|
+
info: display information messages.
|
|
449
|
+
quiet: do not display information messages or progress status;\
|
|
450
|
+
alternatively, this can be achieved by setting the MRTRIX_QUIET\
|
|
451
|
+
environment variable to a non-empty string.
|
|
452
|
+
debug: display debugging messages.
|
|
453
|
+
force: force overwrite of output files (caution: using the same file as\
|
|
454
|
+
input and output might cause unexpected behaviour).
|
|
455
|
+
nthreads: use this number of threads in multi-threaded applications\
|
|
456
|
+
(set to 0 to disable multi-threading).
|
|
457
|
+
config: temporarily set the value of an MRtrix config file entry.
|
|
458
|
+
help_: display this information page and exit.
|
|
459
|
+
version: display version information and exit.
|
|
460
|
+
Returns:
|
|
461
|
+
Parameter dictionary
|
|
462
|
+
"""
|
|
463
|
+
params = {
|
|
464
|
+
"@type": "mrtrix/amp2sh",
|
|
465
|
+
"normalise": normalise,
|
|
466
|
+
"info": info,
|
|
467
|
+
"quiet": quiet,
|
|
468
|
+
"debug": debug,
|
|
469
|
+
"force": force,
|
|
470
|
+
"help": help_,
|
|
471
|
+
"version": version,
|
|
472
|
+
"amp": amp,
|
|
473
|
+
"SH": sh,
|
|
474
|
+
}
|
|
475
|
+
if lmax is not None:
|
|
476
|
+
params["lmax"] = lmax
|
|
477
|
+
if directions is not None:
|
|
478
|
+
params["directions"] = directions
|
|
479
|
+
if rician is not None:
|
|
480
|
+
params["rician"] = rician
|
|
481
|
+
if grad is not None:
|
|
482
|
+
params["grad"] = grad
|
|
483
|
+
if fslgrad is not None:
|
|
484
|
+
params["fslgrad"] = fslgrad
|
|
485
|
+
if shells is not None:
|
|
486
|
+
params["shells"] = shells
|
|
487
|
+
if strides is not None:
|
|
488
|
+
params["strides"] = strides
|
|
489
|
+
if nthreads is not None:
|
|
490
|
+
params["nthreads"] = nthreads
|
|
491
|
+
if config is not None:
|
|
492
|
+
params["config"] = config
|
|
493
|
+
return params
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
def amp2sh_validate(
|
|
497
|
+
params: typing.Any,
|
|
498
|
+
) -> None:
|
|
499
|
+
"""
|
|
500
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
501
|
+
`Amp2shParamsDict` object.
|
|
502
|
+
|
|
503
|
+
Args:
|
|
504
|
+
params: The parameters object to validate.
|
|
505
|
+
"""
|
|
506
|
+
if params is None or not isinstance(params, dict):
|
|
507
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
508
|
+
if params.get("lmax", None) is not None:
|
|
509
|
+
if not isinstance(params["lmax"], int):
|
|
510
|
+
raise StyxValidationError(f'`lmax` has the wrong type: Received `{type(params.get("lmax", None))}` expected `int | None`')
|
|
511
|
+
if params.get("normalise", False) is None:
|
|
512
|
+
raise StyxValidationError("`normalise` must not be None")
|
|
513
|
+
if not isinstance(params["normalise"], bool):
|
|
514
|
+
raise StyxValidationError(f'`normalise` has the wrong type: Received `{type(params.get("normalise", False))}` expected `bool`')
|
|
515
|
+
if params.get("directions", None) is not None:
|
|
516
|
+
if not isinstance(params["directions"], (pathlib.Path, str)):
|
|
517
|
+
raise StyxValidationError(f'`directions` has the wrong type: Received `{type(params.get("directions", None))}` expected `InputPathType | None`')
|
|
518
|
+
if params.get("rician", None) is not None:
|
|
519
|
+
if not isinstance(params["rician"], (pathlib.Path, str)):
|
|
520
|
+
raise StyxValidationError(f'`rician` has the wrong type: Received `{type(params.get("rician", None))}` expected `InputPathType | None`')
|
|
521
|
+
if params.get("grad", None) is not None:
|
|
522
|
+
if not isinstance(params["grad"], (pathlib.Path, str)):
|
|
523
|
+
raise StyxValidationError(f'`grad` has the wrong type: Received `{type(params.get("grad", None))}` expected `InputPathType | None`')
|
|
524
|
+
if params.get("fslgrad", None) is not None:
|
|
525
|
+
amp2sh_fslgrad_validate(params["fslgrad"])
|
|
526
|
+
if params.get("shells", None) is not None:
|
|
527
|
+
if not isinstance(params["shells"], list):
|
|
528
|
+
raise StyxValidationError(f'`shells` has the wrong type: Received `{type(params.get("shells", None))}` expected `list[float] | None`')
|
|
529
|
+
for e in params["shells"]:
|
|
530
|
+
if not isinstance(e, (float, int)):
|
|
531
|
+
raise StyxValidationError(f'`shells` has the wrong type: Received `{type(params.get("shells", None))}` expected `list[float] | None`')
|
|
532
|
+
if params.get("strides", None) is not None:
|
|
533
|
+
if not isinstance(params["strides"], dict):
|
|
534
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params["strides"])}\'')
|
|
535
|
+
if "@type" not in params["strides"]:
|
|
536
|
+
raise StyxValidationError("Params object is missing `@type`")
|
|
537
|
+
if params["strides"]["@type"] not in ["VariousString", "VariousFile"]:
|
|
538
|
+
raise StyxValidationError("Parameter `strides`s `@type` must be one of [\"VariousString\", \"VariousFile\"]")
|
|
539
|
+
amp2sh_strides_validate_dyn_fn(params["strides"]["@type"])(params["strides"])
|
|
540
|
+
if params.get("info", False) is None:
|
|
541
|
+
raise StyxValidationError("`info` must not be None")
|
|
542
|
+
if not isinstance(params["info"], bool):
|
|
543
|
+
raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
|
|
544
|
+
if params.get("quiet", False) is None:
|
|
545
|
+
raise StyxValidationError("`quiet` must not be None")
|
|
546
|
+
if not isinstance(params["quiet"], bool):
|
|
547
|
+
raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
|
|
548
|
+
if params.get("debug", False) is None:
|
|
549
|
+
raise StyxValidationError("`debug` must not be None")
|
|
550
|
+
if not isinstance(params["debug"], bool):
|
|
551
|
+
raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
|
|
552
|
+
if params.get("force", False) is None:
|
|
553
|
+
raise StyxValidationError("`force` must not be None")
|
|
554
|
+
if not isinstance(params["force"], bool):
|
|
555
|
+
raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
|
|
556
|
+
if params.get("nthreads", None) is not None:
|
|
557
|
+
if not isinstance(params["nthreads"], int):
|
|
558
|
+
raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
|
|
559
|
+
if params.get("config", None) is not None:
|
|
560
|
+
if not isinstance(params["config"], list):
|
|
561
|
+
raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[Amp2shConfigParamsDict] | None`')
|
|
562
|
+
for e in params["config"]:
|
|
563
|
+
amp2sh_config_validate(e)
|
|
564
|
+
if params.get("help", False) is None:
|
|
565
|
+
raise StyxValidationError("`help` must not be None")
|
|
566
|
+
if not isinstance(params["help"], bool):
|
|
567
|
+
raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
|
|
568
|
+
if params.get("version", False) is None:
|
|
569
|
+
raise StyxValidationError("`version` must not be None")
|
|
570
|
+
if not isinstance(params["version"], bool):
|
|
571
|
+
raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
|
|
572
|
+
if params.get("amp", None) is None:
|
|
573
|
+
raise StyxValidationError("`amp` must not be None")
|
|
574
|
+
if not isinstance(params["amp"], (pathlib.Path, str)):
|
|
575
|
+
raise StyxValidationError(f'`amp` has the wrong type: Received `{type(params.get("amp", None))}` expected `InputPathType`')
|
|
576
|
+
if params.get("SH", None) is None:
|
|
577
|
+
raise StyxValidationError("`SH` must not be None")
|
|
578
|
+
if not isinstance(params["SH"], str):
|
|
579
|
+
raise StyxValidationError(f'`SH` has the wrong type: Received `{type(params.get("SH", None))}` expected `str`')
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
def amp2sh_cargs(
|
|
583
|
+
params: Amp2shParamsDict,
|
|
584
|
+
execution: Execution,
|
|
585
|
+
) -> list[str]:
|
|
586
|
+
"""
|
|
587
|
+
Build command-line arguments from parameters.
|
|
588
|
+
|
|
589
|
+
Args:
|
|
590
|
+
params: The parameters.
|
|
591
|
+
execution: The execution object for resolving input paths.
|
|
592
|
+
Returns:
|
|
593
|
+
Command-line arguments.
|
|
594
|
+
"""
|
|
595
|
+
cargs = []
|
|
596
|
+
cargs.append("amp2sh")
|
|
597
|
+
if params.get("lmax", None) is not None:
|
|
598
|
+
cargs.extend([
|
|
599
|
+
"-lmax",
|
|
600
|
+
str(params.get("lmax", None))
|
|
601
|
+
])
|
|
602
|
+
if params.get("normalise", False):
|
|
603
|
+
cargs.append("-normalise")
|
|
604
|
+
if params.get("directions", None) is not None:
|
|
605
|
+
cargs.extend([
|
|
606
|
+
"-directions",
|
|
607
|
+
execution.input_file(params.get("directions", None))
|
|
608
|
+
])
|
|
609
|
+
if params.get("rician", None) is not None:
|
|
610
|
+
cargs.extend([
|
|
611
|
+
"-rician",
|
|
612
|
+
execution.input_file(params.get("rician", None))
|
|
613
|
+
])
|
|
614
|
+
if params.get("grad", None) is not None:
|
|
615
|
+
cargs.extend([
|
|
616
|
+
"-grad",
|
|
617
|
+
execution.input_file(params.get("grad", None))
|
|
618
|
+
])
|
|
619
|
+
if params.get("fslgrad", None) is not None:
|
|
620
|
+
cargs.extend(amp2sh_fslgrad_cargs(params.get("fslgrad", None), execution))
|
|
621
|
+
if params.get("shells", None) is not None:
|
|
622
|
+
cargs.extend([
|
|
623
|
+
"-shells",
|
|
624
|
+
",".join(map(str, params.get("shells", None)))
|
|
625
|
+
])
|
|
626
|
+
if params.get("strides", None) is not None:
|
|
627
|
+
cargs.extend([
|
|
628
|
+
"-strides",
|
|
629
|
+
*amp2sh_strides_cargs_dyn_fn(params.get("strides", None)["@type"])(params.get("strides", None), execution)
|
|
630
|
+
])
|
|
631
|
+
if params.get("info", False):
|
|
632
|
+
cargs.append("-info")
|
|
633
|
+
if params.get("quiet", False):
|
|
634
|
+
cargs.append("-quiet")
|
|
635
|
+
if params.get("debug", False):
|
|
636
|
+
cargs.append("-debug")
|
|
637
|
+
if params.get("force", False):
|
|
638
|
+
cargs.append("-force")
|
|
639
|
+
if params.get("nthreads", None) is not None:
|
|
640
|
+
cargs.extend([
|
|
641
|
+
"-nthreads",
|
|
642
|
+
str(params.get("nthreads", None))
|
|
643
|
+
])
|
|
644
|
+
if params.get("config", None) is not None:
|
|
645
|
+
cargs.extend([a for c in [amp2sh_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
|
|
646
|
+
if params.get("help", False):
|
|
647
|
+
cargs.append("-help")
|
|
648
|
+
if params.get("version", False):
|
|
649
|
+
cargs.append("-version")
|
|
650
|
+
cargs.append(execution.input_file(params.get("amp", None)))
|
|
651
|
+
cargs.append(params.get("SH", None))
|
|
652
|
+
return cargs
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
def amp2sh_outputs(
|
|
656
|
+
params: Amp2shParamsDict,
|
|
657
|
+
execution: Execution,
|
|
658
|
+
) -> Amp2shOutputs:
|
|
659
|
+
"""
|
|
660
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
661
|
+
|
|
662
|
+
Args:
|
|
663
|
+
params: The parameters.
|
|
664
|
+
execution: The execution object for resolving input paths.
|
|
665
|
+
Returns:
|
|
666
|
+
Outputs object.
|
|
667
|
+
"""
|
|
668
|
+
ret = Amp2shOutputs(
|
|
669
|
+
root=execution.output_file("."),
|
|
670
|
+
sh=execution.output_file(params.get("SH", None)),
|
|
671
|
+
)
|
|
672
|
+
return ret
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
def amp2sh_execute(
|
|
676
|
+
params: Amp2shParamsDict,
|
|
677
|
+
runner: Runner | None = None,
|
|
678
|
+
) -> Amp2shOutputs:
|
|
679
|
+
"""
|
|
680
|
+
amp2sh
|
|
681
|
+
|
|
682
|
+
Convert a set of amplitudes (defined along a set of corresponding
|
|
683
|
+
directions) to their spherical harmonic representation.
|
|
684
|
+
|
|
685
|
+
The spherical harmonic decomposition is calculated by least-squares linear
|
|
686
|
+
fitting to the amplitude data.
|
|
687
|
+
|
|
688
|
+
The directions can be defined either as a DW gradient scheme (for example to
|
|
689
|
+
compute the SH representation of the DW signal), a set of [az el] pairs as
|
|
690
|
+
output by the dirgen command, or a set of [ x y z ] directions in Cartesian
|
|
691
|
+
coordinates. The DW gradient scheme or direction set can be supplied within
|
|
692
|
+
the input image header or using the -gradient or -directions option. Note
|
|
693
|
+
that if a direction set and DW gradient scheme can be found, the direction
|
|
694
|
+
set will be used by default.
|
|
695
|
+
|
|
696
|
+
The spherical harmonic coefficients are stored according the conventions
|
|
697
|
+
described the main documentation, which can be found at the following link:
|
|
698
|
+
https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
|
|
699
|
+
|
|
700
|
+
References:
|
|
701
|
+
|
|
702
|
+
.
|
|
703
|
+
|
|
704
|
+
Author: MRTrix3 Developers
|
|
705
|
+
|
|
706
|
+
URL: https://www.mrtrix.org/
|
|
707
|
+
|
|
708
|
+
Args:
|
|
709
|
+
params: The parameters.
|
|
710
|
+
runner: Command runner.
|
|
711
|
+
Returns:
|
|
712
|
+
NamedTuple of outputs (described in `Amp2shOutputs`).
|
|
713
|
+
"""
|
|
714
|
+
amp2sh_validate(params)
|
|
715
|
+
runner = runner or get_global_runner()
|
|
716
|
+
execution = runner.start_execution(AMP2SH_METADATA)
|
|
717
|
+
params = execution.params(params)
|
|
718
|
+
cargs = amp2sh_cargs(params, execution)
|
|
719
|
+
ret = amp2sh_outputs(params, execution)
|
|
720
|
+
execution.run(cargs)
|
|
721
|
+
return ret
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
def amp2sh(
|
|
725
|
+
amp: InputPathType,
|
|
726
|
+
sh: str,
|
|
727
|
+
lmax: int | None = None,
|
|
728
|
+
normalise: bool = False,
|
|
729
|
+
directions: InputPathType | None = None,
|
|
730
|
+
rician: InputPathType | None = None,
|
|
731
|
+
grad: InputPathType | None = None,
|
|
732
|
+
fslgrad: Amp2shFslgradParamsDict | None = None,
|
|
733
|
+
shells: list[float] | None = None,
|
|
734
|
+
strides: typing.Union[Amp2shVariousStringParamsDictTagged, Amp2shVariousFileParamsDictTagged] | None = None,
|
|
735
|
+
info: bool = False,
|
|
736
|
+
quiet: bool = False,
|
|
737
|
+
debug: bool = False,
|
|
738
|
+
force: bool = False,
|
|
739
|
+
nthreads: int | None = None,
|
|
740
|
+
config: list[Amp2shConfigParamsDict] | None = None,
|
|
741
|
+
help_: bool = False,
|
|
742
|
+
version: bool = False,
|
|
743
|
+
runner: Runner | None = None,
|
|
744
|
+
) -> Amp2shOutputs:
|
|
745
|
+
"""
|
|
746
|
+
amp2sh
|
|
747
|
+
|
|
748
|
+
Convert a set of amplitudes (defined along a set of corresponding
|
|
749
|
+
directions) to their spherical harmonic representation.
|
|
750
|
+
|
|
751
|
+
The spherical harmonic decomposition is calculated by least-squares linear
|
|
752
|
+
fitting to the amplitude data.
|
|
753
|
+
|
|
754
|
+
The directions can be defined either as a DW gradient scheme (for example to
|
|
755
|
+
compute the SH representation of the DW signal), a set of [az el] pairs as
|
|
756
|
+
output by the dirgen command, or a set of [ x y z ] directions in Cartesian
|
|
757
|
+
coordinates. The DW gradient scheme or direction set can be supplied within
|
|
758
|
+
the input image header or using the -gradient or -directions option. Note
|
|
759
|
+
that if a direction set and DW gradient scheme can be found, the direction
|
|
760
|
+
set will be used by default.
|
|
761
|
+
|
|
762
|
+
The spherical harmonic coefficients are stored according the conventions
|
|
763
|
+
described the main documentation, which can be found at the following link:
|
|
764
|
+
https://mrtrix.readthedocs.io/en/3.0.4/concepts/spherical_harmonics.html
|
|
765
|
+
|
|
766
|
+
References:
|
|
767
|
+
|
|
768
|
+
.
|
|
769
|
+
|
|
770
|
+
Author: MRTrix3 Developers
|
|
771
|
+
|
|
772
|
+
URL: https://www.mrtrix.org/
|
|
773
|
+
|
|
774
|
+
Args:
|
|
775
|
+
amp: the input amplitude image.
|
|
776
|
+
sh: the output spherical harmonics coefficients image.
|
|
777
|
+
lmax: set the maximum harmonic order for the output series. By default,\
|
|
778
|
+
the program will use the highest possible lmax given the number of\
|
|
779
|
+
diffusion-weighted images, up to a maximum of 8.
|
|
780
|
+
normalise: normalise the DW signal to the b=0 image.
|
|
781
|
+
directions: the directions corresponding to the input amplitude image\
|
|
782
|
+
used to sample AFD. By default this option is not required providing\
|
|
783
|
+
the direction set is supplied in the amplitude image. This should be\
|
|
784
|
+
supplied as a list of directions [az el], as generated using the dirgen\
|
|
785
|
+
command, or as a list of [ x y z ] Cartesian coordinates.
|
|
786
|
+
rician: correct for Rician noise induced bias, using noise map supplied.
|
|
787
|
+
grad: Provide the diffusion-weighted gradient scheme used in the\
|
|
788
|
+
acquisition in a text file. This should be supplied as a 4xN text file\
|
|
789
|
+
with each line is in the format [ X Y Z b ], where [ X Y Z ] describe\
|
|
790
|
+
the direction of the applied gradient, and b gives the b-value in units\
|
|
791
|
+
of s/mm^2. If a diffusion gradient scheme is present in the input image\
|
|
792
|
+
header, the data provided with this option will be instead used.
|
|
793
|
+
fslgrad: Provide the diffusion-weighted gradient scheme used in the\
|
|
794
|
+
acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
|
|
795
|
+
scheme is present in the input image header, the data provided with\
|
|
796
|
+
this option will be instead used.
|
|
797
|
+
shells: specify one or more b-values to use during processing, as a\
|
|
798
|
+
comma-separated list of the desired approximate b-values (b-values are\
|
|
799
|
+
clustered to allow for small deviations). Note that some commands are\
|
|
800
|
+
incompatible with multiple b-values, and will report an error if more\
|
|
801
|
+
than one b-value is provided.\
|
|
802
|
+
WARNING: note that, even though the b=0 volumes are never referred\
|
|
803
|
+
to as shells in the literature, they still have to be explicitly\
|
|
804
|
+
included in the list of b-values as provided to the -shell option!\
|
|
805
|
+
Several algorithms which include the b=0 volumes in their\
|
|
806
|
+
computations may otherwise return an undesired result.
|
|
807
|
+
strides: specify the strides of the output data in memory; either as a\
|
|
808
|
+
comma-separated list of (signed) integers, or as a template image from\
|
|
809
|
+
which the strides shall be extracted and used. The actual strides\
|
|
810
|
+
produced will depend on whether the output image format can support it.
|
|
811
|
+
info: display information messages.
|
|
812
|
+
quiet: do not display information messages or progress status;\
|
|
813
|
+
alternatively, this can be achieved by setting the MRTRIX_QUIET\
|
|
814
|
+
environment variable to a non-empty string.
|
|
815
|
+
debug: display debugging messages.
|
|
816
|
+
force: force overwrite of output files (caution: using the same file as\
|
|
817
|
+
input and output might cause unexpected behaviour).
|
|
818
|
+
nthreads: use this number of threads in multi-threaded applications\
|
|
819
|
+
(set to 0 to disable multi-threading).
|
|
820
|
+
config: temporarily set the value of an MRtrix config file entry.
|
|
821
|
+
help_: display this information page and exit.
|
|
822
|
+
version: display version information and exit.
|
|
823
|
+
runner: Command runner.
|
|
824
|
+
Returns:
|
|
825
|
+
NamedTuple of outputs (described in `Amp2shOutputs`).
|
|
826
|
+
"""
|
|
827
|
+
params = amp2sh_params(
|
|
828
|
+
lmax=lmax,
|
|
829
|
+
normalise=normalise,
|
|
830
|
+
directions=directions,
|
|
831
|
+
rician=rician,
|
|
832
|
+
grad=grad,
|
|
833
|
+
fslgrad=fslgrad,
|
|
834
|
+
shells=shells,
|
|
835
|
+
strides=strides,
|
|
836
|
+
info=info,
|
|
837
|
+
quiet=quiet,
|
|
838
|
+
debug=debug,
|
|
839
|
+
force=force,
|
|
840
|
+
nthreads=nthreads,
|
|
841
|
+
config=config,
|
|
842
|
+
help_=help_,
|
|
843
|
+
version=version,
|
|
844
|
+
amp=amp,
|
|
845
|
+
sh=sh,
|
|
846
|
+
)
|
|
847
|
+
return amp2sh_execute(params, runner)
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
__all__ = [
|
|
851
|
+
"AMP2SH_METADATA",
|
|
852
|
+
"Amp2shConfigParamsDict",
|
|
853
|
+
"Amp2shConfigParamsDictTagged",
|
|
854
|
+
"Amp2shFslgradParamsDict",
|
|
855
|
+
"Amp2shFslgradParamsDictTagged",
|
|
856
|
+
"Amp2shOutputs",
|
|
857
|
+
"Amp2shParamsDict",
|
|
858
|
+
"Amp2shParamsDictTagged",
|
|
859
|
+
"Amp2shVariousFileParamsDict",
|
|
860
|
+
"Amp2shVariousFileParamsDictTagged",
|
|
861
|
+
"Amp2shVariousStringParamsDict",
|
|
862
|
+
"Amp2shVariousStringParamsDictTagged",
|
|
863
|
+
"amp2sh",
|
|
864
|
+
"amp2sh_config",
|
|
865
|
+
"amp2sh_execute",
|
|
866
|
+
"amp2sh_fslgrad",
|
|
867
|
+
"amp2sh_params",
|
|
868
|
+
"amp2sh_various_file",
|
|
869
|
+
"amp2sh_various_string",
|
|
870
|
+
]
|