Reputation: 355
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
Reputation: 703
$ mkdir -p ~/bin
# 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
Reputation: 3736
On Ubuntu, I did the following and it works:
unzip Fiji-download.zip -d ~/.
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
Reputation: 31
On Ubuntu, I had the exact same problem, here is the solution:
fiji will include all the plugins you need to display mri files, such as nifti and mha
Upvotes: 3
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