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,1774 @@
|
|
|
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
|
+
DWI2RESPONSE_METADATA = Metadata(
|
|
9
|
+
id="a5bba2228d610c2212f7a54e18b1cd513bb93b58.boutiques",
|
|
10
|
+
name="dwi2response",
|
|
11
|
+
package="mrtrix",
|
|
12
|
+
container_image_tag="mrtrix3/mrtrix3:3.0.4",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
_Dwi2responseDhollanderParamsDictNoTag = typing.TypedDict('_Dwi2responseDhollanderParamsDictNoTag', {
|
|
17
|
+
"input": InputPathType,
|
|
18
|
+
"out_sfwm": str,
|
|
19
|
+
"out_gm": str,
|
|
20
|
+
"out_csf": str,
|
|
21
|
+
"erode": typing.NotRequired[int | None],
|
|
22
|
+
"fa": typing.NotRequired[float | None],
|
|
23
|
+
"sfwm": typing.NotRequired[float | None],
|
|
24
|
+
"gm": typing.NotRequired[float | None],
|
|
25
|
+
"csf": typing.NotRequired[float | None],
|
|
26
|
+
"wm_algo": typing.NotRequired[typing.Literal["fa", "tax", "tournier"] | None],
|
|
27
|
+
})
|
|
28
|
+
Dwi2responseDhollanderParamsDictTagged = typing.TypedDict('Dwi2responseDhollanderParamsDictTagged', {
|
|
29
|
+
"@type": typing.Literal["dhollander"],
|
|
30
|
+
"input": InputPathType,
|
|
31
|
+
"out_sfwm": str,
|
|
32
|
+
"out_gm": str,
|
|
33
|
+
"out_csf": str,
|
|
34
|
+
"erode": typing.NotRequired[int | None],
|
|
35
|
+
"fa": typing.NotRequired[float | None],
|
|
36
|
+
"sfwm": typing.NotRequired[float | None],
|
|
37
|
+
"gm": typing.NotRequired[float | None],
|
|
38
|
+
"csf": typing.NotRequired[float | None],
|
|
39
|
+
"wm_algo": typing.NotRequired[typing.Literal["fa", "tax", "tournier"] | None],
|
|
40
|
+
})
|
|
41
|
+
Dwi2responseDhollanderParamsDict = _Dwi2responseDhollanderParamsDictNoTag | Dwi2responseDhollanderParamsDictTagged
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
_Dwi2responseFaParamsDictNoTag = typing.TypedDict('_Dwi2responseFaParamsDictNoTag', {
|
|
45
|
+
"input": InputPathType,
|
|
46
|
+
"output": str,
|
|
47
|
+
"erode": typing.NotRequired[int | None],
|
|
48
|
+
"number": typing.NotRequired[int | None],
|
|
49
|
+
"threshold": typing.NotRequired[float | None],
|
|
50
|
+
})
|
|
51
|
+
Dwi2responseFaParamsDictTagged = typing.TypedDict('Dwi2responseFaParamsDictTagged', {
|
|
52
|
+
"@type": typing.Literal["fa"],
|
|
53
|
+
"input": InputPathType,
|
|
54
|
+
"output": str,
|
|
55
|
+
"erode": typing.NotRequired[int | None],
|
|
56
|
+
"number": typing.NotRequired[int | None],
|
|
57
|
+
"threshold": typing.NotRequired[float | None],
|
|
58
|
+
})
|
|
59
|
+
Dwi2responseFaParamsDict = _Dwi2responseFaParamsDictNoTag | Dwi2responseFaParamsDictTagged
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
_Dwi2responseManualParamsDictNoTag = typing.TypedDict('_Dwi2responseManualParamsDictNoTag', {
|
|
63
|
+
"input": InputPathType,
|
|
64
|
+
"in_voxels": InputPathType,
|
|
65
|
+
"output": str,
|
|
66
|
+
"dirs": typing.NotRequired[InputPathType | None],
|
|
67
|
+
})
|
|
68
|
+
Dwi2responseManualParamsDictTagged = typing.TypedDict('Dwi2responseManualParamsDictTagged', {
|
|
69
|
+
"@type": typing.Literal["manual"],
|
|
70
|
+
"input": InputPathType,
|
|
71
|
+
"in_voxels": InputPathType,
|
|
72
|
+
"output": str,
|
|
73
|
+
"dirs": typing.NotRequired[InputPathType | None],
|
|
74
|
+
})
|
|
75
|
+
Dwi2responseManualParamsDict = _Dwi2responseManualParamsDictNoTag | Dwi2responseManualParamsDictTagged
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
_Dwi2responseMsmt5ttParamsDictNoTag = typing.TypedDict('_Dwi2responseMsmt5ttParamsDictNoTag', {
|
|
79
|
+
"input": InputPathType,
|
|
80
|
+
"in_5tt": InputPathType,
|
|
81
|
+
"out_wm": str,
|
|
82
|
+
"out_gm": str,
|
|
83
|
+
"out_csf": str,
|
|
84
|
+
"dirs": typing.NotRequired[InputPathType | None],
|
|
85
|
+
"fa": typing.NotRequired[float | None],
|
|
86
|
+
"pvf": typing.NotRequired[float | None],
|
|
87
|
+
"wm_algo": typing.NotRequired[typing.Literal["fa", "tax", "tournier"] | None],
|
|
88
|
+
"sfwm_fa_threshold": typing.NotRequired[float | None],
|
|
89
|
+
})
|
|
90
|
+
Dwi2responseMsmt5ttParamsDictTagged = typing.TypedDict('Dwi2responseMsmt5ttParamsDictTagged', {
|
|
91
|
+
"@type": typing.Literal["msmt_5tt"],
|
|
92
|
+
"input": InputPathType,
|
|
93
|
+
"in_5tt": InputPathType,
|
|
94
|
+
"out_wm": str,
|
|
95
|
+
"out_gm": str,
|
|
96
|
+
"out_csf": str,
|
|
97
|
+
"dirs": typing.NotRequired[InputPathType | None],
|
|
98
|
+
"fa": typing.NotRequired[float | None],
|
|
99
|
+
"pvf": typing.NotRequired[float | None],
|
|
100
|
+
"wm_algo": typing.NotRequired[typing.Literal["fa", "tax", "tournier"] | None],
|
|
101
|
+
"sfwm_fa_threshold": typing.NotRequired[float | None],
|
|
102
|
+
})
|
|
103
|
+
Dwi2responseMsmt5ttParamsDict = _Dwi2responseMsmt5ttParamsDictNoTag | Dwi2responseMsmt5ttParamsDictTagged
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
_Dwi2responseTaxParamsDictNoTag = typing.TypedDict('_Dwi2responseTaxParamsDictNoTag', {
|
|
107
|
+
"input": InputPathType,
|
|
108
|
+
"output": str,
|
|
109
|
+
"peak_ratio": typing.NotRequired[float | None],
|
|
110
|
+
"max_iters": typing.NotRequired[int | None],
|
|
111
|
+
"convergence": typing.NotRequired[float | None],
|
|
112
|
+
})
|
|
113
|
+
Dwi2responseTaxParamsDictTagged = typing.TypedDict('Dwi2responseTaxParamsDictTagged', {
|
|
114
|
+
"@type": typing.Literal["tax"],
|
|
115
|
+
"input": InputPathType,
|
|
116
|
+
"output": str,
|
|
117
|
+
"peak_ratio": typing.NotRequired[float | None],
|
|
118
|
+
"max_iters": typing.NotRequired[int | None],
|
|
119
|
+
"convergence": typing.NotRequired[float | None],
|
|
120
|
+
})
|
|
121
|
+
Dwi2responseTaxParamsDict = _Dwi2responseTaxParamsDictNoTag | Dwi2responseTaxParamsDictTagged
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
_Dwi2responseTournierParamsDictNoTag = typing.TypedDict('_Dwi2responseTournierParamsDictNoTag', {
|
|
125
|
+
"input": InputPathType,
|
|
126
|
+
"output": str,
|
|
127
|
+
"number": typing.NotRequired[int | None],
|
|
128
|
+
"iter_voxels": typing.NotRequired[int | None],
|
|
129
|
+
"dilate": typing.NotRequired[int | None],
|
|
130
|
+
"max_iters": typing.NotRequired[int | None],
|
|
131
|
+
})
|
|
132
|
+
Dwi2responseTournierParamsDictTagged = typing.TypedDict('Dwi2responseTournierParamsDictTagged', {
|
|
133
|
+
"@type": typing.Literal["tournier"],
|
|
134
|
+
"input": InputPathType,
|
|
135
|
+
"output": str,
|
|
136
|
+
"number": typing.NotRequired[int | None],
|
|
137
|
+
"iter_voxels": typing.NotRequired[int | None],
|
|
138
|
+
"dilate": typing.NotRequired[int | None],
|
|
139
|
+
"max_iters": typing.NotRequired[int | None],
|
|
140
|
+
})
|
|
141
|
+
Dwi2responseTournierParamsDict = _Dwi2responseTournierParamsDictNoTag | Dwi2responseTournierParamsDictTagged
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
_Dwi2responseFslgradParamsDictNoTag = typing.TypedDict('_Dwi2responseFslgradParamsDictNoTag', {
|
|
145
|
+
"bvecs": InputPathType,
|
|
146
|
+
"bvals": InputPathType,
|
|
147
|
+
})
|
|
148
|
+
Dwi2responseFslgradParamsDictTagged = typing.TypedDict('Dwi2responseFslgradParamsDictTagged', {
|
|
149
|
+
"@type": typing.Literal["fslgrad"],
|
|
150
|
+
"bvecs": InputPathType,
|
|
151
|
+
"bvals": InputPathType,
|
|
152
|
+
})
|
|
153
|
+
Dwi2responseFslgradParamsDict = _Dwi2responseFslgradParamsDictNoTag | Dwi2responseFslgradParamsDictTagged
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
_Dwi2responseConfigParamsDictNoTag = typing.TypedDict('_Dwi2responseConfigParamsDictNoTag', {
|
|
157
|
+
"key": str,
|
|
158
|
+
"value": str,
|
|
159
|
+
})
|
|
160
|
+
Dwi2responseConfigParamsDictTagged = typing.TypedDict('Dwi2responseConfigParamsDictTagged', {
|
|
161
|
+
"@type": typing.Literal["config"],
|
|
162
|
+
"key": str,
|
|
163
|
+
"value": str,
|
|
164
|
+
})
|
|
165
|
+
Dwi2responseConfigParamsDict = _Dwi2responseConfigParamsDictNoTag | Dwi2responseConfigParamsDictTagged
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
_Dwi2responseParamsDictNoTag = typing.TypedDict('_Dwi2responseParamsDictNoTag', {
|
|
169
|
+
"algorithm": typing.Union[Dwi2responseDhollanderParamsDictTagged, Dwi2responseFaParamsDictTagged, Dwi2responseManualParamsDictTagged, Dwi2responseMsmt5ttParamsDictTagged, Dwi2responseTaxParamsDictTagged, Dwi2responseTournierParamsDictTagged],
|
|
170
|
+
"grad": typing.NotRequired[InputPathType | None],
|
|
171
|
+
"fslgrad": typing.NotRequired[Dwi2responseFslgradParamsDict | None],
|
|
172
|
+
"mask": typing.NotRequired[InputPathType | None],
|
|
173
|
+
"voxels": typing.NotRequired[str | None],
|
|
174
|
+
"shells": typing.NotRequired[list[int] | None],
|
|
175
|
+
"lmax": typing.NotRequired[list[int] | None],
|
|
176
|
+
"nocleanup": bool,
|
|
177
|
+
"scratch": typing.NotRequired[str | None],
|
|
178
|
+
"continue": typing.NotRequired[str | None],
|
|
179
|
+
"info": bool,
|
|
180
|
+
"quiet": bool,
|
|
181
|
+
"debug": bool,
|
|
182
|
+
"force": bool,
|
|
183
|
+
"nthreads": typing.NotRequired[int | None],
|
|
184
|
+
"config": typing.NotRequired[list[Dwi2responseConfigParamsDict] | None],
|
|
185
|
+
"help": bool,
|
|
186
|
+
"version": bool,
|
|
187
|
+
})
|
|
188
|
+
Dwi2responseParamsDictTagged = typing.TypedDict('Dwi2responseParamsDictTagged', {
|
|
189
|
+
"@type": typing.Literal["mrtrix/dwi2response"],
|
|
190
|
+
"algorithm": typing.Union[Dwi2responseDhollanderParamsDictTagged, Dwi2responseFaParamsDictTagged, Dwi2responseManualParamsDictTagged, Dwi2responseMsmt5ttParamsDictTagged, Dwi2responseTaxParamsDictTagged, Dwi2responseTournierParamsDictTagged],
|
|
191
|
+
"grad": typing.NotRequired[InputPathType | None],
|
|
192
|
+
"fslgrad": typing.NotRequired[Dwi2responseFslgradParamsDict | None],
|
|
193
|
+
"mask": typing.NotRequired[InputPathType | None],
|
|
194
|
+
"voxels": typing.NotRequired[str | None],
|
|
195
|
+
"shells": typing.NotRequired[list[int] | None],
|
|
196
|
+
"lmax": typing.NotRequired[list[int] | None],
|
|
197
|
+
"nocleanup": bool,
|
|
198
|
+
"scratch": typing.NotRequired[str | None],
|
|
199
|
+
"continue": typing.NotRequired[str | None],
|
|
200
|
+
"info": bool,
|
|
201
|
+
"quiet": bool,
|
|
202
|
+
"debug": bool,
|
|
203
|
+
"force": bool,
|
|
204
|
+
"nthreads": typing.NotRequired[int | None],
|
|
205
|
+
"config": typing.NotRequired[list[Dwi2responseConfigParamsDict] | None],
|
|
206
|
+
"help": bool,
|
|
207
|
+
"version": bool,
|
|
208
|
+
})
|
|
209
|
+
Dwi2responseParamsDict = _Dwi2responseParamsDictNoTag | Dwi2responseParamsDictTagged
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def dwi2response_algorithm_cargs_dyn_fn(
|
|
213
|
+
t: str,
|
|
214
|
+
) -> typing.Any:
|
|
215
|
+
"""
|
|
216
|
+
Get build cargs function by command type.
|
|
217
|
+
|
|
218
|
+
Args:
|
|
219
|
+
t: Command type.
|
|
220
|
+
Returns:
|
|
221
|
+
Build cargs function.
|
|
222
|
+
"""
|
|
223
|
+
return {
|
|
224
|
+
"dhollander": dwi2response_dhollander_cargs,
|
|
225
|
+
"fa": dwi2response_fa_cargs,
|
|
226
|
+
"manual": dwi2response_manual_cargs,
|
|
227
|
+
"msmt_5tt": dwi2response_msmt_5tt_cargs,
|
|
228
|
+
"tax": dwi2response_tax_cargs,
|
|
229
|
+
"tournier": dwi2response_tournier_cargs,
|
|
230
|
+
}.get(t)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def dwi2response_algorithm_outputs_dyn_fn(
|
|
234
|
+
t: str,
|
|
235
|
+
) -> typing.Any:
|
|
236
|
+
"""
|
|
237
|
+
Get build outputs function by command type.
|
|
238
|
+
|
|
239
|
+
Args:
|
|
240
|
+
t: Command type.
|
|
241
|
+
Returns:
|
|
242
|
+
Build outputs function.
|
|
243
|
+
"""
|
|
244
|
+
return {
|
|
245
|
+
"dhollander": dwi2response_dhollander_outputs,
|
|
246
|
+
"fa": dwi2response_fa_outputs,
|
|
247
|
+
"manual": dwi2response_manual_outputs,
|
|
248
|
+
"msmt_5tt": dwi2response_msmt_5tt_outputs,
|
|
249
|
+
"tax": dwi2response_tax_outputs,
|
|
250
|
+
"tournier": dwi2response_tournier_outputs,
|
|
251
|
+
}.get(t)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def dwi2response_algorithm_validate_dyn_fn(
|
|
255
|
+
t: str,
|
|
256
|
+
) -> typing.Any:
|
|
257
|
+
"""
|
|
258
|
+
Get validate params function by command type.
|
|
259
|
+
|
|
260
|
+
Args:
|
|
261
|
+
t: Command type.
|
|
262
|
+
Returns:
|
|
263
|
+
Validate params function.
|
|
264
|
+
"""
|
|
265
|
+
return {
|
|
266
|
+
"dhollander": dwi2response_dhollander_validate,
|
|
267
|
+
"fa": dwi2response_fa_validate,
|
|
268
|
+
"manual": dwi2response_manual_validate,
|
|
269
|
+
"msmt_5tt": dwi2response_msmt_5tt_validate,
|
|
270
|
+
"tax": dwi2response_tax_validate,
|
|
271
|
+
"tournier": dwi2response_tournier_validate,
|
|
272
|
+
}.get(t)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
class Dwi2responseDhollanderOutputs(typing.NamedTuple):
|
|
276
|
+
"""
|
|
277
|
+
Output object returned when calling `Dwi2responseDhollanderParamsDict(...)`.
|
|
278
|
+
"""
|
|
279
|
+
root: OutputPathType
|
|
280
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
281
|
+
out_sfwm: OutputPathType
|
|
282
|
+
"""Output single-fibre WM response function text file"""
|
|
283
|
+
out_gm: OutputPathType
|
|
284
|
+
"""Output GM response function text file"""
|
|
285
|
+
out_csf: OutputPathType
|
|
286
|
+
"""Output CSF response function text file"""
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def dwi2response_dhollander(
|
|
290
|
+
input_: InputPathType,
|
|
291
|
+
out_sfwm: str,
|
|
292
|
+
out_gm: str,
|
|
293
|
+
out_csf: str,
|
|
294
|
+
erode: int | None = None,
|
|
295
|
+
fa: float | None = None,
|
|
296
|
+
sfwm: float | None = None,
|
|
297
|
+
gm: float | None = None,
|
|
298
|
+
csf: float | None = None,
|
|
299
|
+
wm_algo: typing.Literal["fa", "tax", "tournier"] | None = None,
|
|
300
|
+
) -> Dwi2responseDhollanderParamsDictTagged:
|
|
301
|
+
"""
|
|
302
|
+
Build parameters.
|
|
303
|
+
|
|
304
|
+
Args:
|
|
305
|
+
input_: Input DWI dataset.
|
|
306
|
+
out_sfwm: Output single-fibre WM response function text file.
|
|
307
|
+
out_gm: Output GM response function text file.
|
|
308
|
+
out_csf: Output CSF response function text file.
|
|
309
|
+
erode: Number of erosion passes to apply to initial (whole brain) mask.\
|
|
310
|
+
Set to 0 to not erode the brain mask. (default: 3).
|
|
311
|
+
fa: FA threshold for crude WM versus GM-CSF separation. (default: 0.2).
|
|
312
|
+
sfwm: Final number of single-fibre WM voxels to select, as a percentage\
|
|
313
|
+
of refined WM. (default: 0.5 per cent).
|
|
314
|
+
gm: Final number of GM voxels to select, as a percentage of refined GM.\
|
|
315
|
+
(default: 2 per cent).
|
|
316
|
+
csf: Final number of CSF voxels to select, as a percentage of refined\
|
|
317
|
+
CSF. (default: 10 per cent).
|
|
318
|
+
wm_algo: Use external dwi2response algorithm for WM single-fibre voxel\
|
|
319
|
+
selection (options: fa, tax, tournier) (default: built-in Dhollander\
|
|
320
|
+
2019).
|
|
321
|
+
Returns:
|
|
322
|
+
Parameter dictionary
|
|
323
|
+
"""
|
|
324
|
+
params = {
|
|
325
|
+
"@type": "dhollander",
|
|
326
|
+
"input": input_,
|
|
327
|
+
"out_sfwm": out_sfwm,
|
|
328
|
+
"out_gm": out_gm,
|
|
329
|
+
"out_csf": out_csf,
|
|
330
|
+
}
|
|
331
|
+
if erode is not None:
|
|
332
|
+
params["erode"] = erode
|
|
333
|
+
if fa is not None:
|
|
334
|
+
params["fa"] = fa
|
|
335
|
+
if sfwm is not None:
|
|
336
|
+
params["sfwm"] = sfwm
|
|
337
|
+
if gm is not None:
|
|
338
|
+
params["gm"] = gm
|
|
339
|
+
if csf is not None:
|
|
340
|
+
params["csf"] = csf
|
|
341
|
+
if wm_algo is not None:
|
|
342
|
+
params["wm_algo"] = wm_algo
|
|
343
|
+
return params
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def dwi2response_dhollander_validate(
|
|
347
|
+
params: typing.Any,
|
|
348
|
+
) -> None:
|
|
349
|
+
"""
|
|
350
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
351
|
+
`Dwi2responseDhollanderParamsDict` object.
|
|
352
|
+
|
|
353
|
+
Args:
|
|
354
|
+
params: The parameters object to validate.
|
|
355
|
+
"""
|
|
356
|
+
if params is None or not isinstance(params, dict):
|
|
357
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
358
|
+
if params.get("input", None) is None:
|
|
359
|
+
raise StyxValidationError("`input` must not be None")
|
|
360
|
+
if not isinstance(params["input"], (pathlib.Path, str)):
|
|
361
|
+
raise StyxValidationError(f'`input` has the wrong type: Received `{type(params.get("input", None))}` expected `InputPathType`')
|
|
362
|
+
if params.get("out_sfwm", None) is None:
|
|
363
|
+
raise StyxValidationError("`out_sfwm` must not be None")
|
|
364
|
+
if not isinstance(params["out_sfwm"], str):
|
|
365
|
+
raise StyxValidationError(f'`out_sfwm` has the wrong type: Received `{type(params.get("out_sfwm", None))}` expected `str`')
|
|
366
|
+
if params.get("out_gm", None) is None:
|
|
367
|
+
raise StyxValidationError("`out_gm` must not be None")
|
|
368
|
+
if not isinstance(params["out_gm"], str):
|
|
369
|
+
raise StyxValidationError(f'`out_gm` has the wrong type: Received `{type(params.get("out_gm", None))}` expected `str`')
|
|
370
|
+
if params.get("out_csf", None) is None:
|
|
371
|
+
raise StyxValidationError("`out_csf` must not be None")
|
|
372
|
+
if not isinstance(params["out_csf"], str):
|
|
373
|
+
raise StyxValidationError(f'`out_csf` has the wrong type: Received `{type(params.get("out_csf", None))}` expected `str`')
|
|
374
|
+
if params.get("erode", None) is not None:
|
|
375
|
+
if not isinstance(params["erode"], int):
|
|
376
|
+
raise StyxValidationError(f'`erode` has the wrong type: Received `{type(params.get("erode", None))}` expected `int | None`')
|
|
377
|
+
if params.get("fa", None) is not None:
|
|
378
|
+
if not isinstance(params["fa"], (float, int)):
|
|
379
|
+
raise StyxValidationError(f'`fa` has the wrong type: Received `{type(params.get("fa", None))}` expected `float | None`')
|
|
380
|
+
if params.get("sfwm", None) is not None:
|
|
381
|
+
if not isinstance(params["sfwm"], (float, int)):
|
|
382
|
+
raise StyxValidationError(f'`sfwm` has the wrong type: Received `{type(params.get("sfwm", None))}` expected `float | None`')
|
|
383
|
+
if params.get("gm", None) is not None:
|
|
384
|
+
if not isinstance(params["gm"], (float, int)):
|
|
385
|
+
raise StyxValidationError(f'`gm` has the wrong type: Received `{type(params.get("gm", None))}` expected `float | None`')
|
|
386
|
+
if params.get("csf", None) is not None:
|
|
387
|
+
if not isinstance(params["csf"], (float, int)):
|
|
388
|
+
raise StyxValidationError(f'`csf` has the wrong type: Received `{type(params.get("csf", None))}` expected `float | None`')
|
|
389
|
+
if params.get("wm_algo", None) is not None:
|
|
390
|
+
if not isinstance(params["wm_algo"], str):
|
|
391
|
+
raise StyxValidationError(f'`wm_algo` has the wrong type: Received `{type(params.get("wm_algo", None))}` expected `typing.Literal["fa", "tax", "tournier"] | None`')
|
|
392
|
+
if params["wm_algo"] not in ["fa", "tax", "tournier"]:
|
|
393
|
+
raise StyxValidationError("Parameter `wm_algo` must be one of [\"fa\", \"tax\", \"tournier\"]")
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
def dwi2response_dhollander_cargs(
|
|
397
|
+
params: Dwi2responseDhollanderParamsDict,
|
|
398
|
+
execution: Execution,
|
|
399
|
+
) -> list[str]:
|
|
400
|
+
"""
|
|
401
|
+
Build command-line arguments from parameters.
|
|
402
|
+
|
|
403
|
+
Args:
|
|
404
|
+
params: The parameters.
|
|
405
|
+
execution: The execution object for resolving input paths.
|
|
406
|
+
Returns:
|
|
407
|
+
Command-line arguments.
|
|
408
|
+
"""
|
|
409
|
+
cargs = []
|
|
410
|
+
cargs.append("dhollander")
|
|
411
|
+
cargs.append(execution.input_file(params.get("input", None)))
|
|
412
|
+
cargs.append(params.get("out_sfwm", None))
|
|
413
|
+
cargs.append(params.get("out_gm", None))
|
|
414
|
+
cargs.append(params.get("out_csf", None))
|
|
415
|
+
if params.get("erode", None) is not None:
|
|
416
|
+
cargs.extend([
|
|
417
|
+
"-erode",
|
|
418
|
+
str(params.get("erode", None))
|
|
419
|
+
])
|
|
420
|
+
if params.get("fa", None) is not None:
|
|
421
|
+
cargs.extend([
|
|
422
|
+
"-fa",
|
|
423
|
+
str(params.get("fa", None))
|
|
424
|
+
])
|
|
425
|
+
if params.get("sfwm", None) is not None:
|
|
426
|
+
cargs.extend([
|
|
427
|
+
"-sfwm",
|
|
428
|
+
str(params.get("sfwm", None))
|
|
429
|
+
])
|
|
430
|
+
if params.get("gm", None) is not None:
|
|
431
|
+
cargs.extend([
|
|
432
|
+
"-gm",
|
|
433
|
+
str(params.get("gm", None))
|
|
434
|
+
])
|
|
435
|
+
if params.get("csf", None) is not None:
|
|
436
|
+
cargs.extend([
|
|
437
|
+
"-csf",
|
|
438
|
+
str(params.get("csf", None))
|
|
439
|
+
])
|
|
440
|
+
if params.get("wm_algo", None) is not None:
|
|
441
|
+
cargs.extend([
|
|
442
|
+
"-wm_algo",
|
|
443
|
+
params.get("wm_algo", None)
|
|
444
|
+
])
|
|
445
|
+
return cargs
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
def dwi2response_dhollander_outputs(
|
|
449
|
+
params: Dwi2responseDhollanderParamsDict,
|
|
450
|
+
execution: Execution,
|
|
451
|
+
) -> Dwi2responseDhollanderOutputs:
|
|
452
|
+
"""
|
|
453
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
454
|
+
|
|
455
|
+
Args:
|
|
456
|
+
params: The parameters.
|
|
457
|
+
execution: The execution object for resolving input paths.
|
|
458
|
+
Returns:
|
|
459
|
+
Outputs object.
|
|
460
|
+
"""
|
|
461
|
+
ret = Dwi2responseDhollanderOutputs(
|
|
462
|
+
root=execution.output_file("."),
|
|
463
|
+
out_sfwm=execution.output_file(params.get("out_sfwm", None)),
|
|
464
|
+
out_gm=execution.output_file(params.get("out_gm", None)),
|
|
465
|
+
out_csf=execution.output_file(params.get("out_csf", None)),
|
|
466
|
+
)
|
|
467
|
+
return ret
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
class Dwi2responseFaOutputs(typing.NamedTuple):
|
|
471
|
+
"""
|
|
472
|
+
Output object returned when calling `Dwi2responseFaParamsDict(...)`.
|
|
473
|
+
"""
|
|
474
|
+
root: OutputPathType
|
|
475
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
476
|
+
output: OutputPathType
|
|
477
|
+
"""The output response function text file"""
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
def dwi2response_fa(
|
|
481
|
+
input_: InputPathType,
|
|
482
|
+
output: str,
|
|
483
|
+
erode: int | None = None,
|
|
484
|
+
number: int | None = None,
|
|
485
|
+
threshold: float | None = None,
|
|
486
|
+
) -> Dwi2responseFaParamsDictTagged:
|
|
487
|
+
"""
|
|
488
|
+
Build parameters.
|
|
489
|
+
|
|
490
|
+
Args:
|
|
491
|
+
input_: The input DWI.
|
|
492
|
+
output: The output response function text file.
|
|
493
|
+
erode: Number of brain mask erosion steps to apply prior to threshold\
|
|
494
|
+
(not used if mask is provided manually).
|
|
495
|
+
number: The number of highest-FA voxels to use.
|
|
496
|
+
threshold: Apply a hard FA threshold, rather than selecting the top\
|
|
497
|
+
voxels.
|
|
498
|
+
Returns:
|
|
499
|
+
Parameter dictionary
|
|
500
|
+
"""
|
|
501
|
+
params = {
|
|
502
|
+
"@type": "fa",
|
|
503
|
+
"input": input_,
|
|
504
|
+
"output": output,
|
|
505
|
+
}
|
|
506
|
+
if erode is not None:
|
|
507
|
+
params["erode"] = erode
|
|
508
|
+
if number is not None:
|
|
509
|
+
params["number"] = number
|
|
510
|
+
if threshold is not None:
|
|
511
|
+
params["threshold"] = threshold
|
|
512
|
+
return params
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
def dwi2response_fa_validate(
|
|
516
|
+
params: typing.Any,
|
|
517
|
+
) -> None:
|
|
518
|
+
"""
|
|
519
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
520
|
+
`Dwi2responseFaParamsDict` object.
|
|
521
|
+
|
|
522
|
+
Args:
|
|
523
|
+
params: The parameters object to validate.
|
|
524
|
+
"""
|
|
525
|
+
if params is None or not isinstance(params, dict):
|
|
526
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
527
|
+
if params.get("input", None) is None:
|
|
528
|
+
raise StyxValidationError("`input` must not be None")
|
|
529
|
+
if not isinstance(params["input"], (pathlib.Path, str)):
|
|
530
|
+
raise StyxValidationError(f'`input` has the wrong type: Received `{type(params.get("input", None))}` expected `InputPathType`')
|
|
531
|
+
if params.get("output", None) is None:
|
|
532
|
+
raise StyxValidationError("`output` must not be None")
|
|
533
|
+
if not isinstance(params["output"], str):
|
|
534
|
+
raise StyxValidationError(f'`output` has the wrong type: Received `{type(params.get("output", None))}` expected `str`')
|
|
535
|
+
if params.get("erode", None) is not None:
|
|
536
|
+
if not isinstance(params["erode"], int):
|
|
537
|
+
raise StyxValidationError(f'`erode` has the wrong type: Received `{type(params.get("erode", None))}` expected `int | None`')
|
|
538
|
+
if params.get("number", None) is not None:
|
|
539
|
+
if not isinstance(params["number"], int):
|
|
540
|
+
raise StyxValidationError(f'`number` has the wrong type: Received `{type(params.get("number", None))}` expected `int | None`')
|
|
541
|
+
if params.get("threshold", None) is not None:
|
|
542
|
+
if not isinstance(params["threshold"], (float, int)):
|
|
543
|
+
raise StyxValidationError(f'`threshold` has the wrong type: Received `{type(params.get("threshold", None))}` expected `float | None`')
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
def dwi2response_fa_cargs(
|
|
547
|
+
params: Dwi2responseFaParamsDict,
|
|
548
|
+
execution: Execution,
|
|
549
|
+
) -> list[str]:
|
|
550
|
+
"""
|
|
551
|
+
Build command-line arguments from parameters.
|
|
552
|
+
|
|
553
|
+
Args:
|
|
554
|
+
params: The parameters.
|
|
555
|
+
execution: The execution object for resolving input paths.
|
|
556
|
+
Returns:
|
|
557
|
+
Command-line arguments.
|
|
558
|
+
"""
|
|
559
|
+
cargs = []
|
|
560
|
+
cargs.append("fa")
|
|
561
|
+
cargs.append(execution.input_file(params.get("input", None)))
|
|
562
|
+
cargs.append(params.get("output", None))
|
|
563
|
+
if params.get("erode", None) is not None:
|
|
564
|
+
cargs.extend([
|
|
565
|
+
"-erode",
|
|
566
|
+
str(params.get("erode", None))
|
|
567
|
+
])
|
|
568
|
+
if params.get("number", None) is not None:
|
|
569
|
+
cargs.extend([
|
|
570
|
+
"-number",
|
|
571
|
+
str(params.get("number", None))
|
|
572
|
+
])
|
|
573
|
+
if params.get("threshold", None) is not None:
|
|
574
|
+
cargs.extend([
|
|
575
|
+
"-threshold",
|
|
576
|
+
str(params.get("threshold", None))
|
|
577
|
+
])
|
|
578
|
+
return cargs
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
def dwi2response_fa_outputs(
|
|
582
|
+
params: Dwi2responseFaParamsDict,
|
|
583
|
+
execution: Execution,
|
|
584
|
+
) -> Dwi2responseFaOutputs:
|
|
585
|
+
"""
|
|
586
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
587
|
+
|
|
588
|
+
Args:
|
|
589
|
+
params: The parameters.
|
|
590
|
+
execution: The execution object for resolving input paths.
|
|
591
|
+
Returns:
|
|
592
|
+
Outputs object.
|
|
593
|
+
"""
|
|
594
|
+
ret = Dwi2responseFaOutputs(
|
|
595
|
+
root=execution.output_file("."),
|
|
596
|
+
output=execution.output_file(params.get("output", None)),
|
|
597
|
+
)
|
|
598
|
+
return ret
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
class Dwi2responseManualOutputs(typing.NamedTuple):
|
|
602
|
+
"""
|
|
603
|
+
Output object returned when calling `Dwi2responseManualParamsDict(...)`.
|
|
604
|
+
"""
|
|
605
|
+
root: OutputPathType
|
|
606
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
607
|
+
output: OutputPathType
|
|
608
|
+
"""Output response function text file"""
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
def dwi2response_manual(
|
|
612
|
+
input_: InputPathType,
|
|
613
|
+
in_voxels: InputPathType,
|
|
614
|
+
output: str,
|
|
615
|
+
dirs: InputPathType | None = None,
|
|
616
|
+
) -> Dwi2responseManualParamsDictTagged:
|
|
617
|
+
"""
|
|
618
|
+
Build parameters.
|
|
619
|
+
|
|
620
|
+
Args:
|
|
621
|
+
input_: The input DWI.
|
|
622
|
+
in_voxels: Input voxel selection mask.
|
|
623
|
+
output: Output response function text file.
|
|
624
|
+
dirs: Manually provide the fibre direction in each voxel (a tensor fit\
|
|
625
|
+
will be used otherwise).
|
|
626
|
+
Returns:
|
|
627
|
+
Parameter dictionary
|
|
628
|
+
"""
|
|
629
|
+
params = {
|
|
630
|
+
"@type": "manual",
|
|
631
|
+
"input": input_,
|
|
632
|
+
"in_voxels": in_voxels,
|
|
633
|
+
"output": output,
|
|
634
|
+
}
|
|
635
|
+
if dirs is not None:
|
|
636
|
+
params["dirs"] = dirs
|
|
637
|
+
return params
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
def dwi2response_manual_validate(
|
|
641
|
+
params: typing.Any,
|
|
642
|
+
) -> None:
|
|
643
|
+
"""
|
|
644
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
645
|
+
`Dwi2responseManualParamsDict` object.
|
|
646
|
+
|
|
647
|
+
Args:
|
|
648
|
+
params: The parameters object to validate.
|
|
649
|
+
"""
|
|
650
|
+
if params is None or not isinstance(params, dict):
|
|
651
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
652
|
+
if params.get("input", None) is None:
|
|
653
|
+
raise StyxValidationError("`input` must not be None")
|
|
654
|
+
if not isinstance(params["input"], (pathlib.Path, str)):
|
|
655
|
+
raise StyxValidationError(f'`input` has the wrong type: Received `{type(params.get("input", None))}` expected `InputPathType`')
|
|
656
|
+
if params.get("in_voxels", None) is None:
|
|
657
|
+
raise StyxValidationError("`in_voxels` must not be None")
|
|
658
|
+
if not isinstance(params["in_voxels"], (pathlib.Path, str)):
|
|
659
|
+
raise StyxValidationError(f'`in_voxels` has the wrong type: Received `{type(params.get("in_voxels", None))}` expected `InputPathType`')
|
|
660
|
+
if params.get("output", None) is None:
|
|
661
|
+
raise StyxValidationError("`output` must not be None")
|
|
662
|
+
if not isinstance(params["output"], str):
|
|
663
|
+
raise StyxValidationError(f'`output` has the wrong type: Received `{type(params.get("output", None))}` expected `str`')
|
|
664
|
+
if params.get("dirs", None) is not None:
|
|
665
|
+
if not isinstance(params["dirs"], (pathlib.Path, str)):
|
|
666
|
+
raise StyxValidationError(f'`dirs` has the wrong type: Received `{type(params.get("dirs", None))}` expected `InputPathType | None`')
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
def dwi2response_manual_cargs(
|
|
670
|
+
params: Dwi2responseManualParamsDict,
|
|
671
|
+
execution: Execution,
|
|
672
|
+
) -> list[str]:
|
|
673
|
+
"""
|
|
674
|
+
Build command-line arguments from parameters.
|
|
675
|
+
|
|
676
|
+
Args:
|
|
677
|
+
params: The parameters.
|
|
678
|
+
execution: The execution object for resolving input paths.
|
|
679
|
+
Returns:
|
|
680
|
+
Command-line arguments.
|
|
681
|
+
"""
|
|
682
|
+
cargs = []
|
|
683
|
+
cargs.append("manual")
|
|
684
|
+
cargs.append(execution.input_file(params.get("input", None)))
|
|
685
|
+
cargs.append(execution.input_file(params.get("in_voxels", None)))
|
|
686
|
+
cargs.append(params.get("output", None))
|
|
687
|
+
if params.get("dirs", None) is not None:
|
|
688
|
+
cargs.extend([
|
|
689
|
+
"-dirs",
|
|
690
|
+
execution.input_file(params.get("dirs", None))
|
|
691
|
+
])
|
|
692
|
+
return cargs
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
def dwi2response_manual_outputs(
|
|
696
|
+
params: Dwi2responseManualParamsDict,
|
|
697
|
+
execution: Execution,
|
|
698
|
+
) -> Dwi2responseManualOutputs:
|
|
699
|
+
"""
|
|
700
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
701
|
+
|
|
702
|
+
Args:
|
|
703
|
+
params: The parameters.
|
|
704
|
+
execution: The execution object for resolving input paths.
|
|
705
|
+
Returns:
|
|
706
|
+
Outputs object.
|
|
707
|
+
"""
|
|
708
|
+
ret = Dwi2responseManualOutputs(
|
|
709
|
+
root=execution.output_file("."),
|
|
710
|
+
output=execution.output_file(params.get("output", None)),
|
|
711
|
+
)
|
|
712
|
+
return ret
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
class Dwi2responseMsmt5ttOutputs(typing.NamedTuple):
|
|
716
|
+
"""
|
|
717
|
+
Output object returned when calling `Dwi2responseMsmt5ttParamsDict(...)`.
|
|
718
|
+
"""
|
|
719
|
+
root: OutputPathType
|
|
720
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
721
|
+
out_wm: OutputPathType
|
|
722
|
+
"""Output WM response text file"""
|
|
723
|
+
out_gm: OutputPathType
|
|
724
|
+
"""Output GM response text file"""
|
|
725
|
+
out_csf: OutputPathType
|
|
726
|
+
"""Output CSF response text file"""
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
def dwi2response_msmt_5tt(
|
|
730
|
+
input_: InputPathType,
|
|
731
|
+
in_5tt: InputPathType,
|
|
732
|
+
out_wm: str,
|
|
733
|
+
out_gm: str,
|
|
734
|
+
out_csf: str,
|
|
735
|
+
dirs: InputPathType | None = None,
|
|
736
|
+
fa: float | None = None,
|
|
737
|
+
pvf: float | None = None,
|
|
738
|
+
wm_algo: typing.Literal["fa", "tax", "tournier"] | None = None,
|
|
739
|
+
sfwm_fa_threshold: float | None = None,
|
|
740
|
+
) -> Dwi2responseMsmt5ttParamsDictTagged:
|
|
741
|
+
"""
|
|
742
|
+
Build parameters.
|
|
743
|
+
|
|
744
|
+
Args:
|
|
745
|
+
input_: The input DWI.
|
|
746
|
+
in_5tt: Input co-registered 5TT image.
|
|
747
|
+
out_wm: Output WM response text file.
|
|
748
|
+
out_gm: Output GM response text file.
|
|
749
|
+
out_csf: Output CSF response text file.
|
|
750
|
+
dirs: Manually provide the fibre direction in each voxel (a tensor fit\
|
|
751
|
+
will be used otherwise).
|
|
752
|
+
fa: Upper fractional anisotropy threshold for GM and CSF voxel\
|
|
753
|
+
selection (default: 0.2).
|
|
754
|
+
pvf: Partial volume fraction threshold for tissue voxel selection\
|
|
755
|
+
(default: 0.95).
|
|
756
|
+
wm_algo: algorithm dwi2response algorithm to use for WM single-fibre\
|
|
757
|
+
voxel selection (options: fa, tax, tournier; default: tournier).
|
|
758
|
+
sfwm_fa_threshold: Sets -wm_algo to fa and allows to specify a hard FA\
|
|
759
|
+
threshold for single-fibre WM voxels, which is passed to the -threshold\
|
|
760
|
+
option of the fa algorithm (warning: overrides -wm_algo option).
|
|
761
|
+
Returns:
|
|
762
|
+
Parameter dictionary
|
|
763
|
+
"""
|
|
764
|
+
params = {
|
|
765
|
+
"@type": "msmt_5tt",
|
|
766
|
+
"input": input_,
|
|
767
|
+
"in_5tt": in_5tt,
|
|
768
|
+
"out_wm": out_wm,
|
|
769
|
+
"out_gm": out_gm,
|
|
770
|
+
"out_csf": out_csf,
|
|
771
|
+
}
|
|
772
|
+
if dirs is not None:
|
|
773
|
+
params["dirs"] = dirs
|
|
774
|
+
if fa is not None:
|
|
775
|
+
params["fa"] = fa
|
|
776
|
+
if pvf is not None:
|
|
777
|
+
params["pvf"] = pvf
|
|
778
|
+
if wm_algo is not None:
|
|
779
|
+
params["wm_algo"] = wm_algo
|
|
780
|
+
if sfwm_fa_threshold is not None:
|
|
781
|
+
params["sfwm_fa_threshold"] = sfwm_fa_threshold
|
|
782
|
+
return params
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
def dwi2response_msmt_5tt_validate(
|
|
786
|
+
params: typing.Any,
|
|
787
|
+
) -> None:
|
|
788
|
+
"""
|
|
789
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
790
|
+
`Dwi2responseMsmt5ttParamsDict` object.
|
|
791
|
+
|
|
792
|
+
Args:
|
|
793
|
+
params: The parameters object to validate.
|
|
794
|
+
"""
|
|
795
|
+
if params is None or not isinstance(params, dict):
|
|
796
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
797
|
+
if params.get("input", None) is None:
|
|
798
|
+
raise StyxValidationError("`input` must not be None")
|
|
799
|
+
if not isinstance(params["input"], (pathlib.Path, str)):
|
|
800
|
+
raise StyxValidationError(f'`input` has the wrong type: Received `{type(params.get("input", None))}` expected `InputPathType`')
|
|
801
|
+
if params.get("in_5tt", None) is None:
|
|
802
|
+
raise StyxValidationError("`in_5tt` must not be None")
|
|
803
|
+
if not isinstance(params["in_5tt"], (pathlib.Path, str)):
|
|
804
|
+
raise StyxValidationError(f'`in_5tt` has the wrong type: Received `{type(params.get("in_5tt", None))}` expected `InputPathType`')
|
|
805
|
+
if params.get("out_wm", None) is None:
|
|
806
|
+
raise StyxValidationError("`out_wm` must not be None")
|
|
807
|
+
if not isinstance(params["out_wm"], str):
|
|
808
|
+
raise StyxValidationError(f'`out_wm` has the wrong type: Received `{type(params.get("out_wm", None))}` expected `str`')
|
|
809
|
+
if params.get("out_gm", None) is None:
|
|
810
|
+
raise StyxValidationError("`out_gm` must not be None")
|
|
811
|
+
if not isinstance(params["out_gm"], str):
|
|
812
|
+
raise StyxValidationError(f'`out_gm` has the wrong type: Received `{type(params.get("out_gm", None))}` expected `str`')
|
|
813
|
+
if params.get("out_csf", None) is None:
|
|
814
|
+
raise StyxValidationError("`out_csf` must not be None")
|
|
815
|
+
if not isinstance(params["out_csf"], str):
|
|
816
|
+
raise StyxValidationError(f'`out_csf` has the wrong type: Received `{type(params.get("out_csf", None))}` expected `str`')
|
|
817
|
+
if params.get("dirs", None) is not None:
|
|
818
|
+
if not isinstance(params["dirs"], (pathlib.Path, str)):
|
|
819
|
+
raise StyxValidationError(f'`dirs` has the wrong type: Received `{type(params.get("dirs", None))}` expected `InputPathType | None`')
|
|
820
|
+
if params.get("fa", None) is not None:
|
|
821
|
+
if not isinstance(params["fa"], (float, int)):
|
|
822
|
+
raise StyxValidationError(f'`fa` has the wrong type: Received `{type(params.get("fa", None))}` expected `float | None`')
|
|
823
|
+
if params.get("pvf", None) is not None:
|
|
824
|
+
if not isinstance(params["pvf"], (float, int)):
|
|
825
|
+
raise StyxValidationError(f'`pvf` has the wrong type: Received `{type(params.get("pvf", None))}` expected `float | None`')
|
|
826
|
+
if params.get("wm_algo", None) is not None:
|
|
827
|
+
if not isinstance(params["wm_algo"], str):
|
|
828
|
+
raise StyxValidationError(f'`wm_algo` has the wrong type: Received `{type(params.get("wm_algo", None))}` expected `typing.Literal["fa", "tax", "tournier"] | None`')
|
|
829
|
+
if params["wm_algo"] not in ["fa", "tax", "tournier"]:
|
|
830
|
+
raise StyxValidationError("Parameter `wm_algo` must be one of [\"fa\", \"tax\", \"tournier\"]")
|
|
831
|
+
if params.get("sfwm_fa_threshold", None) is not None:
|
|
832
|
+
if not isinstance(params["sfwm_fa_threshold"], (float, int)):
|
|
833
|
+
raise StyxValidationError(f'`sfwm_fa_threshold` has the wrong type: Received `{type(params.get("sfwm_fa_threshold", None))}` expected `float | None`')
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
def dwi2response_msmt_5tt_cargs(
|
|
837
|
+
params: Dwi2responseMsmt5ttParamsDict,
|
|
838
|
+
execution: Execution,
|
|
839
|
+
) -> list[str]:
|
|
840
|
+
"""
|
|
841
|
+
Build command-line arguments from parameters.
|
|
842
|
+
|
|
843
|
+
Args:
|
|
844
|
+
params: The parameters.
|
|
845
|
+
execution: The execution object for resolving input paths.
|
|
846
|
+
Returns:
|
|
847
|
+
Command-line arguments.
|
|
848
|
+
"""
|
|
849
|
+
cargs = []
|
|
850
|
+
cargs.append("msmt_5tt")
|
|
851
|
+
cargs.append(execution.input_file(params.get("input", None)))
|
|
852
|
+
cargs.append(execution.input_file(params.get("in_5tt", None)))
|
|
853
|
+
cargs.append(params.get("out_wm", None))
|
|
854
|
+
cargs.append(params.get("out_gm", None))
|
|
855
|
+
cargs.append(params.get("out_csf", None))
|
|
856
|
+
if params.get("dirs", None) is not None:
|
|
857
|
+
cargs.extend([
|
|
858
|
+
"-dirs",
|
|
859
|
+
execution.input_file(params.get("dirs", None))
|
|
860
|
+
])
|
|
861
|
+
if params.get("fa", None) is not None:
|
|
862
|
+
cargs.extend([
|
|
863
|
+
"-fa",
|
|
864
|
+
str(params.get("fa", None))
|
|
865
|
+
])
|
|
866
|
+
if params.get("pvf", None) is not None:
|
|
867
|
+
cargs.extend([
|
|
868
|
+
"-pvf",
|
|
869
|
+
str(params.get("pvf", None))
|
|
870
|
+
])
|
|
871
|
+
if params.get("wm_algo", None) is not None:
|
|
872
|
+
cargs.extend([
|
|
873
|
+
"-wm_algo",
|
|
874
|
+
params.get("wm_algo", None)
|
|
875
|
+
])
|
|
876
|
+
if params.get("sfwm_fa_threshold", None) is not None:
|
|
877
|
+
cargs.extend([
|
|
878
|
+
"-sfwm_fa_threshold",
|
|
879
|
+
str(params.get("sfwm_fa_threshold", None))
|
|
880
|
+
])
|
|
881
|
+
return cargs
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
def dwi2response_msmt_5tt_outputs(
|
|
885
|
+
params: Dwi2responseMsmt5ttParamsDict,
|
|
886
|
+
execution: Execution,
|
|
887
|
+
) -> Dwi2responseMsmt5ttOutputs:
|
|
888
|
+
"""
|
|
889
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
890
|
+
|
|
891
|
+
Args:
|
|
892
|
+
params: The parameters.
|
|
893
|
+
execution: The execution object for resolving input paths.
|
|
894
|
+
Returns:
|
|
895
|
+
Outputs object.
|
|
896
|
+
"""
|
|
897
|
+
ret = Dwi2responseMsmt5ttOutputs(
|
|
898
|
+
root=execution.output_file("."),
|
|
899
|
+
out_wm=execution.output_file(params.get("out_wm", None)),
|
|
900
|
+
out_gm=execution.output_file(params.get("out_gm", None)),
|
|
901
|
+
out_csf=execution.output_file(params.get("out_csf", None)),
|
|
902
|
+
)
|
|
903
|
+
return ret
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
class Dwi2responseTaxOutputs(typing.NamedTuple):
|
|
907
|
+
"""
|
|
908
|
+
Output object returned when calling `Dwi2responseTaxParamsDict(...)`.
|
|
909
|
+
"""
|
|
910
|
+
root: OutputPathType
|
|
911
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
912
|
+
output: OutputPathType
|
|
913
|
+
"""The output response function text file"""
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
def dwi2response_tax(
|
|
917
|
+
input_: InputPathType,
|
|
918
|
+
output: str,
|
|
919
|
+
peak_ratio: float | None = None,
|
|
920
|
+
max_iters: int | None = None,
|
|
921
|
+
convergence: float | None = None,
|
|
922
|
+
) -> Dwi2responseTaxParamsDictTagged:
|
|
923
|
+
"""
|
|
924
|
+
Build parameters.
|
|
925
|
+
|
|
926
|
+
Args:
|
|
927
|
+
input_: The input DWI.
|
|
928
|
+
output: The output response function text file.
|
|
929
|
+
peak_ratio: Second-to-first-peak amplitude ratio threshold.
|
|
930
|
+
max_iters: Maximum number of iterations.
|
|
931
|
+
convergence: Percentile change in any RF coefficient required to\
|
|
932
|
+
continue iterating.
|
|
933
|
+
Returns:
|
|
934
|
+
Parameter dictionary
|
|
935
|
+
"""
|
|
936
|
+
params = {
|
|
937
|
+
"@type": "tax",
|
|
938
|
+
"input": input_,
|
|
939
|
+
"output": output,
|
|
940
|
+
}
|
|
941
|
+
if peak_ratio is not None:
|
|
942
|
+
params["peak_ratio"] = peak_ratio
|
|
943
|
+
if max_iters is not None:
|
|
944
|
+
params["max_iters"] = max_iters
|
|
945
|
+
if convergence is not None:
|
|
946
|
+
params["convergence"] = convergence
|
|
947
|
+
return params
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
def dwi2response_tax_validate(
|
|
951
|
+
params: typing.Any,
|
|
952
|
+
) -> None:
|
|
953
|
+
"""
|
|
954
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
955
|
+
`Dwi2responseTaxParamsDict` object.
|
|
956
|
+
|
|
957
|
+
Args:
|
|
958
|
+
params: The parameters object to validate.
|
|
959
|
+
"""
|
|
960
|
+
if params is None or not isinstance(params, dict):
|
|
961
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
962
|
+
if params.get("input", None) is None:
|
|
963
|
+
raise StyxValidationError("`input` must not be None")
|
|
964
|
+
if not isinstance(params["input"], (pathlib.Path, str)):
|
|
965
|
+
raise StyxValidationError(f'`input` has the wrong type: Received `{type(params.get("input", None))}` expected `InputPathType`')
|
|
966
|
+
if params.get("output", None) is None:
|
|
967
|
+
raise StyxValidationError("`output` must not be None")
|
|
968
|
+
if not isinstance(params["output"], str):
|
|
969
|
+
raise StyxValidationError(f'`output` has the wrong type: Received `{type(params.get("output", None))}` expected `str`')
|
|
970
|
+
if params.get("peak_ratio", None) is not None:
|
|
971
|
+
if not isinstance(params["peak_ratio"], (float, int)):
|
|
972
|
+
raise StyxValidationError(f'`peak_ratio` has the wrong type: Received `{type(params.get("peak_ratio", None))}` expected `float | None`')
|
|
973
|
+
if params.get("max_iters", None) is not None:
|
|
974
|
+
if not isinstance(params["max_iters"], int):
|
|
975
|
+
raise StyxValidationError(f'`max_iters` has the wrong type: Received `{type(params.get("max_iters", None))}` expected `int | None`')
|
|
976
|
+
if params.get("convergence", None) is not None:
|
|
977
|
+
if not isinstance(params["convergence"], (float, int)):
|
|
978
|
+
raise StyxValidationError(f'`convergence` has the wrong type: Received `{type(params.get("convergence", None))}` expected `float | None`')
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
def dwi2response_tax_cargs(
|
|
982
|
+
params: Dwi2responseTaxParamsDict,
|
|
983
|
+
execution: Execution,
|
|
984
|
+
) -> list[str]:
|
|
985
|
+
"""
|
|
986
|
+
Build command-line arguments from parameters.
|
|
987
|
+
|
|
988
|
+
Args:
|
|
989
|
+
params: The parameters.
|
|
990
|
+
execution: The execution object for resolving input paths.
|
|
991
|
+
Returns:
|
|
992
|
+
Command-line arguments.
|
|
993
|
+
"""
|
|
994
|
+
cargs = []
|
|
995
|
+
cargs.append("tax")
|
|
996
|
+
cargs.append(execution.input_file(params.get("input", None)))
|
|
997
|
+
cargs.append(params.get("output", None))
|
|
998
|
+
if params.get("peak_ratio", None) is not None:
|
|
999
|
+
cargs.extend([
|
|
1000
|
+
"-peak_ratio",
|
|
1001
|
+
str(params.get("peak_ratio", None))
|
|
1002
|
+
])
|
|
1003
|
+
if params.get("max_iters", None) is not None:
|
|
1004
|
+
cargs.extend([
|
|
1005
|
+
"-max_iters",
|
|
1006
|
+
str(params.get("max_iters", None))
|
|
1007
|
+
])
|
|
1008
|
+
if params.get("convergence", None) is not None:
|
|
1009
|
+
cargs.extend([
|
|
1010
|
+
"-convergence",
|
|
1011
|
+
str(params.get("convergence", None))
|
|
1012
|
+
])
|
|
1013
|
+
return cargs
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
def dwi2response_tax_outputs(
|
|
1017
|
+
params: Dwi2responseTaxParamsDict,
|
|
1018
|
+
execution: Execution,
|
|
1019
|
+
) -> Dwi2responseTaxOutputs:
|
|
1020
|
+
"""
|
|
1021
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
1022
|
+
|
|
1023
|
+
Args:
|
|
1024
|
+
params: The parameters.
|
|
1025
|
+
execution: The execution object for resolving input paths.
|
|
1026
|
+
Returns:
|
|
1027
|
+
Outputs object.
|
|
1028
|
+
"""
|
|
1029
|
+
ret = Dwi2responseTaxOutputs(
|
|
1030
|
+
root=execution.output_file("."),
|
|
1031
|
+
output=execution.output_file(params.get("output", None)),
|
|
1032
|
+
)
|
|
1033
|
+
return ret
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
class Dwi2responseTournierOutputs(typing.NamedTuple):
|
|
1037
|
+
"""
|
|
1038
|
+
Output object returned when calling `Dwi2responseTournierParamsDict(...)`.
|
|
1039
|
+
"""
|
|
1040
|
+
root: OutputPathType
|
|
1041
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
1042
|
+
output: OutputPathType
|
|
1043
|
+
"""The output response function text file"""
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
def dwi2response_tournier(
|
|
1047
|
+
input_: InputPathType,
|
|
1048
|
+
output: str,
|
|
1049
|
+
number: int | None = None,
|
|
1050
|
+
iter_voxels: int | None = None,
|
|
1051
|
+
dilate: int | None = None,
|
|
1052
|
+
max_iters: int | None = None,
|
|
1053
|
+
) -> Dwi2responseTournierParamsDictTagged:
|
|
1054
|
+
"""
|
|
1055
|
+
Build parameters.
|
|
1056
|
+
|
|
1057
|
+
Args:
|
|
1058
|
+
input_: The input DWI.
|
|
1059
|
+
output: The output response function text file.
|
|
1060
|
+
number: Number of single-fibre voxels to use when calculating response\
|
|
1061
|
+
function.
|
|
1062
|
+
iter_voxels: Number of single-fibre voxels to select when preparing for\
|
|
1063
|
+
the next iteration (default = 10 x value given in -number).
|
|
1064
|
+
dilate: Number of mask dilation steps to apply when deriving voxel mask\
|
|
1065
|
+
to test in the next iteration.
|
|
1066
|
+
max_iters: Maximum number of iterations.
|
|
1067
|
+
Returns:
|
|
1068
|
+
Parameter dictionary
|
|
1069
|
+
"""
|
|
1070
|
+
params = {
|
|
1071
|
+
"@type": "tournier",
|
|
1072
|
+
"input": input_,
|
|
1073
|
+
"output": output,
|
|
1074
|
+
}
|
|
1075
|
+
if number is not None:
|
|
1076
|
+
params["number"] = number
|
|
1077
|
+
if iter_voxels is not None:
|
|
1078
|
+
params["iter_voxels"] = iter_voxels
|
|
1079
|
+
if dilate is not None:
|
|
1080
|
+
params["dilate"] = dilate
|
|
1081
|
+
if max_iters is not None:
|
|
1082
|
+
params["max_iters"] = max_iters
|
|
1083
|
+
return params
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
def dwi2response_tournier_validate(
|
|
1087
|
+
params: typing.Any,
|
|
1088
|
+
) -> None:
|
|
1089
|
+
"""
|
|
1090
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
1091
|
+
`Dwi2responseTournierParamsDict` object.
|
|
1092
|
+
|
|
1093
|
+
Args:
|
|
1094
|
+
params: The parameters object to validate.
|
|
1095
|
+
"""
|
|
1096
|
+
if params is None or not isinstance(params, dict):
|
|
1097
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
1098
|
+
if params.get("input", None) is None:
|
|
1099
|
+
raise StyxValidationError("`input` must not be None")
|
|
1100
|
+
if not isinstance(params["input"], (pathlib.Path, str)):
|
|
1101
|
+
raise StyxValidationError(f'`input` has the wrong type: Received `{type(params.get("input", None))}` expected `InputPathType`')
|
|
1102
|
+
if params.get("output", None) is None:
|
|
1103
|
+
raise StyxValidationError("`output` must not be None")
|
|
1104
|
+
if not isinstance(params["output"], str):
|
|
1105
|
+
raise StyxValidationError(f'`output` has the wrong type: Received `{type(params.get("output", None))}` expected `str`')
|
|
1106
|
+
if params.get("number", None) is not None:
|
|
1107
|
+
if not isinstance(params["number"], int):
|
|
1108
|
+
raise StyxValidationError(f'`number` has the wrong type: Received `{type(params.get("number", None))}` expected `int | None`')
|
|
1109
|
+
if params.get("iter_voxels", None) is not None:
|
|
1110
|
+
if not isinstance(params["iter_voxels"], int):
|
|
1111
|
+
raise StyxValidationError(f'`iter_voxels` has the wrong type: Received `{type(params.get("iter_voxels", None))}` expected `int | None`')
|
|
1112
|
+
if params.get("dilate", None) is not None:
|
|
1113
|
+
if not isinstance(params["dilate"], int):
|
|
1114
|
+
raise StyxValidationError(f'`dilate` has the wrong type: Received `{type(params.get("dilate", None))}` expected `int | None`')
|
|
1115
|
+
if params.get("max_iters", None) is not None:
|
|
1116
|
+
if not isinstance(params["max_iters"], int):
|
|
1117
|
+
raise StyxValidationError(f'`max_iters` has the wrong type: Received `{type(params.get("max_iters", None))}` expected `int | None`')
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
def dwi2response_tournier_cargs(
|
|
1121
|
+
params: Dwi2responseTournierParamsDict,
|
|
1122
|
+
execution: Execution,
|
|
1123
|
+
) -> list[str]:
|
|
1124
|
+
"""
|
|
1125
|
+
Build command-line arguments from parameters.
|
|
1126
|
+
|
|
1127
|
+
Args:
|
|
1128
|
+
params: The parameters.
|
|
1129
|
+
execution: The execution object for resolving input paths.
|
|
1130
|
+
Returns:
|
|
1131
|
+
Command-line arguments.
|
|
1132
|
+
"""
|
|
1133
|
+
cargs = []
|
|
1134
|
+
cargs.append("tournier")
|
|
1135
|
+
cargs.append(execution.input_file(params.get("input", None)))
|
|
1136
|
+
cargs.append(params.get("output", None))
|
|
1137
|
+
if params.get("number", None) is not None:
|
|
1138
|
+
cargs.extend([
|
|
1139
|
+
"-number",
|
|
1140
|
+
str(params.get("number", None))
|
|
1141
|
+
])
|
|
1142
|
+
if params.get("iter_voxels", None) is not None:
|
|
1143
|
+
cargs.extend([
|
|
1144
|
+
"-iter_voxels",
|
|
1145
|
+
str(params.get("iter_voxels", None))
|
|
1146
|
+
])
|
|
1147
|
+
if params.get("dilate", None) is not None:
|
|
1148
|
+
cargs.extend([
|
|
1149
|
+
"-dilate",
|
|
1150
|
+
str(params.get("dilate", None))
|
|
1151
|
+
])
|
|
1152
|
+
if params.get("max_iters", None) is not None:
|
|
1153
|
+
cargs.extend([
|
|
1154
|
+
"-max_iters",
|
|
1155
|
+
str(params.get("max_iters", None))
|
|
1156
|
+
])
|
|
1157
|
+
return cargs
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
def dwi2response_tournier_outputs(
|
|
1161
|
+
params: Dwi2responseTournierParamsDict,
|
|
1162
|
+
execution: Execution,
|
|
1163
|
+
) -> Dwi2responseTournierOutputs:
|
|
1164
|
+
"""
|
|
1165
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
1166
|
+
|
|
1167
|
+
Args:
|
|
1168
|
+
params: The parameters.
|
|
1169
|
+
execution: The execution object for resolving input paths.
|
|
1170
|
+
Returns:
|
|
1171
|
+
Outputs object.
|
|
1172
|
+
"""
|
|
1173
|
+
ret = Dwi2responseTournierOutputs(
|
|
1174
|
+
root=execution.output_file("."),
|
|
1175
|
+
output=execution.output_file(params.get("output", None)),
|
|
1176
|
+
)
|
|
1177
|
+
return ret
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
def dwi2response_fslgrad(
|
|
1181
|
+
bvecs: InputPathType,
|
|
1182
|
+
bvals: InputPathType,
|
|
1183
|
+
) -> Dwi2responseFslgradParamsDictTagged:
|
|
1184
|
+
"""
|
|
1185
|
+
Build parameters.
|
|
1186
|
+
|
|
1187
|
+
Args:
|
|
1188
|
+
bvecs: Provide the diffusion-weighted gradient scheme used in the\
|
|
1189
|
+
acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
|
|
1190
|
+
scheme is present in the input image header, the data provided with\
|
|
1191
|
+
this option will be instead used.
|
|
1192
|
+
bvals: Provide the diffusion-weighted gradient scheme used in the\
|
|
1193
|
+
acquisition in FSL bvecs/bvals format files. If a diffusion gradient\
|
|
1194
|
+
scheme is present in the input image header, the data provided with\
|
|
1195
|
+
this option will be instead used.
|
|
1196
|
+
Returns:
|
|
1197
|
+
Parameter dictionary
|
|
1198
|
+
"""
|
|
1199
|
+
params = {
|
|
1200
|
+
"@type": "fslgrad",
|
|
1201
|
+
"bvecs": bvecs,
|
|
1202
|
+
"bvals": bvals,
|
|
1203
|
+
}
|
|
1204
|
+
return params
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
def dwi2response_fslgrad_validate(
|
|
1208
|
+
params: typing.Any,
|
|
1209
|
+
) -> None:
|
|
1210
|
+
"""
|
|
1211
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
1212
|
+
`Dwi2responseFslgradParamsDict` object.
|
|
1213
|
+
|
|
1214
|
+
Args:
|
|
1215
|
+
params: The parameters object to validate.
|
|
1216
|
+
"""
|
|
1217
|
+
if params is None or not isinstance(params, dict):
|
|
1218
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
1219
|
+
if params.get("bvecs", None) is None:
|
|
1220
|
+
raise StyxValidationError("`bvecs` must not be None")
|
|
1221
|
+
if not isinstance(params["bvecs"], (pathlib.Path, str)):
|
|
1222
|
+
raise StyxValidationError(f'`bvecs` has the wrong type: Received `{type(params.get("bvecs", None))}` expected `InputPathType`')
|
|
1223
|
+
if params.get("bvals", None) is None:
|
|
1224
|
+
raise StyxValidationError("`bvals` must not be None")
|
|
1225
|
+
if not isinstance(params["bvals"], (pathlib.Path, str)):
|
|
1226
|
+
raise StyxValidationError(f'`bvals` has the wrong type: Received `{type(params.get("bvals", None))}` expected `InputPathType`')
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
def dwi2response_fslgrad_cargs(
|
|
1230
|
+
params: Dwi2responseFslgradParamsDict,
|
|
1231
|
+
execution: Execution,
|
|
1232
|
+
) -> list[str]:
|
|
1233
|
+
"""
|
|
1234
|
+
Build command-line arguments from parameters.
|
|
1235
|
+
|
|
1236
|
+
Args:
|
|
1237
|
+
params: The parameters.
|
|
1238
|
+
execution: The execution object for resolving input paths.
|
|
1239
|
+
Returns:
|
|
1240
|
+
Command-line arguments.
|
|
1241
|
+
"""
|
|
1242
|
+
cargs = []
|
|
1243
|
+
cargs.append("-fslgrad")
|
|
1244
|
+
cargs.append(execution.input_file(params.get("bvecs", None)))
|
|
1245
|
+
cargs.append(execution.input_file(params.get("bvals", None)))
|
|
1246
|
+
return cargs
|
|
1247
|
+
|
|
1248
|
+
|
|
1249
|
+
def dwi2response_config(
|
|
1250
|
+
key: str,
|
|
1251
|
+
value: str,
|
|
1252
|
+
) -> Dwi2responseConfigParamsDictTagged:
|
|
1253
|
+
"""
|
|
1254
|
+
Build parameters.
|
|
1255
|
+
|
|
1256
|
+
Args:
|
|
1257
|
+
key: temporarily set the value of an MRtrix config file entry.
|
|
1258
|
+
value: temporarily set the value of an MRtrix config file entry.
|
|
1259
|
+
Returns:
|
|
1260
|
+
Parameter dictionary
|
|
1261
|
+
"""
|
|
1262
|
+
params = {
|
|
1263
|
+
"@type": "config",
|
|
1264
|
+
"key": key,
|
|
1265
|
+
"value": value,
|
|
1266
|
+
}
|
|
1267
|
+
return params
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
def dwi2response_config_validate(
|
|
1271
|
+
params: typing.Any,
|
|
1272
|
+
) -> None:
|
|
1273
|
+
"""
|
|
1274
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
1275
|
+
`Dwi2responseConfigParamsDict` object.
|
|
1276
|
+
|
|
1277
|
+
Args:
|
|
1278
|
+
params: The parameters object to validate.
|
|
1279
|
+
"""
|
|
1280
|
+
if params is None or not isinstance(params, dict):
|
|
1281
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
1282
|
+
if params.get("key", None) is None:
|
|
1283
|
+
raise StyxValidationError("`key` must not be None")
|
|
1284
|
+
if not isinstance(params["key"], str):
|
|
1285
|
+
raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
|
|
1286
|
+
if params.get("value", None) is None:
|
|
1287
|
+
raise StyxValidationError("`value` must not be None")
|
|
1288
|
+
if not isinstance(params["value"], str):
|
|
1289
|
+
raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')
|
|
1290
|
+
|
|
1291
|
+
|
|
1292
|
+
def dwi2response_config_cargs(
|
|
1293
|
+
params: Dwi2responseConfigParamsDict,
|
|
1294
|
+
execution: Execution,
|
|
1295
|
+
) -> list[str]:
|
|
1296
|
+
"""
|
|
1297
|
+
Build command-line arguments from parameters.
|
|
1298
|
+
|
|
1299
|
+
Args:
|
|
1300
|
+
params: The parameters.
|
|
1301
|
+
execution: The execution object for resolving input paths.
|
|
1302
|
+
Returns:
|
|
1303
|
+
Command-line arguments.
|
|
1304
|
+
"""
|
|
1305
|
+
cargs = []
|
|
1306
|
+
cargs.append("-config")
|
|
1307
|
+
cargs.append(params.get("key", None))
|
|
1308
|
+
cargs.append(params.get("value", None))
|
|
1309
|
+
return cargs
|
|
1310
|
+
|
|
1311
|
+
|
|
1312
|
+
class Dwi2responseOutputs(typing.NamedTuple):
|
|
1313
|
+
"""
|
|
1314
|
+
Output object returned when calling `Dwi2responseParamsDict(...)`.
|
|
1315
|
+
"""
|
|
1316
|
+
root: OutputPathType
|
|
1317
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
1318
|
+
algorithm: typing.Union[Dwi2responseDhollanderOutputs, Dwi2responseFaOutputs, Dwi2responseManualOutputs, Dwi2responseMsmt5ttOutputs, Dwi2responseTaxOutputs, Dwi2responseTournierOutputs]
|
|
1319
|
+
"""Outputs from `Dwi2responseDhollanderParamsDict` or
|
|
1320
|
+
`Dwi2responseFaParamsDict` or `Dwi2responseManualParamsDict` or
|
|
1321
|
+
`Dwi2responseMsmt5ttParamsDict` or `Dwi2responseTaxParamsDict` or
|
|
1322
|
+
`Dwi2responseTournierParamsDict`."""
|
|
1323
|
+
|
|
1324
|
+
|
|
1325
|
+
def dwi2response_params(
|
|
1326
|
+
algorithm: typing.Union[Dwi2responseDhollanderParamsDictTagged, Dwi2responseFaParamsDictTagged, Dwi2responseManualParamsDictTagged, Dwi2responseMsmt5ttParamsDictTagged, Dwi2responseTaxParamsDictTagged, Dwi2responseTournierParamsDictTagged],
|
|
1327
|
+
grad: InputPathType | None = None,
|
|
1328
|
+
fslgrad: Dwi2responseFslgradParamsDict | None = None,
|
|
1329
|
+
mask: InputPathType | None = None,
|
|
1330
|
+
voxels: str | None = None,
|
|
1331
|
+
shells: list[int] | None = None,
|
|
1332
|
+
lmax: list[int] | None = None,
|
|
1333
|
+
nocleanup: bool = False,
|
|
1334
|
+
scratch: str | None = None,
|
|
1335
|
+
continue_: str | None = None,
|
|
1336
|
+
info: bool = False,
|
|
1337
|
+
quiet: bool = False,
|
|
1338
|
+
debug: bool = False,
|
|
1339
|
+
force: bool = False,
|
|
1340
|
+
nthreads: int | None = None,
|
|
1341
|
+
config: list[Dwi2responseConfigParamsDict] | None = None,
|
|
1342
|
+
help_: bool = False,
|
|
1343
|
+
version: bool = False,
|
|
1344
|
+
) -> Dwi2responseParamsDictTagged:
|
|
1345
|
+
"""
|
|
1346
|
+
Build parameters.
|
|
1347
|
+
|
|
1348
|
+
Args:
|
|
1349
|
+
algorithm: Select the algorithm to be used to complete the script\
|
|
1350
|
+
operation; additional details and options become available once an\
|
|
1351
|
+
algorithm is nominated. Options are: dhollander, fa, manual, msmt_5tt,\
|
|
1352
|
+
tax, tournier.
|
|
1353
|
+
grad: Provide the diffusion gradient table in MRtrix format.
|
|
1354
|
+
fslgrad: Provide the diffusion gradient table in FSL bvecs/bvals format.
|
|
1355
|
+
mask: Only process voxels within the specified binary brain mask image.
|
|
1356
|
+
voxels: Output an image showing the final voxel selection(s).
|
|
1357
|
+
shells: b-value(s) to use in response function estimation\
|
|
1358
|
+
(comma-separated list in case of multiple b-values, b=0 must be\
|
|
1359
|
+
included explicitly).
|
|
1360
|
+
lmax: maximum harmonic degree(s) for response function estimation\
|
|
1361
|
+
(comma-separated list in case of multiple b-values).
|
|
1362
|
+
nocleanup: do not delete intermediate files during script execution,\
|
|
1363
|
+
and do not delete scratch directory at script completion.
|
|
1364
|
+
scratch: manually specify the path in which to generate the scratch\
|
|
1365
|
+
directory.
|
|
1366
|
+
continue_: continue the script from a previous execution; must provide\
|
|
1367
|
+
the scratch directory path, and the name of the last\
|
|
1368
|
+
successfully-generated file.
|
|
1369
|
+
info: display information messages.
|
|
1370
|
+
quiet: do not display information messages or progress status;\
|
|
1371
|
+
alternatively, this can be achieved by setting the MRTRIX_QUIET\
|
|
1372
|
+
environment variable to a non-empty string.
|
|
1373
|
+
debug: display debugging messages.
|
|
1374
|
+
force: force overwrite of output files (caution: using the same file as\
|
|
1375
|
+
input and output might cause unexpected behaviour).
|
|
1376
|
+
nthreads: use this number of threads in multi-threaded applications\
|
|
1377
|
+
(set to 0 to disable multi-threading).
|
|
1378
|
+
config: temporarily set the value of an MRtrix config file entry.
|
|
1379
|
+
help_: display this information page and exit.
|
|
1380
|
+
version: display version information and exit.
|
|
1381
|
+
Returns:
|
|
1382
|
+
Parameter dictionary
|
|
1383
|
+
"""
|
|
1384
|
+
params = {
|
|
1385
|
+
"@type": "mrtrix/dwi2response",
|
|
1386
|
+
"algorithm": algorithm,
|
|
1387
|
+
"nocleanup": nocleanup,
|
|
1388
|
+
"info": info,
|
|
1389
|
+
"quiet": quiet,
|
|
1390
|
+
"debug": debug,
|
|
1391
|
+
"force": force,
|
|
1392
|
+
"help": help_,
|
|
1393
|
+
"version": version,
|
|
1394
|
+
}
|
|
1395
|
+
if grad is not None:
|
|
1396
|
+
params["grad"] = grad
|
|
1397
|
+
if fslgrad is not None:
|
|
1398
|
+
params["fslgrad"] = fslgrad
|
|
1399
|
+
if mask is not None:
|
|
1400
|
+
params["mask"] = mask
|
|
1401
|
+
if voxels is not None:
|
|
1402
|
+
params["voxels"] = voxels
|
|
1403
|
+
if shells is not None:
|
|
1404
|
+
params["shells"] = shells
|
|
1405
|
+
if lmax is not None:
|
|
1406
|
+
params["lmax"] = lmax
|
|
1407
|
+
if scratch is not None:
|
|
1408
|
+
params["scratch"] = scratch
|
|
1409
|
+
if continue_ is not None:
|
|
1410
|
+
params["continue"] = continue_
|
|
1411
|
+
if nthreads is not None:
|
|
1412
|
+
params["nthreads"] = nthreads
|
|
1413
|
+
if config is not None:
|
|
1414
|
+
params["config"] = config
|
|
1415
|
+
return params
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
def dwi2response_validate(
|
|
1419
|
+
params: typing.Any,
|
|
1420
|
+
) -> None:
|
|
1421
|
+
"""
|
|
1422
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
1423
|
+
`Dwi2responseParamsDict` object.
|
|
1424
|
+
|
|
1425
|
+
Args:
|
|
1426
|
+
params: The parameters object to validate.
|
|
1427
|
+
"""
|
|
1428
|
+
if params is None or not isinstance(params, dict):
|
|
1429
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
1430
|
+
if params.get("algorithm", None) is None:
|
|
1431
|
+
raise StyxValidationError("`algorithm` must not be None")
|
|
1432
|
+
if not isinstance(params["algorithm"], dict):
|
|
1433
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params["algorithm"])}\'')
|
|
1434
|
+
if "@type" not in params["algorithm"]:
|
|
1435
|
+
raise StyxValidationError("Params object is missing `@type`")
|
|
1436
|
+
if params["algorithm"]["@type"] not in ["dhollander", "fa", "manual", "msmt_5tt", "tax", "tournier"]:
|
|
1437
|
+
raise StyxValidationError("Parameter `algorithm`s `@type` must be one of [\"dhollander\", \"fa\", \"manual\", \"msmt_5tt\", \"tax\", \"tournier\"]")
|
|
1438
|
+
dwi2response_algorithm_validate_dyn_fn(params["algorithm"]["@type"])(params["algorithm"])
|
|
1439
|
+
if params.get("grad", None) is not None:
|
|
1440
|
+
if not isinstance(params["grad"], (pathlib.Path, str)):
|
|
1441
|
+
raise StyxValidationError(f'`grad` has the wrong type: Received `{type(params.get("grad", None))}` expected `InputPathType | None`')
|
|
1442
|
+
if params.get("fslgrad", None) is not None:
|
|
1443
|
+
dwi2response_fslgrad_validate(params["fslgrad"])
|
|
1444
|
+
if params.get("mask", None) is not None:
|
|
1445
|
+
if not isinstance(params["mask"], (pathlib.Path, str)):
|
|
1446
|
+
raise StyxValidationError(f'`mask` has the wrong type: Received `{type(params.get("mask", None))}` expected `InputPathType | None`')
|
|
1447
|
+
if params.get("voxels", None) is not None:
|
|
1448
|
+
if not isinstance(params["voxels"], str):
|
|
1449
|
+
raise StyxValidationError(f'`voxels` has the wrong type: Received `{type(params.get("voxels", None))}` expected `str | None`')
|
|
1450
|
+
if params.get("shells", None) is not None:
|
|
1451
|
+
if not isinstance(params["shells"], list):
|
|
1452
|
+
raise StyxValidationError(f'`shells` has the wrong type: Received `{type(params.get("shells", None))}` expected `list[int] | None`')
|
|
1453
|
+
for e in params["shells"]:
|
|
1454
|
+
if not isinstance(e, int):
|
|
1455
|
+
raise StyxValidationError(f'`shells` has the wrong type: Received `{type(params.get("shells", None))}` expected `list[int] | None`')
|
|
1456
|
+
if params.get("lmax", None) is not None:
|
|
1457
|
+
if not isinstance(params["lmax"], list):
|
|
1458
|
+
raise StyxValidationError(f'`lmax` has the wrong type: Received `{type(params.get("lmax", None))}` expected `list[int] | None`')
|
|
1459
|
+
for e in params["lmax"]:
|
|
1460
|
+
if not isinstance(e, int):
|
|
1461
|
+
raise StyxValidationError(f'`lmax` has the wrong type: Received `{type(params.get("lmax", None))}` expected `list[int] | None`')
|
|
1462
|
+
if params.get("nocleanup", False) is None:
|
|
1463
|
+
raise StyxValidationError("`nocleanup` must not be None")
|
|
1464
|
+
if not isinstance(params["nocleanup"], bool):
|
|
1465
|
+
raise StyxValidationError(f'`nocleanup` has the wrong type: Received `{type(params.get("nocleanup", False))}` expected `bool`')
|
|
1466
|
+
if params.get("scratch", None) is not None:
|
|
1467
|
+
if not isinstance(params["scratch"], str):
|
|
1468
|
+
raise StyxValidationError(f'`scratch` has the wrong type: Received `{type(params.get("scratch", None))}` expected `str | None`')
|
|
1469
|
+
if params.get("continue", None) is not None:
|
|
1470
|
+
if not isinstance(params["continue"], str):
|
|
1471
|
+
raise StyxValidationError(f'`continue` has the wrong type: Received `{type(params.get("continue", None))}` expected `str | None`')
|
|
1472
|
+
if params.get("info", False) is None:
|
|
1473
|
+
raise StyxValidationError("`info` must not be None")
|
|
1474
|
+
if not isinstance(params["info"], bool):
|
|
1475
|
+
raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
|
|
1476
|
+
if params.get("quiet", False) is None:
|
|
1477
|
+
raise StyxValidationError("`quiet` must not be None")
|
|
1478
|
+
if not isinstance(params["quiet"], bool):
|
|
1479
|
+
raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
|
|
1480
|
+
if params.get("debug", False) is None:
|
|
1481
|
+
raise StyxValidationError("`debug` must not be None")
|
|
1482
|
+
if not isinstance(params["debug"], bool):
|
|
1483
|
+
raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
|
|
1484
|
+
if params.get("force", False) is None:
|
|
1485
|
+
raise StyxValidationError("`force` must not be None")
|
|
1486
|
+
if not isinstance(params["force"], bool):
|
|
1487
|
+
raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
|
|
1488
|
+
if params.get("nthreads", None) is not None:
|
|
1489
|
+
if not isinstance(params["nthreads"], int):
|
|
1490
|
+
raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
|
|
1491
|
+
if params.get("config", None) is not None:
|
|
1492
|
+
if not isinstance(params["config"], list):
|
|
1493
|
+
raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[Dwi2responseConfigParamsDict] | None`')
|
|
1494
|
+
for e in params["config"]:
|
|
1495
|
+
dwi2response_config_validate(e)
|
|
1496
|
+
if params.get("help", False) is None:
|
|
1497
|
+
raise StyxValidationError("`help` must not be None")
|
|
1498
|
+
if not isinstance(params["help"], bool):
|
|
1499
|
+
raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
|
|
1500
|
+
if params.get("version", False) is None:
|
|
1501
|
+
raise StyxValidationError("`version` must not be None")
|
|
1502
|
+
if not isinstance(params["version"], bool):
|
|
1503
|
+
raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
def dwi2response_cargs(
|
|
1507
|
+
params: Dwi2responseParamsDict,
|
|
1508
|
+
execution: Execution,
|
|
1509
|
+
) -> list[str]:
|
|
1510
|
+
"""
|
|
1511
|
+
Build command-line arguments from parameters.
|
|
1512
|
+
|
|
1513
|
+
Args:
|
|
1514
|
+
params: The parameters.
|
|
1515
|
+
execution: The execution object for resolving input paths.
|
|
1516
|
+
Returns:
|
|
1517
|
+
Command-line arguments.
|
|
1518
|
+
"""
|
|
1519
|
+
cargs = []
|
|
1520
|
+
cargs.append("dwi2response")
|
|
1521
|
+
cargs.extend(dwi2response_algorithm_cargs_dyn_fn(params.get("algorithm", None)["@type"])(params.get("algorithm", None), execution))
|
|
1522
|
+
if params.get("grad", None) is not None:
|
|
1523
|
+
cargs.extend([
|
|
1524
|
+
"-grad",
|
|
1525
|
+
execution.input_file(params.get("grad", None))
|
|
1526
|
+
])
|
|
1527
|
+
if params.get("fslgrad", None) is not None:
|
|
1528
|
+
cargs.extend(dwi2response_fslgrad_cargs(params.get("fslgrad", None), execution))
|
|
1529
|
+
if params.get("mask", None) is not None:
|
|
1530
|
+
cargs.extend([
|
|
1531
|
+
"-mask",
|
|
1532
|
+
execution.input_file(params.get("mask", None))
|
|
1533
|
+
])
|
|
1534
|
+
if params.get("voxels", None) is not None:
|
|
1535
|
+
cargs.extend([
|
|
1536
|
+
"-voxels",
|
|
1537
|
+
params.get("voxels", None)
|
|
1538
|
+
])
|
|
1539
|
+
if params.get("shells", None) is not None:
|
|
1540
|
+
cargs.extend([
|
|
1541
|
+
"-shells",
|
|
1542
|
+
",".join(map(str, params.get("shells", None)))
|
|
1543
|
+
])
|
|
1544
|
+
if params.get("lmax", None) is not None:
|
|
1545
|
+
cargs.extend([
|
|
1546
|
+
"-lmax",
|
|
1547
|
+
",".join(map(str, params.get("lmax", None)))
|
|
1548
|
+
])
|
|
1549
|
+
if params.get("nocleanup", False):
|
|
1550
|
+
cargs.append("-nocleanup")
|
|
1551
|
+
if params.get("scratch", None) is not None:
|
|
1552
|
+
cargs.extend([
|
|
1553
|
+
"-scratch",
|
|
1554
|
+
params.get("scratch", None)
|
|
1555
|
+
])
|
|
1556
|
+
if params.get("continue", None) is not None:
|
|
1557
|
+
cargs.extend([
|
|
1558
|
+
"-continue",
|
|
1559
|
+
params.get("continue", None)
|
|
1560
|
+
])
|
|
1561
|
+
if params.get("info", False):
|
|
1562
|
+
cargs.append("-info")
|
|
1563
|
+
if params.get("quiet", False):
|
|
1564
|
+
cargs.append("-quiet")
|
|
1565
|
+
if params.get("debug", False):
|
|
1566
|
+
cargs.append("-debug")
|
|
1567
|
+
if params.get("force", False):
|
|
1568
|
+
cargs.append("-force")
|
|
1569
|
+
if params.get("nthreads", None) is not None:
|
|
1570
|
+
cargs.extend([
|
|
1571
|
+
"-nthreads",
|
|
1572
|
+
str(params.get("nthreads", None))
|
|
1573
|
+
])
|
|
1574
|
+
if params.get("config", None) is not None:
|
|
1575
|
+
cargs.extend([a for c in [dwi2response_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
|
|
1576
|
+
if params.get("help", False):
|
|
1577
|
+
cargs.append("-help")
|
|
1578
|
+
if params.get("version", False):
|
|
1579
|
+
cargs.append("-version")
|
|
1580
|
+
return cargs
|
|
1581
|
+
|
|
1582
|
+
|
|
1583
|
+
def dwi2response_outputs(
|
|
1584
|
+
params: Dwi2responseParamsDict,
|
|
1585
|
+
execution: Execution,
|
|
1586
|
+
) -> Dwi2responseOutputs:
|
|
1587
|
+
"""
|
|
1588
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
1589
|
+
|
|
1590
|
+
Args:
|
|
1591
|
+
params: The parameters.
|
|
1592
|
+
execution: The execution object for resolving input paths.
|
|
1593
|
+
Returns:
|
|
1594
|
+
Outputs object.
|
|
1595
|
+
"""
|
|
1596
|
+
ret = Dwi2responseOutputs(
|
|
1597
|
+
root=execution.output_file("."),
|
|
1598
|
+
algorithm=dwi2response_algorithm_outputs_dyn_fn(params.get("algorithm")["@type"])(params.get("algorithm"), execution),
|
|
1599
|
+
)
|
|
1600
|
+
return ret
|
|
1601
|
+
|
|
1602
|
+
|
|
1603
|
+
def dwi2response_execute(
|
|
1604
|
+
params: Dwi2responseParamsDict,
|
|
1605
|
+
runner: Runner | None = None,
|
|
1606
|
+
) -> Dwi2responseOutputs:
|
|
1607
|
+
"""
|
|
1608
|
+
dwi2response
|
|
1609
|
+
|
|
1610
|
+
Estimate response function(s) for spherical deconvolution.
|
|
1611
|
+
dwi2response offers different algorithms for performing various types of
|
|
1612
|
+
response function estimation. The name of the algorithm must appear as the
|
|
1613
|
+
first argument on the command-line after ‘dwi2response’. The subsequent
|
|
1614
|
+
arguments and options depend on the particular algorithm being invoked.
|
|
1615
|
+
Each algorithm available has its own help page, including necessary
|
|
1616
|
+
references; e.g. to see the help page of the 'fa' algorithm, type
|
|
1617
|
+
'dwi2response fa'.
|
|
1618
|
+
|
|
1619
|
+
Author: MRTrix3 Developers
|
|
1620
|
+
|
|
1621
|
+
URL: https://www.mrtrix.org/
|
|
1622
|
+
|
|
1623
|
+
Args:
|
|
1624
|
+
params: The parameters.
|
|
1625
|
+
runner: Command runner.
|
|
1626
|
+
Returns:
|
|
1627
|
+
NamedTuple of outputs (described in `Dwi2responseOutputs`).
|
|
1628
|
+
"""
|
|
1629
|
+
dwi2response_validate(params)
|
|
1630
|
+
runner = runner or get_global_runner()
|
|
1631
|
+
execution = runner.start_execution(DWI2RESPONSE_METADATA)
|
|
1632
|
+
params = execution.params(params)
|
|
1633
|
+
cargs = dwi2response_cargs(params, execution)
|
|
1634
|
+
ret = dwi2response_outputs(params, execution)
|
|
1635
|
+
execution.run(cargs)
|
|
1636
|
+
return ret
|
|
1637
|
+
|
|
1638
|
+
|
|
1639
|
+
def dwi2response(
|
|
1640
|
+
algorithm: typing.Union[Dwi2responseDhollanderParamsDictTagged, Dwi2responseFaParamsDictTagged, Dwi2responseManualParamsDictTagged, Dwi2responseMsmt5ttParamsDictTagged, Dwi2responseTaxParamsDictTagged, Dwi2responseTournierParamsDictTagged],
|
|
1641
|
+
grad: InputPathType | None = None,
|
|
1642
|
+
fslgrad: Dwi2responseFslgradParamsDict | None = None,
|
|
1643
|
+
mask: InputPathType | None = None,
|
|
1644
|
+
voxels: str | None = None,
|
|
1645
|
+
shells: list[int] | None = None,
|
|
1646
|
+
lmax: list[int] | None = None,
|
|
1647
|
+
nocleanup: bool = False,
|
|
1648
|
+
scratch: str | None = None,
|
|
1649
|
+
continue_: str | None = None,
|
|
1650
|
+
info: bool = False,
|
|
1651
|
+
quiet: bool = False,
|
|
1652
|
+
debug: bool = False,
|
|
1653
|
+
force: bool = False,
|
|
1654
|
+
nthreads: int | None = None,
|
|
1655
|
+
config: list[Dwi2responseConfigParamsDict] | None = None,
|
|
1656
|
+
help_: bool = False,
|
|
1657
|
+
version: bool = False,
|
|
1658
|
+
runner: Runner | None = None,
|
|
1659
|
+
) -> Dwi2responseOutputs:
|
|
1660
|
+
"""
|
|
1661
|
+
dwi2response
|
|
1662
|
+
|
|
1663
|
+
Estimate response function(s) for spherical deconvolution.
|
|
1664
|
+
dwi2response offers different algorithms for performing various types of
|
|
1665
|
+
response function estimation. The name of the algorithm must appear as the
|
|
1666
|
+
first argument on the command-line after ‘dwi2response’. The subsequent
|
|
1667
|
+
arguments and options depend on the particular algorithm being invoked.
|
|
1668
|
+
Each algorithm available has its own help page, including necessary
|
|
1669
|
+
references; e.g. to see the help page of the 'fa' algorithm, type
|
|
1670
|
+
'dwi2response fa'.
|
|
1671
|
+
|
|
1672
|
+
Author: MRTrix3 Developers
|
|
1673
|
+
|
|
1674
|
+
URL: https://www.mrtrix.org/
|
|
1675
|
+
|
|
1676
|
+
Args:
|
|
1677
|
+
algorithm: Select the algorithm to be used to complete the script\
|
|
1678
|
+
operation; additional details and options become available once an\
|
|
1679
|
+
algorithm is nominated. Options are: dhollander, fa, manual, msmt_5tt,\
|
|
1680
|
+
tax, tournier.
|
|
1681
|
+
grad: Provide the diffusion gradient table in MRtrix format.
|
|
1682
|
+
fslgrad: Provide the diffusion gradient table in FSL bvecs/bvals format.
|
|
1683
|
+
mask: Only process voxels within the specified binary brain mask image.
|
|
1684
|
+
voxels: Output an image showing the final voxel selection(s).
|
|
1685
|
+
shells: b-value(s) to use in response function estimation\
|
|
1686
|
+
(comma-separated list in case of multiple b-values, b=0 must be\
|
|
1687
|
+
included explicitly).
|
|
1688
|
+
lmax: maximum harmonic degree(s) for response function estimation\
|
|
1689
|
+
(comma-separated list in case of multiple b-values).
|
|
1690
|
+
nocleanup: do not delete intermediate files during script execution,\
|
|
1691
|
+
and do not delete scratch directory at script completion.
|
|
1692
|
+
scratch: manually specify the path in which to generate the scratch\
|
|
1693
|
+
directory.
|
|
1694
|
+
continue_: continue the script from a previous execution; must provide\
|
|
1695
|
+
the scratch directory path, and the name of the last\
|
|
1696
|
+
successfully-generated file.
|
|
1697
|
+
info: display information messages.
|
|
1698
|
+
quiet: do not display information messages or progress status;\
|
|
1699
|
+
alternatively, this can be achieved by setting the MRTRIX_QUIET\
|
|
1700
|
+
environment variable to a non-empty string.
|
|
1701
|
+
debug: display debugging messages.
|
|
1702
|
+
force: force overwrite of output files (caution: using the same file as\
|
|
1703
|
+
input and output might cause unexpected behaviour).
|
|
1704
|
+
nthreads: use this number of threads in multi-threaded applications\
|
|
1705
|
+
(set to 0 to disable multi-threading).
|
|
1706
|
+
config: temporarily set the value of an MRtrix config file entry.
|
|
1707
|
+
help_: display this information page and exit.
|
|
1708
|
+
version: display version information and exit.
|
|
1709
|
+
runner: Command runner.
|
|
1710
|
+
Returns:
|
|
1711
|
+
NamedTuple of outputs (described in `Dwi2responseOutputs`).
|
|
1712
|
+
"""
|
|
1713
|
+
params = dwi2response_params(
|
|
1714
|
+
algorithm=algorithm,
|
|
1715
|
+
grad=grad,
|
|
1716
|
+
fslgrad=fslgrad,
|
|
1717
|
+
mask=mask,
|
|
1718
|
+
voxels=voxels,
|
|
1719
|
+
shells=shells,
|
|
1720
|
+
lmax=lmax,
|
|
1721
|
+
nocleanup=nocleanup,
|
|
1722
|
+
scratch=scratch,
|
|
1723
|
+
continue_=continue_,
|
|
1724
|
+
info=info,
|
|
1725
|
+
quiet=quiet,
|
|
1726
|
+
debug=debug,
|
|
1727
|
+
force=force,
|
|
1728
|
+
nthreads=nthreads,
|
|
1729
|
+
config=config,
|
|
1730
|
+
help_=help_,
|
|
1731
|
+
version=version,
|
|
1732
|
+
)
|
|
1733
|
+
return dwi2response_execute(params, runner)
|
|
1734
|
+
|
|
1735
|
+
|
|
1736
|
+
__all__ = [
|
|
1737
|
+
"DWI2RESPONSE_METADATA",
|
|
1738
|
+
"Dwi2responseConfigParamsDict",
|
|
1739
|
+
"Dwi2responseConfigParamsDictTagged",
|
|
1740
|
+
"Dwi2responseDhollanderOutputs",
|
|
1741
|
+
"Dwi2responseDhollanderParamsDict",
|
|
1742
|
+
"Dwi2responseDhollanderParamsDictTagged",
|
|
1743
|
+
"Dwi2responseFaOutputs",
|
|
1744
|
+
"Dwi2responseFaParamsDict",
|
|
1745
|
+
"Dwi2responseFaParamsDictTagged",
|
|
1746
|
+
"Dwi2responseFslgradParamsDict",
|
|
1747
|
+
"Dwi2responseFslgradParamsDictTagged",
|
|
1748
|
+
"Dwi2responseManualOutputs",
|
|
1749
|
+
"Dwi2responseManualParamsDict",
|
|
1750
|
+
"Dwi2responseManualParamsDictTagged",
|
|
1751
|
+
"Dwi2responseMsmt5ttOutputs",
|
|
1752
|
+
"Dwi2responseMsmt5ttParamsDict",
|
|
1753
|
+
"Dwi2responseMsmt5ttParamsDictTagged",
|
|
1754
|
+
"Dwi2responseOutputs",
|
|
1755
|
+
"Dwi2responseParamsDict",
|
|
1756
|
+
"Dwi2responseParamsDictTagged",
|
|
1757
|
+
"Dwi2responseTaxOutputs",
|
|
1758
|
+
"Dwi2responseTaxParamsDict",
|
|
1759
|
+
"Dwi2responseTaxParamsDictTagged",
|
|
1760
|
+
"Dwi2responseTournierOutputs",
|
|
1761
|
+
"Dwi2responseTournierParamsDict",
|
|
1762
|
+
"Dwi2responseTournierParamsDictTagged",
|
|
1763
|
+
"dwi2response",
|
|
1764
|
+
"dwi2response_config",
|
|
1765
|
+
"dwi2response_dhollander",
|
|
1766
|
+
"dwi2response_execute",
|
|
1767
|
+
"dwi2response_fa",
|
|
1768
|
+
"dwi2response_fslgrad",
|
|
1769
|
+
"dwi2response_manual",
|
|
1770
|
+
"dwi2response_msmt_5tt",
|
|
1771
|
+
"dwi2response_params",
|
|
1772
|
+
"dwi2response_tax",
|
|
1773
|
+
"dwi2response_tournier",
|
|
1774
|
+
]
|