Algorithm for estimating response function


Sorry this questions probably been asked, but I am new here, in the page for the dwi2response on the official site it talks about the link to the algorithm page

but the link doesnt work.

edit: I found it but how do i save the dwi2response file to a directory, do i need to know python??? i dont know python


When you say it doesn’t work, was the error message ‘command not found’? If so, the most likely problem is that the scripts folder isn’t in your PATH. If you look closely at the instructions for setting things up, you’ll see that you need to add both the release/bin and scripts folders to your PATH environment variable for the system to find dwi2response.

You mean this step?

echo PATH=$(pwd)/release/bin:$(pwd)/scripts:$PATH >> ~/.bashrc

I tried it and this is the eror i get when i run mrtrix 3.

dyld: Library not loaded: /opt/local/lib/libintl.8.dylib
Referenced from: /usr/local/mrtrix/lib/libmrtrix-0_2_12.dylib
Reason: no suitable image found. Did find:
/opt/local/lib/libintl.8.dylib: stat() failed with errno=62

Although I pressed sudo bash, and everything works including dwi2response. SO i guess I can continue for now, but dont know what the problem is. . Fundamental question I know…srry

OK, there clearly a conflict with an older install of MRtrix 0.2 - the error message is about failing to load a dependency of the libmrtrix-0_2_12.dylib library, located in /usr/local/mrtrix/. I’m not sure why it would even try to do this, the only thing I can think of is that the script is invoking a command common to both MRtrix3 and MRtrix 0.2, and defaulting to the older version, and the older version no longer works…

It’s very hard to make guesses as to exactly what is going on without a much clearer description of the issue. What do you mean by ‘running MRtrix3’? What command did you run exactly? Is what you show the only output from that command? Did you start up a fresh terminal after modifying your PATH? It would really help if you could copy & paste your entire terminal session, it’s otherwise very difficult to figure anything out from little bits of information…

Hi, thanks a lot for your help so far.

Pretty much to get anything done I have to type sudo bash and everything works

If i just open terminal, go cd mrtrix3 (go into mrtrix directory) and type in a command it doesnt work.

Heres a screenshot.

Ok, the problem is likely to be related to your use of sudo to do this. Beyond installing the dependencies (Eigen and Qt), you really shouldn’t need admin rights to install MRtrix3. You can build it as a regular user, and just add the final location to your PATH. I’m thinking that you might have used sudo during installation/building, and then all the executables get created by the superuser, potentiality meaning that regular users don’t have permission to run them, or don’t have access to the folder they’re contained in. The fix would be to make sure the release/bin is readable for all users, and that the executables contained are also readable and executable for all users.

The other option is you’ve run the step that adds MRtrix3 to your PATH as the superuser, in which case your regular account won’t have been updated with that information - it’ll be the superuser’s PATH that would have been modified.

These are just guesses based on the limited information you’ve provided. If none of that helps, I think you’ll need to provide us with a full terminal dump of your session, right from the initial configure & build, so we can have a chance of spotting where things might have gone wrong…

OK, might need to back-track a little on this one, explain some more fundamentals:

in the page for the dwi2response on the official site it talks about the link to the algorithm page, but the link doesnt work.

This was an error in the documentation file, that was causing the documentation generation to not be able to find the intended page that the link was supposed to go to. This will be fixed soon among a bunch of other changes to the documentation.

how do i save the dwi2response file to a directory, do i need to know python??? i dont know python

It’s not clear to me exactly what your question is here. When you execute any of the provided Python scripts at the command line, (at least) one of the compulsory entries you must provide at the command-line is the path to an output file, of whatever that script generates. The scripts are executed at the command-line just like any binary command, and will generate their outputs at whatever location you specify. So there’s no need to have an understanding of Python (unless you wish to make your own modifications to the scripts).

You mean this step?

echo PATH=$(pwd)/release/bin:$(pwd)/scripts:\$PATH >> ~/.bashrc

Just to be clear: When you execute this command, the current directory of the terminal must be the directory in which MRtrix3 is installed.

I tried it and this is the eror i get when i run mrtrix 3. … Although I pressed sudo bash, and everything works including dwi2response.

What the above command is doing is inserting the paths to the MRtrix3 executable directories into the file ~/.bashrc. This file is then executed every time you open a new terminal. However, executing the above line alone does not influence your PATH environment variable in any way; therefore it does not instruct your system where to find the MRtrix3 commands. To execute that file, you need to either re-initialise bash, or simply close the terminal and open a new one.

Likely the reason why sudo bash is working for you, but opening a new terminal is not, is that your configuration of the bashrc file was done as the super-user, and therefore the corresponding change has occurred in the super-user’s version of the bashrc file, which is only executed if a terminal is created (or bash re-initialised) as the super-user. See more below.

Pretty much to get anything done I have to type sudo bash and everything works

If i just open terminal, go cd mrtrix3 (go into mrtrix directory) and type in a command it doesnt work.

As Donald said, this suggests that when you ran this command:
echo PATH=$(pwd)/release/bin:$(pwd)/scripts:\$PATH >> ~/.bashrc
, you were logged in as a super-user. Therefore, this modified the bashrc file for the super-user, not the one for your own user account. Re-run this command using your own user account, from the MRtrix3 installation directory.

Another factor to observe in the above command is that it adds the MRtrix3 paths to the start of the PATH variable. This means that if you try to run a command with a name that is common between MRtrix 0.2 and MRtrix3, your system will find the MRtrix3 version first, and that is the version that will be executed. If you still find that MRtrix 0.2 commands are being executed, it’s possible that some other file is inserting the MRtrix 0.2 binary path into the PATH variable after this step, and therefore those binaries would be the first found by your system.

HI, thanks for your response. I tried running the

echo PATH=$(pwd)/release/bin:$(pwd)/scripts:$PATH >> ~/.bashrc

after going into mrtrix3. Still doesnt work. IS this what you meant by the installation directory.

This is the message that comes up

Like I said, that won’t work: the ‘echo ... >> ~/.bashrc’ line is taking the command that is necessary for adding the MRtrix3 executable directories to your path, and writing it to the file ~/.bashrc. So by running it, your PATH variable is in fact not being updated; what it’s doing is ensuring that MRtrix3 will be added to your path every time you open a new terminal. If, rather than trying to run mrview immediately after that line, you instead close your terminal and open a new one, it should work.

If that continues to not work, it’s possible that the PATH environment variable is not being set correctly. If the above doesn’t work, you can try changing:
echo PATH=$(pwd)/release/bin:$(pwd)/scripts:\$PATH >> ~/.bashrc
echo "export PATH=$(pwd)/release/bin:$(pwd)/scripts:$PATH" >> ~/.bashrc

When you say close my terminal and open again. So I should do nothing? AS it starts fresh evertime. It still doesnt work.

If you still can’t get this approach to work, you’re probably better off breaking the process into steps:

  1. Try running an MRtrix3 command by explicitly providing the complete path, rather than just the command name. So for instance, instead of just typing mrview, use e.g. /home/username/mrtrix3/release/bin/mrview. (Modify to reflect the actual path to your MRtrix3 install)
  2. Try modifying the PATH environment variable just within a single terminal session. So for instance:
    2.1. Just type mrview: Sounds like this will currently try to execute the MRtrix 0.2 version of mrview, which is failing.
    2.2. Add MRtrix3 to the start of your PATH, using:
    export PATH=/home/username/mrtrix3/release/bin:/home/username/mrtrix3/scripts:$PATH
    2.3. Now try typing mrview. Your system should now execute the MRtrix3 version of mrview.
  3. Rather than using the line provided in the documentation for setting PATH, try directly editing your bashrc file. It should be in the home directory of your user account. You might need to change a setting in your file explorer to see it, since it’s a hidden file; alternatively you could use something like gedit ~/.bashrc. You may also need super-user access to edit it. There’s a fair chance that there’ll be a few lines at the end of the file that have been put there by your previous efforts trying to add MRtrix3 to your PATH; delete those, and just have a single line with the following:
    export PATH=/home/username/mrtrix3/release/bin:/home/username/mrtrix3/scripts:$PATH
    That will perform exactly the same as was achieved in step 2, but will execute every time you open a new terminal.
1 Like

OK, let’s see if we can figure this out. Can you copy/paste the full terminal output of these commands, starting from a fresh terminal:

$ cd mrtrix3
$ echo $PATH
$ ls -l release/bin

That might give us a better idea of what’s going on…


OK, clearly your PATH is not being set up as it should. Looks like your ~/.bashrc file is not being read at terminal start-up on your system. I have a vague recollection that this may in fact be the expected behaviour on MacOSX… The more widely used convention on MacOSX might be to read the ~/.profile file (on Linux that would typically only be read at login time).

Try the following:

$ cd mrtrix3
$ echo PATH=$(pwd)/release/bin:$(pwd)/scripts:\$PATH >> ~/.profile 

Then start a fresh terminal and try again…

If that works, we’ll need to amend the MacOSX instructions to match in the doc.

1 Like

YAY it works! Thank You so much. Legends!

I would like to add rsmith suggested this command and reopening terminal. It didnt work before.

echo “export PATH=$(pwd)/release/bin:$(pwd)/scripts:$PATH” >> ~/.bashrc

But when you (jdtournier) told me to put this command it works, may I ask why for curiosity purposes.

echo PATH=$(pwd)/release/bin:$(pwd)/scripts:$PATH >> ~/.profile

(Another thing to add is before I did what you asked, (incase it might affect the result) I resetted my bashrc profile by deleting the previous lines which i tried to add to my mrtrix 3 path. Could this have affected the results.

Glad you’re happy that it works, and not annoyed that it took so much effort… Thanks for your patience with this, this is something we really should have got right to begin with. I’ll amend the installation instructions now.

As to an explanation of why this works, it’s a little messy… Basically, most Unix systems (including MacOSX and the Windows MSYS2 environment) will run bash as the default shell or command interpreter. When you open a terminal, the terminal will invoke bash and run that within itself, so what you see when you interact with the terminal is the output of bash as displayed by the terminal application. When bash starts, it will read various configuration / start-up files (also sometimes referred to as rc files - short for run command). The ~/.profile and ~/.bashrc are two such files, but there are other possibilities. In fact, there are so many possibilities that may be read under different conditions that it’s frustratingly difficult to figure out which file will get read under what circumstances on different systems. Every OS and Linux distribution seems to differ in exactly what gets used - although there are some generally accepted conventions, which are nicely outlined in e.g. this post.

So on most Linux distributions, ~/.bashrc gets read every time bash starts as a non-login session (i.e. every time you open a new terminal). But not on MacOSX, where every new terminal will apparently start a new full-blown login session, so won’t read ~/.bashrc, and will read ~/.bash_profile instead - and this will normally be set up to load in ~/.profile if it exists… See this post for some discussion on the topic.

So as you can see, things are unfortunately not that simple… I wish we had a fool-proof system that worked on all systems, but there’s just too many ways for this to go wrong, so we can only provide what we think is the best advice and hope that it works for most users…