16
16
17
17
from .base import (AFNICommandBase , AFNICommand , AFNICommandInputSpec , AFNICommandOutputSpec ,
18
18
Info , no_afni )
19
- from ..base import CommandLineInputSpec
20
- from ..base import (Directory , TraitedSpec ,
19
+ from ..base import (CommandLineInputSpec , CommandLine , Directory , TraitedSpec ,
21
20
traits , isdefined , File , InputMultiPath , Undefined )
22
21
from ...external .six import string_types
23
22
from ...utils .filemanip import (load_json , save_json , split_filename )
@@ -2374,7 +2373,7 @@ def _list_outputs(self):
2374
2373
return outputs
2375
2374
2376
2375
2377
- class OutlierCountInputSpec (AFNICommandInputSpec ):
2376
+ class OutlierCountInputSpec (CommandLineInputSpec ):
2378
2377
in_file = File (argstr = '%s' , mandatory = True , exists = True , position = - 2 , desc = 'input dataset' )
2379
2378
mask = File (exists = True , argstr = '-mask %s' , xor = ['autoclip' , 'automask' ],
2380
2379
desc = 'only count voxels within the given mask' )
@@ -2405,13 +2404,14 @@ class OutlierCountInputSpec(AFNICommandInputSpec):
2405
2404
keep_extension = False , position = - 1 , desc = 'capture standard output' )
2406
2405
2407
2406
2408
- class OutlierCountOutputSpec (AFNICommandOutputSpec ):
2407
+ class OutlierCountOutputSpec (TraitedSpec ):
2409
2408
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' )
2412
2412
2413
2413
2414
- class OutlierCount (AFNICommand ):
2414
+ class OutlierCount (CommandLine ):
2415
2415
"""Create a 3D dataset from 2D image files using AFNI to3d command
2416
2416
2417
2417
For complete details, see the `to3d Documentation
@@ -2441,21 +2441,8 @@ def _parse_inputs(self, skip=None):
2441
2441
skip += ['outliers_file' ]
2442
2442
return super (OutlierCount , self )._parse_inputs (skip )
2443
2443
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
-
2449
2444
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 ):
2459
2446
in_file = File (argstr = '%s' , mandatory = True , exists = True , position = - 2 , desc = 'input dataset' )
2460
2447
mask = File (exists = True , argstr = '-mask %s' , xor = ['autoclip' , 'automask' ],
2461
2448
desc = 'compute correlation only across masked voxels' )
@@ -2481,11 +2468,11 @@ class QualityIndexInputSpec(AFNICommandInputSpec):
2481
2468
keep_extension = False , position = - 1 , desc = 'capture standard output' )
2482
2469
2483
2470
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 ' )
2486
2473
2487
2474
2488
- class QualityIndex (AFNICommand ):
2475
+ class QualityIndex (CommandLine ):
2489
2476
"""Create a 3D dataset from 2D image files using AFNI to3d command
2490
2477
2491
2478
For complete details, see the `to3d Documentation
@@ -2506,13 +2493,3 @@ class QualityIndex(AFNICommand):
2506
2493
_cmd = '3dTqual'
2507
2494
input_spec = QualityIndexInputSpec
2508
2495
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