-
Notifications
You must be signed in to change notification settings - Fork 191
Rename sh2power to sh2metric, new "entropy" operation #2985
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
base: dev
Are you sure you want to change the base?
Conversation
Includes checking out a new test data commit that moves existing test data and adds new test data.
|
Was potentially a little too idealistic about this metric being useful as a scalar surrogate for multi-contrast registration (as multiple SH images can be provided as input to the entropy calculation). Kind of interesting, and maybe useful in specific use cases such as the unusual template above, but not a game-changer. |
b2c9fdc to
fe604e9
Compare
Conflicts: cpp/cmd/sh2metric.cpp cpp/cmd/sh2power.cpp cpp/core/math/entropy.h testing/binaries/data
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.
clang-tidy made some suggestions
| } | ||
|
|
||
| protected: | ||
| default_type lower; |
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.
warning: member variable 'lower' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]
default_type lower;
^|
|
||
| protected: | ||
| default_type lower; | ||
| default_type upper; |
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.
warning: member variable 'upper' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]
default_type upper;
^| protected: | ||
| default_type lower; | ||
| default_type upper; | ||
| } normalisation; |
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.
warning: member variable 'normalisation' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]
} normalisation;
^| default_type upper; | ||
| } normalisation; | ||
| }; | ||
| std::shared_ptr<Shared> shared; |
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.
warning: member variable 'shared' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]
std::shared_ptr<Shared> shared;
^|
|
||
| const bool spectrum = !get_options("spectrum").empty(); | ||
|
|
||
| const int lmax = Math::SH::LforN(SH_data.size(3)); |
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.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
const int lmax = Math::SH::LforN(SH_data.size(3));
^| float power = 0.0; | ||
| for (int m = -l; m <= l; ++m) { | ||
| SH.index(3) = Math::SH::index(l, m); | ||
| float val = SH.value(); |
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.
warning: variable 'val' of type 'float' can be declared 'const' [misc-const-correctness]
| float val = SH.value(); | |
| float const val = SH.value(); |
| float val = SH.value(); | ||
| power += Math::pow2(val); | ||
| } | ||
| P.value() = power / (Math::pi * 4); |
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.
warning: narrowing conversion from 'double' to 'value_type' (aka 'float') [bugprone-narrowing-conversions]
P.value() = power / (Math::pi * 4);
^| float power = 0.0; | ||
| for (int l = 0; l <= lmax; l += 2) { | ||
| for (int m = -l; m <= l; ++m) { | ||
| SH.index(3) = Math::SH::index(l, m); |
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.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'ssize_t' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
SH.index(3) = Math::SH::index(l, m);
^| for (int l = 0; l <= lmax; l += 2) { | ||
| for (int m = -l; m <= l; ++m) { | ||
| SH.index(3) = Math::SH::index(l, m); | ||
| float val = SH.value(); |
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.
warning: variable 'val' of type 'float' can be declared 'const' [misc-const-correctness]
| float val = SH.value(); | |
| float const val = SH.value(); |
| power += Math::pow2(val); | ||
| } | ||
| } | ||
| P.value() = power / (Math::pi * 4); |
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.
warning: narrowing conversion from 'double' to 'value_type' (aka 'float') [bugprone-narrowing-conversions]
P.value() = power / (Math::pi * 4);
^

Had previously thought about this from the perspective of registration, but have also been looking at a collaborator dataset where doing satisfactory masking for FBA has been difficult, and using that to revised FBA documentation (#2685).
Here is the WM FOD l=0 image, which you can see doesn't do a very good job of separating what one would like to analyse vs. not:
Then this is the entropy of the WM FOD template (normalised & inverted):
Implement the Spherical Harmonic Entropy (SHE) metric as per:
https://arxiv.org/pdf/1805.08084
This may yield the same or similar result much faster
Add command-line option to modify the direction set that's used for amplitude sampling
Implement entropy operations for:
Revisit templated entropy calculation code
For some reason had trouble specifying the logarithm function as a template. The
switchstatement should get optimised out by the compiler, but maybe I'll have another go before merging.