9
9
10
10
>>> task = Topup(input_image="input.nii", encoding_file="encoding.txt")
11
11
>>> task.cmdline # doctest: +ELLIPSIS
12
- 'topup --imain input.nii --datain encoding.txt --out input_topup \
13
- --fout ...input_fieldmap.nii --iout ...input_unwarped.nii ...'
12
+ 'topup --imain= input.nii --datain= encoding.txt --out= input_topup \
13
+ --fout= ...input_fieldmap.nii --iout= ...input_unwarped.nii ...'
14
14
15
15
Using a multiple resolution approach:
16
16
21
21
... smoothing_per_level=(8.0, 4.0, 0.0),
22
22
... )
23
23
>>> task.cmdline # doctest: +ELLIPSIS
24
- 'topup --imain input.nii --datain encoding.txt ... --subsamp 4,2,1 --fwhm 8.0,4.0,0.0 ...'
24
+ 'topup --imain= input.nii --datain= encoding.txt ... --subsamp= 4,2,1 --fwhm= 8.0,4.0,0.0 ...'
25
25
"""
26
26
27
27
__all__ = ["Topup" ]
36
36
37
37
38
38
def to_field_per_level (field , param ) -> str :
39
- return f"--{ param } { ',' .join ([str (elem ) for elem in field ])} "
39
+ return f"--{ param } = { ',' .join ([str (elem ) for elem in field ])} "
40
40
41
41
42
42
def to_output_basename (field , input_image ) -> str :
43
- return f"--out { field or PurePath (input_image ).name .split ('.' , 1 )[0 ] + '_topup' } "
43
+ return f"--out= { field or PurePath (input_image ).name .split ('.' , 1 )[0 ] + '_topup' } "
44
44
45
45
46
46
@define (slots = False , kw_only = True )
47
47
class TopupSpec (ShellSpec ):
48
48
"""Specifications for topup."""
49
49
50
- input_image : PathLike = field (metadata = {"help_string" : "input image" , "mandatory" : True , "argstr" : "--imain" })
50
+ input_image : PathLike = field (
51
+ metadata = {"help_string" : "input image" , "mandatory" : True , "argstr" : "--imain={input_image}" }
52
+ )
51
53
52
54
encoding_file : PathLike = field (
53
55
metadata = {
54
56
"help_string" : "text file containing phase encoding directions and timings" ,
55
57
"mandatory" : True ,
56
- "argstr" : "--datain" ,
58
+ "argstr" : "--datain={encoding_file} " ,
57
59
}
58
60
)
59
61
@@ -67,15 +69,15 @@ class TopupSpec(ShellSpec):
67
69
output_fieldmap_image : str = field (
68
70
metadata = {
69
71
"help_string" : "output fieldmap image" ,
70
- "argstr" : "--fout" ,
72
+ "argstr" : "--fout={output_fieldmap_image} " ,
71
73
"output_file_template" : "{input_image}_fieldmap" ,
72
74
}
73
75
)
74
76
75
77
output_unwarped_image : str = field (
76
78
metadata = {
77
79
"help_string" : "output unwarped image" ,
78
- "argstr" : "--iout" ,
80
+ "argstr" : "--iout={output_unwarped_image} " ,
79
81
"output_file_template" : "{input_image}_unwarped" ,
80
82
}
81
83
)
@@ -145,15 +147,15 @@ class TopupSpec(ShellSpec):
145
147
default = True ,
146
148
metadata = {
147
149
"help_string" : "weight regularisation by sum-of-squares" ,
148
- "formatter" : lambda field : f"--ssqlambda { int ( field ) } " ,
150
+ "formatter" : lambda field : f"--ssqlambda= { field :d } " ,
149
151
},
150
152
)
151
153
152
154
regularisation_model : str = field (
153
155
default = "bending_energy" ,
154
156
metadata = {
155
157
"help_string" : "regularisation model" ,
156
- "argstr" : "--regmod" ,
158
+ "argstr" : "--regmod={regularisation_model} " ,
157
159
"allowed_values" : {"bending_energy" , "membrane_energy" },
158
160
},
159
161
)
@@ -162,38 +164,48 @@ class TopupSpec(ShellSpec):
162
164
default = 3 ,
163
165
metadata = {
164
166
"help_string" : "use quadratic (2) or cubic (3) splines" ,
165
- "argstr" : "--splineorder" ,
167
+ "argstr" : "--splineorder={spline_order} " ,
166
168
"allowed_values" : {2 , 3 },
167
169
},
168
170
)
169
171
170
172
precision : str = field (
171
173
default = "double" ,
172
- metadata = {"help_string" : "numerical precision" , "argstr" : "--numprec" , "allowed_values" : {"float" , "double" }},
174
+ metadata = {
175
+ "help_string" : "numerical precision" ,
176
+ "argstr" : "--numprec={precision}" ,
177
+ "allowed_values" : {"float" , "double" },
178
+ },
173
179
)
174
180
175
181
interpolation : str = field (
176
182
default = "spline" ,
177
- metadata = {"help_string" : "interpolation model" , "argstr" : "--interp" , "allowed_values" : {"linear" , "spline" }},
183
+ metadata = {
184
+ "help_string" : "interpolation model" ,
185
+ "argstr" : "--interp={interpolation}" ,
186
+ "allowed_values" : {"linear" , "spline" },
187
+ },
178
188
)
179
189
180
190
scale : bool = field (
181
191
default = False ,
182
192
metadata = {
183
193
"help_string" : "scale images to a common mean" ,
184
- "formatter" : lambda field : f"--scale { int ( field ) } " ,
194
+ "formatter" : lambda field : f"--scale= { field :d } " ,
185
195
},
186
196
)
187
197
188
198
regrid : bool = field (
189
199
default = True ,
190
200
metadata = {
191
201
"help_string" : "perform calculations on a different grid" ,
192
- "formatter" : lambda field : f"--regrid { int ( field ) } " ,
202
+ "formatter" : lambda field : f"--regrid= { field :d } " ,
193
203
},
194
204
)
195
205
196
- num_threads : int = field (default = 1 , metadata = {"help_string" : "number of threads to use" , "argstr" : "--nthr" })
206
+ num_threads : int = field (
207
+ default = 1 , metadata = {"help_string" : "number of threads to use" , "argstr" : "--nthr={num_threads}" }
208
+ )
197
209
198
210
verbose : bool = field (metadata = {"help_string" : "enable verbose logging" , "argstr" : "--verbose" })
199
211
0 commit comments