Skip to content

Commit 69150f1

Browse files
committed
Merge pull request #557 from satra/enh/nodeconfig
Enh/nodeconfig
2 parents 85afb98 + 5bdc051 commit 69150f1

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

CHANGES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ Next release
99
with rotation of the B-matrix, and susceptibility correction for EPI imaging using
1010
fieldmaps. Updated eddy_correct pipeline to support both dMRI and fMRI, and new parameters.
1111
* ENH: Minor improvements to FSL's FUGUE and FLIRT interfaces
12-
* ENH: Added optional dilation of parcels in cmtk.Parcellate
12+
* ENH: Added optional dilation of parcels in cmtk.Parcellate
1313
* ENH: Interpolation mode added to afni.Resample
1414
* ENH: Function interface can accept a list of strings containing import statements
1515
that allow external functions to run without their imports defined in the
1616
function body
17+
* ENH: Allow node configurations to override master configuration
1718

1819
* FIX: SpecifyModel works with 3D files correctly now.
1920

examples/fmri_spm.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
datasource.inputs.base_directory = data_dir
9999
datasource.inputs.template = '%s/%s.nii'
100100
datasource.inputs.template_args = info
101-
101+
datasource.inputs.sort_filelist = True
102102

103103
"""Use :class:`nipype.interfaces.spm.Realign` for motion correction
104104
and register all images to the mean image.
@@ -194,7 +194,7 @@ def subjectinfo(subject_id):
194194
"""
195195

196196
modelspec = pe.Node(interface=model.SpecifySPMModel(), name= "modelspec")
197-
modelspec.inputs.concatenate_runs = True
197+
modelspec.inputs.concatenate_runs = False
198198
modelspec.inputs.input_units = 'secs'
199199
modelspec.inputs.output_units = 'secs'
200200
modelspec.inputs.time_repetition = 3.
@@ -223,6 +223,8 @@ def subjectinfo(subject_id):
223223

224224
contrastestimate = pe.Node(interface = spm.EstimateContrast(), name="contrastestimate")
225225
contrastestimate.inputs.contrasts = contrasts
226+
contrastestimate.overwrite = True
227+
contrastestimate.config = {'execution': {'remove_unnecessary_outputs': False}}
226228

227229
"""
228230
Setup the pipeline

nipype/pipeline/engine.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def __init__(self, name=None, base_dir=None, **kwargs):
143143
special characters (e.g., '.', '@').
144144
"""
145145
self.base_dir = base_dir
146-
self.config = deepcopy(config._sections)
146+
self.config = None #deepcopy(config._sections)
147147
if name is None:
148148
raise Exception("init requires a name for this %s" %
149149
self.__class__.__name__)
@@ -215,6 +215,7 @@ class Workflow(WorkflowBase):
215215
def __init__(self, *args, **kwargs):
216216
super(Workflow, self).__init__(* args, **kwargs)
217217
self._graph = nx.DiGraph()
218+
self.config = deepcopy(config._sections)
218219

219220
# PUBLIC API
220221
def clone(self, name):
@@ -657,7 +658,7 @@ def run(self, plugin=None, plugin_args=None, updatehash=False):
657658
self._set_needed_outputs(flatgraph)
658659
execgraph = generate_expanded_graph(deepcopy(flatgraph))
659660
for index, node in enumerate(execgraph.nodes()):
660-
node.config = self.config
661+
node.config = merge_dict(deepcopy(self.config), node.config)
661662
node.base_dir = self.base_dir
662663
node.index = index
663664
if isinstance(node, MapNode):
@@ -1205,7 +1206,10 @@ def run(self, updatehash=False):
12051206
Update the hash stored in the output directory
12061207
"""
12071208
# check to see if output directory and hash exist
1208-
self.config = merge_dict(deepcopy(config._sections), self.config)
1209+
if self.config is None:
1210+
self.config = deepcopy(config._sections)
1211+
else:
1212+
self.config = merge_dict(deepcopy(config._sections), self.config)
12091213
if not self._got_inputs:
12101214
self._get_inputs()
12111215
self._got_inputs = True

nipype/pipeline/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ def merge_dict(d1, d2, merge=lambda x, y: y):
729729
if not isinstance(d1, dict):
730730
return merge(d1, d2)
731731
result = dict(d1)
732+
if d2 is None:
733+
return result
732734
for k, v in d2.iteritems():
733735
if k in result:
734736
result[k] = merge_dict(result[k], v, merge=merge)

0 commit comments

Comments
 (0)