5ttedit Pathology Image (using a WMH mask)


New user to mrtrix here, and I am working on updating some processing with my PI. She essentially wants me to run 5ttgen hsvs and then incorporate a WMH mask as a pathology image using 5ttedit.

I was able to generate3 the 5tt.mif easy enough, but when I try

5ttedit -path ${WMH_Mask} 5tt_t1space.mif 5tt_wmh.mif

I get a message that my mask

does not match 5TT image dimensions

Do I have to convert my WMH mask into a 5tt compatible format with 5tt2gmwmi? How is that done with tckgen? I saw that here.

Thanks for any help- apologies if I am being unclear or not understanding properly.


Hey @Caleb_Haynes ,

Your WMH mask needs to have the same matrix size and voxel dimensions as the 5TT image, to be able to merge these.

You should be able to do match the dimensions using mrgrid, with these steps:

  1. Obtain one volume from your 5TT as a reference
    mrconvert 5tt_t1space.mif -coord 3 0 -axes 0,1,2 5tt_t1space_gm.mif
  2. Regrid the WMH mask to the dimensions of the 5TT volume
    mrgrid ${WMH_Mask} regrid -template 5tt_t1space_gm.mif wmh_mask_t1space.mif
  3. Replace the 5th tissue type with this volume instead
    5ttedit -path wmh_mask_t1space.mif 5tt_t1space.mif 5tt_wmh.mif

Hope this helps,


This is great help, thank you so much. If I wanted to have my output in dMRI space instead of T1 space, would I have to register each image in the 5tt stack? Or would I change how I generate the 5tt image?

Hi Caleb,

For your original question:

I encountered the same issue a couple of days ago with adding a manually edited ROI on the diffusion scan to the 5tt file. I used mrtransform. If I have to rewrite based on the question:
mrtransform ${WMH_Mask} -template 5tt_t1space.mif ${WMH_Mask}_transformed.mif
I think it is much faster than regridding.

For your current question:
By “my output in dMRI space” which output are you referring to? This 5tt to dMRI registration is an important issue and the solution in BATMAN Tutorial page 16 works almost fine for most of the data, however, in my experience using epi_reg have been a better option. If you follow the guidelines there, you can use the transform matrix generated for T1 to dMRI to also bring the lesion/WMH to the dMRI space using mrtransform WMH.mif -linear diff2struct_mrtrix.txt -inverse WMH_in_dmri.mif


1 Like

Thank you for your detailed response Amir, this gives me a lot to think about. I will compare your mrtransform approach with the mrregrid one above, that looks useful.

The BATMAN tutorial looks great, I’m going to see if my advisor thinks I should change how I was registering the 4tt to dMRI to match this workflow - it looks pretty neat. epi_reg is something I’ll have to look into more, I haven’t used that before.

Of course. So I am writing down the suggested step for epi_reg below, just in case your PI wants to change the registration method.

The common workflow in registering the 5tt to dMRI involves two steps in brief:

  1. Registering the mean b0 of the preprocessed file to the T1 using FSL FLIRT (or in my case epi_reg)
  2. Use the inverse of the generated transform matrix to bring the 5tt from T1 space to dMRI

The difference between FLIRT and epi_reg is that the latter is specific for EPI acquisitions (most dMRI fMRI) registration. See here.

As an example:
epi_reg --epi=mean_b0.nii.gz --t1=T1.nii.gz --t1brain=T1_bet.nii.gz --out=diff2struct_fsl
The only difference with BATMAN is that you have to use epi_reg instead of the flirt command on the third line. If you have used 5ttgen hsvs you have definitely done recon-all by FreeSurfer. For --t1brain you can pass brain.mgz file in the $SUBJECTS_DIR/$subjid/mri/ folder (after converting to .nii.gz). Of note, since you are working on pathological data, you have to double-check the results (for each case maybe) with the registration results whatever method you are using.


1 Like