-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add script to validate gradient tables #1110
base: master
Are you sure you want to change the base?
Add script to validate gradient tables #1110
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1110 +/- ##
==========================================
- Coverage 69.56% 69.55% -0.02%
==========================================
Files 448 449 +1
Lines 24078 24176 +98
Branches 3290 3305 +15
==========================================
+ Hits 16751 16816 +65
- Misses 5934 5962 +28
- Partials 1393 1398 +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.
Looks really clean and well-written! (Although I don't understand very well the energy section, might require an additional reviewer).
Let's not forget to update after PR #1113 is merged.
nb_shells = len(ubvals) | ||
nb_dir_per_shell = [np.sum(shell_idx == idx) for idx in range(nb_shells)] | ||
|
||
ubvecs = np.unique(bvecs, axis=0) |
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.
Should you also check if some bvecs are the same as another inversed one (-bvecs)?
Quick description
I wrote a script that validates the distribution of directions of b-vectors. To do so, I used the already existing functions in
scilpy.gradients.gen_gradient_sampling
to compute the electrostatic-like repulsion energy of inputed b-vectors and compare its energy to the energy of "optimal" b-vectors. These optimal b-vectors are computed on-the-fly withgenerate_gradient_sampling
, the Caruyer method we use inscil_gradients_generate_sampling.py
, with the same architecture of number of bvecs per shell as the input.The script starts by looking for b0s, to remove them from the analysis. Then, it looks for duplicate b-vectors. Finally, both energies are computed and compared as the ratio between the inputed b-vectors' energy and the optimal b-vectors' energy (input_energy/optimal_energy). Above a given maximum ratio value, the script raises a warning.
The user might want to use the -v verbose option to see the computed energies. The --visualize option displays both the inputed and optimal b-vectors on a single shell.
For the default value of
max_ratio
(1.25), I looked at various databases like HCP, Penthera, ADNI3 and converged at this number. Multi-shell gradient tables often brake this, because many gtabs have similar bvecs across shells and it raises the energy a lot. I could add an option "split_shells".Would be curious to know what @mdesco thinks about this!
...
Type of change
Check the relevant options.
Provide data, screenshots, command line to test (if relevant)
...
Checklist