本文整理汇总了Python中dcmstack.dcmmeta.NiftiWrapper.to_filename方法的典型用法代码示例。如果您正苦于以下问题:Python NiftiWrapper.to_filename方法的具体用法?Python NiftiWrapper.to_filename怎么用?Python NiftiWrapper.to_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dcmstack.dcmmeta.NiftiWrapper
的用法示例。
在下文中一共展示了NiftiWrapper.to_filename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run_interface
# 需要导入模块: from dcmstack.dcmmeta import NiftiWrapper [as 别名]
# 或者: from dcmstack.dcmmeta.NiftiWrapper import to_filename [as 别名]
def _run_interface(self, runtime):
src_nii = nb.load(self.inputs.src_file)
src = NiftiWrapper(src_nii, make_empty=True)
dest_nii = nb.load(self.inputs.dest_file)
dest = NiftiWrapper(dest_nii, make_empty=True)
classes = src.meta_ext.get_valid_classes()
if self.inputs.include_classes:
classes = [cls
for cls in classes
if cls in self.inputs.include_classes
]
if self.inputs.exclude_classes:
classes = [cls
for cls in classes
if not cls in self.inputs.exclude_classes
]
for cls in classes:
src_dict = src.meta_ext.get_class_dict(cls)
dest_dict = dest.meta_ext.get_class_dict(cls)
dest_dict.update(src_dict)
# Update the shape and slice dimension to reflect the meta extension update.
dest.meta_ext.slice_dim = src.meta_ext.slice_dim
dest.meta_ext.shape = src.meta_ext.shape
self.out_path = path.join(os.getcwd(),
path.basename(self.inputs.dest_file))
dest.to_filename(self.out_path)
return runtime
示例2: _run_interface
# 需要导入模块: from dcmstack.dcmmeta import NiftiWrapper [as 别名]
# 或者: from dcmstack.dcmmeta.NiftiWrapper import to_filename [as 别名]
def _run_interface(self, runtime):
src = NiftiWrapper.from_filename(self.inputs.src_file)
dest_nii = nb.load(self.inputs.dest_file)
dest = NiftiWrapper(dest_nii, make_empty=True)
classes = src.meta_ext.get_valid_classes()
if self.inputs.include_classes:
classes = [cls
for cls in classes
if cls in self.inputs.include_classes
]
if self.inputs.exclude_classes:
classes = [cls
for cls in classes
if not cls in self.inputs.exclude_classes
]
for cls in classes:
src_dict = src.meta_ext.get_class_dict(cls)
dest_dict = dest.meta_ext.get_class_dict(cls)
dest_dict.update(src_dict)
self.out_path = path.join(os.getcwd(),
path.basename(self.inputs.dest_file))
dest.to_filename(self.out_path)
return runtime