I have below code. print(image.GetDimension())
works and prints the output (512, 512, 17)
. But sitk.Show(image)
doesn't work.
My Code
import SimpleITK as sitk
path = "C:/Users/myUserName/Desktop/0001.DCM"
image = sitk.ReadImage(path)
print(image.GetDimension())
sitk.Show(image)
My error message is:
RuntimeError: Exception thrown in SimpleITK Show: D:\a\1\sitk\Code\IO\src\sitkImageViewer.cxx:562:
sitk::ERROR: Error in administrating child process: [Access is denied].
Command line: 'C:\Users\myUserName\Fiji.app' 'C:\\Users\\myUserName\\AppData\\Local\\Temp\\TempFile-21536-2.mha'
How can I fix that? I have unzipped ImageJ and put the Fiji.app
folder at C:\Users\myUserName\Fiji.app
. The DICOM image 0001.DCM
has no problem as I can view it via some online DICOM viewer. I am using Windows 10, and run my Python code in Spyder. Thanks in advance!
Try setting the SITK_SHOW_COMMAND to point directly to the ImageJ executable. For your installation of Fiji, the environment variable should be set to C:\Users\myUserName\Fiji.app\ImageJ-win64.exe.
OK, here's my slightly modified version of your script:
import SimpleITK as sitk
#path = "C:/Users/myUserName/Desktop/0001.DCM"
path = "C:\SimpleITK-build\SimpleITK-build\ExternalData\Testing\Data\Input\DicomSeries\Image0075.dcm"
image = sitk.ReadImage(path)
print(image.GetDimension())
sitk.Show(image, debugOn=True)
The only difference is that I added the debugOn flag to the call to Show.
And here's my output:
Debug: In D:\bld\libsimpleitk_1627514864077\work\Code\IO\src\sitkImageViewer.cxx, line 495: ExecuteCommand: 'C:/Users/dchen/Fiji.app/ImageJ-win64.exe' '-eval' 'open("C:\\Users\\dchen\\AppData\\Local\\Temp\\TempFile-10808-0.mha"); rename("C:\\Users\\dchen\\AppData\\Local\\Temp\\TempFile-10808-0.mha");'
Debug: In D:\bld\libsimpleitk_1627514864077\work\Code\IO\src\sitkImageViewer.cxx, line 576: Done. Deleting process.
And you can see exactly the command that SimpleITK is executing to invoke Fiji. In particular, the program being launched is 'C:/Users/dchen/Fiji.app/ImageJ-win64.exe'.
If you turn on the debugOn flag, what does SimpleITK output?