Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Small fix to insure that fwDTI non-linear procedure does not crash #1137
Current coverage is 84.64% (diff: 100%)
@@ master #1137 diff @@ ========================================== Files 219 219 Lines 24884 24897 +13 Methods 0 0 Messages 0 0 Branches 2514 2514 ========================================== + Hits 21056 21073 +17 + Misses 3199 3195 -4 Partials 629 629
Great. I like the comprehensive approach. Thanks for the elegant solution to this problem!
Just a couple of really small changes proposed.
And a couple of questions:
- Can you get a LinAlgError even with an input that is not all nans? Might be good to add something like that as a test as well. The all-nans is a bit contrived, if it is possible otherwise.
- Does it make sense to set a reasonable default for
tensor_alternative? Does it make sense to check whether this input really is Hermitian, before using it (maybe inside the
Hi @arokem - actually finding an concrete signal to reproduce this problem is not that trivial. I encountered this problem when processing more than 600 subjects in my units cluster. The problem only occurred in background voxels of 9 subjects. I tried to create a test based on these signals however I noticed that the previous codes were processing these signals fine with the previous code version. After looking to the source of the issue in the cluster nodes, I notice that this has happening due to an overflow of the exponential function of non-linear diffusion model fits which were given NaN tensor elements. Since in my home computer I was not getting this problem, I assume that testing this issue from signals depend on the system that you are running dipy. Therefore, I decided to test the problem from tensors with NaN elements. For this, I created a helper function with the lines of code that were dealing with this problem for the standard dti non-linear fit. With this I am reducing duplicate code and testing previously non covered lines of dti.py - the test was added in test_dti.py.
@arokem - just noticed your comments! I will carry on the work tomorrow (getting late here in Cambridge). I think my last comment covers your 1st point, right? Regarding point 2 - since _decompose_tensor_nan is only a helper function, I didn't want to increase complexity and eventually decrease code speed performance. Moreover, if you see _decompose_tensor_nan is just a generalization of decompose_tensor. I would also prefer not giving a default value for tensor_alternative - since this should be used for non-linear approaches the best tensor alternative is always the parameters initial estimate.