error using new DKI features

Hi DIPY users, I got errors while using the new DKI "RESTORE" feature. After reading DWI data, mask image, bvecs and bvals files, here is what i did, sigma = ne.estimate_sigma(data) dki_restoremodel = dki.DiffusionKurtosisModel(gtab, fit_method='RESTORE', sigma=sigma) dkifit_restore = dki_restoremodel.fit(data, mask=mask) The error message, /home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dti.py:1891: RuntimeWarning: divide by zero encountered in true_divide params[vox, 12:] = this_param[6:-1] / md2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dki.py", line 1608, in fit *self.args, **self.kwargs) File "/home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dti.py", line 1862, in restore_fit_tensor Dfun=_nlls_jacobian_func) File "/home/yehp/anaconda3/lib/python3.7/site-packages/scipy/optimize/minpack.py", line 387, in leastsq raise TypeError('Improper input: N=%s must not exceed M=%s' % (n, m)) TypeError: Improper input: N=22 must not exceed M=19 Any suggestions? Thank you. Ping

Hey Ping, Thanks for reporting. How did you calculate the sigma? This looks like something that would happen if sigma is "too small". Cheers, Ariel On Thu, Jan 16, 2020 at 12:03 PM Ping-Hong Yeh <pinghongyeh@gmail.com> wrote:

Hi Ariel, Thanks for the prompt reply. I used the whole DWI data to estimate sigma, import dipy.denoise.noise_estimate as ne sigma = ne.estimate_sigma(data) ping On Thu, Jan 16, 2020 at 3:10 PM Ariel Rokem <arokem@gmail.com> wrote:

On Thu, Jan 16, 2020 at 12:24 PM Ping-Hong Yeh <pinghongyeh@gmail.com> wrote:
Yeah. That all seems fine. Another reason this could be happening is that the data in that voxel is funky: like all zeros. Can you drop into the debugger and see what the signal values are in the voxel where this happens? If that is indeed the case, you might want to mask out voxels like that. Cheers, Ariel

Hi Ping, It might be a good idea to try the noise estimation from the Marcenko-Pastur PCA (MPPCA) algorithm instead of the NLMeans. ?So instead of doing: import dipy.denoise.noise_estimate as ne sigma = ne.estimate_sigma(data) You can use the sigma from MPPCA as follows: from dipy.denoise.localpca import mppca _, sigma = mppca(data, patch_radius=2, return_sigma=True) I guess this should work. If it does not, let us know and we can try to figure out another solution :) Regards, Shreyas ________________________________ From: Ariel Rokem <arokem@gmail.com> Sent: Friday, January 17, 2020 12:14 AM To: Ping-Hong Yeh Cc: dipy@python.org Subject: [External] [Dipy] Re: error using new DKI features This message was sent from a non-IU address. Please exercise caution when clicking links or opening attachments from external sources. On Thu, Jan 16, 2020 at 12:24 PM Ping-Hong Yeh <pinghongyeh@gmail.com<mailto:pinghongyeh@gmail.com>> wrote: Hi Ariel, Thanks for the prompt reply. I used the whole DWI data to estimate sigma, import dipy.denoise.noise_estimate as ne sigma = ne.estimate_sigma(data) Yeah. That all seems fine. Another reason this could be happening is that the data in that voxel is funky: like all zeros. Can you drop into the debugger and see what the signal values are in the voxel where this happens? If that is indeed the case, you might want to mask out voxels like that. Cheers, Ariel ping On Thu, Jan 16, 2020 at 3:10 PM Ariel Rokem <arokem@gmail.com<mailto:arokem@gmail.com>> wrote: Hey Ping, Thanks for reporting. How did you calculate the sigma? This looks like something that would happen if sigma is "too small". Cheers, Ariel On Thu, Jan 16, 2020 at 12:03 PM Ping-Hong Yeh <pinghongyeh@gmail.com<mailto:pinghongyeh@gmail.com>> wrote: Hi DIPY users, I got errors while using the new DKI "RESTORE" feature. After reading DWI data, mask image, bvecs and bvals files, here is what i did, sigma = ne.estimate_sigma(data) dki_restoremodel = dki.DiffusionKurtosisModel(gtab, fit_method='RESTORE', sigma=sigma) dkifit_restore = dki_restoremodel.fit(data, mask=mask) The error message, /home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dti.py:1891: RuntimeWarning: divide by zero encountered in true_divide params[vox, 12:] = this_param[6:-1] / md2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dki.py", line 1608, in fit *self.args, **self.kwargs) File "/home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dti.py", line 1862, in restore_fit_tensor Dfun=_nlls_jacobian_func) File "/home/yehp/anaconda3/lib/python3.7/site-packages/scipy/optimize/minpack.py", line 387, in leastsq raise TypeError('Improper input: N=%s must not exceed M=%s' % (n, m)) TypeError: Improper input: N=22 must not exceed M=19 Any suggestions? Thank you. Ping _______________________________________________ Dipy mailing list -- dipy@python.org<mailto:dipy@python.org> To unsubscribe send an email to dipy-leave@python.org<mailto:dipy-leave@python.org> https://mail.python.org/mailman3/lists/dipy.python.org/

Hi Shreyas, Thanks for the suggestion. I have tried _, sigma = mppca(data, patch_radius=2, return_sigma=True) ,bu it failed with errors, ValueError: You asked for PCA denoising with a patch_radius of 2 for data with 289 directions. This would result in an ill-conditioned PCA matrix. Please increase the patch_radius. We have three-shells DWI (90 directions) plus several b0, adding up 289 volumes. I've increased the path_radius to 4, or should only non-diffusion b0 be used to estimate sigma? Thanks. Ping On Mon, Jan 20, 2020 at 10:44 AM Fadnavis, Shreyas Sanjeev <shfadn@iu.edu> wrote:

Hi Ping. ? I have tried _, sigma = mppca(data, patch_radius=2, return_sigma=True) ,bu it failed with errors, ValueError: You asked for PCA denoising with a patch_radius of 2 for data with 289 directions. This would result in an ill-conditioned PCA matrix. Please increase the patch_radius. We have three-shells DWI (90 directions) plus several b0, adding up 289 volumes. I've increased the path_radius to 4, or should only non-diffusion b0 be used to estimate sigma?
You can feed MPPCA with the 4D DWI data as is (i.e. b0 included) and do not need to segregate b0 volumes. 289 volumes seems high though. What does the range of b-values look like? Did the `sigma` obtained from patch_radius 4 work?
Regards, Shreyas On Mon, Jan 20, 2020 at 10:44 AM Fadnavis, Shreyas Sanjeev <shfadn@iu.edu<mailto:shfadn@iu.edu>> wrote: Hi Ping, It might be a good idea to try the noise estimation from the Marcenko-Pastur PCA (MPPCA) algorithm instead of the NLMeans. ?So instead of doing: import dipy.denoise.noise_estimate as ne sigma = ne.estimate_sigma(data) You can use the sigma from MPPCA as follows: from dipy.denoise.localpca import mppca _, sigma = mppca(data, patch_radius=2, return_sigma=True) I guess this should work. If it does not, let us know and we can try to figure out another solution :) Regards, Shreyas ________________________________ From: Ariel Rokem <arokem@gmail.com<mailto:arokem@gmail.com>> Sent: Friday, January 17, 2020 12:14 AM To: Ping-Hong Yeh Cc: dipy@python.org<mailto:dipy@python.org> Subject: [External] [Dipy] Re: error using new DKI features This message was sent from a non-IU address. Please exercise caution when clicking links or opening attachments from external sources. On Thu, Jan 16, 2020 at 12:24 PM Ping-Hong Yeh <pinghongyeh@gmail.com<mailto:pinghongyeh@gmail.com>> wrote: Hi Ariel, Thanks for the prompt reply. I used the whole DWI data to estimate sigma, import dipy.denoise.noise_estimate as ne sigma = ne.estimate_sigma(data) Yeah. That all seems fine. Another reason this could be happening is that the data in that voxel is funky: like all zeros. Can you drop into the debugger and see what the signal values are in the voxel where this happens? If that is indeed the case, you might want to mask out voxels like that. Cheers, Ariel ping On Thu, Jan 16, 2020 at 3:10 PM Ariel Rokem <arokem@gmail.com<mailto:arokem@gmail.com>> wrote: Hey Ping, Thanks for reporting. How did you calculate the sigma? This looks like something that would happen if sigma is "too small". Cheers, Ariel On Thu, Jan 16, 2020 at 12:03 PM Ping-Hong Yeh <pinghongyeh@gmail.com<mailto:pinghongyeh@gmail.com>> wrote: Hi DIPY users, I got errors while using the new DKI "RESTORE" feature. After reading DWI data, mask image, bvecs and bvals files, here is what i did, sigma = ne.estimate_sigma(data) dki_restoremodel = dki.DiffusionKurtosisModel(gtab, fit_method='RESTORE', sigma=sigma) dkifit_restore = dki_restoremodel.fit(data, mask=mask) The error message, /home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dti.py:1891: RuntimeWarning: divide by zero encountered in true_divide params[vox, 12:] = this_param[6:-1] / md2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dki.py", line 1608, in fit *self.args, **self.kwargs) File "/home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dti.py", line 1862, in restore_fit_tensor Dfun=_nlls_jacobian_func) File "/home/yehp/anaconda3/lib/python3.7/site-packages/scipy/optimize/minpack.py", line 387, in leastsq raise TypeError('Improper input: N=%s must not exceed M=%s' % (n, m)) TypeError: Improper input: N=22 must not exceed M=19 Any suggestions? Thank you. Ping _______________________________________________ Dipy mailing list -- dipy@python.org<mailto:dipy@python.org> To unsubscribe send an email to dipy-leave@python.org<mailto:dipy-leave@python.org> https://mail.python.org/mailman3/lists/dipy.python.org/

Hey Ping, Thanks for reporting. How did you calculate the sigma? This looks like something that would happen if sigma is "too small". Cheers, Ariel On Thu, Jan 16, 2020 at 12:03 PM Ping-Hong Yeh <pinghongyeh@gmail.com> wrote:

Hi Ariel, Thanks for the prompt reply. I used the whole DWI data to estimate sigma, import dipy.denoise.noise_estimate as ne sigma = ne.estimate_sigma(data) ping On Thu, Jan 16, 2020 at 3:10 PM Ariel Rokem <arokem@gmail.com> wrote:

On Thu, Jan 16, 2020 at 12:24 PM Ping-Hong Yeh <pinghongyeh@gmail.com> wrote:
Yeah. That all seems fine. Another reason this could be happening is that the data in that voxel is funky: like all zeros. Can you drop into the debugger and see what the signal values are in the voxel where this happens? If that is indeed the case, you might want to mask out voxels like that. Cheers, Ariel

Hi Ping, It might be a good idea to try the noise estimation from the Marcenko-Pastur PCA (MPPCA) algorithm instead of the NLMeans. ?So instead of doing: import dipy.denoise.noise_estimate as ne sigma = ne.estimate_sigma(data) You can use the sigma from MPPCA as follows: from dipy.denoise.localpca import mppca _, sigma = mppca(data, patch_radius=2, return_sigma=True) I guess this should work. If it does not, let us know and we can try to figure out another solution :) Regards, Shreyas ________________________________ From: Ariel Rokem <arokem@gmail.com> Sent: Friday, January 17, 2020 12:14 AM To: Ping-Hong Yeh Cc: dipy@python.org Subject: [External] [Dipy] Re: error using new DKI features This message was sent from a non-IU address. Please exercise caution when clicking links or opening attachments from external sources. On Thu, Jan 16, 2020 at 12:24 PM Ping-Hong Yeh <pinghongyeh@gmail.com<mailto:pinghongyeh@gmail.com>> wrote: Hi Ariel, Thanks for the prompt reply. I used the whole DWI data to estimate sigma, import dipy.denoise.noise_estimate as ne sigma = ne.estimate_sigma(data) Yeah. That all seems fine. Another reason this could be happening is that the data in that voxel is funky: like all zeros. Can you drop into the debugger and see what the signal values are in the voxel where this happens? If that is indeed the case, you might want to mask out voxels like that. Cheers, Ariel ping On Thu, Jan 16, 2020 at 3:10 PM Ariel Rokem <arokem@gmail.com<mailto:arokem@gmail.com>> wrote: Hey Ping, Thanks for reporting. How did you calculate the sigma? This looks like something that would happen if sigma is "too small". Cheers, Ariel On Thu, Jan 16, 2020 at 12:03 PM Ping-Hong Yeh <pinghongyeh@gmail.com<mailto:pinghongyeh@gmail.com>> wrote: Hi DIPY users, I got errors while using the new DKI "RESTORE" feature. After reading DWI data, mask image, bvecs and bvals files, here is what i did, sigma = ne.estimate_sigma(data) dki_restoremodel = dki.DiffusionKurtosisModel(gtab, fit_method='RESTORE', sigma=sigma) dkifit_restore = dki_restoremodel.fit(data, mask=mask) The error message, /home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dti.py:1891: RuntimeWarning: divide by zero encountered in true_divide params[vox, 12:] = this_param[6:-1] / md2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dki.py", line 1608, in fit *self.args, **self.kwargs) File "/home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dti.py", line 1862, in restore_fit_tensor Dfun=_nlls_jacobian_func) File "/home/yehp/anaconda3/lib/python3.7/site-packages/scipy/optimize/minpack.py", line 387, in leastsq raise TypeError('Improper input: N=%s must not exceed M=%s' % (n, m)) TypeError: Improper input: N=22 must not exceed M=19 Any suggestions? Thank you. Ping _______________________________________________ Dipy mailing list -- dipy@python.org<mailto:dipy@python.org> To unsubscribe send an email to dipy-leave@python.org<mailto:dipy-leave@python.org> https://mail.python.org/mailman3/lists/dipy.python.org/

Hi Shreyas, Thanks for the suggestion. I have tried _, sigma = mppca(data, patch_radius=2, return_sigma=True) ,bu it failed with errors, ValueError: You asked for PCA denoising with a patch_radius of 2 for data with 289 directions. This would result in an ill-conditioned PCA matrix. Please increase the patch_radius. We have three-shells DWI (90 directions) plus several b0, adding up 289 volumes. I've increased the path_radius to 4, or should only non-diffusion b0 be used to estimate sigma? Thanks. Ping On Mon, Jan 20, 2020 at 10:44 AM Fadnavis, Shreyas Sanjeev <shfadn@iu.edu> wrote:

Hi Ping. ? I have tried _, sigma = mppca(data, patch_radius=2, return_sigma=True) ,bu it failed with errors, ValueError: You asked for PCA denoising with a patch_radius of 2 for data with 289 directions. This would result in an ill-conditioned PCA matrix. Please increase the patch_radius. We have three-shells DWI (90 directions) plus several b0, adding up 289 volumes. I've increased the path_radius to 4, or should only non-diffusion b0 be used to estimate sigma?
You can feed MPPCA with the 4D DWI data as is (i.e. b0 included) and do not need to segregate b0 volumes. 289 volumes seems high though. What does the range of b-values look like? Did the `sigma` obtained from patch_radius 4 work?
Regards, Shreyas On Mon, Jan 20, 2020 at 10:44 AM Fadnavis, Shreyas Sanjeev <shfadn@iu.edu<mailto:shfadn@iu.edu>> wrote: Hi Ping, It might be a good idea to try the noise estimation from the Marcenko-Pastur PCA (MPPCA) algorithm instead of the NLMeans. ?So instead of doing: import dipy.denoise.noise_estimate as ne sigma = ne.estimate_sigma(data) You can use the sigma from MPPCA as follows: from dipy.denoise.localpca import mppca _, sigma = mppca(data, patch_radius=2, return_sigma=True) I guess this should work. If it does not, let us know and we can try to figure out another solution :) Regards, Shreyas ________________________________ From: Ariel Rokem <arokem@gmail.com<mailto:arokem@gmail.com>> Sent: Friday, January 17, 2020 12:14 AM To: Ping-Hong Yeh Cc: dipy@python.org<mailto:dipy@python.org> Subject: [External] [Dipy] Re: error using new DKI features This message was sent from a non-IU address. Please exercise caution when clicking links or opening attachments from external sources. On Thu, Jan 16, 2020 at 12:24 PM Ping-Hong Yeh <pinghongyeh@gmail.com<mailto:pinghongyeh@gmail.com>> wrote: Hi Ariel, Thanks for the prompt reply. I used the whole DWI data to estimate sigma, import dipy.denoise.noise_estimate as ne sigma = ne.estimate_sigma(data) Yeah. That all seems fine. Another reason this could be happening is that the data in that voxel is funky: like all zeros. Can you drop into the debugger and see what the signal values are in the voxel where this happens? If that is indeed the case, you might want to mask out voxels like that. Cheers, Ariel ping On Thu, Jan 16, 2020 at 3:10 PM Ariel Rokem <arokem@gmail.com<mailto:arokem@gmail.com>> wrote: Hey Ping, Thanks for reporting. How did you calculate the sigma? This looks like something that would happen if sigma is "too small". Cheers, Ariel On Thu, Jan 16, 2020 at 12:03 PM Ping-Hong Yeh <pinghongyeh@gmail.com<mailto:pinghongyeh@gmail.com>> wrote: Hi DIPY users, I got errors while using the new DKI "RESTORE" feature. After reading DWI data, mask image, bvecs and bvals files, here is what i did, sigma = ne.estimate_sigma(data) dki_restoremodel = dki.DiffusionKurtosisModel(gtab, fit_method='RESTORE', sigma=sigma) dkifit_restore = dki_restoremodel.fit(data, mask=mask) The error message, /home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dti.py:1891: RuntimeWarning: divide by zero encountered in true_divide params[vox, 12:] = this_param[6:-1] / md2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dki.py", line 1608, in fit *self.args, **self.kwargs) File "/home/yehp/anaconda3/lib/python3.7/site-packages/dipy/reconst/dti.py", line 1862, in restore_fit_tensor Dfun=_nlls_jacobian_func) File "/home/yehp/anaconda3/lib/python3.7/site-packages/scipy/optimize/minpack.py", line 387, in leastsq raise TypeError('Improper input: N=%s must not exceed M=%s' % (n, m)) TypeError: Improper input: N=22 must not exceed M=19 Any suggestions? Thank you. Ping _______________________________________________ Dipy mailing list -- dipy@python.org<mailto:dipy@python.org> To unsubscribe send an email to dipy-leave@python.org<mailto:dipy-leave@python.org> https://mail.python.org/mailman3/lists/dipy.python.org/
participants (3)
-
Ariel Rokem
-
Fadnavis, Shreyas Sanjeev
-
Ping-Hong Yeh