Use of MRtrix3 in MATLAB

Dear all,

I’ve been trying to using MRtrix3 in MATLAB with ‘system’ commands.
However, it appears that I need to specify the shell under which the ‘system’ command operates to mingw-w64, instead of the default windows shell. I’ve been trying different methods, like:
setenv MATLAB_SHELL C:\msys2\mingw64.exe
before e.g. system(‘mrview’) in my script, but it doesn’t seem to be working.

Any ideas what went wrong and what should be done to fix this?

Many thanks in advance.
James

1 Like

Hi James,

Running MRtrix commands from Matlab can be a bit of a headache – see this old thread outlining some of the issues.

In your case however, you’re trying to run this on a Windows system, presumably using the Windows-native version of Matlab to invoke the MSYS2 version of MRtrix executables. That’s going to be even trickier… There’s a whole page on the MSYS2 wiki on how to do it, if you really want to give it a shot. From what I can gather, something like:

system ('C:\msys64\usr\bin\env MSYSTEM=MINGW64 /usr/bin/bash -li mrview')

might do the trick… (though you may need to edit the location of the env command for your system, depending on where you installed MSYS2).

Good luck,
Donald.