Skip to content

Commit c1376c4

Browse files
committed
Updated keyword in result dictionary to runtime instead of cmd-level
1 parent 116a6a1 commit c1376c4

File tree

5 files changed

+116
-22
lines changed

5 files changed

+116
-22
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
from .base import Info
1010
from .preprocess import (To3D, Refit, Resample, TStat, Automask, Volreg, Merge,
11-
ZCutUp, Calc, TShift, Warp, Detrend, Despike, Copy,
12-
Fourier, Allineate, Maskave, SkullStrip, TCat, Fim,
11+
ZCutUp, Calc, TShift, Warp, Detrend, Despike, DegreeCentrality,
12+
Copy, Fourier, Allineate, Maskave, SkullStrip, TCat, Fim,
1313
BlurInMask, Autobox, TCorrMap, Bandpass, Retroicor,
1414
TCorrelate, TCorr1D, BrickStat, ROIStats, AutoTcorrelate,
1515
AFNItoNIFTI, Eval, Means)

nipype/interfaces/afni/preprocess.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class RefitInputSpec(CommandLineInputSpec):
180180
' template type, e.g. TLRC, MNI, ORIG')
181181

182182

183+
183184
class Refit(CommandLine):
184185
"""Changes some of the information inside a 3D dataset's header
185186
@@ -506,6 +507,104 @@ class Despike(AFNICommand):
506507
output_spec = AFNICommandOutputSpec
507508

508509

510+
class CentralityInputSpec(AFNICommandInputSpec):
511+
"""
512+
inherits the out_file parameter from AFNICommandOutputSpec base class
513+
"""
514+
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+
522+
mask = File(desc='mask file to mask input data',
523+
argstr="-mask %s",
524+
exists=True)
525+
526+
thresh = traits.Float(desc='threshold to exclude connections where corr <= thresh',
527+
argstr='-thresh %f')
528+
529+
polort = traits.Int(desc='', argstr='-polort %d')
530+
531+
autoclip = traits.Bool(desc='Clip off low-intensity regions in the dataset',
532+
argstr='-autoclip')
533+
534+
automask = traits.Bool(desc='Mask the dataset to target brain-only voxels',
535+
argstr='-automask')
536+
537+
538+
class DegreeCentralityInputSpec(CentralityInputSpec):
539+
"""
540+
inherits the out_file parameter from AFNICommandOutputSpec base class
541+
"""
542+
543+
in_file = File(desc='input file to 3dDegreeCentrality',
544+
argstr='%s',
545+
position=-1,
546+
mandatory=True,
547+
exists=True,
548+
copyfile=False)
549+
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+
557+
sparsity = traits.Float(desc='only take the top percent of connections',
558+
argstr='-sparsity %f')
559+
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')
570+
571+
572+
class DegreeCentralityOutputSpec(AFNICommandOutputSpec):
573+
"""
574+
inherits the out_file parameter from AFNICommandOutputSpec base class
575+
"""
576+
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')
581+
582+
583+
class DegreeCentrality(AFNICommand):
584+
"""Performs degree centrality on a dataset using a given maskfile
585+
via 3dDegreeCentrality
586+
587+
For complete details, see the `3dDegreeCentrality Documentation.
588+
<http://afni.nimh.nih.gov/pub/dist/doc/program_help/3dDegreeCentrality.html>
589+
590+
Examples
591+
========
592+
593+
>>> from nipype.interfaces import afni as afni
594+
>>> degree = afni.DegreeCentrality()
595+
>>> degree.inputs.in_file = 'func_preproc.nii'
596+
>>> degree.inputs.mask = 'mask.nii'
597+
>>> degree.inputs.sparsity = 1 # keep the top one percent of connections
598+
>>> degree.cmdline
599+
'3dDegreeCentrality -sparsity 1 -mask mask.nii func_preproc.nii'
600+
>>> res = degree.run() # doctest: +SKIP
601+
"""
602+
603+
_cmd = '3dDegreeCentrality'
604+
input_spec = DegreeCentralityInputSpec
605+
output_spec = DegreeCentralityOutputSpec
606+
607+
509608
class AutomaskInputSpec(AFNICommandInputSpec):
510609
in_file = File(desc='input file to 3dAutomask',
511610
argstr='%s',

nipype/interfaces/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,8 +1375,8 @@ def _process(drain=0):
13751375
result['stderr'] = []
13761376
result['merged'] = ''
13771377

1378-
setattr(runtime, 'cmd_memory', mem_mb/1024.0)
1379-
setattr(runtime, 'cmd_threads', num_threads)
1378+
setattr(runtime, 'runtime_memory', mem_mb/1024.0)
1379+
setattr(runtime, 'runtime_threads', num_threads)
13801380
runtime.stderr = '\n'.join(result['stderr'])
13811381
runtime.stdout = '\n'.join(result['stdout'])
13821382
runtime.merged = result['merged']

nipype/pipeline/plugins/callback_log.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,20 @@ def log_nodes_cb(node, status, result=None):
1010

1111
# Check runtime profile stats
1212
if result is None:
13-
node_mem = cmd_mem = run_seconds = cmd_threads = 'N/A'
13+
runtime_memory = runtime_seconds = runtime_threads = 'N/A'
1414
else:
1515
try:
16-
node_mem = result['node_memory']
16+
runtime_memory = result['runtime_memory']
1717
except KeyError:
18-
node_mem = 'Unknown'
18+
runtime_memory = 'Unknown'
1919
try:
20-
cmd_mem = result['cmd_memory']
20+
runtime_seconds = result['runtime_seconds']
2121
except KeyError:
22-
cmd_mem = 'Unknown'
22+
runtime_seconds = 'Unknown'
2323
try:
24-
run_seconds = result['run_seconds']
25-
except KeyError:
26-
run_seconds = 'Unknown'
27-
try:
28-
cmd_threads = result['cmd_threads']
24+
runtime_threads = result['runtime_threads']
2925
except:
30-
cmd_threads = 'Unknown'
26+
runtime_threads = 'Unknown'
3127

3228
# Check status and write to log
3329
# Start
@@ -44,10 +40,9 @@ def log_nodes_cb(node, status, result=None):
4440
node._id + '"' + ',"finish":' + '"' + str(datetime.datetime.now()) + \
4541
'"' + ',"estimated_memory":' + '"'+ str(node._interface.estimated_memory) + '"'+ \
4642
',"num_threads":' + '"'+ str(node._interface.num_threads) + '"'+ \
47-
',"cmd-level_threads":' + '"'+ str(cmd_threads) + '"'+ \
48-
',"node-level_memory":' + '"'+ str(node_mem) + '"'+ \
49-
',"cmd-level_memory":' + '"'+ str(cmd_mem) + '"' + \
50-
',"run_seconds":' + '"'+ str(run_seconds) + '"'+ '}'
43+
',"runtime_threads":' + '"'+ str(runtime_threads) + '"'+ \
44+
',"runtime_memory":' + '"'+ str(runtime_memory) + '"' + \
45+
',"runtime_seconds":' + '"'+ str(runtime_seconds) + '"'+ '}'
5146

5247
logger.debug(message)
5348
# Other

nipype/pipeline/plugins/multiproc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ def run_node(node, updatehash, runtime_profile=False):
4040
retval = node.run(updatehash=updatehash)
4141
run_secs = (datetime.datetime.now() - start).total_seconds()
4242
result['result'] = retval
43-
result['run_seconds'] = run_secs
43+
result['runtime_seconds'] = run_secs
4444
if hasattr(retval.runtime, 'get'):
45-
result['cmd_memory'] = retval.runtime.get('cmd_memory')
46-
result['cmd_threads'] = retval.runtime.get('cmd_threads')
45+
result['runtime_memory'] = retval.runtime.get('runtime_memory')
46+
result['runtime_threads'] = retval.runtime.get('runtime_threads')
4747
except:
4848
etype, eval, etr = sys.exc_info()
4949
result['traceback'] = format_exception(etype,eval,etr)

0 commit comments

Comments
 (0)