python sitk.show()与imageJ结合使用常见的问题


Posted in Python onApril 20, 2020

在python中配置simpleITK时,遇到了以下这个问题。

simpleITK已经通过pip install安装,但是sitk.show()功能无法正常使用,类似如下

实例代码

import SimpleITK as sitk
import sys
import os
example = sitk.ReadImage("filename")
sitk.show(example)

在sitk.show()这一步会出现以下错误

“Traceback (most recent call last):
File "", line 1, in 
sitk.Show(image)
File "C:\Python27\lib\site-packages\SimpleITK.py", line 4158, in Show
return _SimpleITK.Show(*args, **kwargs)
RuntimeError: Exception thrown in SimpleITK Show: ............\Build\ITK\SimpleITK-0.7.1\Code\IO\src\sitkShow.cxx:463:
 
sitk::ERROR: Error in administrating child process: [参数错误。]”

原因是SimpleITK的图像显示功能是通过类似ITK-snap,ImageJ进行实现的,所以在进行sitk.show()之前,需要对此进行设置才能正常实现。

这里参考stack overflow别人给的意见https://stackoverflow.com/questions/43215774/can-not-linksimpleitkshow-with-fiji

ImageJ Installation

Go to https://imagej.nih.gov/ij/download.html

Make sure to download the bundled with 64-bit Java 1.8.0_112 version

ImageJ Setup

Go to https://imagej.nih.gov/ij/plugins/nifti.html

Download nifti_io.jar

Go to C:\blah\blah\ImageJ\plugins\Input-Output

Delete the existing nifti_io.jar file from the folder

Copy the downloaded nifti_io.jar file into the folder

Restart ImageJ and check if File -> Import -> NIfTI-Analyze is there

If it is there, the plugin was successfully installed

SimpleITK Setup

Find the path where your ImageJ.exe file exists

Open cmd

Type in setx SITK_SHOW_COMMAND "C:\blah\blah\ImageJ\ImageJ.exe"

You should get the message SUCCESS: Specified value was saved

Check if everything works

Restart your text editor or IDE (if it was already open)

Run your code

​​​​​​除了下载ImageJ操作,另外的很简单。

  • 在环境变量里面添加SITK_SHOW_COMMAND ,以imageJ为例,路径指向ImageJ-win64.exe
  • 在环境变量中的path中添加%SITK_SHOW_COMMAND%

到此这篇关于python sitk.show()与imageJ结合使用常见的问题的文章就介绍到这了,更多相关sitk.show()结合imageJ内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!

Python 相关文章推荐
python 将字符串转换成字典dict
Mar 24 Python
Python的Django框架中使用SQLAlchemy操作数据库的教程
Jun 02 Python
python将回车作为输入内容的实例
Jun 23 Python
解决python os.mkdir创建目录失败的问题
Oct 16 Python
python 快速把超大txt文件转存为csv的实例
Oct 26 Python
代码实例讲解python3的编码问题
Jul 08 Python
在Python中通过threshold创建mask方式
Feb 19 Python
使用Matplotlib绘制不同颜色的带箭头的线实例
Apr 17 Python
numpy的Fancy Indexing和array比较详解
Jun 11 Python
Django crontab定时任务模块操作方法解析
Sep 10 Python
python-地图可视化组件folium的操作
Dec 14 Python
利用python做表格数据处理
Apr 13 Python
使用Python对Dicom文件进行读取与写入的实现
Apr 20 #Python
python 错误处理 assert详解
Apr 20 #Python
解决Jupyter Notebook使用parser.parse_args出现错误问题
Apr 20 #Python
在ipython notebook中使用argparse方式
Apr 20 #Python
Python绘制全球疫情变化地图的实例代码
Apr 20 #Python
spyder 在控制台(console)执行python文件,debug python程序方式
Apr 20 #Python
python实现小程序推送页面收录脚本
Apr 20 #Python
You might like
配置php网页显示各种语法错误
2013/09/23 PHP
浅谈Laravel队列实现原理解决问题记录
2017/08/19 PHP
JavaScript 脚本将当地时间转换成其它时区
2009/03/19 Javascript
jquery isEmptyObject判断是否为空对象的函数
2011/02/14 Javascript
JavaScript中数组的排序、乱序和搜索实现代码
2011/11/30 Javascript
xml转json的js代码
2012/08/28 Javascript
js精度溢出解决方案
2012/12/02 Javascript
JS随机生成不重复数据的实例方法
2013/07/17 Javascript
JS检测图片大小的实例
2013/08/21 Javascript
Jquery判断$("#id")获取的对象是否存在的方法
2013/09/25 Javascript
JS+CSS实现实用的单击输入框弹出选择框的方法
2015/02/28 Javascript
JS+CSS实现自适应选项卡宽度的圆角滑动门效果
2015/09/15 Javascript
JavaScript学习笔记--常用的互动方法
2016/12/07 Javascript
jQuery中的100个技巧汇总
2016/12/15 Javascript
canvas实现刮刮卡效果
2017/03/14 Javascript
vue.js中指令Directives详解
2017/03/20 Javascript
js实现抽奖效果
2017/03/27 Javascript
详解React中的组件通信问题
2017/07/31 Javascript
详解Vue CLI3 多页应用实践和源码设计
2018/08/30 Javascript
Python 深入理解yield
2008/09/06 Python
Python判断直线和矩形是否相交的方法
2015/07/14 Python
python使用socket创建tcp服务器和客户端
2018/04/12 Python
解决Python requests库编码 socks5代理的问题
2018/05/07 Python
Python猴子补丁Monkey Patch用法实例解析
2020/03/23 Python
详解Python爬虫爬取博客园问题列表所有的问题
2021/01/18 Python
Python页面加载的等待方式总结
2021/02/28 Python
发现世界上最好的珠宝设计师:JewelStreet
2017/12/17 全球购物
Nike德国官网:Nike.com (DE)
2018/11/13 全球购物
高中毕业生自我鉴定
2013/11/03 职场文书
校园达人秀策划书
2014/01/12 职场文书
信息技术专业大学生职业生涯规划书
2014/01/24 职场文书
项目经理任命书范本
2014/06/05 职场文书
2014年扶贫帮困工作总结
2014/12/09 职场文书
《乘法分配律》教学反思
2016/02/24 职场文书
Python3 多线程(连接池)操作MySQL插入数据
2021/06/09 Python
vue实现在data里引入相对路径
2022/06/05 Vue.js