rafaelnh / gibbs-removal Goto Github PK
View Code? Open in Web Editor NEWIn this repository, I am sharing an algorithm to suppress Gibbs artefact.
In this repository, I am sharing an algorithm to suppress Gibbs artefact.
Hi,
Thanks for the codes. But there seems to be an issue with indexing. I tired to run GIBBSremoval_in_DWI.ipynb and in cell#2, I've got this error:
`
TypeError Traceback (most recent call last)
in ()
28
29 # Correct gibbs
---> 30 image_cor, tv = gibbs_removal_2d(image_gibbs)
31
32 # plot
/mysystem/gibbs-removal-master/gibbs_removal.py in gibbs_removal_2d(image, fn, nn, G0, G1)
270 G0, G1 = gibbs_removal_2d_weigthing_functions(image.shape)
271
--> 272 img_c1, tv_c1 = gibbs_removal_1d(image, a=1, fn=fn, nn=nn)
273 img_c0, tv_c0 = gibbs_removal_1d(image, a=0, fn=fn, nn=nn)
274
/mysystem/gibbs-removal-master/gibbs_removal.py in gibbs_removal_1d(x, a, fn, nn)
145
146 # TV for shift zero (baseline)
--> 147 TVR, TVL = image_tv(x, fn=fn, nn=nn, a=a)
148 TVP = np.minimum(TVR, TVL)
149 TVN = TVP.copy()
/mysystem/gibbs-removal-master/gibbs_removal.py in image_tv(x, fn, nn, a)
95 NTV = np.absolute(xs[:, (nn+fn):(-nn-fn)] - xs[:, (nn+fn-1):(-nn-fn-1)])
96 for n in np.linspace(fn+1, nn-2, num=nn-2):
---> 97 PTV = PTV + np.absolute(xs[:, (nn+fn+n):(-nn-fn+n)] -
98 xs[:, (nn+fn+n+1):(-nn-fn+n+1)])
99 NTV = NTV + np.absolute(xs[:, (nn+fn-n):(-nn-fn-n)] - \
TypeError: slice indices must be integers or None or have an index method`
This was caused by that the way you genereated the iteration list for n using np.linspace, of which the output is a float ndarray, thus n is also a float, but for indexing it must be an integer. So just
for n in np.linspace(fn+1, nn-2, num=nn-2, dtype=int):
fixed the issue. I'm not familiar with python, so I guess this might be something to do with the python2 and python3? I used anaconda-packaged python3, so this might have return an integer ndarray without specifying dtype?
Thanks for implementing this in python, I'm trying some tests and getting a failure:
> import gibbs_removal
> import SimpleITK as sitk
> image = sitk.ReadImage("../unring/fsl/brain1_t2_1.nii")
> imagedata = sitk.GetArrayFromImage(image)
> print(imagedata.shape)
(555, 487, 548)
>
dering = gibbs_removal.gibbs_removal(imagedata)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-14-f26ec4e4264c> in <module>
----> 1 dering = gibbs_removal.gibbs_removal(imagedata)
/scratch/gibbs-removal/gibbs_removal.py in gibbs_removal(vol, slice_axis, n_points)
317 # Produce weigthing functions for 2D gibbs removal
318 shap = vol.shape
--> 319 G0, G1 = _weights(shap[:2])
320
321 # Run gibbs removal of 2D images
/scratch/gibbs-removal/gibbs_removal.py in _weights(shape)
187 cosk0 = 1.0 + np.cos(K0)
188 cosk1 = 1.0 + np.cos(K1)
--> 189 G1[1:-1, 1:-1] = cosk0 / (cosk0+cosk1)
190 G0[1:-1, 1:-1] = cosk1 / (cosk0+cosk1)
191
ValueError: could not broadcast input array from shape (553,553) into shape (553,485)
> conda list | grep numpy
numpy 1.16.2 py37h7e9f1db_0
numpy-base 1.16.2 py37hde5b4d6_0
numpydoc 0.8.0 py37_0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.