
Hi all, We face this issue commonly where the tensor image doesn't look as expected and the MD image is empty. For the same data, FSL creates perfect tensors and MD images. May I know if we are doing something wrong? data, affine = load_nifti(os.path.join(os.getcwd(), '_AXIAL_DTI_MDDW_20230421090830_32.nii')) bvals, bvecs = read_bvals_bvecs(os.path.join(os.getcwd(), '_AXIAL_DTI_MDDW_20230421090830_32.bval'), os.path.join(os.getcwd(), '_AXIAL_DTI_MDDW_20230421090830_32.bvec')) gtab = gradient_table(bvals, bvecs) image_mask, mask_affine = load_nifti(os.path.join(os.getcwd(), 'brain_mask_warped.nii.gz')) tensor_model = dti.TensorModel(gtab) tensor=tensor_model.fit(data, mask=image_mask) FA = fractional_anisotropy(tensor.evals) FA[np.isnan(FA)] = 0 tensor_vals = dti.lower_triangular(tensor.quadratic_form) save_nifti( os.path.join(os.getcwd(), 'tensor.nii.gz'), tensor_vals, affine) save_nifti( os.path.join(os.getcwd(), 'FA.nii.gz'), FA, affine) [image: image.png][image: image.png] Madhura

Hi Madhura, Concerning the tensor images, it depends on your combination of viewer + diffusion imaging tool. Every software saves the diffusion tensor elements in different lower triangular order. For examples: - DIPY order: [Dxx, Dxy, Dyy, Dxz, Dyz, Dzz]. See: https://github.com/dipy/dipy/blob/master/dipy/reconst/dti.py#L1639 - MRTRIX order: [Dxx, Dyy, Dzz, Dxy, Dxz, Dyz] See: https://mrtrix.readthedocs.io/en/dev/reference/commands/dwi2tensor.html - ANTS: [Dxx, Dxy, Dyy, Dxz, Dyz, Dzz]. See: https://github.com/ANTsX/ANTs/wiki/Importing-diffusion-tensor-data-from-othe... - FSL: [Dxx, Dxy, Dxz, Dyy, Dyz, Dzz] Ref: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FDT/UserGuide So, you need to know in which order you save your diffusion tensor and what order the viewer is expecting to visualize it correctly. you can convert from one order to another with DIPY, see here : https://docs.dipy.org/stable/recipes I hope it helps. Serge Koudoro Software Developer Intelligent Systems Engineering Garyfallidis Research Group<https://grg.luddy.indiana.edu/> School of Informatics, Computing, and Engineering Luddy Hall 700 N Woodlawn Ave, 4056 Bloomington, IN 47408 skoudoro@iu.edu<mailto:skoudoro@indiana.edu> ________________________________ From: madhura ingalhalikar <mingalhalikar@gmail.com> Sent: Wednesday, May 22, 2024 11:39 AM To: dipy@python.org <dipy@python.org> Subject: [External] [DIPY] weird tensor images, empty MD images You don't often get email from mingalhalikar@gmail.com. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification> This message was sent from a non-IU address. Please exercise caution when clicking links or opening attachments from external sources. Hi all, We face this issue commonly where the tensor image doesn't look as expected and the MD image is empty. For the same data, FSL creates perfect tensors and MD images. May I know if we are doing something wrong? data, affine = load_nifti(os.path.join(os.getcwd(), '_AXIAL_DTI_MDDW_20230421090830_32.nii')) bvals, bvecs = read_bvals_bvecs(os.path.join(os.getcwd(), '_AXIAL_DTI_MDDW_20230421090830_32.bval'), os.path.join(os.getcwd(), '_AXIAL_DTI_MDDW_20230421090830_32.bvec')) gtab = gradient_table(bvals, bvecs) image_mask, mask_affine = load_nifti(os.path.join(os.getcwd(), 'brain_mask_warped.nii.gz')) tensor_model = dti.TensorModel(gtab) tensor=tensor_model.fit(data, mask=image_mask) FA = fractional_anisotropy(tensor.evals) FA[np.isnan(FA)] = 0 tensor_vals = dti.lower_triangular(tensor.quadratic_form) save_nifti( os.path.join(os.getcwd(), 'tensor.nii.gz'), tensor_vals, affine) save_nifti( os.path.join(os.getcwd(), 'FA.nii.gz'), FA, affine) [image.png][image.png] Madhura

Hi Serge, thanks for your quick response. I understand what you mean, however even the Dxx image from dipy is empty and that concerns me. This has been the case for 3 cases we tested. Is there any reason that would happen? Madhura On Thu, May 23, 2024 at 9:18 AM Koudoro, Serge <skoudoro@iu.edu> wrote:

Hi Madhura, Concerning the tensor images, it depends on your combination of viewer + diffusion imaging tool. Every software saves the diffusion tensor elements in different lower triangular order. For examples: - DIPY order: [Dxx, Dxy, Dyy, Dxz, Dyz, Dzz]. See: https://github.com/dipy/dipy/blob/master/dipy/reconst/dti.py#L1639 - MRTRIX order: [Dxx, Dyy, Dzz, Dxy, Dxz, Dyz] See: https://mrtrix.readthedocs.io/en/dev/reference/commands/dwi2tensor.html - ANTS: [Dxx, Dxy, Dyy, Dxz, Dyz, Dzz]. See: https://github.com/ANTsX/ANTs/wiki/Importing-diffusion-tensor-data-from-othe... - FSL: [Dxx, Dxy, Dxz, Dyy, Dyz, Dzz] Ref: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FDT/UserGuide So, you need to know in which order you save your diffusion tensor and what order the viewer is expecting to visualize it correctly. you can convert from one order to another with DIPY, see here : https://docs.dipy.org/stable/recipes I hope it helps. Serge Koudoro Software Developer Intelligent Systems Engineering Garyfallidis Research Group<https://grg.luddy.indiana.edu/> School of Informatics, Computing, and Engineering Luddy Hall 700 N Woodlawn Ave, 4056 Bloomington, IN 47408 skoudoro@iu.edu<mailto:skoudoro@indiana.edu> ________________________________ From: madhura ingalhalikar <mingalhalikar@gmail.com> Sent: Wednesday, May 22, 2024 11:39 AM To: dipy@python.org <dipy@python.org> Subject: [External] [DIPY] weird tensor images, empty MD images You don't often get email from mingalhalikar@gmail.com. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification> This message was sent from a non-IU address. Please exercise caution when clicking links or opening attachments from external sources. Hi all, We face this issue commonly where the tensor image doesn't look as expected and the MD image is empty. For the same data, FSL creates perfect tensors and MD images. May I know if we are doing something wrong? data, affine = load_nifti(os.path.join(os.getcwd(), '_AXIAL_DTI_MDDW_20230421090830_32.nii')) bvals, bvecs = read_bvals_bvecs(os.path.join(os.getcwd(), '_AXIAL_DTI_MDDW_20230421090830_32.bval'), os.path.join(os.getcwd(), '_AXIAL_DTI_MDDW_20230421090830_32.bvec')) gtab = gradient_table(bvals, bvecs) image_mask, mask_affine = load_nifti(os.path.join(os.getcwd(), 'brain_mask_warped.nii.gz')) tensor_model = dti.TensorModel(gtab) tensor=tensor_model.fit(data, mask=image_mask) FA = fractional_anisotropy(tensor.evals) FA[np.isnan(FA)] = 0 tensor_vals = dti.lower_triangular(tensor.quadratic_form) save_nifti( os.path.join(os.getcwd(), 'tensor.nii.gz'), tensor_vals, affine) save_nifti( os.path.join(os.getcwd(), 'FA.nii.gz'), FA, affine) [image.png][image.png] Madhura

Hi Serge, thanks for your quick response. I understand what you mean, however even the Dxx image from dipy is empty and that concerns me. This has been the case for 3 cases we tested. Is there any reason that would happen? Madhura On Thu, May 23, 2024 at 9:18 AM Koudoro, Serge <skoudoro@iu.edu> wrote:
participants (2)
-
Koudoro, Serge
-
madhura ingalhalikar