Reg. IVIM processing using DIPY
Dear Experts, I tried to process ivim data by following https://www.frontiersin.org/articles/10.3389/fninf.2014.00008/full and https://dipy.org/documentation/1.1.1./examples_built/reconst_ivim/. However, I am unable to get output. I will be highly obliged if you can examine the log below and advice. Best Regards, Amitkumar J. Choudhari, Assistant Professor, Dept. of Radiology, Tata Memorial Hospital, Mumbai.
fimg = "dwi.nii.gz" import nibabel as nib img = nib.load(fimg) data = img.get_data() <stdin>:1: DeprecationWarning: get_data() is deprecated in favor of get_fdata(), which has a more predictable return type. To obtain get_data() behavior going forward, use numpy.asanyarray(img.dataobj).
* deprecated from version: 3.0 * Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 5.0
data.shape (176, 176, 23, 43) affine = img.get_affine() <stdin>:1: DeprecationWarning: get_affine method is deprecated. Please use the ``img.affine`` property instead.
* deprecated from version: 2.1 * Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 4.0
header = img.get_header() <stdin>:1: DeprecationWarning: get_header method is deprecated. Please use the ``img.header`` property instead.
* deprecated from version: 2.1 * Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 4.0
header = img.get_header()
voxel_size = header.get_zooms()[:3] voxel_size
(1.3068181, 1.3068181, 6.0)
S0 = data[:, :, :, 0] img2 = nib.Nifti1Image(S0, affine) nib.save (img2, "sub_data.nii.gz") from dipy.segment.mask import median_otsu mask, S0_mask = median_otsu(data [:, :, :, 0]) fbval = "dwi.bval" fbvec = "dwi.bvec" from dipy.io<http://dipy.io/> import read_bvals_bvecs bvals, bvecs = read_bvals_bvecs(fbval, fbvec) from dipy.core.gradients import gradient_table gtab = gradient_table(bvals, bvecs) gtab <dipy.core.gradients.GradientTable object at 0x7f7265d78820> import matplotlib.pyplot as plt import numpy as np from dipy.reconst.ivim import IvimModel from dipy.data import get_fnameshttps://dipy.org/documentation/1.1.1./examples_built/reconst_ivim/<http://dipy.org/documentation/1.1.1./examples_built/reconst_ivim/> from dipy.io.image import load_nifti_data fraw, fbval, fbvec = get_fnames('ivim') Download Progress: [########################################] 100.00% of 0.00 MB>>> data = img.get_data() <stdin>:1: DeprecationWarning: get_data() is deprecated in favor of get_fdata(), which has a more predictable return type. To obtain get_data() behavior going forward, use numpy.asanyarray(img.dataobj).
* deprecated from version: 3.0 * Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 5.0
bvals, bvecs = read_bvals_bvecs(fbval, fbvec) gtab = gradient_table(bvals, bvecs, b0_threshold=0) print('data.shape (%d, %d, %d, %d)' % data.shape) data.shape (176, 176, 23, 43) z = 12 b = 0 plt.imshow(data[:, :, z, b].T, origin='lower', cmap='gray', ... interpolation='nearest') <matplotlib.image.AxesImage object at 0x7f723009d5e0> plt.axhline(y=100) <matplotlib.lines.Line2D object at 0x7f7233b643a0> plt.axvline(x=170) <matplotlib.lines.Line2D object at 0x7f723009dd00> plt.savefig("ivim_data_slice.png") plt.close() ivimmodel = IvimModel(gtab, fit_method='trr') /home/amitjc/.local/lib/python3.8/site-packages/dipy/reconst/ivim.py:147: UserWarning: Bounds for this fit have been set from experiments and literature survey. To change the bounds, please input your bounds in model definition... warnings.warn(bounds_warning, UserWarning) x1, x2 = 50, 125 y1, y2 = 40, 140 data_slice = data[x1:x2, y1:y2, z, :] plt.imshow(data[x1:x2, y1:y2, z, b].T, origin='lower', ... cmap="gray", interpolation='nearest') <matplotlib.image.AxesImage object at 0x7f72232b7c70> plt.savefig("CSF_slice.png") plt.close() ivimmodel = IvimModel(gtab, fit_method='trr') ivimfit = ivimmodel.fit(data_slice) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/amitjc/.local/lib/python3.8/site-packages/dipy/reconst/multi_voxel.py", line 33, in new_fit fit_array[ijk] = single_voxel_fit(self, data[ijk]) File "/home/amitjc/.local/lib/python3.8/site-packages/dipy/reconst/ivim.py", line 317, in fit S0_prime, D = self.estimate_linear_fit( File "/home/amitjc/.local/lib/python3.8/site-packages/dipy/reconst/ivim.py", line 377, in estimate_linear_fit -np.log(data[self.gtab.bvals >= IndexError: boolean index did not match indexed array along dimension 0; dimension is 43 but corresponding boolean dimension is 21
participants (1)
-
Amit Choudhari