Skip to content

Commit 8e88e09

Browse files
committed
Added 3dECM interface
1 parent 3f0470e commit 8e88e09

File tree

1 file changed

+86
-11
lines changed

1 file changed

+86
-11
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 86 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,9 @@ class Despike(AFNICommand):
509509

510510

511511
class CentralityInputSpec(AFNICommandInputSpec):
512+
"""Common input spec class for all centrality-related commmands
512513
"""
513-
inherits the out_file parameter from AFNICommandOutputSpec base class
514-
"""
514+
515515

516516
mask = File(desc='mask file to mask input data',
517517
argstr="-mask %s",
@@ -530,8 +530,7 @@ class CentralityInputSpec(AFNICommandInputSpec):
530530

531531

532532
class DegreeCentralityInputSpec(CentralityInputSpec):
533-
"""
534-
inherits the out_file parameter from AFNICommandOutputSpec base class
533+
"""DegreeCentrality inputspec
535534
"""
536535

537536
in_file = File(desc='input file to 3dDegreeCentrality',
@@ -549,8 +548,7 @@ class DegreeCentralityInputSpec(CentralityInputSpec):
549548

550549

551550
class DegreeCentralityOutputSpec(AFNICommandOutputSpec):
552-
"""
553-
inherits the out_file parameter from AFNICommandOutputSpec base class
551+
"""DegreeCentrality outputspec
554552
"""
555553

556554
oned_file = File(desc='The text output of the similarity matrix computed'\
@@ -574,8 +572,9 @@ class DegreeCentrality(AFNICommand):
574572
>>> degree.inputs.in_file = 'func_preproc.nii'
575573
>>> degree.inputs.mask = 'mask.nii'
576574
>>> degree.inputs.sparsity = 1 # keep the top one percent of connections
575+
>>> degree.inputs.out_file = 'out.nii'
577576
>>> degree.cmdline
578-
'3dDegreeCentrality -sparsity 1 -mask mask.nii func_preproc.nii'
577+
'3dDegreeCentrality -sparsity 1 -mask mask.nii -prefix out.nii func_preproc.nii'
579578
>>> res = degree.run() # doctest: +SKIP
580579
"""
581580

@@ -596,9 +595,84 @@ def _list_outputs(self):
596595
return outputs
597596

598597

599-
class LFCDInputSpec(CentralityInputSpec):
598+
class ECMInputSpec(CentralityInputSpec):
599+
"""ECM inputspec
600600
"""
601-
inherits the out_file parameter from AFNICommandOutputSpec base class
601+
602+
in_file = File(desc='input file to 3dECM',
603+
argstr='%s',
604+
position=-1,
605+
mandatory=True,
606+
exists=True,
607+
copyfile=False)
608+
609+
sparsity = traits.Float(desc='only take the top percent of connections',
610+
argstr='-sparsity %f')
611+
612+
full = traits.Bool(desc='Full power method; enables thresholding; '\
613+
'automatically selected if -thresh or -sparsity '\
614+
'are set',
615+
argstr='-full')
616+
617+
fecm = traits.Bool(desc='Fast centrality method; substantial speed '\
618+
'increase but cannot accomodate thresholding; '\
619+
'automatically selected if -thresh or -sparsity '\
620+
'are not set',
621+
argstr='-fecm')
622+
623+
shift = traits.Float(desc='shift correlation coefficients in similarity '\
624+
'matrix to enforce non-negativity, s >= 0.0; '\
625+
'default = 0.0 for -full, 1.0 for -fecm',
626+
argstr='-shift %f')
627+
628+
scale = traits.Float(desc='scale correlation coefficients in similarity '\
629+
'matrix to after shifting, x >= 0.0; '\
630+
'default = 1.0 for -full, 0.5 for -fecm',
631+
argstr='-scale %f')
632+
633+
eps = traits.Float(desc='sets the stopping criterion for the power '\
634+
'iteration; l2|v_old - v_new| < eps*|v_old|; '\
635+
'default = 0.001',
636+
argstr='-eps %f')
637+
638+
max_iter = traits.Int(desc='sets the maximum number of iterations to use '\
639+
'in the power iteration; default = 1000',
640+
argstr='-max_iter %d')
641+
642+
memory = traits.Float(desc='Limit memory consumption on system by setting '\
643+
'the amount of GB to limit the algorithm to; '\
644+
'default = 2GB',
645+
argstr='-memory %f')
646+
647+
648+
class ECM(AFNICommand):
649+
"""Performs degree centrality on a dataset using a given maskfile
650+
via the 3dLFCD command
651+
652+
For complete details, see the `3dECM Documentation.
653+
<http://afni.nimh.nih.gov/pub/dist/doc/program_help/3dECM.html>
654+
655+
Examples
656+
========
657+
658+
>>> from nipype.interfaces import afni as afni
659+
>>> ecm = afni.ECM()
660+
>>> ecm.inputs.in_file = 'func_preproc.nii'
661+
>>> ecm.inputs.mask = 'mask.nii'
662+
>>> ecm.inputs.sparsity = 0.1 # keep top 0.1% of connections
663+
>>> ecm.inputs.out_file = 'out.nii'
664+
>>> ecm.cmdline
665+
'3dECM -sparsity 0.1 -mask mask.nii -prefix out.nii func_preproc.nii'
666+
>>> res = ecm.run() # doctest: +SKIP
667+
"""
668+
669+
_cmd = '3dECM'
670+
input_spec = ECMInputSpec
671+
output_spec = AFNICommandOutputSpec
672+
673+
674+
class LFCDInputSpec(CentralityInputSpec):
675+
"""LFCD inputspec
602676
"""
603677

604678
in_file = File(desc='input file to 3dLFCD',
@@ -623,9 +697,10 @@ class LFCD(AFNICommand):
623697
>>> lfcd = afni.LFCD()
624698
>>> lfcd.inputs.in_file = 'func_preproc.nii'
625699
>>> lfcd.inputs.mask = 'mask.nii'
626-
>>> lfcd.inputs.threshold = .8 # keep all connections with corr >= 0.8
700+
>>> lfcd.inputs.thresh = 0.8 # keep all connections with corr >= 0.8
701+
>>> lfcd.inputs.out_file = 'out.nii'
627702
>>> lfcd.cmdline
628-
'3dLFCD -threshold 0.8 -mask mask.nii func_preproc.nii'
703+
'3dLFCD -thresh 0.8 -mask mask.nii -prefix out.nii func_preproc.nii'
629704
>>> res = lfcd.run() # doctest: +SKIP
630705
"""
631706

0 commit comments

Comments
 (0)