// Threshold GM to binary in dwi space
thr_img = nib.load(self.gm_in_dwi)
np.asarray(thr_img.dataobj)[np.asarray(thr_img.dataobj) < 0.2] = 0
nib.save(thr_img, self.gm_in_dwi_bin)
// Threshold CSF to binary in dwi space
After Change
// Threshold WM to binary in dwi space
thr_img = nib.load(self.wm_in_dwi)
thr_img = math_img("img > 0.1", img=thr_img)
nib.save(thr_img, self.wm_in_dwi_bin)
// Threshold GM to binary in dwi space
thr_img = nib.load(self.gm_in_dwi)