Skip to content

Commit 43bd933

Browse files
committed
[ENH] Convenient load/save of interface inputs
Implements #1578
1 parent 399f38b commit 43bd933

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

nipype/interfaces/base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from datetime import datetime as dt
3636
from dateutil.parser import parse as parseutc
3737
from warnings import warn
38-
38+
import simplejson as json
3939

4040
from .traits_extension import (traits, Undefined, TraitDictObject,
4141
TraitListObject, TraitError,
@@ -1148,6 +1148,15 @@ def version(self):
11481148
self.__class__.__name__)
11491149
return self._version
11501150

1151+
def load_inputs_from_json(self, json_file):
1152+
with open(json_file) as fhandle:
1153+
inputs_dict = json.load(fhandle)
1154+
1155+
for key, val in list(inputs_dict.items()):
1156+
if not isdefined(getattr(self.inputs, key, Undefined)):
1157+
setattr(self.inputs, key, val)
1158+
1159+
11511160

11521161
class Stream(object):
11531162
"""Function to capture stdout and stderr streams with timestamps

0 commit comments

Comments
 (0)