19
19
from nipype .utils .filemanip import fname_presuffix
20
20
from .base import AFNICommand , AFNICommandInputSpec ,\
21
21
AFNICommandOutputSpec
22
- from nipype .interfaces .base import CommandLineInputSpec , CommandLine
22
+ from nipype .interfaces .base import CommandLineInputSpec , CommandLine ,\
23
+ OutputMultiPath
23
24
24
25
warn = warnings .warn
25
26
warnings .filterwarnings ('always' , category = UserWarning )
@@ -1443,7 +1444,7 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
1443
1444
return outputs
1444
1445
1445
1446
1446
- class ROIStatsInputSpec (AFNICommandInputSpec ):
1447
+ class ROIStatsInputSpec (CommandLineInputSpec ):
1447
1448
in_file = File (desc = 'input file to 3dROIstats' ,
1448
1449
argstr = '%s' ,
1449
1450
position = - 1 ,
@@ -1465,12 +1466,18 @@ class ROIStatsInputSpec(AFNICommandInputSpec):
1465
1466
argstr = '-quiet' ,
1466
1467
position = 1 )
1467
1468
1469
+ terminal_output = traits .Enum ('allatonce' ,
1470
+ desc = ('Control terminal output:'
1471
+ '`allatonce` - waits till command is '
1472
+ 'finished to display output' ),
1473
+ nohash = True , mandatory = True , usedefault = True )
1474
+
1468
1475
1469
1476
class ROIStatsOutputSpec (TraitedSpec ):
1470
- stats = File (desc = 'output' , exists = True )
1477
+ stats = File (desc = 'output tab separated values file ' , exists = True )
1471
1478
1472
1479
1473
- class ROIStats (AFNICommand ):
1480
+ class ROIStats (CommandLine ):
1474
1481
"""Display statistics over masked regions
1475
1482
1476
1483
For complete details, see the `3dROIstats Documentation.
@@ -1492,37 +1499,13 @@ class ROIStats(AFNICommand):
1492
1499
output_spec = ROIStatsOutputSpec
1493
1500
1494
1501
def aggregate_outputs (self , runtime = None , needed_outputs = None ):
1495
-
1496
1502
outputs = self ._outputs ()
1503
+ output_filename = "roi_stats.csv"
1504
+ f = open (output_filename , "w" )
1505
+ f .write (runtime .stdout )
1506
+ f .close ()
1497
1507
1498
- outfile = os .path .join (os .getcwd (), 'stat_result.json' )
1499
-
1500
- if runtime is None :
1501
- try :
1502
- stats = load_json (outfile )['stat' ]
1503
- except IOError :
1504
- return self .run ().outputs
1505
- else :
1506
- stats = []
1507
- for line in runtime .stdout .split ('\n ' ):
1508
- if line :
1509
- values = line .split ()
1510
- if len (values ) > 1 :
1511
- stats .append ([float (val ) for val in values ])
1512
- else :
1513
- stats .extend ([float (val ) for val in values ])
1514
-
1515
- if len (stats ) == 1 :
1516
- stats = stats [0 ]
1517
- of = os .path .join (os .getcwd (), 'TS.1D' )
1518
- f = open (of , 'w' )
1519
-
1520
- for st in stats :
1521
- f .write (str (st ) + '\n ' )
1522
- f .close ()
1523
- save_json (outfile , dict (stat = of ))
1524
- outputs .stats = of
1525
-
1508
+ outputs .stats = os .path .abspath (output_filename )
1526
1509
return outputs
1527
1510
1528
1511
0 commit comments