Skip to content

Commit 889115d

Browse files
committed
Merge upstream/master [skip ci]
2 parents bd211d4 + 157d3bd commit 889115d

File tree

8 files changed

+127
-18
lines changed

8 files changed

+127
-18
lines changed

.zenodo.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,11 @@
568568
"affiliation": "University College London",
569569
"name": "Mancini, Matteo",
570570
"orcid": "0000-0001-7194-4568"
571+
},
572+
{
573+
"affiliation": "Donders Institute for Brain, Cognition and Behavior, Center for Cognitive Neuroimaging",
574+
"name": "Chetverikov, Andrey",
575+
"orcid": "0000-0003-2767-6310"
571576
}
572577
],
573578
"keywords": [

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Upcoming release (0.14.1)
22
=========================
33

44
* REF+FIX: Move BIDSDataGrabber to `interfaces.io` + fix correct default behavior (https://github.com/nipy/nipype/pull/2336)
5+
* ENH: Add AFNI interface for 3dConvertDset (https://github.com/nipy/nipype/pull/2337)
56
* MAINT: Cleanup EngineBase (https://github.com/nipy/nipype/pull/2376)
67
* FIX: Robustly handled outputs of 3dFWHMx across different versions of AFNI (https://github.com/nipy/nipype/pull/2373)
78
* FIX: Cluster threshold in randomise + change default prefix (https://github.com/nipy/nipype/pull/2369)

nipype/interfaces/afni/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
ROIStats, Retroicor, Seg, SkullStrip, TCorr1D, TCorrMap, TCorrelate, TNorm,
1616
TShift, Volreg, Warp, QwarpPlusMinus, Qwarp)
1717
from .svm import (SVMTest, SVMTrain)
18-
from .utils import (ABoverlap, AFNItoNIFTI, Autobox, Axialize, BrickStat,
19-
Bucket, Calc, Cat, CatMatvec, CenterMass, Copy, Dot, Edge3,
20-
Eval, FWHMx, MaskTool, Merge, Notes, NwarpApply, NwarpCat,
21-
OneDToolPy, Refit, Resample, TCat, TCatSubBrick, TStat,
22-
To3D, Unifize, Undump, ZCutUp, GCOR, Zcat, Zeropad)
18+
from .utils import (
19+
ABoverlap, AFNItoNIFTI, Autobox, Axialize, BrickStat, Bucket, Calc, Cat,
20+
CatMatvec, CenterMass, ConvertDset, Copy, Dot, Edge3, Eval, FWHMx,
21+
MaskTool, Merge, Notes, NwarpApply, NwarpCat, OneDToolPy, Refit, Resample,
22+
TCat, TCatSubBrick, TStat, To3D, Unifize, Undump, ZCutUp, GCOR, Zcat,
23+
Zeropad)
2324
from .model import (Deconvolve, Remlfit, Synthesize)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from __future__ import unicode_literals
3+
from ..utils import ConvertDset
4+
5+
6+
def test_ConvertDset_inputs():
7+
input_map = dict(args=dict(argstr='%s',
8+
),
9+
environ=dict(nohash=True,
10+
usedefault=True,
11+
),
12+
ignore_exception=dict(deprecated='1.0.0',
13+
nohash=True,
14+
usedefault=True,
15+
),
16+
in_file=dict(argstr='-input %s',
17+
mandatory=True,
18+
position=-2,
19+
),
20+
out_file=dict(argstr='-prefix %s',
21+
position=-1,
22+
),
23+
out_type=dict(argstr='-o_%s',
24+
mandatory=True,
25+
position=0,
26+
),
27+
terminal_output=dict(deprecated='1.0.0',
28+
nohash=True,
29+
),
30+
)
31+
inputs = ConvertDset.input_spec()
32+
33+
for key, metadata in list(input_map.items()):
34+
for metakey, value in list(metadata.items()):
35+
assert getattr(inputs.traits()[key], metakey) == value
36+
37+
38+
def test_ConvertDset_outputs():
39+
output_map = dict(out_file=dict(),
40+
)
41+
outputs = ConvertDset.output_spec()
42+
43+
for key, metadata in list(output_map.items()):
44+
for metakey, value in list(metadata.items()):
45+
assert getattr(outputs.traits()[key], metakey) == value

nipype/interfaces/afni/utils.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,59 @@ def _list_outputs(self):
712712
return outputs
713713

714714

715+
class ConvertDsetInputSpec(AFNICommandInputSpec):
716+
in_file = File(
717+
desc='input file to ConvertDset',
718+
argstr='-input %s',
719+
position=-2,
720+
mandatory=True,
721+
exists=True)
722+
723+
out_file = File(
724+
desc='output file for ConvertDset',
725+
argstr='-prefix %s',
726+
position=-1,
727+
mandatory=True)
728+
729+
out_type = traits.Enum(
730+
('niml', 'niml_asc', 'niml_bi',
731+
'1D', '1Dp', '1Dpt',
732+
'gii', 'gii_asc', 'gii_b64', 'gii_b64gz'),
733+
desc='output type',
734+
argstr='-o_%s',
735+
mandatory=True,
736+
position=0)
737+
738+
739+
class ConvertDset(AFNICommandBase):
740+
"""Converts a surface dataset from one format to another.
741+
742+
For complete details, see the `ConvertDset Documentation.
743+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/ConvertDset.html>`_
744+
745+
Examples
746+
========
747+
748+
>>> from nipype.interfaces import afni
749+
>>> convertdset = afni.ConvertDset()
750+
>>> convertdset.inputs.in_file = 'lh.pial_converted.gii'
751+
>>> convertdset.inputs.out_type = 'niml_asc'
752+
>>> convertdset.inputs.out_file = 'lh.pial_converted.niml.dset'
753+
>>> convertdset.cmdline
754+
'ConvertDset -o_niml_asc -input lh.pial_converted.gii -prefix lh.pial_converted.niml.dset'
755+
>>> res = convertdset.run() # doctest: +SKIP
756+
"""
757+
758+
_cmd = 'ConvertDset'
759+
input_spec = ConvertDsetInputSpec
760+
output_spec = AFNICommandOutputSpec
761+
762+
def _list_outputs(self):
763+
outputs = self.output_spec().get()
764+
outputs['out_file'] = op.abspath(self.inputs.out_file)
765+
return outputs
766+
767+
715768
class CopyInputSpec(AFNICommandInputSpec):
716769
in_file = File(
717770
desc='input file to 3dcopy',

nipype/pipeline/plugins/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,15 +528,15 @@ def run(self, graph, config, updatehash=False):
528528
pyfiles = []
529529
dependencies = {}
530530
self._config = config
531-
nodes = nx.topological_sort(graph)
531+
nodes = list(nx.topological_sort(graph))
532532
logger.debug('Creating executable python files for each node')
533533
for idx, node in enumerate(nodes):
534534
pyfiles.append(
535535
create_pyscript(
536536
node, updatehash=updatehash, store_exception=False))
537537
dependencies[idx] = [
538-
nodes.index(prevnode) for prevnode in graph.predecessors(node)
539-
]
538+
nodes.index(prevnode)
539+
for prevnode in list(graph.predecessors(node))]
540540
self._submit_graph(pyfiles, dependencies, nodes)
541541

542542
def _get_args(self, node, keywords):

nipype/pipeline/plugins/multiproc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
223223

224224
# Check to see if a job is available (jobs with all dependencies run)
225225
# See https://github.com/nipy/nipype/pull/2200#discussion_r141605722
226-
jobids = np.nonzero(~self.proc_done & (self.depidx.sum(0) == 0))[1]
226+
# See also https://github.com/nipy/nipype/issues/2372
227+
jobids = np.flatnonzero(~self.proc_done &
228+
(self.depidx.sum(axis=0) == 0).__array__())
227229

228230
# Check available resources by summing all threads and memory used
229231
free_memory_gb, free_processors = self._check_resources(

nipype/pipeline/plugins/pbs.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,20 @@ def __init__(self, **kwargs):
4949
super(PBSPlugin, self).__init__(template, **kwargs)
5050

5151
def _is_pending(self, taskid):
52-
result = CommandLine(
53-
'qstat {}'.format(taskid),
54-
environ=dict(os.environ),
55-
terminal_output='allatonce',
56-
resource_monitor=False,
57-
ignore_exception=True).run()
58-
errmsg = 'Unknown Job Id' # %s' % taskid
52+
result = CommandLine('qstat -f {}'.format(taskid),
53+
environ=dict(os.environ),
54+
terminal_output='file_split',
55+
resource_monitor=False,
56+
ignore_exception=True).run()
57+
58+
stdout = result.runtime.stdout
59+
stderr = result.runtime.stderr
60+
errmsg = 'Unknown Job Id'
5961
success = 'Job has finished'
60-
if success in e: # Fix for my PBS
62+
if (success in stderr) or ('job_state = C' in stdout):
6163
return False
6264
else:
63-
return errmsg not in e
65+
return errmsg not in stderr
6466

6567
def _submit_batchtask(self, scriptfile, node):
6668
cmd = CommandLine(

0 commit comments

Comments
 (0)