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测试驱动开发实例
Oct 08 Python
总结Python编程中函数的使用要点
Mar 20 Python
Python如何通过subprocess调用adb命令详解
Aug 27 Python
Python读写docx文件的方法
May 08 Python
python实现决策树分类(2)
Aug 30 Python
对python opencv 添加文字 cv2.putText 的各参数介绍
Dec 05 Python
Django后端接收嵌套Json数据及解析详解
Jul 17 Python
Python简易版图书管理系统
Aug 12 Python
使用Python的turtle模块画国旗
Sep 24 Python
Python RabbitMQ实现简单的进程间通信示例
Jul 02 Python
PyQt5的相对布局管理的实现
Aug 07 Python
python实现ping命令小程序
Dec 28 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
ninety plus是什么?ninety plus咖啡好吗?
2021/03/04 新手入门
将数组写入txt文件 var_export
2009/04/21 PHP
Javascript中判断对象是否为空
2015/06/10 Javascript
Backbone.js 0.9.2 源码注释中文翻译版
2015/06/25 Javascript
纯javascript代码实现计算器功能(三种方法)
2015/09/07 Javascript
Java Mybatis框架入门基础教程
2015/09/21 Javascript
使用Function.apply()的参数数组化来提高 JavaScript程序性能的技巧
2015/12/23 Javascript
nodejs修复ipa处理过的png图片
2016/02/17 NodeJs
select自定义小三角样式代码(实用总结)
2017/08/18 Javascript
微信小程序实现顶部普通选项卡效果(非swiper)
2020/06/19 Javascript
4 种滚动吸顶实现方式的比较
2019/04/09 Javascript
微信小程序 checkbox使用实例解析
2019/09/09 Javascript
vue实现表单录入小案例
2019/09/27 Javascript
SublimeText 2编译python出错的解决方法(The system cannot find the file specified)
2013/11/27 Python
Python中内置数据类型list,tuple,dict,set的区别和用法
2015/12/14 Python
Python二叉搜索树与双向链表转换实现方法
2016/04/29 Python
解决python3在anaconda下安装caffe失败的问题
2017/06/15 Python
django限制匿名用户访问及重定向的方法实例
2018/02/07 Python
python 通过麦克风录音 生成wav文件的方法
2019/01/09 Python
python使用wxpy实现微信消息防撤回脚本
2019/04/29 Python
Windows下pycharm创建Django 项目(虚拟环境)过程解析
2019/09/16 Python
keras读取训练好的模型参数并把参数赋值给其它模型详解
2020/06/15 Python
Python实现Kerberos用户的增删改查操作
2020/12/14 Python
html5 canvas合成海报所遇问题及解决方案总结
2017/08/03 HTML / CSS
Html5原生拖拽相关事件简介以及基础实现
2020/11/19 HTML / CSS
Etam德国:内衣精品店
2019/08/25 全球购物
Levi’s西班牙官方网站:李维斯,著名的牛仔裤品牌
2020/08/20 全球购物
什么是JNDI的上下文?如何初始化JNDI上下文
2012/03/10 面试题
机械设备与数控技术专业求职信
2014/08/10 职场文书
2014年乡镇团委工作总结
2014/12/18 职场文书
六年级小学生评语
2014/12/26 职场文书
餐厅收银员岗位职责
2015/04/07 职场文书
导游词之上海东方明珠塔
2019/09/25 职场文书
Python生成九宫格图片的示例代码
2021/04/14 Python
如何Tomcat中使用ipv6地址
2022/05/06 Servers
前端传参数进行Mybatis调用mysql存储过程执行返回值详解
2022/08/14 MySQL