Environment incompatibilities for system command

19 次查看(过去 30 天)
Dear community,
I'm using a Matlab-based toolkit, the lesion quantification toolkit: lesion quantification toolkit
I'm a bit confused by one thing. This toolkit executes an application externally called DSI studio by launching the terminal from Matlab using the "system" command. Actually, I had to modify this and use system instead of the original combination of eval and ! as the toolkit was developed using a Linux platform.
My confusion comes from the fact that without starting the toolkit I can actually use the system command to run some operations in DSI studio from Matlab. But (!!) if I run the function from the toolkit where the system command is used to execute DSI studio externally, I get the following error message:
/bin/bash: /Applications/dsi_studio.app/Contents/MacOS/dsi_studio/: Not a directory
"Not a directory" is false, as I can run the same command without errors before starting the toolkit. My deduction is that the toolkit is setting the wrong environment for the system command?
This is the original code snippet that works without starting the toolkit and using a cfg file with the paths and filenames:
cmd= sprintf('%s --action=ana --source=%s --tract=%s --output=%s --connectivity=%s --connectivity_type=%s --connectivity_threshold=0 --export=tdi',...
cfg.dsi_path,fullfile(cfg.source_path, source_fib),fullfile(cfg.source_path, all_tracts),out_file,cfg.parcel_path,cfg.con_type);
system(cmd)
I would appreciate if a more advanced Matlab user could confirm my suspicion and help me to find a workaround for this?
Thank you in advance for your time!!
Best,
Noelia
  2 个评论
Walter Roberson
Walter Roberson 2024-3-5
cmd= sprintf('"%s" --action=ana --source="%s" --tract="%s" --output="%s" --connectivity="%s" --connectivity_type="%s" --connectivity_threshold=0 --export=tdi',...
cfg.dsi_path,fullfile(cfg.source_path, source_fib),fullfile(cfg.source_path, all_tracts),out_file,cfg.parcel_path,cfg.con_type);
system(cmd)
Noelia Martinez Molina
Thank you for your reply, Walter. I used the double quotes but still I'm getting exactly the same error.
How can I check the current environment in Matlab? Maybe that could help to see whether the toolkit is changing the environment and that's why I keep getting this error.

请先登录,再进行评论。

回答(1 个)

Chandrika
Chandrika 2024-7-3,7:54
Hello Noelia,
You may use the "getenv" function to display the environment variables before and after running the Lesion Quantification Toolkit in MATLAB to check if the Toolkit is altering the environment.
You may find detailed information on the "getenv" function in the following documentation:
Hope it helps!
Regards,
Chandrika

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by