-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] DKI ODF redux #2304
base: master
Are you sure you want to change the base?
[WIP] DKI ODF redux #2304
Conversation
Hello @arokem, Thank you for updating !
Comment last updated at 2021-10-07 18:28:52 UTC |
I think I got it all this time! 😅 |
Hi @arokem, Do you plan to clean a bit this PR before a review? is it still WIP? After a really quick look, I saw some |
Yes. This is still wip!
…On Thu, Dec 3, 2020 at 5:36 PM Serge Koudoro ***@***.***> wrote:
Hi @arokem <https://github.com/arokem>,
Do you plan to clean a bit this PR before a review? is it still WIP? After
a really quick look, I saw some fvtk so I suppose it might have some old
function too. Let us know when it is ready for review!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2304 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA46NUNSCYVQ4EVS6NPA7DSTA4LFANCNFSM4UMYHKLA>
.
|
OK - this is no longer WIP - ready for a review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @arokem,
Here a quick first review. I still need to render locally the example, run the tests, and look deeper at the code.
Thanks!
dipy/reconst/dki.py
Outdated
The DKI-ODF is calculated in the vertices of this input. | ||
alpha : float, optional | ||
radial weighting power. Default is 4 according to [Jen2014]_ and | ||
[Raf2015] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing the underscore [Raf2015]_
dipy/reconst/dki.py
Outdated
normalize_peaks=False, npeaks=3, gtol=1e-5): | ||
""" Estimation of fiber directions based on diffusion kurtosis imaging | ||
(DKI). Fiber directions are estimated as the maxima of the DKI | ||
orientation distribution function [Jen2014]. This function is based on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing the underscore [Jen2014]_
dipy/reconst/dki.py
Outdated
return dki_directions(self.model_params, sphere, alpha=4, | ||
relative_peak_threshold=0.1, | ||
min_separation_angle=20, mask=None, | ||
return_odf=False, normalize_peaks=False, | ||
npeaks=3, gtol=1e-5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a problem here. alpha=alpha, relative_peak_threshold=relative_peak_threshold, etc...
instead
dipy/reconst/dki.py
Outdated
kODF = np.zeros((len(kt), len(V))) | ||
|
||
# select non-zero voxels | ||
# (when #677 is merged replace this code lines by function _positive_evals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is merged so this comment can be removed
dipy/reconst/dki.py
Outdated
normalize_peaks=False, npeaks=3, gtol=1e-5): | ||
""" Estimation of fiber direction based on diffusion kurtosis imaging | ||
(DKI). Fiber directions are estimated as the maxima of the orientation | ||
distribution function [Jen2014]. This function is based on the work done by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing underscore [Jen2014]_
dipy/reconst/dki.py
Outdated
relative_peak_threshold : float, optional | ||
Only return peaks greater than ``relative_peak_threshold * m`` where m | ||
is the largest peak. | ||
min_separation_angle : float in [0, 90], optinal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, optional
doc/examples/dki_tractography.py
Outdated
affine = img.affine | ||
|
||
""" | ||
Having the acquition paramenters of the loaded data, we can define the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, parameters and acquisition
doc/examples/dki_tractography.py
Outdated
tensors = tensors.reshape((5, 2, 1, len(sphere.vertices))) | ||
tensors_actor = actor.odf_slicer(tensors, sphere=sphere, scale=0.5) | ||
scene.add(tensors_actor) | ||
window.show(scene) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc generation will block.
if interactive=True:
window.show(scene)
doc/examples/dki_tractography.py
Outdated
ODF = ODF.reshape((5, 1, 1, len(sphere.vertices)), order='F') | ||
odf_actor = actor.odf_slicer(ODF, sphere=sphere, scale=0.5) | ||
scene.add(tensors_actor) | ||
window.show(scene) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc generation will block
if interactive=True:
window.show(scene)
doc/examples/dki_tractography.py
Outdated
den = img.get_fdata() | ||
else: | ||
den = patch2self(data, gtab.bvals) | ||
nib.save(nib.Nifti1Image(den, affine), 'denoised_cenir_multib.nii.gz') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you use save_nifti
function (from dipy.io.image import load_nifti, save_nifti
)
Also, could you fix the pep8 issues |
Thanks for the review @skoudoro ! I think that I've addressed the comments in the recent commit. |
Thank you for the update! @ShreyasFadnavis, Can you check this PR too? thank you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @arokem,
- Can you add your examples in
valid_examples.txt
andexamples_index.rst
. - Running the tutorial takes all my resources (memory, etc...) and freeze my laptop. It does not seem normal to me. So, it needs further introspection, or do you have an explanation?
- Furthermore, the tutorial is super long to run! more than 1 hour on my laptop for 1 tutorial. This is really too long. there are 80 tutorials during doc generation. You might want to reduce the data size. I did not check which step take all this time.
- Concerning the math part, I will let someone else have the last look.
for v in range(len(five_voxel_angles)): | ||
angles = five_voxel_angles[v] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's be more pythonic by using
for idx, angles in enumerate(five_voxel_angles):
signal_dki[idx], ....
|
||
# convert fiber directions ground truth angles to Cartesian coordinates | ||
gt_dir = np.zeros((5, 1, 2, 3)) | ||
for d in range(5): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we do not iterate over five_voxel_angles
for more clarity
|
||
Parameters | ||
---------- | ||
sphere : Sphere class instance, optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional
to remove
kODFi = kODF[rel_i] | ||
|
||
# loop over all relevant voxels | ||
for vox in range(len(kt)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
range(len(
is not recommended in general. There are many alternatives more pythonic.
|
||
# loop over all directions | ||
sampledODF = np.zeros(len(V)) | ||
for i in range(len(V)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above
range(len(
is not recommended in general. There are many alternatives more pythonic.
# loop over all relevant voxels | ||
for vox in range(len(kt)): | ||
# Compute dimensionless tensor U | ||
R = evecs[vox] | ||
dt = np.dot(np.dot(R, np.diag(evals[vox])), R.T) | ||
MD = (dt[0, 0] + dt[1, 1] + dt[2, 2]) / 3 | ||
U = np.linalg.pinv(dt) * MD | ||
|
||
# loop over all directions | ||
sampledODF = np.zeros(len(V)) | ||
for i in range(len(V)): | ||
sampledODF[i] = _dki_odf_core(V[i], kt[vox], U, alpha) | ||
|
||
kODFi[vox] = sampledODF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be good to review this block. I think this whole block can be managed more efficiently.
normalize_peaks=False, npeaks=3, gtol=1e-5): | ||
""" Estimation of fiber direction based on diffusion kurtosis imaging | ||
(DKI). Fiber directions are estimated as the maxima of the orientation | ||
distribution function [Jen2014]_. This function is based on the work done by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pep8: it should stop at done
Also, Do you plan to use this opportunity to fix #1773 (option to invert the signal in DKI WMTI)? |
Hi @arokem, Do you think you can finalize this for the next release, 1 week from now, or should I move it for the release in June? |
Sorry. I am swamped right now. Let’s push back to next cycle. I don’t think
this is too urgent.
…On Fri, Apr 16, 2021 at 8:13 AM Serge Koudoro ***@***.***> wrote:
Hi @arokem <https://github.com/arokem>,
Do you think you can finalize this for the next release, 1 week from now,
or should I move it for the release in June?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2304 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA46NTCYUNAUB4OADTHV7TTJBHZLANCNFSM4UMYHKLA>
.
|
ok, no problem, thanks! |
…Wcons which is being revised in PR dipy#677. I am adding here this function to carry with thr dki-odf test. However when the 2 pull requests are merged we have to insure that duplicates of this function are removed
… was added on the sample of usage script.
… corrections in previous parts
…only this was computed before
…ODFs in the example
Hi @arokem, What is the status of this PR? How is your schedule? Do you plan to come back on it? |
1419292
to
ca6268a
Compare
5935e1e
to
765963e
Compare
This revisits the old #685, which I think we should incorporate.