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,570 @@
|
|
|
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
|
+
DWIDENOISE_METADATA = Metadata(
|
|
9
|
+
id="82c3888900162dbe688e89a630bf3f397f859b0b.boutiques",
|
|
10
|
+
name="dwidenoise",
|
|
11
|
+
package="mrtrix",
|
|
12
|
+
container_image_tag="mrtrix3/mrtrix3:3.0.4",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
_DwidenoiseConfigParamsDictNoTag = typing.TypedDict('_DwidenoiseConfigParamsDictNoTag', {
|
|
17
|
+
"key": str,
|
|
18
|
+
"value": str,
|
|
19
|
+
})
|
|
20
|
+
DwidenoiseConfigParamsDictTagged = typing.TypedDict('DwidenoiseConfigParamsDictTagged', {
|
|
21
|
+
"@type": typing.Literal["config"],
|
|
22
|
+
"key": str,
|
|
23
|
+
"value": str,
|
|
24
|
+
})
|
|
25
|
+
DwidenoiseConfigParamsDict = _DwidenoiseConfigParamsDictNoTag | DwidenoiseConfigParamsDictTagged
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
_DwidenoiseParamsDictNoTag = typing.TypedDict('_DwidenoiseParamsDictNoTag', {
|
|
29
|
+
"mask": typing.NotRequired[InputPathType | None],
|
|
30
|
+
"extent": typing.NotRequired[list[int] | None],
|
|
31
|
+
"noise": typing.NotRequired[str | None],
|
|
32
|
+
"datatype": typing.NotRequired[str | None],
|
|
33
|
+
"estimator": typing.NotRequired[str | None],
|
|
34
|
+
"info": bool,
|
|
35
|
+
"quiet": bool,
|
|
36
|
+
"debug": bool,
|
|
37
|
+
"force": bool,
|
|
38
|
+
"nthreads": typing.NotRequired[int | None],
|
|
39
|
+
"config": typing.NotRequired[list[DwidenoiseConfigParamsDict] | None],
|
|
40
|
+
"help": bool,
|
|
41
|
+
"version": bool,
|
|
42
|
+
"dwi": InputPathType,
|
|
43
|
+
"out": str,
|
|
44
|
+
})
|
|
45
|
+
DwidenoiseParamsDictTagged = typing.TypedDict('DwidenoiseParamsDictTagged', {
|
|
46
|
+
"@type": typing.Literal["mrtrix/dwidenoise"],
|
|
47
|
+
"mask": typing.NotRequired[InputPathType | None],
|
|
48
|
+
"extent": typing.NotRequired[list[int] | None],
|
|
49
|
+
"noise": typing.NotRequired[str | None],
|
|
50
|
+
"datatype": typing.NotRequired[str | None],
|
|
51
|
+
"estimator": typing.NotRequired[str | None],
|
|
52
|
+
"info": bool,
|
|
53
|
+
"quiet": bool,
|
|
54
|
+
"debug": bool,
|
|
55
|
+
"force": bool,
|
|
56
|
+
"nthreads": typing.NotRequired[int | None],
|
|
57
|
+
"config": typing.NotRequired[list[DwidenoiseConfigParamsDict] | None],
|
|
58
|
+
"help": bool,
|
|
59
|
+
"version": bool,
|
|
60
|
+
"dwi": InputPathType,
|
|
61
|
+
"out": str,
|
|
62
|
+
})
|
|
63
|
+
DwidenoiseParamsDict = _DwidenoiseParamsDictNoTag | DwidenoiseParamsDictTagged
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def dwidenoise_config(
|
|
67
|
+
key: str,
|
|
68
|
+
value: str,
|
|
69
|
+
) -> DwidenoiseConfigParamsDictTagged:
|
|
70
|
+
"""
|
|
71
|
+
Build parameters.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
key: temporarily set the value of an MRtrix config file entry.
|
|
75
|
+
value: temporarily set the value of an MRtrix config file entry.
|
|
76
|
+
Returns:
|
|
77
|
+
Parameter dictionary
|
|
78
|
+
"""
|
|
79
|
+
params = {
|
|
80
|
+
"@type": "config",
|
|
81
|
+
"key": key,
|
|
82
|
+
"value": value,
|
|
83
|
+
}
|
|
84
|
+
return params
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def dwidenoise_config_validate(
|
|
88
|
+
params: typing.Any,
|
|
89
|
+
) -> None:
|
|
90
|
+
"""
|
|
91
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
92
|
+
`DwidenoiseConfigParamsDict` object.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
params: The parameters object to validate.
|
|
96
|
+
"""
|
|
97
|
+
if params is None or not isinstance(params, dict):
|
|
98
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
99
|
+
if params.get("key", None) is None:
|
|
100
|
+
raise StyxValidationError("`key` must not be None")
|
|
101
|
+
if not isinstance(params["key"], str):
|
|
102
|
+
raise StyxValidationError(f'`key` has the wrong type: Received `{type(params.get("key", None))}` expected `str`')
|
|
103
|
+
if params.get("value", None) is None:
|
|
104
|
+
raise StyxValidationError("`value` must not be None")
|
|
105
|
+
if not isinstance(params["value"], str):
|
|
106
|
+
raise StyxValidationError(f'`value` has the wrong type: Received `{type(params.get("value", None))}` expected `str`')
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def dwidenoise_config_cargs(
|
|
110
|
+
params: DwidenoiseConfigParamsDict,
|
|
111
|
+
execution: Execution,
|
|
112
|
+
) -> list[str]:
|
|
113
|
+
"""
|
|
114
|
+
Build command-line arguments from parameters.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
params: The parameters.
|
|
118
|
+
execution: The execution object for resolving input paths.
|
|
119
|
+
Returns:
|
|
120
|
+
Command-line arguments.
|
|
121
|
+
"""
|
|
122
|
+
cargs = []
|
|
123
|
+
cargs.append("-config")
|
|
124
|
+
cargs.append(params.get("key", None))
|
|
125
|
+
cargs.append(params.get("value", None))
|
|
126
|
+
return cargs
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class DwidenoiseOutputs(typing.NamedTuple):
|
|
130
|
+
"""
|
|
131
|
+
Output object returned when calling `DwidenoiseParamsDict(...)`.
|
|
132
|
+
"""
|
|
133
|
+
root: OutputPathType
|
|
134
|
+
"""Output root folder. This is the root folder for all outputs."""
|
|
135
|
+
out: OutputPathType
|
|
136
|
+
"""the output denoised DWI image."""
|
|
137
|
+
noise: OutputPathType | None
|
|
138
|
+
"""The output noise map, i.e., the estimated noise level 'sigma' in the
|
|
139
|
+
data. Note that on complex input data, this will be the total noise level
|
|
140
|
+
across real and imaginary channels, so a scale factor sqrt(2) applies. """
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def dwidenoise_params(
|
|
144
|
+
dwi: InputPathType,
|
|
145
|
+
out: str,
|
|
146
|
+
mask: InputPathType | None = None,
|
|
147
|
+
extent: list[int] | None = None,
|
|
148
|
+
noise: str | None = None,
|
|
149
|
+
datatype: str | None = None,
|
|
150
|
+
estimator: str | None = None,
|
|
151
|
+
info: bool = False,
|
|
152
|
+
quiet: bool = False,
|
|
153
|
+
debug: bool = False,
|
|
154
|
+
force: bool = False,
|
|
155
|
+
nthreads: int | None = None,
|
|
156
|
+
config: list[DwidenoiseConfigParamsDict] | None = None,
|
|
157
|
+
help_: bool = False,
|
|
158
|
+
version: bool = False,
|
|
159
|
+
) -> DwidenoiseParamsDictTagged:
|
|
160
|
+
"""
|
|
161
|
+
Build parameters.
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
dwi: the input diffusion-weighted image.
|
|
165
|
+
out: the output denoised DWI image.
|
|
166
|
+
mask: Only process voxels within the specified binary brain mask image.
|
|
167
|
+
extent: Set the patch size of the denoising filter. By default, the\
|
|
168
|
+
command will select the smallest isotropic patch size that exceeds the\
|
|
169
|
+
number of DW images in the input data, e.g., 5x5x5 for data with <= 125\
|
|
170
|
+
DWI volumes, 7x7x7 for data with <= 343 DWI volumes, etc.
|
|
171
|
+
noise: The output noise map, i.e., the estimated noise level 'sigma' in\
|
|
172
|
+
the data. Note that on complex input data, this will be the total noise\
|
|
173
|
+
level across real and imaginary channels, so a scale factor sqrt(2)\
|
|
174
|
+
applies.
|
|
175
|
+
datatype: Datatype for the eigenvalue decomposition (single or double\
|
|
176
|
+
precision). For complex input data, this will select complex float32 or\
|
|
177
|
+
complex float64 datatypes.
|
|
178
|
+
estimator: Select the noise level estimator (default = Exp2), either:\
|
|
179
|
+
* Exp1: the original estimator used in Veraart et al. (2016), or\
|
|
180
|
+
* Exp2: the improved estimator introduced in Cordero-Grande et al.\
|
|
181
|
+
(2019).
|
|
182
|
+
info: display information messages.
|
|
183
|
+
quiet: do not display information messages or progress status;\
|
|
184
|
+
alternatively, this can be achieved by setting the MRTRIX_QUIET\
|
|
185
|
+
environment variable to a non-empty string.
|
|
186
|
+
debug: display debugging messages.
|
|
187
|
+
force: force overwrite of output files (caution: using the same file as\
|
|
188
|
+
input and output might cause unexpected behaviour).
|
|
189
|
+
nthreads: use this number of threads in multi-threaded applications\
|
|
190
|
+
(set to 0 to disable multi-threading).
|
|
191
|
+
config: temporarily set the value of an MRtrix config file entry.
|
|
192
|
+
help_: display this information page and exit.
|
|
193
|
+
version: display version information and exit.
|
|
194
|
+
Returns:
|
|
195
|
+
Parameter dictionary
|
|
196
|
+
"""
|
|
197
|
+
params = {
|
|
198
|
+
"@type": "mrtrix/dwidenoise",
|
|
199
|
+
"info": info,
|
|
200
|
+
"quiet": quiet,
|
|
201
|
+
"debug": debug,
|
|
202
|
+
"force": force,
|
|
203
|
+
"help": help_,
|
|
204
|
+
"version": version,
|
|
205
|
+
"dwi": dwi,
|
|
206
|
+
"out": out,
|
|
207
|
+
}
|
|
208
|
+
if mask is not None:
|
|
209
|
+
params["mask"] = mask
|
|
210
|
+
if extent is not None:
|
|
211
|
+
params["extent"] = extent
|
|
212
|
+
if noise is not None:
|
|
213
|
+
params["noise"] = noise
|
|
214
|
+
if datatype is not None:
|
|
215
|
+
params["datatype"] = datatype
|
|
216
|
+
if estimator is not None:
|
|
217
|
+
params["estimator"] = estimator
|
|
218
|
+
if nthreads is not None:
|
|
219
|
+
params["nthreads"] = nthreads
|
|
220
|
+
if config is not None:
|
|
221
|
+
params["config"] = config
|
|
222
|
+
return params
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def dwidenoise_validate(
|
|
226
|
+
params: typing.Any,
|
|
227
|
+
) -> None:
|
|
228
|
+
"""
|
|
229
|
+
Validate parameters. Throws an error if `params` is not a valid
|
|
230
|
+
`DwidenoiseParamsDict` object.
|
|
231
|
+
|
|
232
|
+
Args:
|
|
233
|
+
params: The parameters object to validate.
|
|
234
|
+
"""
|
|
235
|
+
if params is None or not isinstance(params, dict):
|
|
236
|
+
raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
|
|
237
|
+
if params.get("mask", None) is not None:
|
|
238
|
+
if not isinstance(params["mask"], (pathlib.Path, str)):
|
|
239
|
+
raise StyxValidationError(f'`mask` has the wrong type: Received `{type(params.get("mask", None))}` expected `InputPathType | None`')
|
|
240
|
+
if params.get("extent", None) is not None:
|
|
241
|
+
if not isinstance(params["extent"], list):
|
|
242
|
+
raise StyxValidationError(f'`extent` has the wrong type: Received `{type(params.get("extent", None))}` expected `list[int] | None`')
|
|
243
|
+
for e in params["extent"]:
|
|
244
|
+
if not isinstance(e, int):
|
|
245
|
+
raise StyxValidationError(f'`extent` has the wrong type: Received `{type(params.get("extent", None))}` expected `list[int] | None`')
|
|
246
|
+
if params.get("noise", None) is not None:
|
|
247
|
+
if not isinstance(params["noise"], str):
|
|
248
|
+
raise StyxValidationError(f'`noise` has the wrong type: Received `{type(params.get("noise", None))}` expected `str | None`')
|
|
249
|
+
if params.get("datatype", None) is not None:
|
|
250
|
+
if not isinstance(params["datatype"], str):
|
|
251
|
+
raise StyxValidationError(f'`datatype` has the wrong type: Received `{type(params.get("datatype", None))}` expected `str | None`')
|
|
252
|
+
if params.get("estimator", None) is not None:
|
|
253
|
+
if not isinstance(params["estimator"], str):
|
|
254
|
+
raise StyxValidationError(f'`estimator` has the wrong type: Received `{type(params.get("estimator", None))}` expected `str | None`')
|
|
255
|
+
if params.get("info", False) is None:
|
|
256
|
+
raise StyxValidationError("`info` must not be None")
|
|
257
|
+
if not isinstance(params["info"], bool):
|
|
258
|
+
raise StyxValidationError(f'`info` has the wrong type: Received `{type(params.get("info", False))}` expected `bool`')
|
|
259
|
+
if params.get("quiet", False) is None:
|
|
260
|
+
raise StyxValidationError("`quiet` must not be None")
|
|
261
|
+
if not isinstance(params["quiet"], bool):
|
|
262
|
+
raise StyxValidationError(f'`quiet` has the wrong type: Received `{type(params.get("quiet", False))}` expected `bool`')
|
|
263
|
+
if params.get("debug", False) is None:
|
|
264
|
+
raise StyxValidationError("`debug` must not be None")
|
|
265
|
+
if not isinstance(params["debug"], bool):
|
|
266
|
+
raise StyxValidationError(f'`debug` has the wrong type: Received `{type(params.get("debug", False))}` expected `bool`')
|
|
267
|
+
if params.get("force", False) is None:
|
|
268
|
+
raise StyxValidationError("`force` must not be None")
|
|
269
|
+
if not isinstance(params["force"], bool):
|
|
270
|
+
raise StyxValidationError(f'`force` has the wrong type: Received `{type(params.get("force", False))}` expected `bool`')
|
|
271
|
+
if params.get("nthreads", None) is not None:
|
|
272
|
+
if not isinstance(params["nthreads"], int):
|
|
273
|
+
raise StyxValidationError(f'`nthreads` has the wrong type: Received `{type(params.get("nthreads", None))}` expected `int | None`')
|
|
274
|
+
if params.get("config", None) is not None:
|
|
275
|
+
if not isinstance(params["config"], list):
|
|
276
|
+
raise StyxValidationError(f'`config` has the wrong type: Received `{type(params.get("config", None))}` expected `list[DwidenoiseConfigParamsDict] | None`')
|
|
277
|
+
for e in params["config"]:
|
|
278
|
+
dwidenoise_config_validate(e)
|
|
279
|
+
if params.get("help", False) is None:
|
|
280
|
+
raise StyxValidationError("`help` must not be None")
|
|
281
|
+
if not isinstance(params["help"], bool):
|
|
282
|
+
raise StyxValidationError(f'`help` has the wrong type: Received `{type(params.get("help", False))}` expected `bool`')
|
|
283
|
+
if params.get("version", False) is None:
|
|
284
|
+
raise StyxValidationError("`version` must not be None")
|
|
285
|
+
if not isinstance(params["version"], bool):
|
|
286
|
+
raise StyxValidationError(f'`version` has the wrong type: Received `{type(params.get("version", False))}` expected `bool`')
|
|
287
|
+
if params.get("dwi", None) is None:
|
|
288
|
+
raise StyxValidationError("`dwi` must not be None")
|
|
289
|
+
if not isinstance(params["dwi"], (pathlib.Path, str)):
|
|
290
|
+
raise StyxValidationError(f'`dwi` has the wrong type: Received `{type(params.get("dwi", None))}` expected `InputPathType`')
|
|
291
|
+
if params.get("out", None) is None:
|
|
292
|
+
raise StyxValidationError("`out` must not be None")
|
|
293
|
+
if not isinstance(params["out"], str):
|
|
294
|
+
raise StyxValidationError(f'`out` has the wrong type: Received `{type(params.get("out", None))}` expected `str`')
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def dwidenoise_cargs(
|
|
298
|
+
params: DwidenoiseParamsDict,
|
|
299
|
+
execution: Execution,
|
|
300
|
+
) -> list[str]:
|
|
301
|
+
"""
|
|
302
|
+
Build command-line arguments from parameters.
|
|
303
|
+
|
|
304
|
+
Args:
|
|
305
|
+
params: The parameters.
|
|
306
|
+
execution: The execution object for resolving input paths.
|
|
307
|
+
Returns:
|
|
308
|
+
Command-line arguments.
|
|
309
|
+
"""
|
|
310
|
+
cargs = []
|
|
311
|
+
cargs.append("dwidenoise")
|
|
312
|
+
if params.get("mask", None) is not None:
|
|
313
|
+
cargs.extend([
|
|
314
|
+
"-mask",
|
|
315
|
+
execution.input_file(params.get("mask", None))
|
|
316
|
+
])
|
|
317
|
+
if params.get("extent", None) is not None:
|
|
318
|
+
cargs.extend([
|
|
319
|
+
"-extent",
|
|
320
|
+
*map(str, params.get("extent", None))
|
|
321
|
+
])
|
|
322
|
+
if params.get("noise", None) is not None:
|
|
323
|
+
cargs.extend([
|
|
324
|
+
"-noise",
|
|
325
|
+
params.get("noise", None)
|
|
326
|
+
])
|
|
327
|
+
if params.get("datatype", None) is not None:
|
|
328
|
+
cargs.extend([
|
|
329
|
+
"-datatype",
|
|
330
|
+
params.get("datatype", None)
|
|
331
|
+
])
|
|
332
|
+
if params.get("estimator", None) is not None:
|
|
333
|
+
cargs.extend([
|
|
334
|
+
"-estimator",
|
|
335
|
+
params.get("estimator", None)
|
|
336
|
+
])
|
|
337
|
+
if params.get("info", False):
|
|
338
|
+
cargs.append("-info")
|
|
339
|
+
if params.get("quiet", False):
|
|
340
|
+
cargs.append("-quiet")
|
|
341
|
+
if params.get("debug", False):
|
|
342
|
+
cargs.append("-debug")
|
|
343
|
+
if params.get("force", False):
|
|
344
|
+
cargs.append("-force")
|
|
345
|
+
if params.get("nthreads", None) is not None:
|
|
346
|
+
cargs.extend([
|
|
347
|
+
"-nthreads",
|
|
348
|
+
str(params.get("nthreads", None))
|
|
349
|
+
])
|
|
350
|
+
if params.get("config", None) is not None:
|
|
351
|
+
cargs.extend([a for c in [dwidenoise_config_cargs(s, execution) for s in params.get("config", None)] for a in c])
|
|
352
|
+
if params.get("help", False):
|
|
353
|
+
cargs.append("-help")
|
|
354
|
+
if params.get("version", False):
|
|
355
|
+
cargs.append("-version")
|
|
356
|
+
cargs.append(execution.input_file(params.get("dwi", None)))
|
|
357
|
+
cargs.append(params.get("out", None))
|
|
358
|
+
return cargs
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
def dwidenoise_outputs(
|
|
362
|
+
params: DwidenoiseParamsDict,
|
|
363
|
+
execution: Execution,
|
|
364
|
+
) -> DwidenoiseOutputs:
|
|
365
|
+
"""
|
|
366
|
+
Build outputs object containing output file paths and possibly stdout/stderr.
|
|
367
|
+
|
|
368
|
+
Args:
|
|
369
|
+
params: The parameters.
|
|
370
|
+
execution: The execution object for resolving input paths.
|
|
371
|
+
Returns:
|
|
372
|
+
Outputs object.
|
|
373
|
+
"""
|
|
374
|
+
ret = DwidenoiseOutputs(
|
|
375
|
+
root=execution.output_file("."),
|
|
376
|
+
out=execution.output_file(params.get("out", None)),
|
|
377
|
+
noise=execution.output_file(params.get("noise", None)) if (params.get("noise") is not None) else None,
|
|
378
|
+
)
|
|
379
|
+
return ret
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
def dwidenoise_execute(
|
|
383
|
+
params: DwidenoiseParamsDict,
|
|
384
|
+
runner: Runner | None = None,
|
|
385
|
+
) -> DwidenoiseOutputs:
|
|
386
|
+
"""
|
|
387
|
+
dwidenoise
|
|
388
|
+
|
|
389
|
+
dMRI noise level estimation and denoising using Marchenko-Pastur PCA.
|
|
390
|
+
|
|
391
|
+
DWI data denoising and noise map estimation by exploiting data redundancy in
|
|
392
|
+
the PCA domain using the prior knowledge that the eigenspectrum of random
|
|
393
|
+
covariance matrices is described by the universal Marchenko-Pastur (MP)
|
|
394
|
+
distribution. Fitting the MP distribution to the spectrum of patch-wise
|
|
395
|
+
signal matrices hence provides an estimator of the noise level 'sigma', as
|
|
396
|
+
was first shown in Veraart et al. (2016) and later improved in
|
|
397
|
+
Cordero-Grande et al. (2019). This noise level estimate then determines the
|
|
398
|
+
optimal cut-off for PCA denoising.
|
|
399
|
+
|
|
400
|
+
Important note: image denoising must be performed as the first step of the
|
|
401
|
+
image processing pipeline. The routine will fail if interpolation or
|
|
402
|
+
smoothing has been applied to the data prior to denoising.
|
|
403
|
+
|
|
404
|
+
Note that this function does not correct for non-Gaussian noise biases
|
|
405
|
+
present in magnitude-reconstructed MRI images. If available, including the
|
|
406
|
+
MRI phase data can reduce such non-Gaussian biases, and the command now
|
|
407
|
+
supports complex input data.
|
|
408
|
+
|
|
409
|
+
References:
|
|
410
|
+
|
|
411
|
+
Veraart, J.; Novikov, D.S.; Christiaens, D.; Ades-aron, B.; Sijbers, J. &
|
|
412
|
+
Fieremans, E. Denoising of diffusion MRI using random matrix theory.
|
|
413
|
+
NeuroImage, 2016, 142, 394-406, doi: 10.1016/j.neuroimage.2016.08.016
|
|
414
|
+
|
|
415
|
+
Veraart, J.; Fieremans, E. & Novikov, D.S. Diffusion MRI noise mapping using
|
|
416
|
+
random matrix theory. Magn. Res. Med., 2016, 76(5), 1582-1593, doi:
|
|
417
|
+
10.1002/mrm.26059
|
|
418
|
+
|
|
419
|
+
Cordero-Grande, L.; Christiaens, D.; Hutter, J.; Price, A.N.; Hajnal, J.V.
|
|
420
|
+
Complex diffusion-weighted image estimation via matrix recovery under
|
|
421
|
+
general noise models. NeuroImage, 2019, 200, 391-404, doi:
|
|
422
|
+
10.1016/j.neuroimage.2019.06.039.
|
|
423
|
+
|
|
424
|
+
Author: MRTrix3 Developers
|
|
425
|
+
|
|
426
|
+
URL: https://www.mrtrix.org/
|
|
427
|
+
|
|
428
|
+
Args:
|
|
429
|
+
params: The parameters.
|
|
430
|
+
runner: Command runner.
|
|
431
|
+
Returns:
|
|
432
|
+
NamedTuple of outputs (described in `DwidenoiseOutputs`).
|
|
433
|
+
"""
|
|
434
|
+
dwidenoise_validate(params)
|
|
435
|
+
runner = runner or get_global_runner()
|
|
436
|
+
execution = runner.start_execution(DWIDENOISE_METADATA)
|
|
437
|
+
params = execution.params(params)
|
|
438
|
+
cargs = dwidenoise_cargs(params, execution)
|
|
439
|
+
ret = dwidenoise_outputs(params, execution)
|
|
440
|
+
execution.run(cargs)
|
|
441
|
+
return ret
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
def dwidenoise(
|
|
445
|
+
dwi: InputPathType,
|
|
446
|
+
out: str,
|
|
447
|
+
mask: InputPathType | None = None,
|
|
448
|
+
extent: list[int] | None = None,
|
|
449
|
+
noise: str | None = None,
|
|
450
|
+
datatype: str | None = None,
|
|
451
|
+
estimator: str | None = None,
|
|
452
|
+
info: bool = False,
|
|
453
|
+
quiet: bool = False,
|
|
454
|
+
debug: bool = False,
|
|
455
|
+
force: bool = False,
|
|
456
|
+
nthreads: int | None = None,
|
|
457
|
+
config: list[DwidenoiseConfigParamsDict] | None = None,
|
|
458
|
+
help_: bool = False,
|
|
459
|
+
version: bool = False,
|
|
460
|
+
runner: Runner | None = None,
|
|
461
|
+
) -> DwidenoiseOutputs:
|
|
462
|
+
"""
|
|
463
|
+
dwidenoise
|
|
464
|
+
|
|
465
|
+
dMRI noise level estimation and denoising using Marchenko-Pastur PCA.
|
|
466
|
+
|
|
467
|
+
DWI data denoising and noise map estimation by exploiting data redundancy in
|
|
468
|
+
the PCA domain using the prior knowledge that the eigenspectrum of random
|
|
469
|
+
covariance matrices is described by the universal Marchenko-Pastur (MP)
|
|
470
|
+
distribution. Fitting the MP distribution to the spectrum of patch-wise
|
|
471
|
+
signal matrices hence provides an estimator of the noise level 'sigma', as
|
|
472
|
+
was first shown in Veraart et al. (2016) and later improved in
|
|
473
|
+
Cordero-Grande et al. (2019). This noise level estimate then determines the
|
|
474
|
+
optimal cut-off for PCA denoising.
|
|
475
|
+
|
|
476
|
+
Important note: image denoising must be performed as the first step of the
|
|
477
|
+
image processing pipeline. The routine will fail if interpolation or
|
|
478
|
+
smoothing has been applied to the data prior to denoising.
|
|
479
|
+
|
|
480
|
+
Note that this function does not correct for non-Gaussian noise biases
|
|
481
|
+
present in magnitude-reconstructed MRI images. If available, including the
|
|
482
|
+
MRI phase data can reduce such non-Gaussian biases, and the command now
|
|
483
|
+
supports complex input data.
|
|
484
|
+
|
|
485
|
+
References:
|
|
486
|
+
|
|
487
|
+
Veraart, J.; Novikov, D.S.; Christiaens, D.; Ades-aron, B.; Sijbers, J. &
|
|
488
|
+
Fieremans, E. Denoising of diffusion MRI using random matrix theory.
|
|
489
|
+
NeuroImage, 2016, 142, 394-406, doi: 10.1016/j.neuroimage.2016.08.016
|
|
490
|
+
|
|
491
|
+
Veraart, J.; Fieremans, E. & Novikov, D.S. Diffusion MRI noise mapping using
|
|
492
|
+
random matrix theory. Magn. Res. Med., 2016, 76(5), 1582-1593, doi:
|
|
493
|
+
10.1002/mrm.26059
|
|
494
|
+
|
|
495
|
+
Cordero-Grande, L.; Christiaens, D.; Hutter, J.; Price, A.N.; Hajnal, J.V.
|
|
496
|
+
Complex diffusion-weighted image estimation via matrix recovery under
|
|
497
|
+
general noise models. NeuroImage, 2019, 200, 391-404, doi:
|
|
498
|
+
10.1016/j.neuroimage.2019.06.039.
|
|
499
|
+
|
|
500
|
+
Author: MRTrix3 Developers
|
|
501
|
+
|
|
502
|
+
URL: https://www.mrtrix.org/
|
|
503
|
+
|
|
504
|
+
Args:
|
|
505
|
+
dwi: the input diffusion-weighted image.
|
|
506
|
+
out: the output denoised DWI image.
|
|
507
|
+
mask: Only process voxels within the specified binary brain mask image.
|
|
508
|
+
extent: Set the patch size of the denoising filter. By default, the\
|
|
509
|
+
command will select the smallest isotropic patch size that exceeds the\
|
|
510
|
+
number of DW images in the input data, e.g., 5x5x5 for data with <= 125\
|
|
511
|
+
DWI volumes, 7x7x7 for data with <= 343 DWI volumes, etc.
|
|
512
|
+
noise: The output noise map, i.e., the estimated noise level 'sigma' in\
|
|
513
|
+
the data. Note that on complex input data, this will be the total noise\
|
|
514
|
+
level across real and imaginary channels, so a scale factor sqrt(2)\
|
|
515
|
+
applies.
|
|
516
|
+
datatype: Datatype for the eigenvalue decomposition (single or double\
|
|
517
|
+
precision). For complex input data, this will select complex float32 or\
|
|
518
|
+
complex float64 datatypes.
|
|
519
|
+
estimator: Select the noise level estimator (default = Exp2), either:\
|
|
520
|
+
* Exp1: the original estimator used in Veraart et al. (2016), or\
|
|
521
|
+
* Exp2: the improved estimator introduced in Cordero-Grande et al.\
|
|
522
|
+
(2019).
|
|
523
|
+
info: display information messages.
|
|
524
|
+
quiet: do not display information messages or progress status;\
|
|
525
|
+
alternatively, this can be achieved by setting the MRTRIX_QUIET\
|
|
526
|
+
environment variable to a non-empty string.
|
|
527
|
+
debug: display debugging messages.
|
|
528
|
+
force: force overwrite of output files (caution: using the same file as\
|
|
529
|
+
input and output might cause unexpected behaviour).
|
|
530
|
+
nthreads: use this number of threads in multi-threaded applications\
|
|
531
|
+
(set to 0 to disable multi-threading).
|
|
532
|
+
config: temporarily set the value of an MRtrix config file entry.
|
|
533
|
+
help_: display this information page and exit.
|
|
534
|
+
version: display version information and exit.
|
|
535
|
+
runner: Command runner.
|
|
536
|
+
Returns:
|
|
537
|
+
NamedTuple of outputs (described in `DwidenoiseOutputs`).
|
|
538
|
+
"""
|
|
539
|
+
params = dwidenoise_params(
|
|
540
|
+
mask=mask,
|
|
541
|
+
extent=extent,
|
|
542
|
+
noise=noise,
|
|
543
|
+
datatype=datatype,
|
|
544
|
+
estimator=estimator,
|
|
545
|
+
info=info,
|
|
546
|
+
quiet=quiet,
|
|
547
|
+
debug=debug,
|
|
548
|
+
force=force,
|
|
549
|
+
nthreads=nthreads,
|
|
550
|
+
config=config,
|
|
551
|
+
help_=help_,
|
|
552
|
+
version=version,
|
|
553
|
+
dwi=dwi,
|
|
554
|
+
out=out,
|
|
555
|
+
)
|
|
556
|
+
return dwidenoise_execute(params, runner)
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
__all__ = [
|
|
560
|
+
"DWIDENOISE_METADATA",
|
|
561
|
+
"DwidenoiseConfigParamsDict",
|
|
562
|
+
"DwidenoiseConfigParamsDictTagged",
|
|
563
|
+
"DwidenoiseOutputs",
|
|
564
|
+
"DwidenoiseParamsDict",
|
|
565
|
+
"DwidenoiseParamsDictTagged",
|
|
566
|
+
"dwidenoise",
|
|
567
|
+
"dwidenoise_config",
|
|
568
|
+
"dwidenoise_execute",
|
|
569
|
+
"dwidenoise_params",
|
|
570
|
+
]
|