Problem linking SimpleITK with ImageJ

Hello, I apologize in advance for such an elementary question but I am having a surprising amount of trouble getting SimpleITK to open ImageJ as a viewer.

I have installed python on my Windows 7 work computer using Anaconda and installed Simple ITK as well with the command

conda install -c https://conda.anaconda.org/simpleitk SimpleITK

I have installed the newest version of imageJ and have noted the path to the imageJ executeable. I have set the path to the executeable appropriately, and I can open imageJ from the command prompt using:

start PATH_TO/ImageJ.exe

However when I attempt to run the first notebook 00 Setup from here http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/

running the code:

sitk.Show(sitk.ReadImage(fetch_data(ā€œSimpleITK.jpgā€)), ā€œSimpleITK Logoā€, debugOn=True)

throws the error


RuntimeError Traceback (most recent call last)
in ()
7 # NOTE: The debug information is printed to the terminal from which you launched the notebook
8 # server.
----> 9 sitk.Show(sitk.ReadImage(fetch_data(ā€œSimpleITK.jpgā€)), ā€œSimpleITK Logoā€, debugOn=True)

C:\Users\tplautz\Anaconda\lib\site-packages\SimpleITK\SimpleITK.py in Show(*args, **kwargs)
7743
7744 ā€œā€"
-> 7745 return _SimpleITK.Show(*args, **kwargs)
7746 class ImageFileWriter(ProcessObject):
7747 ā€œā€"

RuntimeError: Exception thrown in SimpleITK Show: C:\Users\dashboard\Miniconda3\conda-bld\simpleitk_1520871257773\work\Code\IO\src\sitkShow.cxx:495:
sitk::ERROR: No appropriate executable found.

So I am pretty sure that SimpleITK is not finding ImageJ, but I do not know how to fix this problem.

Thanks in advance for your help!

@tia welcome to SimpleITK !

The expectation is that Fiji (modern ImageJ) on windows be installed in: C:\Users[your name]\Fiji.app .

You can see the paths the Show method is trying by enabling its debug mode:
sitk.Show(image, debugOn=True)

You can also point SimpleITK to the specific location of your viewer, if you donā€™t want to place it in the expected location, by setting the an environment variable. From the command line (or same thing from the UI):
setx SITK_SHOW_COMMAND ā€œappropriate_path_to_imageJā€

1 Like

Thanks @zivy so much for such a quick reply. I have actually tried setting the environment variable SITK_SHOW_COMMAND.

Presently it i matches the path to the executeable which is

C:\Users[my_name]\Fiji.app\ImageJ.exe

It is still throwing the same error

untimeError Traceback (most recent call last)
in ()
7 # NOTE: The debug information is printed to the terminal from which you launched the notebook
8 # server.
----> 9 sitk.Show(sitk.ReadImage(fetch_data(ā€œSimpleITK.jpgā€)), ā€œSimpleITK Logoā€, debugOn=True)

C:\Users\tplautz\Anaconda\lib\site-packages\SimpleITK\SimpleITK.py in Show(*args, **kwargs)
7743
7744 ā€œā€"
-> 7745 return _SimpleITK.Show(*args, **kwargs)
7746 class ImageFileWriter(ProcessObject):
7747 ā€œā€"

RuntimeError: Exception thrown in SimpleITK Show: C:\Users\dashboard\Miniconda3\conda-bld\simpleitk_1520871257773\work\Code\IO\src\sitkShow.cxx:495:
sitk::ERROR: No appropriate executable found.

The one thing I do notice is the path it is printing

C:\Users\dashboard\Miniconda3\conda-bld\simpleitk_1520871257773\work\Code\IO\src\sitkShow.cxx:495

does not exist on my computer. I am not sure where that path is coming from? I donā€™t believe I installed Miniconda.

@tia,

Please look at the terminal from which you launched the notebook server - you should see the paths the Show command is trying. On my mac this looks like:

Debug: In /Users/dashboard/miniconda3/conda-bld/simpleitk_1521745484515/work/Code/IO/src/sitkShow.cxx, line 434: FindApplication search path: [ /Applications, /Applications/, /Developer, /opt/, /usr/local/ ]
Result: 


Debug: In /Users/dashboard/miniconda3/conda-bld/simpleitk_1521745484515/work/Code/IO/src/sitkShow.cxx, line 434: FindApplication search path: [ /Applications, /Applications/ImageJ, /Developer, /opt/ImageJ, /usr/local/ImageJ ]
Result: 


Debug: In /Users/dashboard/miniconda3/conda-bld/simpleitk_1521745484515/work/Code/IO/src/sitkShow.cxx, line 434: FindApplication search path: [ /Applications, /Applications/ImageJ, /Developer, /opt/ImageJ, /usr/local/ImageJ ]
Result: 

The path you are seeing printed has to do with where SimpleITK was built, please ignore it.

@zivy

Thanks, I understand now. My problem currently is that the debugOn flag does bring up an output window, and the error messages indeed start the same way yours do in your example, however running the notebook with debugOn=True seems to be causing python to crash and I am unable to read all of the output because the window is too small and I canā€™t resize it.

As an alternative I tried copying the code into a script and running that instead directly from the anaconda prompt. In this case When debugOn=True, I see a window pop up for an instant and then it immediately disappears, but it does not cause python to crash.

Iā€™ve tried everything I can think of. Is there a way I can redirect the output from debug to a text file?

Bests,

@zivy,

So I have tried again to make this work on my Linux VM and I had the same problem that SITK could not find ImageJ. At least in linux I was able to read the debug messages without issue. On the VM I was able to solve the problem by creating a softlink to the ImageJ executable in the project directory. However this workaround does not seem to work in Windows.

You appear to have found a bug with respect to the usage of environment variables on windows (we are working on it).

Is there an issue placing the Fiji directory in the expected location? For me, when I have it in:

C:\Users\Ziv Yaniv\Fiji.app

SimpleITK is able to find the application and everything works fine.

1 Like

Iā€™ve tried using the SITK_SHOW_COMMAND environment variable on Windows, and it worked for me.

Iā€™ve patched SimpleITK so that the debugging output in the Show function goes to the command prompt window instead of popping up a new window.

If you can build SimpleITK, you could try the code out here:
https://github.com/dave3d/SimpleITK/tree/UseLoggerForOutput

Otherwise, hopefully itā€™ll get propagated to a new release version soon.

@zivy I believe I have found the solution.

I uninstalled Fiji completely, then reinstalled, being sure to install it directly into my home directory. SimpleITK is now able to find the application. Before I had installed Fiji elsewhere and then moved it to the home directory. Although I believe I correctly set the path, and was able to execute the app from the command line, SimpleITK was not able to find it this way.

1 Like