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,971 @@
|
|
|
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
|
+
MRFILTER_METADATA = Metadata(
|
|
9
|
+
id="a47cabbb6dd1bf7eda885d594a87568625b0abbc.boutiques",
|
|
10
|
+
name="mrfilter",
|
|
11
|
+
package="mrtrix",
|
|
12
|
+
container_image_tag="mrtrix3/mrtrix3:3.0.4",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
_MrfilterVariousStringParamsDictNoTag = typing.TypedDict('_MrfilterVariousStringParamsDictNoTag', {
|
|
17
|
+
"obj": str,
|
|
18
|
+
})
|
|
19
|
+
MrfilterVariousStringParamsDictTagged = typing.TypedDict('MrfilterVariousStringParamsDictTagged', {
|
|
20
|
+
"@type": typing.Literal["VariousString"],
|
|
21
|
+
"obj": str,
|
|
22
|
+
})
|
|
23
|
+
MrfilterVariousStringParamsDict = _MrfilterVariousStringParamsDictNoTag | MrfilterVariousStringParamsDictTagged
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
_MrfilterVariousFileParamsDictNoTag = typing.TypedDict('_MrfilterVariousFileParamsDictNoTag', {
|
|
27
|
+
"obj": InputPathType,
|
|
28
|
+
})
|
|
29
|
+
MrfilterVariousFileParamsDictTagged = typing.TypedDict('MrfilterVariousFileParamsDictTagged', {
|
|
30
|
+
"@type": typing.Literal["VariousFile"],
|
|
31
|
+
"obj": InputPathType,
|
|
32
|
+
})
|
|
33
|
+
MrfilterVariousFileParamsDict = _MrfilterVariousFileParamsDictNoTag | MrfilterVariousFileParamsDictTagged
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
_MrfilterConfigParamsDictNoTag = typing.TypedDict('_MrfilterConfigParamsDictNoTag', {
|
|
37
|
+
"key": str,
|
|
38
|
+
"value": str,
|
|
39
|
+
})
|
|
40
|
+
MrfilterConfigParamsDictTagged = typing.TypedDict('MrfilterConfigParamsDictTagged', {
|
|
41
|
+
"@type": typing.Literal["config"],
|
|
42
|
+
"key": str,
|
|
43
|
+
"value": str,
|
|
44
|
+
})
|
|
45
|
+
MrfilterConfigParamsDict = _MrfilterConfigParamsDictNoTag | MrfilterConfigParamsDictTagged
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
_MrfilterParamsDictNoTag = typing.TypedDict('_MrfilterParamsDictNoTag', {
|
|
49
|
+
"axes": typing.NotRequired[list[int] | None],
|
|
50
|
+
"inverse": bool,
|
|
51
|
+
"magnitude": bool,
|
|
52
|
+
"centre_zero": bool,
|
|
53
|
+
"stdev": typing.NotRequired[list[float] | None],
|
|
54
|
+
"magnitude_1": bool,
|
|
55
|
+
"scanner": bool,
|
|
56
|
+
"extent": typing.NotRequired[list[int] | None],
|
|
57
|
+
"extent_1": typing.NotRequired[list[int] | None],
|
|
58
|
+
"stdev_1": typing.NotRequired[list[float] | None],
|
|
59
|
+
"fwhm": typing.NotRequired[list[float] | None],
|
|
60
|
+
"extent_2": typing.NotRequired[list[int] | None],
|
|
61
|
+
"zupper": typing.NotRequired[float | None],
|
|
62
|
+
"zlower": typing.NotRequired[float | None],
|
|
63
|
+
"bridge": typing.NotRequired[int | None],
|
|
64
|
+
"maskin": typing.NotRequired[InputPathType | None],
|
|
65
|
+
"maskout": typing.NotRequired[str | None],
|
|
66
|
+
"strides": typing.NotRequired[typing.Union[MrfilterVariousStringParamsDictTagged, MrfilterVariousFileParamsDictTagged] | None],
|
|
67
|
+
"info": bool,
|
|
68
|
+
"quiet": bool,
|
|
69
|
+
"debug": bool,
|
|
70
|
+
"force": bool,
|
|
71
|
+
"nthreads": typing.NotRequired[int | None],
|
|
72
|
+
"config": typing.NotRequired[list[MrfilterConfigParamsDict] | None],
|
|
73
|
+
"help": bool,
|
|
74
|
+
"version": bool,
|
|
75
|
+
"input": InputPathType,
|
|
76
|
+
"filter": str,
|
|
77
|
+
"output": str,
|
|
78
|
+
})
|
|
79
|
+
MrfilterParamsDictTagged = typing.TypedDict('MrfilterParamsDictTagged', {
|
|
80
|
+
"@type": typing.Literal["mrtrix/mrfilter"],
|
|
81
|
+
"axes": typing.NotRequired[list[int] | None],
|
|
82
|
+
"inverse": bool,
|
|
83
|
+
"magnitude": bool,
|
|
84
|
+
"centre_zero": bool,
|
|
85
|
+
"stdev": typing.NotRequired[list[float] | None],
|
|
86
|
+
"magnitude_1": bool,
|
|
87
|
+
"scanner": bool,
|
|
88
|
+
"extent": typing.NotRequired[list[int] | None],
|
|
89
|
+
"extent_1": typing.NotRequired[list[int] | None],
|
|
90
|
+
"stdev_1": typing.NotRequired[list[float] | None],
|
|
91
|
+
"fwhm": typing.NotRequired[list[float] | None],
|
|
92
|
+
"extent_2": typing.NotRequired[list[int] | None],
|
|
93
|
+
"zupper": typing.NotRequired[float | None],
|
|
94
|
+
"zlower": typing.NotRequired[float | None],
|
|
95
|
+
"bridge": typing.NotRequired[int | None],
|
|
96
|
+
"maskin": typing.NotRequired[InputPathType | None],
|
|
97
|
+
"maskout": typing.NotRequired[str | None],
|
|
98
|
+
"strides": typing.NotRequired[typing.Union[MrfilterVariousStringParamsDictTagged, MrfilterVariousFileParamsDictTagged] | None],
|
|
99
|
+
"info": bool,
|
|
100
|
+
"quiet": bool,
|
|
101
|
+
"debug": bool,
|
|
102
|
+
"force": bool,
|
|
103
|
+
"nthreads": typing.NotRequired[int | None],
|
|
104
|
+
"config": typing.NotRequired[list[MrfilterConfigParamsDict] | None],
|
|
105
|
+
"help": bool,
|
|
106
|
+
"version": bool,
|
|
107
|
+
"input": InputPathType,
|
|
108
|
+
"filter": str,
|
|
109
|
+
"output": str,
|
|
110
|
+
})
|
|
111
|
+
MrfilterParamsDict = _MrfilterParamsDictNoTag | MrfilterParamsDictTagged
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def mrfilter_strides_cargs_dyn_fn(
|
|
115
|
+
t: str,
|
|
116
|
+
) -> typing.Any:
|
|
117
|
+
"""
|
|
118
|
+
Get build cargs function by command type.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
t: Command type.
|
|
122
|
+
Returns:
|
|
123
|
+
Build cargs function.
|
|
124
|
+
"""
|
|
125
|
+
return {
|
|
126
|
+
"VariousString": mrfilter_various_string_cargs,
|
|
127
|
+
"VariousFile": mrfilter_various_file_cargs,
|
|
128
|
+
}.get(t)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def mrfilter_strides_validate_dyn_fn(
|
|
132
|
+
t: str,
|
|
133
|
+
) -> typing.Any:
|
|
134
|
+
"""
|
|
135
|
+
Get validate params function by command type.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
t: Command type.
|
|
139
|
+
Returns:
|
|
140
|
+
Validate params function.
|
|
141
|
+
"""
|
|
142
|
+
return {
|
|
143
|
+
"VariousString": mrfilter_various_string_validate,
|
|
144
|
+
"VariousFile": mrfilter_various_file_validate,
|
|
145
|
+
}.get(t)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def mrfilter_various_string(
|
|
149
|
+
obj: str,
|
|
150
|
+
) -> MrfilterVariousStringParamsDictTagged:
|
|
151
|
+
"""
|
|
152
|
+
Build parameters.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
obj: String object.
|
|
156
|
+
Returns:
|
|
157
|
+
Parameter dictionary
|
|
158
|
+
"""
|
|
159
|
+
params = {
|
|
160
|
+
"@type": "VariousString",
|
|
161
|
+
"obj": obj,
|
|
162
|
+
}
|
|
163
|
+
return params
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def mrfilter_various_string_validate(
|
|
167
|
+
params: typing.Any,
|
|
168
|
+
) -> None:
|
|
169
|
+
"""
|
|
170
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
171
|
+
`MrfilterVariousStringParamsDict` object.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
params: The parameters object to validate.
|
|
175
|
+
"""
|
|
176
|
+
if params is None or not isinstance(params, dict):
|
|
177
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
178
|
+
if params.get("obj", None) is None:
|
|
179
|
+
raise StyxValidationError("`obj` must not be None")
|
|
180
|
+
if not isinstance(params["obj"], str):
|
|
181
|
+
raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `str`')
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def mrfilter_various_string_cargs(
|
|
185
|
+
params: MrfilterVariousStringParamsDict,
|
|
186
|
+
execution: Execution,
|
|
187
|
+
) -> list[str]:
|
|
188
|
+
"""
|
|
189
|
+
Build command-line arguments from parameters.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
params: The parameters.
|
|
193
|
+
execution: The execution object for resolving input paths.
|
|
194
|
+
Returns:
|
|
195
|
+
Command-line arguments.
|
|
196
|
+
"""
|
|
197
|
+
cargs = []
|
|
198
|
+
cargs.append(params.get("obj", None))
|
|
199
|
+
return cargs
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def mrfilter_various_file(
|
|
203
|
+
obj: InputPathType,
|
|
204
|
+
) -> MrfilterVariousFileParamsDictTagged:
|
|
205
|
+
"""
|
|
206
|
+
Build parameters.
|
|
207
|
+
|
|
208
|
+
Args:
|
|
209
|
+
obj: File object.
|
|
210
|
+
Returns:
|
|
211
|
+
Parameter dictionary
|
|
212
|
+
"""
|
|
213
|
+
params = {
|
|
214
|
+
"@type": "VariousFile",
|
|
215
|
+
"obj": obj,
|
|
216
|
+
}
|
|
217
|
+
return params
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def mrfilter_various_file_validate(
|
|
221
|
+
params: typing.Any,
|
|
222
|
+
) -> None:
|
|
223
|
+
"""
|
|
224
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
225
|
+
`MrfilterVariousFileParamsDict` object.
|
|
226
|
+
|
|
227
|
+
Args:
|
|
228
|
+
params: The parameters object to validate.
|
|
229
|
+
"""
|
|
230
|
+
if params is None or not isinstance(params, dict):
|
|
231
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
232
|
+
if params.get("obj", None) is None:
|
|
233
|
+
raise StyxValidationError("`obj` must not be None")
|
|
234
|
+
if not isinstance(params["obj"], (pathlib.Path, str)):
|
|
235
|
+
raise StyxValidationError(f'`obj` has the wrong type: Received `{type(params.get("obj", None))}` expected `InputPathType`')
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def mrfilter_various_file_cargs(
|
|
239
|
+
params: MrfilterVariousFileParamsDict,
|
|
240
|
+
execution: Execution,
|
|
241
|
+
) -> list[str]:
|
|
242
|
+
"""
|
|
243
|
+
Build command-line arguments from parameters.
|
|
244
|
+
|
|
245
|
+
Args:
|
|
246
|
+
params: The parameters.
|
|
247
|
+
execution: The execution object for resolving input paths.
|
|
248
|
+
Returns:
|
|
249
|
+
Command-line arguments.
|
|
250
|
+
"""
|
|
251
|
+
cargs = []
|
|
252
|
+
cargs.append(execution.input_file(params.get("obj", None)))
|
|
253
|
+
return cargs
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def mrfilter_config(
|
|
257
|
+
key: str,
|
|
258
|
+
value: str,
|
|
259
|
+
) -> MrfilterConfigParamsDictTagged:
|
|
260
|
+
"""
|
|
261
|
+
Build parameters.
|
|
262
|
+
|
|
263
|
+
Args:
|
|
264
|
+
key: temporarily set the value of an MRtrix config file entry.
|
|
265
|
+
value: temporarily set the value of an MRtrix config file entry.
|
|
266
|
+
Returns:
|
|
267
|
+
Parameter dictionary
|
|
268
|
+
"""
|
|
269
|
+
params = {
|
|
270
|
+
"@type": "config",
|
|
271
|
+
"key": key,
|
|
272
|
+
"value": value,
|
|
273
|
+
}
|
|
274
|
+
return params
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def mrfilter_config_validate(
|
|
278
|
+
params: typing.Any,
|
|
279
|
+
) -> None:
|
|
280
|
+
"""
|
|
281
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
282
|
+
`MrfilterConfigParamsDict` object.
|
|
283
|
+
|
|
284
|
+
Args:
|
|
285
|
+
params: The parameters object to validate.
|
|
286
|
+
"""
|
|
287
|
+
if params is None or not isinstance(params, dict):
|
|
288
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
289
|
+
if params.get("key", None) is None:
|
|
290
|
+
raise StyxValidationError("`key` must not be None")
|
|
291
|
+
if not isinstance(params["key"], str):
|
|
292
|
+
raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
|
|
293
|
+
if params.get("value", None) is None:
|
|
294
|
+
raise StyxValidationError("`value` must not be None")
|
|
295
|
+
if not isinstance(params["value"], str):
|
|
296
|
+
raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def mrfilter_config_cargs(
|
|
300
|
+
params: MrfilterConfigParamsDict,
|
|
301
|
+
execution: Execution,
|
|
302
|
+
) -> list[str]:
|
|
303
|
+
"""
|
|
304
|
+
Build command-line arguments from parameters.
|
|
305
|
+
|
|
306
|
+
Args:
|
|
307
|
+
params: The parameters.
|
|
308
|
+
execution: The execution object for resolving input paths.
|
|
309
|
+
Returns:
|
|
310
|
+
Command-line arguments.
|
|
311
|
+
"""
|
|
312
|
+
cargs = []
|
|
313
|
+
cargs.append("-config")
|
|
314
|
+
cargs.append(params.get("key", None))
|
|
315
|
+
cargs.append(params.get("value", None))
|
|
316
|
+
return cargs
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
class MrfilterOutputs(typing.NamedTuple):
|
|
320
|
+
"""
|
|
321
|
+
Output object returned when calling `MrfilterParamsDict(...)`.
|
|
322
|
+
"""
|
|
323
|
+
root: OutputPathType
|
|
324
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
325
|
+
output: OutputPathType
|
|
326
|
+
"""the output image."""
|
|
327
|
+
maskout: OutputPathType | None
|
|
328
|
+
"""Output a refined mask based on a spatially coherent region with normal
|
|
329
|
+
intensity range. """
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def mrfilter_params(
|
|
333
|
+
input_: InputPathType,
|
|
334
|
+
filter_: str,
|
|
335
|
+
output: str,
|
|
336
|
+
axes: list[int] | None = None,
|
|
337
|
+
inverse: bool = False,
|
|
338
|
+
magnitude: bool = False,
|
|
339
|
+
centre_zero: bool = False,
|
|
340
|
+
stdev: list[float] | None = None,
|
|
341
|
+
magnitude_1: bool = False,
|
|
342
|
+
scanner: bool = False,
|
|
343
|
+
extent: list[int] | None = None,
|
|
344
|
+
extent_1: list[int] | None = None,
|
|
345
|
+
stdev_1: list[float] | None = None,
|
|
346
|
+
fwhm: list[float] | None = None,
|
|
347
|
+
extent_2: list[int] | None = None,
|
|
348
|
+
zupper: float | None = None,
|
|
349
|
+
zlower: float | None = None,
|
|
350
|
+
bridge: int | None = None,
|
|
351
|
+
maskin: InputPathType | None = None,
|
|
352
|
+
maskout: str | None = None,
|
|
353
|
+
strides: typing.Union[MrfilterVariousStringParamsDictTagged, MrfilterVariousFileParamsDictTagged] | None = None,
|
|
354
|
+
info: bool = False,
|
|
355
|
+
quiet: bool = False,
|
|
356
|
+
debug: bool = False,
|
|
357
|
+
force: bool = False,
|
|
358
|
+
nthreads: int | None = None,
|
|
359
|
+
config: list[MrfilterConfigParamsDict] | None = None,
|
|
360
|
+
help_: bool = False,
|
|
361
|
+
version: bool = False,
|
|
362
|
+
) -> MrfilterParamsDictTagged:
|
|
363
|
+
"""
|
|
364
|
+
Build parameters.
|
|
365
|
+
|
|
366
|
+
Args:
|
|
367
|
+
input_: the input image.
|
|
368
|
+
filter_: the type of filter to be applied.
|
|
369
|
+
output: the output image.
|
|
370
|
+
axes: the axes along which to apply the Fourier Transform. By default,\
|
|
371
|
+
the transform is applied along the three spatial axes. Provide as a\
|
|
372
|
+
comma-separate list of axis indices.
|
|
373
|
+
inverse: apply the inverse FFT.
|
|
374
|
+
magnitude: output a magnitude image rather than a complex-valued image.
|
|
375
|
+
centre_zero: re-arrange the FFT results so that the zero-frequency\
|
|
376
|
+
component appears in the centre of the image, rather than at the edges.
|
|
377
|
+
stdev: the standard deviation of the Gaussian kernel used to smooth the\
|
|
378
|
+
input image (in mm). The image is smoothed to reduced large spurious\
|
|
379
|
+
gradients caused by noise. Use this option to override the default\
|
|
380
|
+
stdev of 1 voxel. This can be specified either as a single value to be\
|
|
381
|
+
used for all 3 axes, or as a comma-separated list of 3 values, one for\
|
|
382
|
+
each axis.
|
|
383
|
+
magnitude_1: output the gradient magnitude, rather than the default\
|
|
384
|
+
x,y,z components.
|
|
385
|
+
scanner: define the gradient with respect to the scanner coordinate\
|
|
386
|
+
frame of reference.
|
|
387
|
+
extent: specify extent of median filtering neighbourhood in voxels.\
|
|
388
|
+
This can be specified either as a single value to be used for all 3\
|
|
389
|
+
axes, or as a comma-separated list of 3 values, one for each axis\
|
|
390
|
+
(default: 3x3x3).
|
|
391
|
+
extent_1: specify extent of normalisation filtering neighbourhood in\
|
|
392
|
+
voxels. This can be specified either as a single value to be used for\
|
|
393
|
+
all 3 axes, or as a comma-separated list of 3 values, one for each axis\
|
|
394
|
+
(default: 3x3x3).
|
|
395
|
+
stdev_1: apply Gaussian smoothing with the specified standard\
|
|
396
|
+
deviation. The standard deviation is defined in mm (Default 1 voxel).\
|
|
397
|
+
This can be specified either as a single value to be used for all axes,\
|
|
398
|
+
or as a comma-separated list of the stdev for each axis.
|
|
399
|
+
fwhm: apply Gaussian smoothing with the specified full-width half\
|
|
400
|
+
maximum. The FWHM is defined in mm (Default 1 voxel * 2.3548). This can\
|
|
401
|
+
be specified either as a single value to be used for all axes, or as a\
|
|
402
|
+
comma-separated list of the FWHM for each axis.
|
|
403
|
+
extent_2: specify the extent (width) of kernel size in voxels. This can\
|
|
404
|
+
be specified either as a single value to be used for all axes, or as a\
|
|
405
|
+
comma-separated list of the extent for each axis. The default extent is\
|
|
406
|
+
2 * ceil(2.5 * stdev / voxel_size) - 1.
|
|
407
|
+
zupper: define high intensity outliers: default: 2.5.
|
|
408
|
+
zlower: define low intensity outliers: default: 2.5.
|
|
409
|
+
bridge: number of voxels to gap to fill holes in mask: default: 4.
|
|
410
|
+
maskin: initial mask that defines the maximum spatial extent and the\
|
|
411
|
+
region from which to smaple the intensity range.
|
|
412
|
+
maskout: Output a refined mask based on a spatially coherent region\
|
|
413
|
+
with normal intensity range.
|
|
414
|
+
strides: specify the strides of the output data in memory; either as a\
|
|
415
|
+
comma-separated list of (signed) integers, or as a template image from\
|
|
416
|
+
which the strides shall be extracted and used. The actual strides\
|
|
417
|
+
produced will depend on whether the output image format can support it.
|
|
418
|
+
info: display information messages.
|
|
419
|
+
quiet: do not display information messages or progress status;\
|
|
420
|
+
alternatively, this can be achieved by setting the MRTRIX_QUIET\
|
|
421
|
+
environment variable to a non-empty string.
|
|
422
|
+
debug: display debugging messages.
|
|
423
|
+
force: force overwrite of output files (caution: using the same file as\
|
|
424
|
+
input and output might cause unexpected behaviour).
|
|
425
|
+
nthreads: use this number of threads in multi-threaded applications\
|
|
426
|
+
(set to 0 to disable multi-threading).
|
|
427
|
+
config: temporarily set the value of an MRtrix config file entry.
|
|
428
|
+
help_: display this information page and exit.
|
|
429
|
+
version: display version information and exit.
|
|
430
|
+
Returns:
|
|
431
|
+
Parameter dictionary
|
|
432
|
+
"""
|
|
433
|
+
params = {
|
|
434
|
+
"@type": "mrtrix/mrfilter",
|
|
435
|
+
"inverse": inverse,
|
|
436
|
+
"magnitude": magnitude,
|
|
437
|
+
"centre_zero": centre_zero,
|
|
438
|
+
"magnitude_1": magnitude_1,
|
|
439
|
+
"scanner": scanner,
|
|
440
|
+
"info": info,
|
|
441
|
+
"quiet": quiet,
|
|
442
|
+
"debug": debug,
|
|
443
|
+
"force": force,
|
|
444
|
+
"help": help_,
|
|
445
|
+
"version": version,
|
|
446
|
+
"input": input_,
|
|
447
|
+
"filter": filter_,
|
|
448
|
+
"output": output,
|
|
449
|
+
}
|
|
450
|
+
if axes is not None:
|
|
451
|
+
params["axes"] = axes
|
|
452
|
+
if stdev is not None:
|
|
453
|
+
params["stdev"] = stdev
|
|
454
|
+
if extent is not None:
|
|
455
|
+
params["extent"] = extent
|
|
456
|
+
if extent_1 is not None:
|
|
457
|
+
params["extent_1"] = extent_1
|
|
458
|
+
if stdev_1 is not None:
|
|
459
|
+
params["stdev_1"] = stdev_1
|
|
460
|
+
if fwhm is not None:
|
|
461
|
+
params["fwhm"] = fwhm
|
|
462
|
+
if extent_2 is not None:
|
|
463
|
+
params["extent_2"] = extent_2
|
|
464
|
+
if zupper is not None:
|
|
465
|
+
params["zupper"] = zupper
|
|
466
|
+
if zlower is not None:
|
|
467
|
+
params["zlower"] = zlower
|
|
468
|
+
if bridge is not None:
|
|
469
|
+
params["bridge"] = bridge
|
|
470
|
+
if maskin is not None:
|
|
471
|
+
params["maskin"] = maskin
|
|
472
|
+
if maskout is not None:
|
|
473
|
+
params["maskout"] = maskout
|
|
474
|
+
if strides is not None:
|
|
475
|
+
params["strides"] = strides
|
|
476
|
+
if nthreads is not None:
|
|
477
|
+
params["nthreads"] = nthreads
|
|
478
|
+
if config is not None:
|
|
479
|
+
params["config"] = config
|
|
480
|
+
return params
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
def mrfilter_validate(
|
|
484
|
+
params: typing.Any,
|
|
485
|
+
) -> None:
|
|
486
|
+
"""
|
|
487
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
488
|
+
`MrfilterParamsDict` object.
|
|
489
|
+
|
|
490
|
+
Args:
|
|
491
|
+
params: The parameters object to validate.
|
|
492
|
+
"""
|
|
493
|
+
if params is None or not isinstance(params, dict):
|
|
494
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
495
|
+
if params.get("axes", None) is not None:
|
|
496
|
+
if not isinstance(params["axes"], list):
|
|
497
|
+
raise StyxValidationError(f'`axes` has the wrong type: Received `{type(params.get("axes", None))}` expected `list[int] | None`')
|
|
498
|
+
for e in params["axes"]:
|
|
499
|
+
if not isinstance(e, int):
|
|
500
|
+
raise StyxValidationError(f'`axes` has the wrong type: Received `{type(params.get("axes", None))}` expected `list[int] | None`')
|
|
501
|
+
if params.get("inverse", False) is None:
|
|
502
|
+
raise StyxValidationError("`inverse` must not be None")
|
|
503
|
+
if not isinstance(params["inverse"], bool):
|
|
504
|
+
raise StyxValidationError(f'`inverse` has the wrong type: Received `{type(params.get("inverse", False))}` expected `bool`')
|
|
505
|
+
if params.get("magnitude", False) is None:
|
|
506
|
+
raise StyxValidationError("`magnitude` must not be None")
|
|
507
|
+
if not isinstance(params["magnitude"], bool):
|
|
508
|
+
raise StyxValidationError(f'`magnitude` has the wrong type: Received `{type(params.get("magnitude", False))}` expected `bool`')
|
|
509
|
+
if params.get("centre_zero", False) is None:
|
|
510
|
+
raise StyxValidationError("`centre_zero` must not be None")
|
|
511
|
+
if not isinstance(params["centre_zero"], bool):
|
|
512
|
+
raise StyxValidationError(f'`centre_zero` has the wrong type: Received `{type(params.get("centre_zero", False))}` expected `bool`')
|
|
513
|
+
if params.get("stdev", None) is not None:
|
|
514
|
+
if not isinstance(params["stdev"], list):
|
|
515
|
+
raise StyxValidationError(f'`stdev` has the wrong type: Received `{type(params.get("stdev", None))}` expected `list[float] | None`')
|
|
516
|
+
for e in params["stdev"]:
|
|
517
|
+
if not isinstance(e, (float, int)):
|
|
518
|
+
raise StyxValidationError(f'`stdev` has the wrong type: Received `{type(params.get("stdev", None))}` expected `list[float] | None`')
|
|
519
|
+
if params.get("magnitude_1", False) is None:
|
|
520
|
+
raise StyxValidationError("`magnitude_1` must not be None")
|
|
521
|
+
if not isinstance(params["magnitude_1"], bool):
|
|
522
|
+
raise StyxValidationError(f'`magnitude_1` has the wrong type: Received `{type(params.get("magnitude_1", False))}` expected `bool`')
|
|
523
|
+
if params.get("scanner", False) is None:
|
|
524
|
+
raise StyxValidationError("`scanner` must not be None")
|
|
525
|
+
if not isinstance(params["scanner"], bool):
|
|
526
|
+
raise StyxValidationError(f'`scanner` has the wrong type: Received `{type(params.get("scanner", False))}` expected `bool`')
|
|
527
|
+
if params.get("extent", None) is not None:
|
|
528
|
+
if not isinstance(params["extent"], list):
|
|
529
|
+
raise StyxValidationError(f'`extent` has the wrong type: Received `{type(params.get("extent", None))}` expected `list[int] | None`')
|
|
530
|
+
for e in params["extent"]:
|
|
531
|
+
if not isinstance(e, int):
|
|
532
|
+
raise StyxValidationError(f'`extent` has the wrong type: Received `{type(params.get("extent", None))}` expected `list[int] | None`')
|
|
533
|
+
if params.get("extent_1", None) is not None:
|
|
534
|
+
if not isinstance(params["extent_1"], list):
|
|
535
|
+
raise StyxValidationError(f'`extent_1` has the wrong type: Received `{type(params.get("extent_1", None))}` expected `list[int] | None`')
|
|
536
|
+
for e in params["extent_1"]:
|
|
537
|
+
if not isinstance(e, int):
|
|
538
|
+
raise StyxValidationError(f'`extent_1` has the wrong type: Received `{type(params.get("extent_1", None))}` expected `list[int] | None`')
|
|
539
|
+
if params.get("stdev_1", None) is not None:
|
|
540
|
+
if not isinstance(params["stdev_1"], list):
|
|
541
|
+
raise StyxValidationError(f'`stdev_1` has the wrong type: Received `{type(params.get("stdev_1", None))}` expected `list[float] | None`')
|
|
542
|
+
for e in params["stdev_1"]:
|
|
543
|
+
if not isinstance(e, (float, int)):
|
|
544
|
+
raise StyxValidationError(f'`stdev_1` has the wrong type: Received `{type(params.get("stdev_1", None))}` expected `list[float] | None`')
|
|
545
|
+
if params.get("fwhm", None) is not None:
|
|
546
|
+
if not isinstance(params["fwhm"], list):
|
|
547
|
+
raise StyxValidationError(f'`fwhm` has the wrong type: Received `{type(params.get("fwhm", None))}` expected `list[float] | None`')
|
|
548
|
+
for e in params["fwhm"]:
|
|
549
|
+
if not isinstance(e, (float, int)):
|
|
550
|
+
raise StyxValidationError(f'`fwhm` has the wrong type: Received `{type(params.get("fwhm", None))}` expected `list[float] | None`')
|
|
551
|
+
if params.get("extent_2", None) is not None:
|
|
552
|
+
if not isinstance(params["extent_2"], list):
|
|
553
|
+
raise StyxValidationError(f'`extent_2` has the wrong type: Received `{type(params.get("extent_2", None))}` expected `list[int] | None`')
|
|
554
|
+
for e in params["extent_2"]:
|
|
555
|
+
if not isinstance(e, int):
|
|
556
|
+
raise StyxValidationError(f'`extent_2` has the wrong type: Received `{type(params.get("extent_2", None))}` expected `list[int] | None`')
|
|
557
|
+
if params.get("zupper", None) is not None:
|
|
558
|
+
if not isinstance(params["zupper"], (float, int)):
|
|
559
|
+
raise StyxValidationError(f'`zupper` has the wrong type: Received `{type(params.get("zupper", None))}` expected `float | None`')
|
|
560
|
+
if params.get("zlower", None) is not None:
|
|
561
|
+
if not isinstance(params["zlower"], (float, int)):
|
|
562
|
+
raise StyxValidationError(f'`zlower` has the wrong type: Received `{type(params.get("zlower", None))}` expected `float | None`')
|
|
563
|
+
if params.get("bridge", None) is not None:
|
|
564
|
+
if not isinstance(params["bridge"], int):
|
|
565
|
+
raise StyxValidationError(f'`bridge` has the wrong type: Received `{type(params.get("bridge", None))}` expected `int | None`')
|
|
566
|
+
if params.get("maskin", None) is not None:
|
|
567
|
+
if not isinstance(params["maskin"], (pathlib.Path, str)):
|
|
568
|
+
raise StyxValidationError(f'`maskin` has the wrong type: Received `{type(params.get("maskin", None))}` expected `InputPathType | None`')
|
|
569
|
+
if params.get("maskout", None) is not None:
|
|
570
|
+
if not isinstance(params["maskout"], str):
|
|
571
|
+
raise StyxValidationError(f'`maskout` has the wrong type: Received `{type(params.get("maskout", None))}` expected `str | None`')
|
|
572
|
+
if params.get("strides", None) is not None:
|
|
573
|
+
if not isinstance(params["strides"], dict):
|
|
574
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params["strides"])}\'')
|
|
575
|
+
if "@type" not in params["strides"]:
|
|
576
|
+
raise StyxValidationError("Params object is missing `@type`")
|
|
577
|
+
if params["strides"]["@type"] not in ["VariousString", "VariousFile"]:
|
|
578
|
+
raise StyxValidationError("Parameter `strides`s `@type` must be one of [\"VariousString\", \"VariousFile\"]")
|
|
579
|
+
mrfilter_strides_validate_dyn_fn(params["strides"]["@type"])(params["strides"])
|
|
580
|
+
if params.get("info", False) is None:
|
|
581
|
+
raise StyxValidationError("`info` must not be None")
|
|
582
|
+
if not isinstance(params["info"], bool):
|
|
583
|
+
raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
|
|
584
|
+
if params.get("quiet", False) is None:
|
|
585
|
+
raise StyxValidationError("`quiet` must not be None")
|
|
586
|
+
if not isinstance(params["quiet"], bool):
|
|
587
|
+
raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
|
|
588
|
+
if params.get("debug", False) is None:
|
|
589
|
+
raise StyxValidationError("`debug` must not be None")
|
|
590
|
+
if not isinstance(params["debug"], bool):
|
|
591
|
+
raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
|
|
592
|
+
if params.get("force", False) is None:
|
|
593
|
+
raise StyxValidationError("`force` must not be None")
|
|
594
|
+
if not isinstance(params["force"], bool):
|
|
595
|
+
raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
|
|
596
|
+
if params.get("nthreads", None) is not None:
|
|
597
|
+
if not isinstance(params["nthreads"], int):
|
|
598
|
+
raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
|
|
599
|
+
if params.get("config", None) is not None:
|
|
600
|
+
if not isinstance(params["config"], list):
|
|
601
|
+
raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[MrfilterConfigParamsDict] | None`')
|
|
602
|
+
for e in params["config"]:
|
|
603
|
+
mrfilter_config_validate(e)
|
|
604
|
+
if params.get("help", False) is None:
|
|
605
|
+
raise StyxValidationError("`help` must not be None")
|
|
606
|
+
if not isinstance(params["help"], bool):
|
|
607
|
+
raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
|
|
608
|
+
if params.get("version", False) is None:
|
|
609
|
+
raise StyxValidationError("`version` must not be None")
|
|
610
|
+
if not isinstance(params["version"], bool):
|
|
611
|
+
raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
|
|
612
|
+
if params.get("input", None) is None:
|
|
613
|
+
raise StyxValidationError("`input` must not be None")
|
|
614
|
+
if not isinstance(params["input"], (pathlib.Path, str)):
|
|
615
|
+
raise StyxValidationError(f'`input` has the wrong type: Received `{type(params.get("input", None))}` expected `InputPathType`')
|
|
616
|
+
if params.get("filter", None) is None:
|
|
617
|
+
raise StyxValidationError("`filter` must not be None")
|
|
618
|
+
if not isinstance(params["filter"], str):
|
|
619
|
+
raise StyxValidationError(f'`filter` has the wrong type: Received `{type(params.get("filter", None))}` expected `str`')
|
|
620
|
+
if params.get("output", None) is None:
|
|
621
|
+
raise StyxValidationError("`output` must not be None")
|
|
622
|
+
if not isinstance(params["output"], str):
|
|
623
|
+
raise StyxValidationError(f'`output` has the wrong type: Received `{type(params.get("output", None))}` expected `str`')
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
def mrfilter_cargs(
|
|
627
|
+
params: MrfilterParamsDict,
|
|
628
|
+
execution: Execution,
|
|
629
|
+
) -> list[str]:
|
|
630
|
+
"""
|
|
631
|
+
Build command-line arguments from parameters.
|
|
632
|
+
|
|
633
|
+
Args:
|
|
634
|
+
params: The parameters.
|
|
635
|
+
execution: The execution object for resolving input paths.
|
|
636
|
+
Returns:
|
|
637
|
+
Command-line arguments.
|
|
638
|
+
"""
|
|
639
|
+
cargs = []
|
|
640
|
+
cargs.append("mrfilter")
|
|
641
|
+
if params.get("axes", None) is not None:
|
|
642
|
+
cargs.extend([
|
|
643
|
+
"-axes",
|
|
644
|
+
*map(str, params.get("axes", None))
|
|
645
|
+
])
|
|
646
|
+
if params.get("inverse", False):
|
|
647
|
+
cargs.append("-inverse")
|
|
648
|
+
if params.get("magnitude", False):
|
|
649
|
+
cargs.append("-magnitude")
|
|
650
|
+
if params.get("centre_zero", False):
|
|
651
|
+
cargs.append("-centre_zero")
|
|
652
|
+
if params.get("stdev", None) is not None:
|
|
653
|
+
cargs.extend([
|
|
654
|
+
"-stdev",
|
|
655
|
+
",".join(map(str, params.get("stdev", None)))
|
|
656
|
+
])
|
|
657
|
+
if params.get("magnitude_1", False):
|
|
658
|
+
cargs.append("-magnitude")
|
|
659
|
+
if params.get("scanner", False):
|
|
660
|
+
cargs.append("-scanner")
|
|
661
|
+
if params.get("extent", None) is not None:
|
|
662
|
+
cargs.extend([
|
|
663
|
+
"-extent",
|
|
664
|
+
",".join(map(str, params.get("extent", None)))
|
|
665
|
+
])
|
|
666
|
+
if params.get("extent_1", None) is not None:
|
|
667
|
+
cargs.extend([
|
|
668
|
+
"-extent",
|
|
669
|
+
",".join(map(str, params.get("extent_1", None)))
|
|
670
|
+
])
|
|
671
|
+
if params.get("stdev_1", None) is not None:
|
|
672
|
+
cargs.extend([
|
|
673
|
+
"-stdev",
|
|
674
|
+
",".join(map(str, params.get("stdev_1", None)))
|
|
675
|
+
])
|
|
676
|
+
if params.get("fwhm", None) is not None:
|
|
677
|
+
cargs.extend([
|
|
678
|
+
"-fwhm",
|
|
679
|
+
",".join(map(str, params.get("fwhm", None)))
|
|
680
|
+
])
|
|
681
|
+
if params.get("extent_2", None) is not None:
|
|
682
|
+
cargs.extend([
|
|
683
|
+
"-extent",
|
|
684
|
+
",".join(map(str, params.get("extent_2", None)))
|
|
685
|
+
])
|
|
686
|
+
if params.get("zupper", None) is not None:
|
|
687
|
+
cargs.extend([
|
|
688
|
+
"-zupper",
|
|
689
|
+
str(params.get("zupper", None))
|
|
690
|
+
])
|
|
691
|
+
if params.get("zlower", None) is not None:
|
|
692
|
+
cargs.extend([
|
|
693
|
+
"-zlower",
|
|
694
|
+
str(params.get("zlower", None))
|
|
695
|
+
])
|
|
696
|
+
if params.get("bridge", None) is not None:
|
|
697
|
+
cargs.extend([
|
|
698
|
+
"-bridge",
|
|
699
|
+
str(params.get("bridge", None))
|
|
700
|
+
])
|
|
701
|
+
if params.get("maskin", None) is not None:
|
|
702
|
+
cargs.extend([
|
|
703
|
+
"-maskin",
|
|
704
|
+
execution.input_file(params.get("maskin", None))
|
|
705
|
+
])
|
|
706
|
+
if params.get("maskout", None) is not None:
|
|
707
|
+
cargs.extend([
|
|
708
|
+
"-maskout",
|
|
709
|
+
params.get("maskout", None)
|
|
710
|
+
])
|
|
711
|
+
if params.get("strides", None) is not None:
|
|
712
|
+
cargs.extend([
|
|
713
|
+
"-strides",
|
|
714
|
+
*mrfilter_strides_cargs_dyn_fn(params.get("strides", None)["@type"])(params.get("strides", None), execution)
|
|
715
|
+
])
|
|
716
|
+
if params.get("info", False):
|
|
717
|
+
cargs.append("-info")
|
|
718
|
+
if params.get("quiet", False):
|
|
719
|
+
cargs.append("-quiet")
|
|
720
|
+
if params.get("debug", False):
|
|
721
|
+
cargs.append("-debug")
|
|
722
|
+
if params.get("force", False):
|
|
723
|
+
cargs.append("-force")
|
|
724
|
+
if params.get("nthreads", None) is not None:
|
|
725
|
+
cargs.extend([
|
|
726
|
+
"-nthreads",
|
|
727
|
+
str(params.get("nthreads", None))
|
|
728
|
+
])
|
|
729
|
+
if params.get("config", None) is not None:
|
|
730
|
+
cargs.extend([a for c in [mrfilter_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
|
|
731
|
+
if params.get("help", False):
|
|
732
|
+
cargs.append("-help")
|
|
733
|
+
if params.get("version", False):
|
|
734
|
+
cargs.append("-version")
|
|
735
|
+
cargs.append(execution.input_file(params.get("input", None)))
|
|
736
|
+
cargs.append(params.get("filter", None))
|
|
737
|
+
cargs.append(params.get("output", None))
|
|
738
|
+
return cargs
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
def mrfilter_outputs(
|
|
742
|
+
params: MrfilterParamsDict,
|
|
743
|
+
execution: Execution,
|
|
744
|
+
) -> MrfilterOutputs:
|
|
745
|
+
"""
|
|
746
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
747
|
+
|
|
748
|
+
Args:
|
|
749
|
+
params: The parameters.
|
|
750
|
+
execution: The execution object for resolving input paths.
|
|
751
|
+
Returns:
|
|
752
|
+
Outputs object.
|
|
753
|
+
"""
|
|
754
|
+
ret = MrfilterOutputs(
|
|
755
|
+
root=execution.output_file("."),
|
|
756
|
+
output=execution.output_file(params.get("output", None)),
|
|
757
|
+
maskout=execution.output_file(params.get("maskout", None)) if (params.get("maskout") is not None) else None,
|
|
758
|
+
)
|
|
759
|
+
return ret
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
def mrfilter_execute(
|
|
763
|
+
params: MrfilterParamsDict,
|
|
764
|
+
runner: Runner | None = None,
|
|
765
|
+
) -> MrfilterOutputs:
|
|
766
|
+
"""
|
|
767
|
+
mrfilter
|
|
768
|
+
|
|
769
|
+
Perform filtering operations on 3D / 4D MR images.
|
|
770
|
+
|
|
771
|
+
The available filters are: fft, gradient, median, smooth, normalise, zclean.
|
|
772
|
+
|
|
773
|
+
Each filter has its own unique set of optional parameters.
|
|
774
|
+
|
|
775
|
+
For 4D images, each 3D volume is processed independently.
|
|
776
|
+
|
|
777
|
+
References:
|
|
778
|
+
|
|
779
|
+
.
|
|
780
|
+
|
|
781
|
+
Author: MRTrix3 Developers
|
|
782
|
+
|
|
783
|
+
URL: https://www.mrtrix.org/
|
|
784
|
+
|
|
785
|
+
Args:
|
|
786
|
+
params: The parameters.
|
|
787
|
+
runner: Command runner.
|
|
788
|
+
Returns:
|
|
789
|
+
NamedTuple of outputs (described in `MrfilterOutputs`).
|
|
790
|
+
"""
|
|
791
|
+
mrfilter_validate(params)
|
|
792
|
+
runner = runner or get_global_runner()
|
|
793
|
+
execution = runner.start_execution(MRFILTER_METADATA)
|
|
794
|
+
params = execution.params(params)
|
|
795
|
+
cargs = mrfilter_cargs(params, execution)
|
|
796
|
+
ret = mrfilter_outputs(params, execution)
|
|
797
|
+
execution.run(cargs)
|
|
798
|
+
return ret
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
def mrfilter(
|
|
802
|
+
input_: InputPathType,
|
|
803
|
+
filter_: str,
|
|
804
|
+
output: str,
|
|
805
|
+
axes: list[int] | None = None,
|
|
806
|
+
inverse: bool = False,
|
|
807
|
+
magnitude: bool = False,
|
|
808
|
+
centre_zero: bool = False,
|
|
809
|
+
stdev: list[float] | None = None,
|
|
810
|
+
magnitude_1: bool = False,
|
|
811
|
+
scanner: bool = False,
|
|
812
|
+
extent: list[int] | None = None,
|
|
813
|
+
extent_1: list[int] | None = None,
|
|
814
|
+
stdev_1: list[float] | None = None,
|
|
815
|
+
fwhm: list[float] | None = None,
|
|
816
|
+
extent_2: list[int] | None = None,
|
|
817
|
+
zupper: float | None = None,
|
|
818
|
+
zlower: float | None = None,
|
|
819
|
+
bridge: int | None = None,
|
|
820
|
+
maskin: InputPathType | None = None,
|
|
821
|
+
maskout: str | None = None,
|
|
822
|
+
strides: typing.Union[MrfilterVariousStringParamsDictTagged, MrfilterVariousFileParamsDictTagged] | None = None,
|
|
823
|
+
info: bool = False,
|
|
824
|
+
quiet: bool = False,
|
|
825
|
+
debug: bool = False,
|
|
826
|
+
force: bool = False,
|
|
827
|
+
nthreads: int | None = None,
|
|
828
|
+
config: list[MrfilterConfigParamsDict] | None = None,
|
|
829
|
+
help_: bool = False,
|
|
830
|
+
version: bool = False,
|
|
831
|
+
runner: Runner | None = None,
|
|
832
|
+
) -> MrfilterOutputs:
|
|
833
|
+
"""
|
|
834
|
+
mrfilter
|
|
835
|
+
|
|
836
|
+
Perform filtering operations on 3D / 4D MR images.
|
|
837
|
+
|
|
838
|
+
The available filters are: fft, gradient, median, smooth, normalise, zclean.
|
|
839
|
+
|
|
840
|
+
Each filter has its own unique set of optional parameters.
|
|
841
|
+
|
|
842
|
+
For 4D images, each 3D volume is processed independently.
|
|
843
|
+
|
|
844
|
+
References:
|
|
845
|
+
|
|
846
|
+
.
|
|
847
|
+
|
|
848
|
+
Author: MRTrix3 Developers
|
|
849
|
+
|
|
850
|
+
URL: https://www.mrtrix.org/
|
|
851
|
+
|
|
852
|
+
Args:
|
|
853
|
+
input_: the input image.
|
|
854
|
+
filter_: the type of filter to be applied.
|
|
855
|
+
output: the output image.
|
|
856
|
+
axes: the axes along which to apply the Fourier Transform. By default,\
|
|
857
|
+
the transform is applied along the three spatial axes. Provide as a\
|
|
858
|
+
comma-separate list of axis indices.
|
|
859
|
+
inverse: apply the inverse FFT.
|
|
860
|
+
magnitude: output a magnitude image rather than a complex-valued image.
|
|
861
|
+
centre_zero: re-arrange the FFT results so that the zero-frequency\
|
|
862
|
+
component appears in the centre of the image, rather than at the edges.
|
|
863
|
+
stdev: the standard deviation of the Gaussian kernel used to smooth the\
|
|
864
|
+
input image (in mm). The image is smoothed to reduced large spurious\
|
|
865
|
+
gradients caused by noise. Use this option to override the default\
|
|
866
|
+
stdev of 1 voxel. This can be specified either as a single value to be\
|
|
867
|
+
used for all 3 axes, or as a comma-separated list of 3 values, one for\
|
|
868
|
+
each axis.
|
|
869
|
+
magnitude_1: output the gradient magnitude, rather than the default\
|
|
870
|
+
x,y,z components.
|
|
871
|
+
scanner: define the gradient with respect to the scanner coordinate\
|
|
872
|
+
frame of reference.
|
|
873
|
+
extent: specify extent of median filtering neighbourhood in voxels.\
|
|
874
|
+
This can be specified either as a single value to be used for all 3\
|
|
875
|
+
axes, or as a comma-separated list of 3 values, one for each axis\
|
|
876
|
+
(default: 3x3x3).
|
|
877
|
+
extent_1: specify extent of normalisation filtering neighbourhood in\
|
|
878
|
+
voxels. This can be specified either as a single value to be used for\
|
|
879
|
+
all 3 axes, or as a comma-separated list of 3 values, one for each axis\
|
|
880
|
+
(default: 3x3x3).
|
|
881
|
+
stdev_1: apply Gaussian smoothing with the specified standard\
|
|
882
|
+
deviation. The standard deviation is defined in mm (Default 1 voxel).\
|
|
883
|
+
This can be specified either as a single value to be used for all axes,\
|
|
884
|
+
or as a comma-separated list of the stdev for each axis.
|
|
885
|
+
fwhm: apply Gaussian smoothing with the specified full-width half\
|
|
886
|
+
maximum. The FWHM is defined in mm (Default 1 voxel * 2.3548). This can\
|
|
887
|
+
be specified either as a single value to be used for all axes, or as a\
|
|
888
|
+
comma-separated list of the FWHM for each axis.
|
|
889
|
+
extent_2: specify the extent (width) of kernel size in voxels. This can\
|
|
890
|
+
be specified either as a single value to be used for all axes, or as a\
|
|
891
|
+
comma-separated list of the extent for each axis. The default extent is\
|
|
892
|
+
2 * ceil(2.5 * stdev / voxel_size) - 1.
|
|
893
|
+
zupper: define high intensity outliers: default: 2.5.
|
|
894
|
+
zlower: define low intensity outliers: default: 2.5.
|
|
895
|
+
bridge: number of voxels to gap to fill holes in mask: default: 4.
|
|
896
|
+
maskin: initial mask that defines the maximum spatial extent and the\
|
|
897
|
+
region from which to smaple the intensity range.
|
|
898
|
+
maskout: Output a refined mask based on a spatially coherent region\
|
|
899
|
+
with normal intensity range.
|
|
900
|
+
strides: specify the strides of the output data in memory; either as a\
|
|
901
|
+
comma-separated list of (signed) integers, or as a template image from\
|
|
902
|
+
which the strides shall be extracted and used. The actual strides\
|
|
903
|
+
produced will depend on whether the output image format can support it.
|
|
904
|
+
info: display information messages.
|
|
905
|
+
quiet: do not display information messages or progress status;\
|
|
906
|
+
alternatively, this can be achieved by setting the MRTRIX_QUIET\
|
|
907
|
+
environment variable to a non-empty string.
|
|
908
|
+
debug: display debugging messages.
|
|
909
|
+
force: force overwrite of output files (caution: using the same file as\
|
|
910
|
+
input and output might cause unexpected behaviour).
|
|
911
|
+
nthreads: use this number of threads in multi-threaded applications\
|
|
912
|
+
(set to 0 to disable multi-threading).
|
|
913
|
+
config: temporarily set the value of an MRtrix config file entry.
|
|
914
|
+
help_: display this information page and exit.
|
|
915
|
+
version: display version information and exit.
|
|
916
|
+
runner: Command runner.
|
|
917
|
+
Returns:
|
|
918
|
+
NamedTuple of outputs (described in `MrfilterOutputs`).
|
|
919
|
+
"""
|
|
920
|
+
params = mrfilter_params(
|
|
921
|
+
axes=axes,
|
|
922
|
+
inverse=inverse,
|
|
923
|
+
magnitude=magnitude,
|
|
924
|
+
centre_zero=centre_zero,
|
|
925
|
+
stdev=stdev,
|
|
926
|
+
magnitude_1=magnitude_1,
|
|
927
|
+
scanner=scanner,
|
|
928
|
+
extent=extent,
|
|
929
|
+
extent_1=extent_1,
|
|
930
|
+
stdev_1=stdev_1,
|
|
931
|
+
fwhm=fwhm,
|
|
932
|
+
extent_2=extent_2,
|
|
933
|
+
zupper=zupper,
|
|
934
|
+
zlower=zlower,
|
|
935
|
+
bridge=bridge,
|
|
936
|
+
maskin=maskin,
|
|
937
|
+
maskout=maskout,
|
|
938
|
+
strides=strides,
|
|
939
|
+
info=info,
|
|
940
|
+
quiet=quiet,
|
|
941
|
+
debug=debug,
|
|
942
|
+
force=force,
|
|
943
|
+
nthreads=nthreads,
|
|
944
|
+
config=config,
|
|
945
|
+
help_=help_,
|
|
946
|
+
version=version,
|
|
947
|
+
input_=input_,
|
|
948
|
+
filter_=filter_,
|
|
949
|
+
output=output,
|
|
950
|
+
)
|
|
951
|
+
return mrfilter_execute(params, runner)
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
__all__ = [
|
|
955
|
+
"MRFILTER_METADATA",
|
|
956
|
+
"MrfilterConfigParamsDict",
|
|
957
|
+
"MrfilterConfigParamsDictTagged",
|
|
958
|
+
"MrfilterOutputs",
|
|
959
|
+
"MrfilterParamsDict",
|
|
960
|
+
"MrfilterParamsDictTagged",
|
|
961
|
+
"MrfilterVariousFileParamsDict",
|
|
962
|
+
"MrfilterVariousFileParamsDictTagged",
|
|
963
|
+
"MrfilterVariousStringParamsDict",
|
|
964
|
+
"MrfilterVariousStringParamsDictTagged",
|
|
965
|
+
"mrfilter",
|
|
966
|
+
"mrfilter_config",
|
|
967
|
+
"mrfilter_execute",
|
|
968
|
+
"mrfilter_params",
|
|
969
|
+
"mrfilter_various_file",
|
|
970
|
+
"mrfilter_various_string",
|
|
971
|
+
]
|