Change the value of nodes


#1

Hello,
we met a very specific question here. We wanna make a color map based on AAL template.
And we notice that each label of the ‘nodes’ image has its own value.


So now we are wondering if we could customize the value as we want? Then we can produce a color map based on ‘mrview’.
Do you have any idea about it? Any suggestion will be helpful.
If you don’t think it is a feasible way. Do you have any idea to make the color map?? We’ve tried to manually change the LUT of AAL, but it’s time-consuming and if we wanna change the color scale we have to do it again…


#2

I have a feeling this feature has already been requested… Is this what you had in mind? In general, integer colour-mapping in the viewer would require quite a few changes to the back-end – all trivial, but time-consuming, especially with all the testing that would entail… As always, too many things we’d like to do, but not enough time…


#3

Totally understand and, at least in my mind, you’ve done the best job.
What you mentioned is sort of like what I am looking for. But since that is still a forthcoming method. So I also think out a more stupid method. It may be confusing but I will try to struggle out to explain it:

  1. Because I wanna give each value a customized value. For example, change the left precentral gyrus(value=1) to value=255. So first I use ‘round’ to change all to integer:

mrcalc -round aal.nii.gz aal_round.nii.gz

2 . Then use ‘-eq’ and ‘-mul’ to make 1 to 255…

mrcalc aal_round.nii.gz 1 -eq 255 -mul aal_round_1.nii.gz

  1. What I got is an extracted left precentral gyrus which the value is 255…

So the most time-consuming way is extracting each label and combining them together at the end…
I think there is a smarter and faster way to do it. It would be wonderful if you have any suggestion about it.
Please let me know if there is any step confusing you.
Thanks to your help again.

Best,
Ziqian


#4

Ah, OK. Try this:

mrcalc aal.nii.gz -round 1 255 -replace aal_round_1.nii.gz

#5

That’s very helpful!
Thanks very much.


#6

If you only want to change the indices of a few different nodes, then mrcalc -replace comes in handy. However if there’s more than a few nodes that you wish to change, and you also want to specify a colour for each (which can be used to generate a coloured image via the label2colour command or loaded in the mrview Connectome tool), then the way to do it is to define your own lookup table. As long as the node names are correct, it means a single command call to convert all nodes in one go. The framework was explicitly designed to permit these kinds of node reorderings; the files provided in share/mrtrix3/labelconvert/ are only “examples” for convenience.