@@ -262,6 +262,68 @@ def _format_arg(self, name, trait_spec, value):
262
262
return super (Smooth , self )._format_arg (name , trait_spec , value )
263
263
264
264
265
+ class SliceInputSpec (FSLCommandInputSpec ):
266
+ in_file = File (exists = True , argstr = "%s" , position = 0 , mandatory = True ,
267
+ desc = "input filename" , copyfile = False )
268
+ out_base_name = traits .Str (argstr = "%s" , position = 1 , desc = "outputs prefix" )
269
+
270
+
271
+ class SliceOutputSpec (TraitedSpec ):
272
+ out_files = OutputMultiPath (File (exists = True ))
273
+
274
+
275
+ class Slice (FSLCommand ):
276
+ """Use fslslice to split a 3D file into lots of 2D files (along z-axis).
277
+
278
+
279
+ Examples
280
+ --------
281
+
282
+ >>> from nipype.interfaces.fsl import Slice
283
+ >>> slice = Slice()
284
+ >>> slice.inputs.in_file = 'functional.nii'
285
+ >>> slice.inputs.out_base_name = 'sl'
286
+ >>> slice.cmdline
287
+ 'fslslice functional.nii sl'
288
+
289
+
290
+ """
291
+
292
+ _cmd = 'fslslice'
293
+ input_spec = SliceInputSpec
294
+ output_spec = SliceOutputSpec
295
+
296
+ def _list_outputs (self ):
297
+ """Create a Bunch which contains all possible files generated
298
+ by running the interface. Some files are always generated, others
299
+ depending on which ``inputs`` options are set.
300
+
301
+ Returns
302
+ -------
303
+
304
+ outputs : Bunch object
305
+ Bunch object containing all possible files generated by
306
+ interface object.
307
+
308
+ If None, file was not generated
309
+ Else, contains path, filename of generated outputfile
310
+
311
+ """
312
+ outputs = self ._outputs ().get ()
313
+ ext = Info .output_type_to_ext (self .inputs .output_type )
314
+ suffix = '_slice_*' + ext
315
+ if isdefined (self .inputs .out_base_name ):
316
+ fname_template = os .path .abspath (
317
+ self .inputs .out_base_name + suffix )
318
+ else :
319
+ fname_template = fname_presuffix (self .inputs .in_file ,
320
+ suffix = suffix , use_ext = False )
321
+
322
+ outputs ['out_files' ] = sorted (glob (fname_template ))
323
+
324
+ return outputs
325
+
326
+
265
327
class MergeInputSpec (FSLCommandInputSpec ):
266
328
in_files = traits .List (
267
329
File (exists = True ), argstr = "%s" , position = 2 , mandatory = True )
0 commit comments