Custom / User-specified colourmap

Dear all,

I would like to visualize a set of streamlines with my own user-specified colourmap (and using the -tractography.tsf_load option).

Is there some workaround for creating a custom colourmap (given known RGB triplets)? I have tried looking into the colourmap.cpp, but that didn’t lead me very far.

I’m using the Ubuntu 16.04 and an MRtrix3 version built on June 2018.

Many thanks,

No, I’m afraid there’s no such functionality at the moment. It’s come up before in different contexts, but we’ve not had time to put into making it happen. Feel free to file a feature request as an issue on Github.

As to implementing your own colourmap directly: the current code would make it tricky to implement in the way you might expect, since each colourmap is implemented as code injected directly into the OpenGL fragment shader - it’s not a look-up like in Matlab, etc.

What colourmap where you after implementing anyway?

Hi Donald,

Thank you for the detailed response.

I see, indeed it doesn’t sound like there’s a straightforward solution. I was interested in implementing one of the perceptually uniform colourmaps available in matplotlib.

I will file a feature request as you suggested.

Thanks again.

1 Like

I recently commented in an old closed GitHub issue that while Matlab’s parula is off-limits, the matplotlib perceptually uniform colourmaps are pretty good. One challenge for incorporation of such into mrview is that each colourmap must be defined both in GLSL and as a C++ functor; so need to figure out how to store a colourmap table as a texture and then control fragment colour using it :nerd_face:

Dear all,
have you made any progression resolving this issue since the last post in 2018? As I am stuck in the same situation a solution would be most welcome.
Kind regards, Peter Agger.

Hi Peter,

I’m afraid not. I’ve just had a quick look into it, and it will require quite a bit of refactoring to get it implemented. Nothing difficult, but it’ll take time that I don’t have. On the other hand, we will soon be advertising for a software developer specifically to help with MRtrix, and this will be on the to-do list.

Sorry I can’t give you better news…

OK, despite what I said earlier, I’ve given this a shot, and I have a working implementation that you can try out if you’re keen (beats marking courseworks for a couple of hours…).

You’ll find the implementation on this branch. You can install it if you have an install from source, following these instructions:

cd mrtrix3   # edit as appropriate
git pull
git checkout mrview_custom_colourmap

Refer to the pull request for details on the format for the colourmaps, but it’ll hopefully be fairly simple to use. Feedback welcome!


Hi Donald,
this sounds absolutely amazing. I am trying to compile as you write. I am not allowed to run ./build before I have run ./configure, but when I do so I run into an error that I cannot solve. I can share with you the configure.log file, but I am only allowed to attach image files to this message