Skip to content

Conversation

@Lestropie
Copy link
Member

@Lestropie Lestropie commented Sep 3, 2024

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:

Screenshot from 2024-09-03 16-13-43

Then this is the entropy of the WM FOD template (normalised & inverted):

Screenshot from 2024-09-03 16-14-08


  • 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:

    • mrmath
    • fixel2voxel
  • Revisit templated entropy calculation code
    For some reason had trouble specifying the logarithm function as a template. The switch statement should get optimised out by the compiler, but maybe I'll have another go before merging.

Includes checking out a new test data commit that moves existing test data and adds new test data.
@Lestropie Lestropie self-assigned this Sep 3, 2024
github-actions[bot]

This comment was marked as outdated.

@Lestropie
Copy link
Member Author

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.

Single-subject HCP data:
MSMT_tissues
MSMT_entropy

Conflicts:
	cpp/cmd/sh2metric.cpp
	cpp/cmd/sh2power.cpp
	cpp/core/math/entropy.h
	testing/binaries/data
github-actions[bot]

This comment was marked as outdated.

Copy link

@github-actions github-actions bot left a 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;

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;

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;

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;

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));

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();

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]

Suggested change
float val = SH.value();
float const val = SH.value();

float val = SH.value();
power += Math::pow2(val);
}
P.value() = power / (Math::pi * 4);

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);

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();

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]

Suggested change
float val = SH.value();
float const val = SH.value();

power += Math::pow2(val);
}
}
P.value() = power / (Math::pi * 4);

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);
                ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants