# Algorithm for estimating response function

**URL:** <https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241>\
**Category:** Uncategorized\
**Tags:** installation, macos\
**Created:** [May 21, 2016, 12:52pm UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241 "2016-05-21T12:52:55Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![lower11](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lower11](https://community.mrtrix.org/u/lower11)\
**Post date:** [May 21, 2016, 12:52pm UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/1 "2016-05-21T12:52:56Z")

</div>

Hi,

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

[http://mrtrix.readthedocs.io/en/0.3.16/tutorials/basic\_dwi\_processing.html](http://mrtrix.readthedocs.io/en/0.3.16/tutorials/basic_dwi_processing.html)

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

Cheers

---

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [May 21, 2016, 6:55pm UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/2 "2016-05-21T18:55:33Z")

</div>

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](http://mrtrix.readthedocs.io/en/0.3.16/installation/linux_install.html#set-up-mrtrix3), 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`.

---

<div class="post-metadata">

**Author:** ![lower11](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lower11](https://community.mrtrix.org/u/lower11)\
**Post date:** [May 22, 2016, 2:36am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/3 "2016-05-22T02:36:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [May 22, 2016, 12:28pm UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/4 "2016-05-22T12:28:57Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![lower11](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lower11](https://community.mrtrix.org/u/lower11)\
**Post date:** [May 22, 2016, 12:59pm UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/5 "2016-05-22T12:59:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lower11](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lower11](https://community.mrtrix.org/u/lower11)\
**Post date:** [May 22, 2016, 1:00pm UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/6 "2016-05-22T13:00:08Z")

</div>

![](https://community.mrtrix.org/uploads/default/original/1X/42366410c2fd1d6ab7941db6f100753fac4804ca.png)

---

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [May 22, 2016, 8:49pm UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/7 "2016-05-22T20:49:00Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [May 23, 2016, 5:34am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/8 "2016-05-23T05:34:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lower11](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lower11](https://community.mrtrix.org/u/lower11)\
**Post date:** [May 23, 2016, 5:51am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/9 "2016-05-23T05:51:20Z")

</div>

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

![](https://community.mrtrix.org/uploads/default/original/1X/600eeb219f3a5c6620599a2bef92184b62b344bc.png)

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [May 23, 2016, 6:17am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/10 "2016-05-23T06:17:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [May 23, 2016, 6:22am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/11 "2016-05-23T06:22:44Z")

</div>

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`  
to:  
`echo "export PATH=$(pwd)/release/bin:$(pwd)/scripts:$PATH" >> ~/.bashrc`

---

<div class="post-metadata">

**Author:** ![lower11](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lower11](https://community.mrtrix.org/u/lower11)\
**Post date:** [May 23, 2016, 6:23am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/12 "2016-05-23T06:23:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [May 23, 2016, 7:42am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/13 "2016-05-23T07:42:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [May 23, 2016, 7:44am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/14 "2016-05-23T07:44:28Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![lower11](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lower11](https://community.mrtrix.org/u/lower11)\
**Post date:** [May 23, 2016, 8:04am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/15 "2016-05-23T08:04:52Z")

</div>

Cheers.

 ![](https://community.mrtrix.org/uploads/default/original/1X/8327622cd121051ce10e01bb9da7362915f57a0b.png)

![](https://community.mrtrix.org/uploads/default/original/1X/d8c1b71fe2169927b5a2c47f6e09998f6f7dbea1.png)

---

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [May 23, 2016, 8:26am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/16 "2016-05-23T08:26:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lower11](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lower11](https://community.mrtrix.org/u/lower11)\
**Post date:** [May 23, 2016, 8:34am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/17 "2016-05-23T08:34:47Z")

</div>

YAY it works! Thank You so much. Legends!

---

<div class="post-metadata">

**Author:** ![lower11](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@lower11](https://community.mrtrix.org/u/lower11)\
**Post date:** [May 23, 2016, 8:39am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/18 "2016-05-23T08:39:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [May 23, 2016, 9:37am UTC](https://community.mrtrix.org/t/algorithm-for-estimating-response-function/241/19 "2016-05-23T09:37:27Z")

</div>

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](http://stackoverflow.com/questions/415403/whats-the-difference-between-bashrc-bash-profile-and-environment).

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](http://apple.stackexchange.com/questions/119711/why-doesnt-mac-os-x-source-bashrc) 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…
