Skip to content

Commit 2ce2661

Browse files
committed
Added afni centrality interface
1 parent c1376c4 commit 2ce2661

File tree

2 files changed

+58
-30
lines changed

2 files changed

+58
-30
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from .base import Info
1010
from .preprocess import (To3D, Refit, Resample, TStat, Automask, Volreg, Merge,
1111
ZCutUp, Calc, TShift, Warp, Detrend, Despike, DegreeCentrality,
12-
Copy, Fourier, Allineate, Maskave, SkullStrip, TCat, Fim,
13-
BlurInMask, Autobox, TCorrMap, Bandpass, Retroicor,
12+
LFCD, Copy, Fourier, Allineate, Maskave, SkullStrip, TCat,
13+
Fim, BlurInMask, Autobox, TCorrMap, Bandpass, Retroicor,
1414
TCorrelate, TCorr1D, BrickStat, ROIStats, AutoTcorrelate,
1515
AFNItoNIFTI, Eval, Means)
1616
from .svm import (SVMTest, SVMTrain)

nipype/interfaces/afni/preprocess.py

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -512,13 +512,6 @@ class CentralityInputSpec(AFNICommandInputSpec):
512512
inherits the out_file parameter from AFNICommandOutputSpec base class
513513
"""
514514

515-
in_file = File(desc='input file to 3dDegreeCentrality',
516-
argstr='%s',
517-
position=-1,
518-
mandatory=True,
519-
exists=True,
520-
copyfile=False)
521-
522515
mask = File(desc='mask file to mask input data',
523516
argstr="-mask %s",
524517
exists=True)
@@ -547,37 +540,22 @@ class DegreeCentralityInputSpec(CentralityInputSpec):
547540
exists=True,
548541
copyfile=False)
549542

550-
mask = File(desc='mask file to mask input data',
551-
argstr="-mask %s",
552-
exists=True)
553-
554-
thresh = traits.Float(desc='threshold to exclude connections where corr <= thresh',
555-
argstr='-thresh %f')
556-
557543
sparsity = traits.Float(desc='only take the top percent of connections',
558544
argstr='-sparsity %f')
559545

560-
out_1d = traits.Str(desc='output filepath to text dump of correlation matrix',
561-
argstr='-out1D')
562-
563-
polort = traits.Int(desc='', argstr='-polort %d')
564-
565-
autoclip = traits.Bool(desc='Clip off low-intensity regions in the dataset',
566-
argstr='-autoclip')
567-
568-
automask = traits.Bool(desc='Mask the dataset to target brain-only voxels',
569-
argstr='-automask')
546+
oned_file = traits.Str(desc='output filepath to text dump of correlation matrix',
547+
argstr='-out1D %s', mandatory=False)
570548

571549

572550
class DegreeCentralityOutputSpec(AFNICommandOutputSpec):
573551
"""
574552
inherits the out_file parameter from AFNICommandOutputSpec base class
575553
"""
576554

577-
one_d_file = File(desc='The text output of the similarity matrix computed'\
578-
'after thresholding with one-dimensional and '\
579-
'ijk voxel indices, correlations, image extents, '\
580-
'and affine matrix')
555+
oned_file = File(desc='The text output of the similarity matrix computed'\
556+
'after thresholding with one-dimensional and '\
557+
'ijk voxel indices, correlations, image extents, '\
558+
'and affine matrix')
581559

582560

583561
class DegreeCentrality(AFNICommand):
@@ -604,6 +582,56 @@ class DegreeCentrality(AFNICommand):
604582
input_spec = DegreeCentralityInputSpec
605583
output_spec = DegreeCentralityOutputSpec
606584

585+
# Re-define generated inputs
586+
def _list_outputs(self):
587+
# Import packages
588+
import os
589+
590+
# Update outputs dictionary if oned file is defined
591+
outputs = super(DegreeCentrality, self)._list_outputs()
592+
if self.inputs.oned_file:
593+
outputs['oned_file'] = os.path.abspath(self.inputs.oned_file)
594+
595+
return outputs
596+
597+
598+
class LFCDInputSpec(CentralityInputSpec):
599+
"""
600+
inherits the out_file parameter from AFNICommandOutputSpec base class
601+
"""
602+
603+
in_file = File(desc='input file to 3dLFCD',
604+
argstr='%s',
605+
position=-1,
606+
mandatory=True,
607+
exists=True,
608+
copyfile=False)
609+
610+
611+
class LFCD(AFNICommand):
612+
"""Performs degree centrality on a dataset using a given maskfile
613+
via 3dLFCD
614+
615+
For complete details, see the `3dLFCD Documentation.
616+
<http://afni.nimh.nih.gov/pub/dist/doc/program_help/3dLFCD.html>
617+
618+
Examples
619+
========
620+
621+
>>> from nipype.interfaces import afni as afni
622+
>>> lfcd = afni.LFCD()
623+
>>> lfcd.inputs.in_file = 'func_preproc.nii'
624+
>>> lfcd.inputs.mask = 'mask.nii'
625+
>>> lfcd.inputs.threshold = .8 # keep all connections with corr >= 0.8
626+
>>> lfcd.cmdline
627+
'3dLFCD -threshold 0.8 -mask mask.nii func_preproc.nii'
628+
>>> res = lfcd.run() # doctest: +SKIP
629+
"""
630+
631+
_cmd = '3dLFCD'
632+
input_spec = LFCDInputSpec
633+
output_spec = AFNICommandOutputSpec
634+
607635

608636
class AutomaskInputSpec(AFNICommandInputSpec):
609637
in_file = File(desc='input file to 3dAutomask',

0 commit comments

Comments
 (0)