Repository navigation
NODDI fitting - #16
Merged
Merged
Conversation
…a dictionary start Each voxel starts from the dictionary solve (free water by NNLS, the tissue support by a non-negative L1 + L2 solve, the weights by NNLS on it) and is then fitted as the NODDI Matlab Toolbox 1.05 fits WatsonSHStickTortIsoV_B0: its order-12 series for the Watson sticks, its Watson-averaged zeppelin, S0 from the positive b0s, sigma from their spread divided by 100, the Rician likelihood, its encoding of the parameters and its two stages. The voxel loop runs in C++ on all threads; a whole HCP subject takes 3.5 minutes. The scaled Bessel function I0 moves from the simulation code to common/maths, so both use it. Adds the NODDI guide page and its citations.
… and tighter tests Rename the Python NODDI tests so that mypy no longer sees two test_noddi modules, initialise every field of NoddiSettings and use std::numbers::pi for GCC and MSVC, and split the optimiser into small functions with longer names for clang-tidy. The fit now warns about the voxels it cannot fit, refuses a table with one shell and starting directions that are zero or not finite, and normalises the others. The comparison with the toolbox is bounded at about twice the measured differences, and a new test checks that the chunked readers do not change DTI, DKI or CSD.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds NODDI to Larmor:
larmor.dwi.NoddiModel/NoddiFitand thelar noddicommand, with a guide page.Method. Each voxel starts from a dictionary of NODDI signals about its DTI direction, solved as AMICO
does (free water by NNLS, the tissue support by a non-negative L1 + L2 solve, then NNLS on that support).
From there it is fitted as the NODDI Matlab Toolbox 1.05 fits
WatsonSHStickTortIsoV_B0: the toolbox'sorder-12 series for the Watson sticks and its Watson-averaged zeppelin, S0 from the positive b0s, sigma
from their spread divided by 100, the Rician likelihood, the toolbox's parameter encoding and its two
stages (fractions first, then all five parameters including the direction). The optimiser is a bounded
BFGS with numerical gradients in place of MATLAB's fmincon. The whole voxel loop is C++ on all threads.
Supporting changes.
solve_ridge_nnlstakes an L1 weight (with x >= 0 it is a linear term, so it shifts thecorrelations, and the ridge rows of the QR path get -l1 / ridge); bound as
_core.ridge_l1_nnls.signal_rows,signal_chunks,finite_rowsinlarmor.dwi.inputs) instead of copying every brain voxel as float64 first: DTI, DKI, the WM response,CSD and its response, MSMT-CSD and its responses, and mFOD (which also turns each chunk's amplitudes
into SH before the next). At the default chunk size the outputs are identical to before on clean and
damaged data; with chunks of a few voxels they differ only by rounding (about 1e-8 relative in
MSMT-CSD), which
tests/dwi/test_chunked_reading.pynow checks.compartment_attenuationreleases the GIL; the scaled Bessel I0 moves tocommon/maths.Validation (reference data in
tests/data/noddi, made bymake_noddi_phantom.pyandtests/matlab_scripts/make_noddi_ref.m):difference to the toolbox is 0.0007; the 2 voxels that differ by more than 0.02 have a lower negative
log-likelihood with Larmor.
0.000 (v_iso), directions within 0.0 degrees median; 0.3 s against the toolbox's 211 s.
equations, the coefficient joins, the averaged zeppelin, and noise-free recovery including the direction.