@@ -1378,3 +1378,66 @@ class ZCutUp(AFNICommand):
13781378 _cmd = '3dZcutup'
13791379 input_spec = ZCutUpInputSpec
13801380 output_spec = AFNICommandOutputSpec
1381+
1382+
1383+ class GCORInputSpec (CommandLineInputSpec ):
1384+ in_file = File (
1385+ desc = 'input dataset to compute the GCOR over' ,
1386+ argstr = '-input %s' ,
1387+ position = - 1 ,
1388+ mandatory = True ,
1389+ exists = True ,
1390+ copyfile = False )
1391+
1392+ mask = File (
1393+ desc = 'mask dataset, for restricting the computation' ,
1394+ argstr = '-mask %s' ,
1395+ exists = True ,
1396+ copyfile = False )
1397+
1398+ nfirst = traits .Int (0 , argstr = '-nfirst %d' ,
1399+ desc = 'specify number of initial TRs to ignore' )
1400+ no_demean = traits .Bool (False , argstr = '-no_demean' ,
1401+ desc = 'do not (need to) demean as first step' )
1402+
1403+
1404+ class GCOROutputSpec (TraitedSpec ):
1405+ out = traits .Float (desc = 'global correlation value' )
1406+
1407+
1408+ class GCOR (CommandLine ):
1409+ """
1410+ Computes the average correlation between every voxel
1411+ and ever other voxel, over any give mask.
1412+
1413+
1414+ For complete details, see the `@compute_gcor Documentation.
1415+ <https://afni.nimh.nih.gov/pub/dist/doc/program_help/@compute_gcor.html>`_
1416+
1417+ Examples
1418+ ========
1419+
1420+ >>> from nipype.interfaces import afni
1421+ >>> gcor = afni.GCOR()
1422+ >>> gcor.inputs.in_file = 'structural.nii'
1423+ >>> gcor.inputs.nfirst = 4
1424+ >>> gcor.cmdline # doctest: +ALLOW_UNICODE
1425+ '@compute_gcor -nfirst 4 -input structural.nii'
1426+ >>> res = gcor.run() # doctest: +SKIP
1427+
1428+ """
1429+
1430+ _cmd = '@compute_gcor'
1431+ input_spec = GCORInputSpec
1432+ output_spec = GCOROutputSpec
1433+
1434+ def _run_interface (self , runtime ):
1435+ runtime = super (GCOR , self )._run_interface (runtime )
1436+
1437+ gcor_line = [line .strip () for line in runtime .stdout .split ('\n ' )
1438+ if line .strip ().startswith ('GCOR = ' )][- 1 ]
1439+ setattr (self , '_gcor' , float (gcor_line [len ('GCOR = ' ):]))
1440+ return runtime
1441+
1442+ def _list_outputs (self ):
1443+ return {'out' : getattr (self , '_gcor' )}
0 commit comments