SimpleITK fail to use ImageJ as external image viewer

simpleitk

(Max Yong) #1

System environment:

  • Windows 10 64-bit
  • Python 3.6.5 (Anaconda 64-bit)
  • SimpleITK 1.1.0
  • ImageJ 1.52a
    I am just start to use the python tutorial with the pyrhon launch binder project.

But it did not work as I expected after tried to debug the ImageJ visualization failure problem.
In the first “Setup” tasks I tried to run the following code:
sitk.Show(sitk.ReadImage(fetch_data(“SimpleITK.jpg”)), “SimpleITK Logo”, debugOn=True)

It just keeps return the and cannot load the figure:
Exception thrown in SimpleITK Show: /opt/miniconda2/conda-bld/simpleitk_1521812412263/work/Code/IO/src/sitkShow.cxx:495:
sitk::ERROR: No appropriate executable found.

Can anyone help me fix on this. I really appreciate it !!!


(Max Yong) #2

I can see this is because the interpreter cannot find the ImageJ.
But how can I fix this through setting the environment variable. I already tried that by adding the “C:\Users\Kumawife\ImageJ” to the path, but it did not work actually.


(Ziv Yaniv) #3

Please see the SimpleITK FAQ on the subject. Let us know if this doesn’t address your issue (Fiji should be in a directory path which looks like C:\Users\your_user_name\Fiji.app).


(Max Yong) #4

Thank you for your reply!

I did exactly what that said.
First, I create a new environment with conda:
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32

Secondly, I down the Fiji.app:
On Windows: in my user directory: C:\Users\Kumawife\Fiji.app

Thirdly, I install simpleITK:

import SimpleITK as sitk
print(sitk.Version())
SimpleITK Version: 1.1.0 (ITK 4.13)
Compiled: Mar 22 2018 23:49:u55b6:

Then I tried to type this:
image = “D:\Machine Learning\ITK-img.jpg”
sitk.Show(image, debugOn=True)

But eventually I got this:
Traceback (most recent call last):
File “”, line 1, in
File “D:\ANA\lib\site-packages\SimpleITK\SimpleITK.py”, line 7745, in Show
return _SimpleITK.Show(*args, **kwargs)
TypeError: in method ‘Show’, argument 1 of type ‘itk::simple::Image const &’

Please help me ~~ I really don’t know how to deal with it.
Thank you~


(Max Yong) #5

Thank you! I finally figure out what’s going on.
I didn’t change my configuration anyway.
As to environment variable, I add “C:\Users\Kumawife\Fiji.app” and "“C:\Users\Kumawife\Fiji.app\ImageJ-win64.exe” to the path.
type in this in my Pycharm. yes the sitk.ReadImage() function is needed but the SimpleITK FAQ seems don’t mention this.

sitk.Show(sitk.ReadImage(‘ITK-img.jpg’), “SimpleITKLogo”, debugOn=True)
Finally~~
Again, Thank you zivy!


(Andras Lasso) #6

FYI, a new 3D Slicer based image visualization approach has been made available recently, which uses SimpleITK in the Jupyter kernel embedded into 3D Slicer. This approach allows immediate visualization (it is performed in the kernel), full viewer state is preserved when the cell is re-launched, and all data (transforms, tables, surface models, points, etc.) can be explored and edited interactively using rich GUI.

You can run this kernel on your local computer by installing Slicer and its SlicerJupyter extension.

If computation load is small and passive visualization is sufficient then you can run Slicer Jupyter kernel directly in your web browser, via binder: have a look at this interactive SimpleITK example (no installation is needed). Binder