|
13 | 13 | from ...utils.filemanip import (load_json, save_json, split_filename,
|
14 | 14 | fname_presuffix)
|
15 | 15 | from ..base import (CommandLineInputSpec, CommandLine, TraitedSpec, traits,
|
16 |
| - isdefined, File, InputMultiPath, Undefined, Str, |
| 16 | + isdefined, File, InputMultiPath, Undefined, Str, |
17 | 17 | InputMultiObject)
|
18 | 18 |
|
19 | 19 | from .base import (AFNICommandBase, AFNICommand, AFNICommandInputSpec,
|
@@ -2566,7 +2566,7 @@ class TProject(AFNICommand):
|
2566 | 2566 | _cmd = '3dTproject'
|
2567 | 2567 | input_spec = TProjectInputSpec
|
2568 | 2568 | output_spec = AFNICommandOutputSpec
|
2569 |
| - |
| 2569 | + |
2570 | 2570 |
|
2571 | 2571 |
|
2572 | 2572 | class TShiftInputSpec(AFNICommandInputSpec):
|
@@ -2862,7 +2862,8 @@ class WarpInputSpec(AFNICommandInputSpec):
|
2862 | 2862 | name_template='%s_warp',
|
2863 | 2863 | desc='output image file name',
|
2864 | 2864 | argstr='-prefix %s',
|
2865 |
| - name_source='in_file') |
| 2865 | + name_source='in_file', |
| 2866 | + keep_extension=True) |
2866 | 2867 | tta2mni = traits.Bool(
|
2867 | 2868 | desc='transform dataset from Talairach to MNI152', argstr='-tta2mni')
|
2868 | 2869 | mni2tta = traits.Bool(
|
@@ -2893,6 +2894,13 @@ class WarpInputSpec(AFNICommandInputSpec):
|
2893 | 2894 | argstr='-zpad %d')
|
2894 | 2895 | verbose = traits.Bool(
|
2895 | 2896 | desc='Print out some information along the way.', argstr='-verb')
|
| 2897 | + save_warp = traits.Bool( |
| 2898 | + desc='save warp as .mat file', requires=['verbose']) |
| 2899 | + |
| 2900 | + |
| 2901 | +class WarpOutputSpec(TraitedSpec): |
| 2902 | + out_file = File(desc='Warped file.', exists=True) |
| 2903 | + warp_file = File(desc='warp transform .mat file') |
2896 | 2904 |
|
2897 | 2905 |
|
2898 | 2906 | class Warp(AFNICommand):
|
@@ -2924,7 +2932,25 @@ class Warp(AFNICommand):
|
2924 | 2932 | """
|
2925 | 2933 | _cmd = '3dWarp'
|
2926 | 2934 | input_spec = WarpInputSpec
|
2927 |
| - output_spec = AFNICommandOutputSpec |
| 2935 | + output_spec = WarpOutputSpec |
| 2936 | + |
| 2937 | + def _run_interface(self, runtime): |
| 2938 | + runtime = super(Warp, self)._run_interface(runtime) |
| 2939 | + |
| 2940 | + if self.inputs.save_warp: |
| 2941 | + import numpy as np |
| 2942 | + warp_file = self._list_outputs()['warp_file'] |
| 2943 | + np.savetxt(warp_file, [runtime.stdout], fmt=str('%s')) |
| 2944 | + return runtime |
| 2945 | + |
| 2946 | + def _list_outputs(self): |
| 2947 | + outputs = super(Warp, self)._list_outputs() |
| 2948 | + if self.inputs.save_warp: |
| 2949 | + outputs['warp_file'] = fname_presuffix(outputs['out_file'], |
| 2950 | + suffix='_transform.mat', |
| 2951 | + use_ext=False) |
| 2952 | + |
| 2953 | + return outputs |
2928 | 2954 |
|
2929 | 2955 |
|
2930 | 2956 | class QwarpPlusMinusInputSpec(CommandLineInputSpec):
|
|
0 commit comments