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中处理异常的教程
May 24 Python
通过源码分析Python中的切片赋值
May 08 Python
Python通过属性手段实现只允许调用一次的示例讲解
Apr 21 Python
Python3自动签到 定时任务 判断节假日的实例
Nov 13 Python
Python GUI编程 文本弹窗的实例
Jun 11 Python
使用python实现男神女神颜值打分系统(推荐)
Oct 31 Python
利用Python的turtle库绘制玫瑰教程
Nov 23 Python
Tensorflow 实现将图像与标签数据转化为tfRecord文件
Feb 17 Python
Django如何实现防止XSS攻击
Oct 13 Python
如何使用Python自动生成报表并以邮件发送
Oct 15 Python
pytest进阶教程之fixture函数详解
Mar 29 Python
Python实现将多张图片合成MP4视频并加入背景音乐
Apr 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
php htmlentities和htmlspecialchars 的区别
2008/08/18 PHP
用Zend Studio+PHPnow+Zend Debugger搭建PHP服务器调试环境步骤
2014/01/19 PHP
Yii2中使用asset压缩js,css文件的方法
2016/11/24 PHP
php实现的错误处理封装类实例
2017/06/20 PHP
关于ThinkPHP中的异常处理详解
2018/05/11 PHP
Bookmarklet实现启动jQuery(模仿 云输入法)
2010/09/15 Javascript
javaScript同意等待代码实现心得
2011/01/01 Javascript
window.onload和$(function(){})的区别介绍
2013/10/30 Javascript
Extjs grid panel自带滚动条失效的解决方法
2014/09/11 Javascript
Javascript中函数名.length属性用法分析(对比arguments.length)
2016/09/16 Javascript
D3.js实现饼状图的方法详解
2016/09/21 Javascript
多个上传文件用js验证文件的格式和大小的方法(推荐)
2017/03/09 Javascript
兼容浏览器的js事件绑定函数(详解)
2017/05/09 Javascript
微信小程序表单验证功能完整实例
2017/12/01 Javascript
Vuex实现计数器以及列表展示效果
2018/03/10 Javascript
JS实现的文件拖拽上传功能示例
2018/05/21 Javascript
[02:19]2018年度DOTA2最佳核心位选手-完美盛典
2018/12/17 DOTA
[01:11:46]DOTA2-DPC中国联赛 正赛 iG vs Magma BO3 第一场 2月23日
2021/03/11 DOTA
在Python中操作文件之seek()方法的使用教程
2015/05/24 Python
在Python的Flask框架中构建Web表单的教程
2016/06/04 Python
用Python实现随机森林算法的示例
2017/08/24 Python
在jupyter notebook 添加 conda 环境的操作详解
2020/04/10 Python
python:解析requests返回的response(json格式)说明
2020/04/30 Python
纯CSS3实现3D旋转书本效果
2016/03/21 HTML / CSS
北美大型运动类产品商城:Champs Sports
2017/01/12 全球购物
《临死前的严监生》教学反思
2014/02/13 职场文书
收银出纳员岗位职责
2014/02/23 职场文书
投资合作协议书
2014/04/17 职场文书
大型活动组织方案
2014/05/10 职场文书
公证委托书
2014/08/01 职场文书
父亲节寄语大全
2015/02/27 职场文书
召开会议通知范文
2015/04/15 职场文书
Python-typing: 类型标注与支持 Any类型详解
2021/05/10 Python
python模块与C和C++动态库相互调用实现过程示例
2021/11/02 Python
Windows11里微软已经将驱动程序安装位置A盘删除
2021/11/21 数码科技
《模拟人生4》推出新补丁 “婚礼奇缘”DLC终于得到修复
2022/04/03 其他游戏