dwi2mask: Fix segfault with -fslgrad
dwi2mask: Fix segfault with -fslgrad

If dwi2mask is run with the -fslgrad option, this leads to a segmentation fault when constructing the output mask image. check_DW_scheme() is called within a try{} block to determine whether or not any present gradient table should be cleared upon image creation. However the fourth axis is stripped from the DWI header in order to construct this output image header. Within the check_DW_scheme() function, the load_bvecs_bvals() function is called. This function however fails to test whether or not the template header is a 4D image prior to obtaining the number of volumes and comparing this to the number of columns in bvecs / bvals, which leads to a buffer over-run.

MRtrix3/mrtrix3,MRtrix3/mrtrix3,MRtrix3/mrtrix3,MRtrix3/mrtrix3,MRtrix3/mrtrix3,MRtrix3/mrtrix3