HCP Connectome Tutorial: Tckgen not selecting streamlines when using seed image

MRtrix Team,

I’m facing a weird error while following the HCP Connectome Tutorial [http://mrtrix.readthedocs.io/en/latest/tutorials/hcp_connectome.html]

If I just copy and paste the tutorial everything works perfect, the streamlines are created and I can visualize them with fibernavigator/trackvis without problem.

The problem comes when I try to use a seed mask. Even if I try to use the whole white matter as seeds. More precisely, for the following code:

wb_command -volume-math “(w>=2)*(w<=2)+(w>=41)*(w<=41)+(w>199)*(w<301)” my_wmmask.nii.gz -var w wmparc.nii.gz
tckgen WM_FODs.mif -maxlength 250 -output_seeds used_seeds.txt -seed_image *my_wmmask.nii.gz’ -number 1000 ‘test.tck’

The output is:

tckgen: [ 100%] N generated, 0 selected

Where N is some big number. This also happens with the parameters:

-seed_grid_per_voxel my_wmmask.nii.gz 10
-seed_random_per_voxel my_wmmask.nii.gz 1000

But again, if I simply do:

tckgen WM_FODs.mif test.tck -seed_dynamic WM_FODs.mif -maxlength 250 -number 1000

This works perfectly, and all the streamlines are there, in the test.tck file.


  1. mrinfo WM_FODs.mif and mrinfo my_wmmask.nii.gz report the same Affine matrix (Transform).
  2. mrview DWI.mif my_wmmask.nii.gz shows that the created wmmask and the DWI are well aligned.
  3. The white matter in my_wmmask.nii.gz corresponds well with the one in the file vis.mif.
  4. The error persists if I use -nthreads 0 or the Anatomically-Constrained Tractography options.
  5. The error persists if I transform the wmmask with mrconvert.

You’re making a great work with this toolkit, thanks!.

Best Regards,

That’s indeed pretty odd… I just had a go with your commands on some data I have on my laptop, everything seems to work as it should…

A few things to check:

  • is this an up to date install?

  • is the intensity within the mask as reported by MRView greater than one (or at least, greater than 0.5)?

  • is your my_wmmask.nii.gz stored using an integer type? What happens if you convert to bitwise or uint8 type first, like this:

      $ mrconvert my_wmmask.nii.gz -datatype bit my_wmmask.mif

    and use that file in your tckgen command?
    (you can use uint8 instead of bit, and also store in NIfTI if you want to, that should work fine).

  • what happens if you use the MRtrix3 equivalent command to generate that mask? I assume it would be:

      $ mrcalc wmparc.nii.gz 2 -eq wmparc.nii.gz 41 -eq wmparc.nii.gz 200 -ge wmparc.nii.gz 300 -le -mult -mult -mult my_wmmask.nii.gz
      mrcalc: [100%] uncompressing image "wmparc.nii.gz"
      mrcalc: [100%] computing: ((wmparc.nii.gz == 2) * ((wmparc.nii.gz == 41) * ((wmparc.nii.gz >= 200) * (wmparc.nii.gz <= 300))))
      mrcalc: [100%] compressing image "my_wmmask.nii.gz"
  • what happens if you use dwi2mask to generate a rough brain mask from the RAW images, and use that as the seed image? Is it just your wm_mask.nii.gz image that tckgen struggles with, or does the -seed_image option simply not work no matter what image you provide?

Problem solved.

Actually, there was an error in how I was creating the DWI.mif. The bvals file was incorrect. One of my old scripts had changed them to use the Dipy library. The HCP subjects have a bval=5 for the b0 image. Dipy throws an error if it doesn’t find at least one bval=0. In the folder I was using, the subjects were already preprocessed to be compatible with Dipy.

Your answer make me doubt of my files, so I went to double check them. Thanks for your time and help.

Best Regards,