-
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
Single-shell Free Water DTI (Object Oriented) #2087
base: master
Are you sure you want to change the base?
Conversation
…ions necessary to perform Beltrami regularization. Added functions that convert the diffusion tensor components to the Iwasawa coordinate system. Also added the respective test functions to test_beltrami.py
…ld and d_manifold functions, to match the order used in dipys functions
1) removed redundant masking operations. 2) modified the functions to return an output (no need for pre-allocation).
Forward and backward differences of the Iwasawa coordinates will be used to compute the induced metric.
This function computes the Beltrami operator increments when the chosen metric is euclidean.
These functions compute the Levi-Civita terms for each Iwasawa coordinate, these terms are necessary to compute the Beltrami operator when the affine metric is chosen instead of the euclidean metric.
This function computes the Beltrami and Levi-Civita incremnts to update the Iwasawa coordinates when the affine metric is chosen, the computations are more complex than those of the euclidean metric. Note: When the euclidean metric is chosen, the beltrami_euclidean function is called instead. This function acts directly on the diffusion tensor coordinates (no need for Iwasawa conversion) and there is no need to compute the Levi-Civita terms.
This function computes the Fidelity increments to update the diffusion tensor components, it also computes the increment to update the tissue volume fraction. Note: Similarly to beltrami_euclidean, fidelity_euclidean acts directly on the diffusion tensor data (no Iwasawa parameterization) and the operations involved are simpler than its affine counterpart.
These auxiliary functions compute the matrix dot product q*DXi*q, where q is a single gradient direction and DXi denotes the diffusion tensor expressed in terms of the Iwasawa parameterization, differentiated with respect to Xi (the ith Iwasawa coordinate). The derivative is symbolic. These dot products are necessary to compute the Fidelity increments when the affine metric is chosen over the euclidean. Note: These functions compute the q*DXi*q products for all q.
This function computes the Fidelity increments to update the Iwasawa coordinates when the affine metric is chosen over the euclidean. This version of the fidelity function requires the symbolic derivatives of the diffusion tensor with respect to each Iwasawa coordinate, which are computed with the get_qDXiq functions (added in the previous commit).
This file calls the functions from reconst/beltrami.py to implemnt the main gradient descent routine and estimate the Free Water fraction, also, it deals with pre-processing of the raw data and initialization of the diffusion tensor and free water fraction. Note: Eventually the fucntions from this file should be integrated into the reconst/fwdti.py module.
This function deals with pre-processing the raw data and returns the normalized attenuations, which are necessary to initialize the diffusion tensor and free water fraction before performing the Beltrami routine.
This function estimates the initial guess for the diffusion tensor and tissue volume fraction, which are necessary before performing the Beltrami routine.
This is the main loop that performs the Beltrami routine and estimates the tissue volume fraction and corrected diffusion tensor, it combines all previously implemented functions in beltrami.py
This class treats the diffusion parameters as a manifold and holds the necessary methods and metrics to perfrom regularized gradient descent on the diffusion parameters.
These methods are ncessary to compute the euclidean metric tensor, which in turn is used to compute the Laplace-Beltrami operator.
This method computes the regularization term to smooth the diffusion tensor, using its spatial derivatives.
The fidelity term moves the parameters aginst the gardient direction, i.e. towards the minimum of the cost function. The cost function is implemented to debug and guarantee that the gradient descent routine converges.
The 'update' method increments all parameters of the FW-DTI model, using the Laplace-Beltrami and fidelity terms. Also added property to Manifold class, that outputs the parameters in a form consistent with dipy.
These classes are the equivalent to FreeWtaerTensorModel and FreeWaterTensorFit but for single-shell data. Maybe calling them Beltrami is misleading, since both cases fit the FW-DTI model, Beltrami refers to the regularization of the Laplace-Beltrami operator, maybe change names in the future.
Also added extra properties to BeltramiFit, allowing quik access to the initial FW, MD, FA and FW limits
This fucntion takes the raw data and returns normalized attenuations without multiple b0 data
This function initializes the tissue fraction and its bounds based on the S0 image.
This function initializes the tissue fraction based on the initial MD map, estimated with standard DTI
Hi @skoudoro , sorry for the long silence on my part. Last time we talked with Rafael, we agreed to remove the "regularization" from this implementation because we concluded it offers little benefit after the initialization for single-shell data, it was also becoming hard to make it compatible with the current multi-shell routine (point 2 of the TODO list). Since then, I implemented the initialization routine (without reg) in a single function The docstrings are completed I think, so the only thing missing from the TODO list are the unit tests, which I am bad at designing them, so I will ask Rafael for some help. If you are familiar with the code in EDIT: the function |
…descent/regularization.
…radient descent/regularization.
… information), no gradient descent/regularization.
…e previously added single-shell methods
Thank you for the feedback and the update @mvgolub. I will look into it and try to help also. Currently, you have a small typo ( if not enough_b and self.fit_method in (wls_iter, nls_iter):
mes = "fwDTI requires at least 3 b-values (which can include b=0)"
> mes =+ " when using the NLS or WLS fit methods"
E TypeError: bad operand type for unary +: 'str' |
Fixed that typo in 7748b36 |
Codecov Report
@@ Coverage Diff @@
## master #2087 +/- ##
==========================================
- Coverage 91.21% 84.66% -6.55%
==========================================
Files 250 125 -125
Lines 31803 16706 -15097
Branches 3340 2691 -649
==========================================
- Hits 29008 14144 -14864
+ Misses 2074 1877 -197
+ Partials 721 685 -36
|
Hi. What is the status of this request? Has it merged? The pull request seems to be open. Thanks in advance, |
Hi @txusser, it is not ready to be merged. See below what is missing:
your review and feedback (theory or code) is welcomed! Please let us know if you have any question concerning theory or code. |
I will try to look into it. This is so close to merge and it is a very relevant addition imho, it would be a pity for it to keep hanging. |
Has this ever been implemented in DIPY? I have single shell data that I would like to analyze using the same method/software as my multishell data. |
The algorithm in dipy works only in multi-shell data
…On Wed, Oct 11, 2023, 3:46 PM Amanda Rodrigue ***@***.***> wrote:
Has this ever been implemented in DIPY? I have single shell data that I
would like to analyze using the same method/software as my multishell data.
—
Reply to this email directly, view it on GitHub
<#2087 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGEBKOFWJF3F5UIZVL4QOMTX64AQRANCNFSM4LHCYCJQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yes, but there seems to be a pretty long history of developing the code for single shell data, but this seems to have stalled? Has this project been abandoned?
Thanks,
Amanda
________________________________
From: mbergamino ***@***.***>
Sent: Wednesday, October 11, 2023 4:50 PM
To: dipy/dipy ***@***.***>
Cc: Rodrigue, Amanda ***@***.***>; Comment ***@***.***>
Subject: Re: [dipy/dipy] Single-shell Free Water DTI (Object Oriented) (#2087) [EXTERNAL]
* External Email - Caution *
The algorithm in dipy works only in multi-shell data
On Wed, Oct 11, 2023, 3:46 PM Amanda Rodrigue ***@***.***> wrote:
Has this ever been implemented in DIPY? I have single shell data that I
would like to analyze using the same method/software as my multishell data.
—
Reply to this email directly, view it on GitHub
<#2087 (comment)><https://urldefense.com/v3/__https://github.com/dipy/dipy/pull/2087*issuecomment-1758512028*3E__;IyU!!NZvER7FxgEiBAiR_!t10I1q_z9AIF3baA8tknJNOIw5qKVbRVJ39mPpTJPwBU3z9XWLL_21WC6NKhgZTJfSR8UHu3cARZabYhbWdsq187z_IVTJjuFUu8h5w$>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGEBKOFWJF3F5UIZVL4QOMTX64AQRANCNFSM4LHCYCJQ><https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AGEBKOFWJF3F5UIZVL4QOMTX64AQRANCNFSM4LHCYCJQ*3E__;JQ!!NZvER7FxgEiBAiR_!t10I1q_z9AIF3baA8tknJNOIw5qKVbRVJ39mPpTJPwBU3z9XWLL_21WC6NKhgZTJfSR8UHu3cARZabYhbWdsq187z_IVTJju33GkZ4g$>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
—
Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https://github.com/dipy/dipy/pull/2087*issuecomment-1758517348__;Iw!!NZvER7FxgEiBAiR_!t10I1q_z9AIF3baA8tknJNOIw5qKVbRVJ39mPpTJPwBU3z9XWLL_21WC6NKhgZTJfSR8UHu3cARZabYhbWdsq187z_IVTJjuDGfOmTQ$>, or unsubscribe<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AN347Y6LZJM2UN5BGYYKKHTX64A75ANCNFSM4LHCYCJQ__;!!NZvER7FxgEiBAiR_!t10I1q_z9AIF3baA8tknJNOIw5qKVbRVJ39mPpTJPwBU3z9XWLL_21WC6NKhgZTJfSR8UHu3cARZabYhbWdsq187z_IVTJjuCjCMXag$>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Hi @alrodrig11, As explained above, this PR needs a bit of work. it is not ready to be merged. See below what is missing:
your review and feedback (theory or code) is welcomed! Please let us know if you have any question concerning theory or code. You can easily get this branch, run the model and give us your opinion if it should be in or not. Thank you for your future feedback |
1419292
to
ca6268a
Compare
5935e1e
to
765963e
Compare
This is my third pull request for single-shell FW-DTI. The previous PR's (#1603 and #1744) were abandoned because many changes to the code were made since then.
The main difference of this code is that it was implemented with objects and classes, to be consistent with Dipy's implementations of other reconstruction models; also all functions were written inside the existing
dipy/reconst/fwdti.py
module, instead of being implemented in a separate file.This code is based on a regularized gradient descent approach proposed by [1], but instead uses an euclidean metric for the regularization, as proposed in [2]. Additionally, a more novel initialization method for the FW fraction was implemented, proposed in [3].
The code is not ready to be merged, needs to be reviewed @RafaelNH. When reviewing, please ignore all commits made before 2020, I accidentally branched off from an old feature branch and the old outdated commits appear in this PR, I did not know how to fix it (begginer's mistake, sorry).
TODO:
References:
[1] Pasternak, O., Sochen, N., Gur, Y., Intrator, N., & Assaf, Y. (2009). Free water elimination and mapping from diffusion MRI. Magnetic Resonance in Medicine: An Official Journal of the International Society for Magnetic Resonance in Medicine, 62(3), 717-730. (https://onlinelibrary.wiley.com/doi/full/10.1002/mrm.22055)
[2] Pasternak, O., Maier-Hein, K., Baumgartner, C., Shenton, M. E., Rathi, Y., & Westin, C. F. (2014). The estimation of free-water corrected diffusion tensors. In Visualization and Processing of Tensors and Higher Order Descriptors for Multi-valued Data (pp. 249-270). Springer, Berlin, Heidelberg. (https://link.springer.com/chapter/10.1007/978-3-642-54301-2_11)
[3] Ismail, A. A. O., Parker, D., Hernandez-Fernandez, M., Brem, S., Alexander, S., Pasternak, O., ... & Verma, R. (2018, September). Characterizing peritumoral tissue using DTI-Based free water elimination. In International MICCAI Brainlesion Workshop (pp. 123-131). Springer, Cham. (https://www.hal.inserm.fr/inserm-01867347/file/BrainLes-FWE-2018.pdf)