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删除文件示例分享
Jan 28 Python
python实现的登录和操作开心网脚本分享
Jul 09 Python
Python爬虫_城市公交、地铁站点和线路数据采集实例
Jan 10 Python
python读取csv文件并把文件放入一个list中的实例讲解
Apr 27 Python
python中利用numpy.array()实现俩个数值列表的对应相加方法
Aug 26 Python
python图的深度优先和广度优先算法实例分析
Oct 26 Python
利用Python代码实现一键抠背景功能
Dec 29 Python
Python hashlib常见摘要算法详解
Jan 13 Python
python实点云分割k-means(sklearn)详解
May 28 Python
python利用蒙版抠图(使用PIL.Image和cv2)输出透明背景图
Aug 04 Python
Python制作简单的剪刀石头布游戏
Dec 10 Python
刚学完怎么用Python实现定时任务,转头就跑去撩妹!
Jun 05 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 多继承的几种常见实现方法示例
2019/11/18 PHP
理解Javascript_05_原型继承原理
2010/10/13 Javascript
JQuery 常用方法和事件详细介绍
2013/04/18 Javascript
浅析JavaScript中两种类型的全局对象/函数
2013/12/05 Javascript
使用Jquery获取带特殊符号的ID 标签的方法
2014/04/30 Javascript
javascript操纵OGNL标签示例代码
2014/06/16 Javascript
JavaScript中使用Math.PI圆周率属性的方法
2015/06/14 Javascript
jQuery简单实现仿京东商城的左侧菜单效果代码
2015/09/09 Javascript
JavaScript实现清空(重置)文件类型INPUT元素值的方法
2016/11/17 Javascript
如何解决hover在ie6中的兼容性问题
2016/12/15 Javascript
vue.js单页面应用实例的简单实现
2017/04/10 Javascript
jQuery实现节点的追加、替换、删除、复制功能示例
2017/07/11 jQuery
关于Vue背景图打包之后访问路径错误问题的解决
2017/11/03 Javascript
浅谈vue方法内的方法使用this的问题
2018/09/15 Javascript
vue 移动端适配方案详解
2018/11/15 Javascript
JavaScript中的 new 命令
2019/05/22 Javascript
jQuery cookie的公共方法封装和使用示例
2020/06/01 jQuery
Python随机生成一个6位的验证码代码分享
2015/03/24 Python
深入解析Python设计模式编程中建造者模式的使用
2016/03/02 Python
Python绘制七段数码管实例代码
2017/12/20 Python
Python星号*与**用法分析
2018/02/02 Python
详解Python requests 超时和重试的方法
2018/12/18 Python
OpenCV模板匹配matchTemplate的实现
2019/10/18 Python
python 输出列表元素实例(以空格/逗号为分隔符)
2019/12/25 Python
Python while循环使用else语句代码实例
2020/02/07 Python
如何向scrapy中的spider传递参数的几种方法
2020/11/18 Python
详解pandas apply 并行处理的几种方法
2021/02/24 Python
支持IE8的纯css3开发的响应式设计动画菜单教程
2014/11/05 HTML / CSS
CSS3中的content属性使用示例
2015/07/20 HTML / CSS
HTML5 贪吃蛇游戏实现思路及源代码
2013/09/03 HTML / CSS
尼克松手表官网:Nixon手表
2019/03/17 全球购物
升职自荐信范文
2013/10/05 职场文书
企业军训感想
2014/02/07 职场文书
教师专业自荐书范文
2014/02/10 职场文书
先进工作者申报材料
2014/12/23 职场文书
Python万能模板案例之matplotlib绘制甘特图
2022/04/13 Python