@@ -2627,6 +2627,10 @@ class TShiftInputSpec(AFNICommandInputSpec):
26272627 argstr = '-rlt+' )
26282628
26292629
2630+ class TShiftOutputSpec (AFNICommandOutputSpec ):
2631+ timing_file = File (desc = "AFNI formatted timing file, if ``slice_timing`` is a list" )
2632+
2633+
26302634class TShift (AFNICommand ):
26312635 """Shifts voxel time series from input so that seperate slices are aligned
26322636 to the same temporal origin.
@@ -2650,6 +2654,12 @@ class TShift(AFNICommand):
26502654 >>> tshift.cmdline
26512655 '3dTshift -prefix functional_tshift -tpattern @slice_timing.1D -TR 2.5s -tzero 0.0 functional.nii'
26522656
2657+ When the ``slice_timing`` input is used, the ``timing_file`` output is populated,
2658+ in this case with the generated file.
2659+
2660+ >>> tshift._list_outputs()['timing_file'] # doctest: +ELLIPSIS
2661+ '.../slice_timing.1D'
2662+
26532663 This method creates a ``slice_timing.1D`` file to be passed to ``3dTshift``.
26542664 A pre-existing slice-timing file may be used in the same way:
26552665
@@ -2661,6 +2671,11 @@ class TShift(AFNICommand):
26612671 >>> tshift.cmdline
26622672 '3dTshift -prefix functional_tshift -tpattern @slice_timing.1D -TR 2.5s -tzero 0.0 functional.nii'
26632673
2674+ When a pre-existing file is provided, ``timing_file`` is simply passed through.
2675+
2676+ >>> tshift._list_outputs()['timing_file'] # doctest: +ELLIPSIS
2677+ '.../slice_timing.1D'
2678+
26642679 Alternatively, pre-specified slice timing patterns may be specified with the
26652680 ``tpattern`` input.
26662681 For example, to specify an alternating, ascending slice timing pattern:
@@ -2686,13 +2701,18 @@ class TShift(AFNICommand):
26862701 >>> tshift.cmdline
26872702 '3dTshift -prefix functional_tshift -tpattern @slice_timing.1D -TR 2.5s -tzero 0.0 functional.nii'
26882703
2704+ In these cases, ``timing_file`` is undefined.
2705+
2706+ >>> tshift._list_outputs()['timing_file'] # doctest: +ELLIPSIS
2707+ <undefined>
2708+
26892709 In any configuration, the interface may be run as usual:
26902710
26912711 >>> res = tshift.run() # doctest: +SKIP
26922712 """
26932713 _cmd = '3dTshift'
26942714 input_spec = TShiftInputSpec
2695- output_spec = AFNICommandOutputSpec
2715+ output_spec = TShiftOutputSpec
26962716
26972717 def _format_arg (self , name , trait_spec , value ):
26982718 if name == 'tpattern' and value .startswith ('@' ):
@@ -2708,6 +2728,15 @@ def _write_slice_timing(self):
27082728 fobj .write ('\t ' .join (map (str , self .inputs .slice_timing )))
27092729 return fname
27102730
2731+ def _list_outputs (self ):
2732+ outputs = super (TShift , self )._list_outputs ()
2733+ if isdefined (self .inputs .slice_timing ):
2734+ if isinstance (self .inputs .slice_timing , list ):
2735+ outputs ['timing_file' ] = os .path .abspath ('slice_timing.1D' )
2736+ else :
2737+ outputs ['timing_file' ] = os .path .abspath (self .inputs .slice_timing )
2738+ return outputs
2739+
27112740
27122741class VolregInputSpec (AFNICommandInputSpec ):
27132742 in_file = File (
0 commit comments