How to lanuch ITK-SNAP in MATLAB using the system command

396 views
Skip to first unread message

jiancong wang

unread,
Jan 17, 2015, 12:40:40 AM1/17/15
to itksna...@googlegroups.com
Hey guys, 
I am Cong, a student learning image analysis. I am writing to ask how to launch ITK-SNAP and open a nii file in MATLAB? 
I am working on something like 
command='C:\Program Files (x86)\ITK-SNAP 3.2\bin\ITK-SNAP -g baseline.nii';
system(command)

(assuming there is a baseline.nii file in the path). 

I tried the command in command prompt and it works. But in MATLAB with the system function it kept telling me that 
'C:\Program' is not recognized as an internal or external command, 
operable program or batch file. 

It is weird that when I try 
command='C:\Program Files (x86)\ITK-SNAP 3.2\bin\ITK-SNAP';
system(command)

The code works! I really don't know why adding the -g baseline.nii crashes the function. Please help!

Vincent Finnerty

unread,
Feb 3, 2015, 11:09:42 AM2/3/15
to itksna...@googlegroups.com


Le samedi 17 janvier 2015 00:40:40 UTC-5, jiancong wang a écrit :
command='C:\Program Files (x86)\ITK-SNAP 3.2\bin\ITK-SNAP -g baseline.nii';
system(command)

You should add double quotes to encapsulate your file names (inside the single quotes) otherwise spaces are confusing for system:
command=' "C:\Program Files (x86)\ITK-SNAP 3.2\bin\ITK-SNAP" -g baseline.nii';
system(command)

 
It is weird that when I try 
command='C:\Program Files (x86)\ITK-SNAP 3.2\bin\ITK-SNAP';
system(command)
The code works! I really don't know why adding the -g baseline.nii crashes the function. Please help!

I get that too, it seems when there is only one file Matlab automatically adds the double quotes, because, this command does not word in a real command window (cmd).
 
Reply all
Reply to author
Forward
0 new messages