本文整理汇总了Python中nipype.MapNode.run方法的典型用法代码示例。如果您正苦于以下问题:Python MapNode.run方法的具体用法?Python MapNode.run怎么用?Python MapNode.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nipype.MapNode
的用法示例。
在下文中一共展示了MapNode.run方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mapnode_nested
# 需要导入模块: from nipype import MapNode [as 别名]
# 或者: from nipype.MapNode import run [as 别名]
def test_mapnode_nested():
cwd = os.getcwd()
wd = mkdtemp()
os.chdir(wd)
from nipype import MapNode, Function
def func1(in1):
return in1 + 1
n1 = MapNode(Function(input_names=['in1'],
output_names=['out'],
function=func1),
iterfield=['in1'],
nested=True,
name='n1')
n1.inputs.in1 = [[1, [2]], 3, [4, 5]]
n1.run()
print(n1.get_output('out'))
yield assert_equal, n1.get_output('out'), [[2, [3]], 4, [5, 6]]
n2 = MapNode(Function(input_names=['in1'],
output_names=['out'],
function=func1),
iterfield=['in1'],
nested=False,
name='n1')
n2.inputs.in1 = [[1, [2]], 3, [4, 5]]
error_raised = False
try:
n2.run()
except Exception as e:
from nipype.pipeline.engine.base import logger
logger.info('Exception: %s' % str(e))
error_raised = True
yield assert_true, error_raised
示例2: test_mapnode_nested
# 需要导入模块: from nipype import MapNode [as 别名]
# 或者: from nipype.MapNode import run [as 别名]
def test_mapnode_nested(tmpdir):
tmpdir.chdir()
from nipype import MapNode, Function
def func1(in1):
return in1 + 1
n1 = MapNode(Function(input_names=['in1'],
output_names=['out'],
function=func1),
iterfield=['in1'],
nested=True,
name='n1')
n1.inputs.in1 = [[1, [2]], 3, [4, 5]]
n1.run()
print(n1.get_output('out'))
assert n1.get_output('out') == [[2, [3]], 4, [5, 6]]
n2 = MapNode(Function(input_names=['in1'],
output_names=['out'],
function=func1),
iterfield=['in1'],
nested=False,
name='n1')
n2.inputs.in1 = [[1, [2]], 3, [4, 5]]
with pytest.raises(Exception) as excinfo:
n2.run()
assert "can only concatenate list" in str(excinfo.value)
示例3: run_bet
# 需要导入模块: from nipype import MapNode [as 别名]
# 或者: from nipype.MapNode import run [as 别名]
def run_bet(T1_image, workdir):
"""Run freesurfer, convert to nidm and extract stats
"""
from nipype import fsl
from nipype import MapNode
strip = MapNode(fsl.BET(), iterfield=['in_file'], name='skullstripper')
strip.inputs.in_file = T1_image
strip.inputs.mesh = True
strip.inputs.mask = True
strip.base_dir = workdir
bet_results = strip.run()
provgraph = bet_results.provenance[0]
for bundle in bet_results.provenance[1:]:
provgraph.add_bundle(bundle)
vol = MapNode(fsl.ImageStats(op_string='-V'), iterfield=['in_file'],
name='volumeextractor')
vol.inputs.in_file = bet_results.outputs.out_file
vol.base_dir = workdir
vol_results = vol.run()
for bundle in vol_results.provenance:
provgraph.add_bundle(bundle)
return provgraph, provgraph.rdf()
示例4: test_mapnode_iterfield_type
# 需要导入模块: from nipype import MapNode [as 别名]
# 或者: from nipype.MapNode import run [as 别名]
def test_mapnode_iterfield_type(x_inp, f_exp):
from nipype import MapNode, Function
def double_func(x):
return 2 * x
double = Function(["x"], ["f_x"], double_func)
double_node = MapNode(double, name="double", iterfield=["x"])
double_node.inputs.x = x_inp
res = double_node.run()
assert res.outputs.f_x == f_exp