@@ -131,10 +131,15 @@ def _format_arg(self, name, trait_spec, value):
131
131
class MergeInputSpec (FSLCommandInputSpec ):
132
132
in_files = traits .List (File (exists = True ), argstr = "%s" , position = 2 ,
133
133
mandatory = True )
134
- dimension = traits .Enum ('t' , 'x' , 'y' , 'z' , argstr = "-%s" , position = 0 ,
135
- desc = "dimension along which to merge" ,
134
+ dimension = traits .Enum ('t' , 'x' , 'y' , 'z' , 'a' , argstr = "-%s" , position = 0 ,
135
+ desc = ("dimension along which to merge, optionally "
136
+ "set tr input when dimension is t" ),
136
137
mandatory = True )
137
- merged_file = File (argstr = "%s" , position = 1 , genfile = True , hash_files = False )
138
+ tr = traits .Float (position = - 1 , argstr = '%.2f' ,
139
+ desc = ('use to specify TR in seconds (default is 1.00 '
140
+ 'sec), overrides dimension and sets it to tr' ))
141
+ merged_file = File (argstr = "%s" , position = 1 , name_source = 'in_files' ,
142
+ name_template = '%s_merged' , hash_files = False )
138
143
139
144
140
145
class MergeOutputSpec (TraitedSpec ):
@@ -143,27 +148,42 @@ class MergeOutputSpec(TraitedSpec):
143
148
144
149
class Merge (FSLCommand ):
145
150
"""Use fslmerge to concatenate images
151
+
152
+ Images can be concatenated across time, x, y, or z dimensions. Across the
153
+ time (t) dimension the TR is set by default to 1 sec.
154
+
155
+ Note: to set the TR to a different value, specify 't' for dimension and
156
+ specify the TR value in seconds for the tr input. The dimension will be
157
+ automatically updated to 'tr'.
158
+
159
+ Examples
160
+ --------
161
+ >>> from nipype.interfaces.fsl import Merge
162
+ >>> merger = Merge()
163
+ >>> merger.inputs.in_files = ['functional2.nii', 'functional3.nii']
164
+ >>> merger.inputs.dimension = 't'
165
+ >>> merger.inputs.output_type = 'NIFTI_GZ'
166
+ >>> merger.cmdline
167
+ 'fslmerge -t functional2_merged.nii.gz functional2.nii functional3.nii'
168
+ >>> merger.inputs.tr = 2.25
169
+ >>> merger.cmdline
170
+ 'fslmerge -tr functional2_merged.nii.gz functional2.nii functional3.nii 2.25'
146
171
"""
147
172
148
173
_cmd = 'fslmerge'
149
174
input_spec = MergeInputSpec
150
175
output_spec = MergeOutputSpec
151
176
152
- def _list_outputs (self ):
153
- outputs = self ._outputs ().get ()
154
- outputs ['merged_file' ] = self .inputs .merged_file
155
- if not isdefined (outputs ['merged_file' ]):
156
- outputs ['merged_file' ] = self ._gen_fname (self .inputs .in_files [0 ],
157
- suffix = '_merged' )
158
- else :
159
- outputs ['merged_file' ] = os .path .realpath (self .inputs .merged_file )
160
-
161
- return outputs
162
-
163
- def _gen_filename (self , name ):
164
- if name == 'merged_file' :
165
- return self ._list_outputs ()[name ]
166
- return None
177
+ def _format_arg (self , name , spec , value ):
178
+ if name == 'tr' :
179
+ if self .inputs .dimension != 't' :
180
+ raise ValueError ('When TR is specified, dimension must be t' )
181
+ return spec .argstr % value
182
+ if name == 'dimension' :
183
+ if isdefined (self .inputs .tr ):
184
+ return '-tr'
185
+ return spec .argstr % value
186
+ return super (Merge , self )._format_arg (name , spec , value )
167
187
168
188
169
189
class ExtractROIInputSpec (FSLCommandInputSpec ):
0 commit comments