1616
1717from .base import (AFNICommandBase , AFNICommand , AFNICommandInputSpec , AFNICommandOutputSpec ,
1818 Info , no_afni )
19- from ..base import CommandLineInputSpec
20- from ..base import (Directory , TraitedSpec ,
19+ from ..base import (CommandLineInputSpec , CommandLine , Directory , TraitedSpec ,
2120 traits , isdefined , File , InputMultiPath , Undefined )
2221from ...external .six import string_types
2322from ...utils .filemanip import (load_json , save_json , split_filename )
@@ -2374,7 +2373,7 @@ def _list_outputs(self):
23742373 return outputs
23752374
23762375
2377- class OutlierCountInputSpec (AFNICommandInputSpec ):
2376+ class OutlierCountInputSpec (CommandLineInputSpec ):
23782377 in_file = File (argstr = '%s' , mandatory = True , exists = True , position = - 2 , desc = 'input dataset' )
23792378 mask = File (exists = True , argstr = '-mask %s' , xor = ['autoclip' , 'automask' ],
23802379 desc = 'only count voxels within the given mask' )
@@ -2405,13 +2404,14 @@ class OutlierCountInputSpec(AFNICommandInputSpec):
24052404 keep_extension = False , position = - 1 , desc = 'capture standard output' )
24062405
24072406
2408- class OutlierCountOutputSpec (AFNICommandOutputSpec ):
2407+ class OutlierCountOutputSpec (TraitedSpec ):
24092408 outliers_file = File (exists = True , desc = 'output image file name' )
2410- outliers = traits .List (traits .Float ,
2411- desc = 'parse standard output to get the count of outliers' )
2409+ out_file = File (
2410+ name_template = '%s_tqual' , name_source = ['in_file' ], argstr = '> %s' ,
2411+ keep_extension = False , position = - 1 , desc = 'capture standard output' )
24122412
24132413
2414- class OutlierCount (AFNICommand ):
2414+ class OutlierCount (CommandLine ):
24152415 """Create a 3D dataset from 2D image files using AFNI to3d command
24162416
24172417 For complete details, see the `to3d Documentation
@@ -2441,21 +2441,8 @@ def _parse_inputs(self, skip=None):
24412441 skip += ['outliers_file' ]
24422442 return super (OutlierCount , self )._parse_inputs (skip )
24432443
2444- def _list_outputs (self ):
2445- outputs = self .output_spec ().get ()
2446- outputs ['outliers_file' ] = (Undefined if not self .inputs .save_outliers
2447- else self .inputs .outliers_file )
2448-
24492444
2450- with open (self .inputs .out_file , 'r' ) as fout :
2451- lines = fout .readlines ()
2452- # remove general information and warnings
2453- outputs ['outliers' ] = [float (l )
2454- for l in lines if re .match ("[0-9]+$" , l .strip ())]
2455- return outputs
2456-
2457-
2458- class QualityIndexInputSpec (AFNICommandInputSpec ):
2445+ class QualityIndexInputSpec (CommandLineInputSpec ):
24592446 in_file = File (argstr = '%s' , mandatory = True , exists = True , position = - 2 , desc = 'input dataset' )
24602447 mask = File (exists = True , argstr = '-mask %s' , xor = ['autoclip' , 'automask' ],
24612448 desc = 'compute correlation only across masked voxels' )
@@ -2481,11 +2468,11 @@ class QualityIndexInputSpec(AFNICommandInputSpec):
24812468 keep_extension = False , position = - 1 , desc = 'capture standard output' )
24822469
24832470
2484- class QualityIndexOutputSpec (AFNICommandOutputSpec ):
2485- qi_value = traits . List ( traits . Float , desc = 'output quality index ' )
2471+ class QualityIndexOutputSpec (TraitedSpec ):
2472+ out_file = File ( desc = 'file containing the caputured standard output ' )
24862473
24872474
2488- class QualityIndex (AFNICommand ):
2475+ class QualityIndex (CommandLine ):
24892476 """Create a 3D dataset from 2D image files using AFNI to3d command
24902477
24912478 For complete details, see the `to3d Documentation
@@ -2506,13 +2493,3 @@ class QualityIndex(AFNICommand):
25062493 _cmd = '3dTqual'
25072494 input_spec = QualityIndexInputSpec
25082495 output_spec = QualityIndexOutputSpec
2509-
2510- def _list_outputs (self ):
2511- outputs = self .output_spec ().get ()
2512- with open (self .inputs .out_file , 'r' ) as fout :
2513- lines = fout .readlines ()
2514- # remove general information
2515- lines = [l for l in lines if l [:2 ] != "++" ]
2516- # remove general information and warnings
2517- outputs ['qi_value' ] = [float (l .strip ()) for l in lines ]
2518- return outputs
0 commit comments