DottedGlass
DottedGlass

Reputation: 355

SimpleITK.Show() generates error in ImageJ on Linux

EDIT NOTE: This question was originally phrased as

How to link SimpleITK.Show() to imageJ in linux?

By upgrading SimpleITK 1.0.0 to 1.0.1, I was able to launch ImageJ from SimpleITK.Show(). However, ImageJ is unable to open "sample_mri.hdr". ImageJ generates the following error messages.

File is not in a supported format, a reader

plugin is not available, or it was not found.

root/local/linux/ImageJ/open("/temp/TempFile-7131-2.nii");

root/local/linux/ImageJ/rename("/temp/TempFile-7131-2.nii");

I have installed the appropriate plugins for ImageJ to read hdr/img (Analyze format). I can open "sample_mri.hdr" from ImageJ directly by going to file>open

debug messages:

sitk.Show(img, 'sample image', debugOn=True)

FindApplication search path: [ ./Fiji.app, /cis/home/vwang/bin/Fiji.app, ~/bin/Fiji.app, /opt/Fiji.app, /usr/local/Fiji.app ]

Result:

FindApplication search path: [ ./Fiji.app, /cis/home/vwang/bin/Fiji.app, ~/bin/Fiji.app, /opt/Fiji.app, /usr/local/Fiji.app ]

Result:

FindApplication search path: [ ./ImageJ, /cis/home/vwang/bin/ImageJ, ~/bin/ImageJ, /opt/ImageJ, /usr/local/ImageJ ]

Result:

FindApplication search path: [ ./, /cis/home/vwang/bin/, ~/bin/, /opt/, /usr/local/ ]

Result: /usr/local/bin/ImageJ

Show command: '/usr/local/bin/ImageJ' '-e' 'open("/tmp/sample-4434-0.nii"); rename("sample");'

plugins:

How to link SimpleITK.Show() to imageJ in linux?

I've downloaded ImageJ and I can view images by running ImageJ directly. A similar question was asked and answered in the past (Can not "link"SimpleITK::Show() with FIJI), but the solution was for windows OS. What is the unix equivalent of

setx SITK_SHOW_COMMAND "C:\blah\blah\ImageJ\ImageJ.exe

My python code:

import SimpleITK as sitk

img = sitk.ReadImage("sample_mri.hdr")
sitk.Show(img, 'sample image')

Error message:

    return _SimpleITK.Show(*args, **kwargs)
RuntimeError: Exception thrown in SimpleITK Show: 
/tmp/SimpleITK/Code/IO/src/sitkShow.cxx:500:
sitk::ERROR: Error in administrating child process: [No such file or directory]

Upvotes: 5

Views: 5986

Answers (4)

WhaSukGO
WhaSukGO

Reputation: 703

TL;DR

  1. Ensure the target directory exists, or create it:
$ mkdir -p ~/bin
  1. Create the symbolic link:
# Edit /root/Fiji.app to your Fiji.app location
$ ln -s /root/Fiji.app ~/bin/Fiji.app

Here's a guide from official SimpleITK

Why isn’t Fiji or ImageJ found by the Show function (RuntimeError: Exception thrown…)?
The SimpleITK Show function expects the Fiji or ImageJ application to be installed in specific locations. The recommended installation locations are:

On Windows: in your user directory (e.g. C:\Users\your_user_name\Fiji.app).

On Linux: in ~/bin.

On Mac: in /Applications or ~/Applications.

To see the locations where the function is searching set Show’s debugOn flag.

Upvotes: 0

sushant097
sushant097

Reputation: 3736

On Ubuntu, I did the following and it works:

  1. download http://imagej.net/Fiji
  2. unzip Fiji to home directory, unzip Fiji-download.zip -d ~/.
  3. add this folder to your PATH or Export path as: export SITK_SHOW_COMMAND="$HOME/Fiji.app/ImageJ-linux64" on your shell.

SimpleITK ought to find ImageJ without it, since it's in the expected location, but just try it out to see if it works.

Upvotes: 0

Mingrui Jiang
Mingrui Jiang

Reputation: 31

On Ubuntu, I had the exact same problem, here is the solution:

  1. download http://imagej.net/Fiji
  2. unzip Fiji to home directory, ~/Fiji.app
  3. add this folder to your PATH

fiji will include all the plugins you need to display mri files, such as nifti and mha

Upvotes: 3

Dave Chen
Dave Chen

Reputation: 2085

SimpleITK is unable to find ImageJ. Try adding the debugOn=True parameter to the Show command. That will show you the search path it's using to try and find ImageJ.

So your Show would be the following:

sitk.Show(img, 'sample image', debugOn=True)

On Linux systems, SimpleITK searches the path for the following options: Fiji.app/ImageJ-linux64, Fiji.app/ImageJ-linux32, ImageJ/imagej, ImageJ, and imagej.

If your ImageJ executable is named something else, SimpleITK won't find it. I would suggest either soft linking to make it findable, or using the SITK_SHOW_COMMAND environment variable.

UPDATE: Not finding ImageJ was your original problem. I'm not sure about your update, but with the debugOn flag set, you can see the actual command line that SimpleITK is using to try and launch ImageJ.

Upvotes: 1

Related Questions