How can I obtain individual TDI per voxel (in voxel coordinates)?

Hi Community,
For the follow-up research, I have to obtain all the TDIs for each voxel (in voxel coordinates) within a ROI, that is, one TDI per voxel. Therefore, I have two problems when using MRtrix3. First, I’ve got some sets of voxel coordinates for all the voxels within each participant’s ROI (in local space), but the tckgen command can only seed streamlines per voxel in MNI coordinates. Second, if I don’t seed streamlines per voxel when doing the fiber tracking, I will need to obtain individual TDI per voxel later, but there is no corresponding option in the tckmap command. Is there a way to solve these two problems (or maybe one problem)?

Best regards!


Hi Jen,

You can make a TDI map, given a tractography (.tck file) and some image (.mif or .nii.gz for example) to define the grid:

tckmap tracks.tck -contrast tdi -template image.nii.gz output_tdi.nii.gz

In fact, the default contrast is already ‘tdi’, so you can also leave out the -contrast tdi part. The image.nii.gz in this example is only used to define the grid of the output image. It doesn’t matter what intensities there are in there.

I understand you want to have the TDI value separate in a selection of voxel coordinates (x,y,z), not averaged out or anything. One approach would be to start from the output_tdi.nii.gz and use mrstats with the -mask option to obtain the value in a ROI. This ROI can be an image containing a single voxel. So you could make a loop in which you create a ROI image and compute the TDI in it:

mrcalc image.nii.gz 0 -mult - | mredit - -voxel x,y,z 1 - | mrstats output_tdi.nii.gz -mask - -output mean

This basically takes an image.nii.gz, sets all intensities to 0, then passes it on to mredit to set the intensity of voxel x,y,z (change this within your loop) to value 1. This binary ROI is then passed on to mrstats to be used as a mask on output_tdi.nii.gz, from which the mean value (of a single voxel, so the voxel intensity itself) is taken. Best to check that the value you get is the correct one, else the x,y,z definition needs to be changed.

There may be other solutions, but this is the one that pops in my head for now, given that you want to have the TDI values of each voxel, and not the average across voxels.



Perhaps the mrdump command can be useful. Haven’t tried it, but maybe it will give you the values of each voxel inside a ROI. So:
mrdump output_tdi.nii.gz -mask ROI.nii.gz values.txt

1 Like

I’m sorry for replying you so late. Your advice is a great help, and I will follow your advice to proceed as soon as possible. Thank you so much for your help!!!


Yep, this is a really valuable, yet simple, command. This used to be part of mrstats, so I hope people haven’t “lost track” of it. :wink: But basically, it allows you to do your maths / stats / plotting / … easily in any other package thereafter (e.g. Matlab, etc…).