Is there any command that used to generatewhite matter mask based on a T1 weighted image (or based on other parcellation images) in Mrtrix?
I found it that there’re two commands associated with mask generation.
dwi2mask — It is used to generate a whole brain mask from a DWI image.
5tt2gmwmi — Generate a mask image appropriate for seeding streamlines on the grey matter-white matter interface
For Mrtrix is able to create GM-WM Interface, there should have some methods to generate WM mask based on a T1 image.
Moreover, dwi2response dhollander is able to estimate of WM, GM, and CSF response functions; does not require a T1 image (or segmentation thereof). There may have some method to estimate WM mask without a T1 image.
Your best bet here is to use the output of 5ttgen, and extract the 3rd volume (e.g. mrconvert -coord 3 2 5tt.mif wm.nii) - see the 5TT format documentation for details. All the other commands you mention operate from the DWI data, and so can’t be used to do what you’re asking.
Note that 5ttgen is actually a script that will invoke FSL or FreeSurfer to segment the T1 - MRtrix3 does not itself include bespoke methods for T1 segmentation.
reduce 4D image to 3D image: mrmath t1_mpr_ns_sag_iso_5TT_nocrop_WM.nii.gz mean -axis 3 t1_mpr_ns_sag_iso_5TT_nocrop_WM_axis3.nii.gz
It’s cleaner to do this in a single step: mrconvert -coord 3 2 -axes 0,1,2 t1_mpr_ns_sag_iso_5TT_nocrop.mif t1_mpr_ns_sag_iso_5TT_nocrop_WM.nii.gz
The problem is that: [ERROR] input images do not have the same number of dimensions.
It’s not clear what command you are actually running here that’s producing this error. But yes, while in some contexts it is not necessary for two images to be defined on the same voxel grid, in others it is. In particular if a mask is being used to affect which DWI voxels are processed and which are not, this intrinsically requires that the mask be defined on the same voxel grid as the DWIs, so that the mask provides a “1” or “0” for each voxel. This is tpically achieved using the -template option in mrtransform.