python - 来自 nipype.interfaces.ants 导入 N4BiasFieldCorrection 的 python 问题
问题描述
OSError:在主机 pc 上找不到命令“N4BiasFieldCorrection”。请检查是否安装了相应的软件包。
我在使用 nipype 时遇到问题。你能帮忙吗?
from nipype.interfaces.ants import N4BiasFieldCorrection
n4 = N4BiasFieldCorrection()
n4.inputs.dimension = 3
n4.inputs.input_image =('/home/abhayadev/Desktop/project/Dataset/BRATS2013_CHALLENGE/Challenge/HG/0301/VSD.Brain.XX.O.MR_Flair/VSD.Brain.XX.O.MR_Flair.17572.mha')
n4.inputs.n_iterations = [20, 20, 10, 5]
n4.run()
res=n4.run()
print(res)
输出 :
``OSError Traceback (most recent call last)
<ipython-input-10-49ae4ec58583> in <module>
5 n4.inputs.input_image =`enter code here`('/home/abhayadev/Desktop/project/Dataset/BRATS2013_CHALLENGE/Challenge/HG/0301/VSD.Brain.XX.O.MR_Flair/VSD.Brain.XX.O.MR_Flair.17572.mha')
6 n4.inputs.n_iterations = [20, 20, 10, 5]
----> 7 n4.run()
8 res=n4.run()
9 print(res)
~/anaconda3/lib/python3.7/site-packages/nipype/interfaces/base/core.py in run(self, cwd, ignore_exception, **inputs)
374 try:
375 runtime = self._pre_run_hook(runtime)
--> 376 runtime = self._run_interface(runtime)
377 runtime = self._post_run_hook(runtime)
378 outputs = self.aggregate_outputs(runtime)
~/anaconda3/lib/python3.7/site-packages/nipype/interfaces/base/core.py in _run_interface(self, runtime, correct_return_codes)
750 'No command "%s" found on host %s. Please check that the '
751 'corresponding package is installed.' % (executable_name,
--> 752 runtime.hostname))
753
754 runtime.command_path = cmd_path
OSError: No command "N4BiasFieldCorrection" found on host abhayadev. Please check that the corresponding package is installed.
解决方案
您需要在 PATH 变量中包含 ANTS 的安装目录。从安装指南:
假设您的安装前缀是 /opt/ANTs,现在将有一个二进制目录 /opt/ANTs/bin,其中包含 ANTs 可执行文件和脚本。这些脚本还需要 ANTSPATH 指向包含尾部斜杠的 bin 目录。
对于 bash shell(Mac 和某些 Linux 上的默认设置),您需要设置
export ANTSPATH=/opt/ANTs/bin/ export PATH=${ANTSPATH}:$PATH
如果您在 neurodocker 中使用 nipype(推荐),您必须:
source activate neuro
让 ANTS 命令可用。
推荐阅读
- ssl - 如何连接到安全网站 (https:)?
- javascript - 在 Quasar 中使用 Dexie 导出 IndexedDB 数据库
- gzip - 解压 tar.gz 文件会导致错误:错误不可恢复
- java - 春季启动自动接线服务为空
- git - git diff changes with name only 正确显示更改,但不包括从开始的提交中更改的文件
- docker - 为什么我不能从我的 docker 容器 curl 到远程服务
- php - 如何在 Yii2 中使用表关系获取记录的更多详细信息
- r - 将字符串转换为时间格式,以便计算差异
- amazon-web-services - 如何将密钥从我的桌面导入到 cloudformation 模板?
- javascript - 发送推文失败。错误为:{"name":"Exception"} - Google 应用脚本