@@ -1594,6 +1594,7 @@ class LocalstatInputSpec(AFNICommandInputSpec):
15941594class Localstat (AFNICommand ):
15951595 """3dLocalstat - computes statistics at each voxel,
15961596 based on a local neighborhood of that voxel.
1597+
15971598 For complete details, see the `3dLocalstat Documentation.
15981599 <https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dLocalstat.html>`_
15991600
@@ -2301,6 +2302,129 @@ def _list_outputs(self):
23012302 return outputs
23022303
23032304
2305+ class ReHoInputSpec (CommandLineInputSpec ):
2306+ in_file = File (
2307+ desc = 'input dataset' ,
2308+ argstr = '-inset %s' ,
2309+ position = 1 ,
2310+ mandatory = True ,
2311+ exists = True )
2312+ out_file = traits .File (
2313+ desc = 'Output dataset.' ,
2314+ argstr = '-prefix %s' ,
2315+ name_source = 'in_file' ,
2316+ name_template = '%s_localstat' ,
2317+ keep_extension = True ,
2318+ position = 0 )
2319+ chi_sq = traits .Bool (
2320+ argstr = '-chi_sq' ,
2321+ desc = 'Output the Friedman chi-squared value in addition to the '
2322+ 'Kendall\' s W.' )
2323+ mask = traits .File (
2324+ desc = 'Mask within which ReHo should be calculated voxelwise' ,
2325+ argstr = '-mask %s' )
2326+ neighborhood = traits .Enum (
2327+ 'faces' ,
2328+ 'edges' ,
2329+ 'vertices' ,
2330+ xor = ['sphere' , 'ellipsoid' ],
2331+ argstr = '-nneigh %s' ,
2332+ desc = 'voxels in neighborhood. can be: '
2333+ 'faces (for voxel and 6 facewise neighbors, only),'
2334+ 'edges (for voxel and 18 face- and edge-wise neighbors),'
2335+ 'vertices (for voxel and 26 face-, edge-, and node-wise neighbors).' )
2336+ sphere = traits .Float (
2337+ argstr = '-neigh_RAD %s' ,
2338+ xor = ['neighborhood' , 'ellipsoid' ],
2339+ desc = 'for additional voxelwise neighborhood control, the '
2340+ 'radius R of a desired neighborhood can be put in; R is '
2341+ 'a floating point number, and must be >1. Examples of '
2342+ 'the numbers of voxels in a given radius are as follows '
2343+ '(you can roughly approximate with the ol\' 4*PI*(R^3)/3 '
2344+ 'thing):'
2345+ ' R=2.0 -> V=33,'
2346+ ' R=2.3 -> V=57, '
2347+ ' R=2.9 -> V=93, '
2348+ ' R=3.1 -> V=123, '
2349+ ' R=3.9 -> V=251, '
2350+ ' R=4.5 -> V=389, '
2351+ ' R=6.1 -> V=949, '
2352+ 'but you can choose most any value.' )
2353+ ellipsoid = traits .Tuple (
2354+ traits .Float ,
2355+ traits .Float ,
2356+ traits .Float ,
2357+ xor = ['sphere' , 'neighborhood' ],
2358+ argstr = '-neigh_X %s -neigh_Y %s -neigh_Z %s' ,
2359+ desc = 'Tuple indicating the x, y, and z radius of an ellipsoid '
2360+ 'defining the neighbourhood of each voxel.'
2361+ 'The \' hood is then made according to the following relation:'
2362+ '(i/A)^2 + (j/B)^2 + (k/C)^2 <=1.'
2363+ 'which will have approx. V=4*PI*A*B*C/3. The impetus for '
2364+ 'this freedom was for use with data having anisotropic '
2365+ 'voxel edge lengths.' )
2366+ label_set = File (
2367+ exists = True ,
2368+ argstr = '-in_rois %s' ,
2369+ desc = 'a set of ROIs, each labelled with distinct '
2370+ 'integers. ReHo will then be calculated per ROI.' )
2371+ overwrite = traits .Bool (
2372+ desc = 'overwrite output file if it already exists' ,
2373+ argstr = '-overwrite' )
2374+
2375+
2376+ class ReHoOutputSpec (TraitedSpec ):
2377+ out_file = File (exists = True , desc = 'Voxelwise regional homogeneity map' )
2378+ out_vals = File (desc = 'Table of labelwise regional homogenity values' )
2379+
2380+
2381+ class ReHo (AFNICommandBase ):
2382+ """Compute regional homogenity for a given neighbourhood.l,
2383+ based on a local neighborhood of that voxel.
2384+
2385+ For complete details, see the `3dReHo Documentation.
2386+ <https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dReHo.html>`_
2387+
2388+ Examples
2389+ ========
2390+
2391+ >>> from nipype.interfaces import afni
2392+ >>> reho = afni.ReHo()
2393+ >>> reho.inputs.in_file = 'bold.nii.gz'
2394+ >>> reho.inputs.neighborhood = 'vertices'
2395+ >>> reho.inputs.label_set = 'power264.nii.gz'
2396+ >>> reho.cmdline
2397+ "3dReHo -prefix bold_reho.nii.gz \
2398+ -nneigh 27 \
2399+ -in_rois power264.nii.gz"
2400+ >>> rh = reho.run() # doctest: +SKIP
2401+ """
2402+ _cmd = '3dReHo'
2403+ input_spec = ReHoInputSpec
2404+ output_spec = ReHoOutputSpec
2405+
2406+ def _list_outputs (self ):
2407+
2408+ outputs = super (ReHo , self )._list_outputs ()
2409+
2410+ if self .inputs .label_set :
2411+ outputs ['out_vals' ] = outputs ['out_file' ] + '_ROI_reho.vals'
2412+
2413+ return outputs
2414+
2415+ def _format_arg (self , name , spec , value ):
2416+
2417+ _neigh_dict = {
2418+ 'faces' : 7 ,
2419+ 'edges' : 19 ,
2420+ 'vertices' : 27 ,
2421+ }
2422+ if name == 'neighborhood' :
2423+ value = _neigh_dict [value ]
2424+
2425+ return super (ReHo , self )._format_arg (name , spec , value )
2426+
2427+
23042428class ResampleInputSpec (AFNICommandInputSpec ):
23052429
23062430 in_file = File (
0 commit comments