my goal is to run Afni functions in Matlab.
I can run the functions in the shell and they work (only to clarify that that is not the problem).
My Afni lives in Ubuntu (\home\user\abin\afni’] which is now included in Win 10 and can be used without a virtual machine.
I can call other basic Unix functions in Matlab (like !ubuntu -c ls or !ubuntu run pwd etc.), so this is not the problem either.
I just cannot access Afni or any of its functions.
It seems that all is a matter of configuring the Unix environment correctly and having the bin file put in a way that Matlab can access it.
What I saw working for people using Mac is:
path1 = [path1 ‘\home\user\abin\afni’]
setenv (‘PATH’, path1)
If I run that it actually puts the correct path with setenv, it gives me the directory where my Afni actually lives and I can verify that by looking at its path in Ubuntu directly. But still I cannot access Afni functions (e.g. !ubuntu run which afni or any other Afni functions do not work). But the strangest thing here is that after setting the path as above, the ubuntu general commands do not work anymore either, indeed after setting the path as described above if I run things like !ubuntu run pwd etc. again, I get the error “‘ubuntu’ is not recognized as an internal or external command, operable program or batch file.” If I close Matlab and start it again, those basic commands work again because the path is apparently deleted by restarting the program.
I thought this might be related with Windows being blind for Ubuntu directories or not having permission to access them but even setting the path directly to Ubuntu files stored in Windows (as decribed here: https://www.howtogeek.com/261383/how-to-access-your-ubuntu-bash-files-in-windows-and-your-windows-system-drive-in-bash/ ) does not do the job.
Anyone using Win 10 and Ubuntu who tried something similar and has any idea what to do?
Thanks in adnavce!!
I don’t know matlab, but when setting PATH, it should not include the actual ‘afni’ binary. So consider changing that path1 assignment to:
path1 = [path1 ‘\home\user\abin’]
sorry my bad, yes it is indeed path1 = [path1 ‘\home\user\abin’] but it doesn’t work that way either.
EDIT: Daniel mentioned that you were running matlab from windows, which I had not understood. Hopefully someone else will have something more useful to say.
This is a little strange because of the dual operating system environment. Trying to use Matlab under Windows to start an operating system/subsystem that calls a shell that calls an AFNI program is going to be a little tricky. There is a long series of environments to traverse to get to the command you want. I would recommend using a version of Matlab that can run under the Ubuntu side if that’s possible. That would then inherit the environment including the path you expect. The Windows default paths don’t carry over to the Linux side and vice versa, but that can can change.
Still this might work. The ‘ls’ and similar built-commands work because they don’t require a path to get to them, and they don’t depend on any other libraries that requires a path in the environment to find them. Calling the “ubuntu -c” command starts the whole Linux subsystem and runs a specific command. I expect that the shell is bash. Check that the .bashrc file and the .bash_profile files have the paths configured to include AFNI’s directory.I will try this later, when I have access to a Windows system with an Ubuntu setup.
This documentation is the best I could find on possible methods using “ubuntu”, “wsl” or “bash” to call Linux commands.
thank you very much for your answer!
I tried a few more things in the meanwhile but they indeed pointed all to the fact you mentioned, i.e. that there is a long series of environments to traverse to get to these commands.
Yes, my shell is bash. I will check that the .bashrc file and the .bash_profile files have the paths configured to include AFNI’s directory, let me know if you get any results for that in case you have a chance to try it out.