10
10
"""
11
11
12
12
import os
13
- from sys import platform
14
13
import os .path as op
15
14
import re
16
15
import numpy as np
17
16
18
- from .base import AFNICommand , AFNICommandInputSpec , AFNICommandOutputSpec , Info , no_afni
19
- from ..base import CommandLineInputSpec , CommandLine
17
+ from .base import (AFNICommandBase , AFNICommand , AFNICommandInputSpec , AFNICommandOutputSpec ,
18
+ Info , no_afni )
19
+ from ..base import CommandLineInputSpec
20
20
from ..base import (Directory , TraitedSpec ,
21
21
traits , isdefined , File , InputMultiPath , Undefined )
22
22
from ...external .six import string_types
@@ -182,7 +182,7 @@ class RefitInputSpec(CommandLineInputSpec):
182
182
' template type, e.g. TLRC, MNI, ORIG' )
183
183
184
184
185
- class Refit (CommandLine ):
185
+ class Refit (AFNICommandBase ):
186
186
"""Changes some of the information inside a 3D dataset's header
187
187
188
188
For complete details, see the `3drefit Documentation.
@@ -1546,7 +1546,7 @@ class ROIStatsOutputSpec(TraitedSpec):
1546
1546
stats = File (desc = 'output tab separated values file' , exists = True )
1547
1547
1548
1548
1549
- class ROIStats (CommandLine ):
1549
+ class ROIStats (AFNICommandBase ):
1550
1550
"""Display statistics over masked regions
1551
1551
1552
1552
For complete details, see the `3dROIstats Documentation.
@@ -2115,7 +2115,7 @@ class HistOutputSpec(TraitedSpec):
2115
2115
out_show = File (desc = 'output visual histogram' )
2116
2116
2117
2117
2118
- class Hist (CommandLine ):
2118
+ class Hist (AFNICommandBase ):
2119
2119
"""Computes average of all voxels in the input dataset
2120
2120
which satisfy the criterion in the options list
2121
2121
@@ -2197,8 +2197,8 @@ class FWHMxInputSpec(CommandLineInputSpec):
2197
2197
combine = traits .Bool (argstr = '-combine' , desc = 'combine the final measurements along each axis' )
2198
2198
compat = traits .Bool (argstr = '-compat' , desc = 'be compatible with the older 3dFWHM' )
2199
2199
acf = traits .Either (
2200
- traits .Bool (), File (exists = True ), traits .Tuple (File (exists = True ), traits .Float ()),
2201
- argstr = '-acf' , desc = 'computes the spatial autocorrelation' )
2200
+ traits .Bool (), File (), traits .Tuple (File (exists = True ), traits .Float ()),
2201
+ default = False , usedefault = True , argstr = '-acf' , desc = 'computes the spatial autocorrelation' )
2202
2202
2203
2203
2204
2204
class FWHMxOutputSpec (TraitedSpec ):
@@ -2209,9 +2209,14 @@ class FWHMxOutputSpec(TraitedSpec):
2209
2209
traits .Tuple (traits .Float (), traits .Float (), traits .Float ()),
2210
2210
traits .Tuple (traits .Float (), traits .Float (), traits .Float (), traits .Float ()),
2211
2211
desc = 'FWHM along each axis' )
2212
+ acf_param = traits .Either (
2213
+ traits .Tuple (traits .Float (), traits .Float (), traits .Float ()),
2214
+ traits .Tuple (traits .Float (), traits .Float (), traits .Float (), traits .Float ()),
2215
+ desc = 'fitted ACF model parameters' )
2216
+ out_acf = File (exists = True , desc = 'output acf file' )
2212
2217
2213
2218
2214
- class FWHMx (CommandLine ):
2219
+ class FWHMx (AFNICommandBase ):
2215
2220
"""
2216
2221
Unlike the older 3dFWHM, this program computes FWHMs for all sub-bricks
2217
2222
in the input dataset, each one separately. The output for each one is
@@ -2312,6 +2317,7 @@ class FWHMx(CommandLine):
2312
2317
_cmd = '3dFWHMx'
2313
2318
input_spec = FWHMxInputSpec
2314
2319
output_spec = FWHMxOutputSpec
2320
+ _acf = True
2315
2321
2316
2322
def _parse_inputs (self , skip = None ):
2317
2323
if not self .inputs .detrend :
@@ -2331,20 +2337,18 @@ def _format_arg(self, name, trait_spec, value):
2331
2337
return trait_spec .argstr + ' %d' % value
2332
2338
2333
2339
if name == 'acf' :
2334
- if isinstance (value , tuple ):
2340
+ if isinstance (value , bool ):
2341
+ if value :
2342
+ return trait_spec .argstr
2343
+ else :
2344
+ self ._acf = False
2345
+ return None
2346
+ elif isinstance (value , tuple ):
2335
2347
return trait_spec .argstr + ' %s %f' % value
2336
2348
elif isinstance (value , string_types ):
2337
2349
return trait_spec .argstr + ' ' + value
2338
2350
return super (FWHMx , self )._format_arg (name , trait_spec , value )
2339
2351
2340
- def _run_interface (self , runtime ):
2341
- if platform == 'darwin' :
2342
- # http://afni.nimh.nih.gov/afni/community/board/read.php?1,145346,145347#msg-145347
2343
- runtime .environ ['DYLD_FALLBACK_LIBRARY_PATH' ] = '/usr/local/afni/'
2344
-
2345
- return super (FWHMx , self )._run_interface (runtime )
2346
-
2347
-
2348
2352
def _list_outputs (self ):
2349
2353
outputs = super (FWHMx , self )._list_outputs ()
2350
2354
@@ -2357,5 +2361,14 @@ def _list_outputs(self):
2357
2361
else :
2358
2362
outputs ['out_detrend' ] = Undefined
2359
2363
2360
- outputs ['fwhm' ] = tuple (np .loadtxt (outputs ['out_file' ])) #pylint: disable=E1101
2364
+ sout = np .loadtxt (outputs ['out_file' ]) #pylint: disable=E1101
2365
+ if self ._acf :
2366
+ outputs ['acf_param' ] = tuple (sout [1 ])
2367
+ sout = tuple (sout [0 ])
2368
+
2369
+ outputs ['out_acf' ] = op .abspath ('3dFWHMx.1D' )
2370
+ if isinstance (self .inputs .acf , string_types ):
2371
+ outputs ['out_acf' ] = op .abspath (self .inputs .acf )
2372
+
2373
+ outputs ['fwhm' ] = tuple (sout )
2361
2374
return outputs
0 commit comments