本文整理汇总了Python中nipype.pipeline.engine.Node.base_dir方法的典型用法代码示例。如果您正苦于以下问题:Python Node.base_dir方法的具体用法?Python Node.base_dir怎么用?Python Node.base_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nipype.pipeline.engine.Node
的用法示例。
在下文中一共展示了Node.base_dir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from nipype.pipeline.engine import Node [as 别名]
# 或者: from nipype.pipeline.engine.Node import base_dir [as 别名]
def __call__(self, **kwargs):
kwargs = modify_paths(kwargs, relative=False)
interface = self.interface()
# Set the inputs early to get some argument checking
interface.inputs.set(**kwargs)
# Make a name for our node
inputs = interface.inputs.get_hashval()
hasher = hashlib.new('md5')
hasher.update(pickle.dumps(inputs))
dir_name = '%s-%s' % (interface.__class__.__module__.replace('.', '-'),
interface.__class__.__name__)
job_name = hasher.hexdigest()
node = Node(interface, name=job_name)
node.base_dir = os.path.join(self.base_dir, dir_name)
cwd = os.getcwd()
try:
out = node.run()
finally:
# node.run() changes to the node directory - if something goes wrong
# before it cds back you would end up in strange places
os.chdir(cwd)
if self.callback is not None:
self.callback(dir_name, job_name)
return out
示例2: _merge_nii
# 需要导入模块: from nipype.pipeline.engine import Node [as 别名]
# 或者: from nipype.pipeline.engine.Node import base_dir [as 别名]
def _merge_nii(file_list, out_filename):
from nipype.pipeline.engine import Node, Workflow
import nipype.interfaces.fsl as fsl
merge = Node(fsl.Merge(dimension='t'), name='merge')
merge.base_dir = os.getcwd()
merge.inputs.in_files = file_list
merge.inputs.merged_file = out_filename
result = merge.run()
return result.outputs.merged_file
示例3: __call__
# 需要导入模块: from nipype.pipeline.engine import Node [as 别名]
# 或者: from nipype.pipeline.engine.Node import base_dir [as 别名]
def __call__(self, **kwargs):
kwargs = modify_paths(kwargs, relative=False)
interface = self.interface()
# Set the inputs early to get some argument checking
interface.inputs.set(**kwargs)
# Make a name for our node
inputs = interface.inputs.get_hashval()
hasher = hashlib.new('md5')
hasher.update(pickle.dumps(inputs))
dir_name = '%s-%s' % (interface.__class__.__module__.replace('.', '-'),
interface.__class__.__name__)
job_name = hasher.hexdigest()
node = Node(interface, name=job_name)
node.base_dir = os.path.join(self.base_dir, dir_name)
out = node.run()
if self.callback is not None:
self.callback(dir_name, job_name)
return out
示例4: Workflow
# 需要导入模块: from nipype.pipeline.engine import Node [as 别名]
# 或者: from nipype.pipeline.engine.Node import base_dir [as 别名]
####
from nipype.pipeline.engine import Node, Workflow
import nipype.interfaces.io as nio
#from nipype.interfaces.ants.registration import RegistrationSynQuick
import os
os.chdir('/Users/franzliem/Desktop/antstest')
wf = Workflow(name='normalize')
wf.base_dir = os.path.join('/Users/franzliem/Desktop/antstest/wf')
ds = Node(nio.DataSink(), name='ds')
ds.inputs.base_directory = '/Users/franzliem/Desktop/antstest/ds'
s = Node(RegistrationSynQuick(), name='s_rigid')
s.base_dir = '/Users/franzliem/Desktop/antstest/node_test'
s.inputs.fixed_image = '/Applications/FSL/data/standard/FMRIB58_FA_1mm.nii.gz'
s.inputs.moving_image = '/Users/franzliem/Desktop/antstest/dtifit__FA_ero.nii.gz'
s.inputs.output_prefix = 'ants_mni'
s.inputs.num_threads=4
# s.inputs.use_histogram_matching = True
# s.inputs.transform_type = 'r'
# s.inputs.histogram_bins = 44
# s.inputs.spline_distance = 15
# s.inputs.precision_type = 'double'
for f in ['warped_image', 'out_matrix', 'forward_warp_field', 'inverse_warp_field']:
wf.connect(s, f, ds, f)
wf.run()