Sure, I also need to do this all the time, not just between MRtrix 0.2 and 3, but also between different versions of MRtrix3 itself… There’s a few options, but probably the simplest is to only keep one of the versions in your PATH (the one you actually use the most), and invoke the other version by specifying the full path to the executable, or amend the
PATH when you need to.
For example, I have MRtrix 0.2 and MRtrix3 installed in the folders
mrtrix3 respectively within in my home folder. My PATH includes
/home/donald/mrtrix3/bin, but nothing related to
mrtrix2 (you can check your PATH by typing
echo $PATH). This means I’ll always be using my main MRtrix3 install by default. If I need to invoke a command from MRtrix 0.2, I can do so by invoking the command using its full path, like this:
$ ~/mrtrix2/bin/streamtrack SD_PROB fod.mif ...
$ /home/donald/mrtrix2/bin/streamtrack SD_PROB fod.mif ...
This basically sidesteps the normal
If you want to run a session where all the commands are guaranteed to be the older version, you can always amend the
PATH directly on the command-line:
$ export PATH=~/mrtrix2/bin:$PATH
at which point all subsequent command lookups within that shell session will look in the
~/mrtrix2/bin folder first, so use that version preferentially. You can of course also include this at the head of your scripts, etc. as required.
Finally, if you need to do this often, you can also include a line like this in your
~/.bashrc file (or whichever is the correct startup script on your system):
alias mrtrix2="export PATH=~/mrtrix2/bin:$PATH"
You’ll then be able to simply type
mrtrix2 at the terminal, and it’ll amend your
PATH to use the MRtrix 0.2 commands preferentially.