Conversation
If some per-streamline statistic is to be computed, then it is possible to provide as input multiple images to be sampled from as a 4D volume series; the command uotput will then be a 2D matrix (one row per streamline, one column per metric) rather than a 1D vector (one scalar per streamline).
|
012eb5a to
5deef15
Compare
5deef15 to
012eb5a
Compare
Implemented class inheritance structure such that code branches based on the fundamental contrast being sampled does not need to occur for each streamline.
tcksample: Ability to sample SH amplitudes
Conflicts: cmd/tcksample.cpp
|
| }; | ||
|
|
||
| template <class Interp> class SamplerNonPrecise { | ||
| class SamplerBase { |
There was a problem hiding this comment.
warning: class 'SamplerBase' defines a non-default destructor and a copy constructor but does not define a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
class SamplerBase {
^| const stat_tck _statistic; | ||
| }; | ||
|
|
||
| template <class Interp> class SamplerNonPreciseBase : public SamplerBase { |
There was a problem hiding this comment.
warning: class 'SamplerNonPreciseBase' defines a default destructor and a copy constructor but does not define a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
template <class Interp> class SamplerNonPreciseBase : public SamplerBase {
^| SamplerNonPreciseBase(Image<value_type> &image, const contrast_type contrast, const stat_tck statistic) | ||
| : BaseType(contrast, statistic), interp(image) {} | ||
| SamplerNonPreciseBase(const SamplerNonPreciseBase &that) = default; | ||
| virtual ~SamplerNonPreciseBase() = default; |
There was a problem hiding this comment.
warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [cppcoreguidelines-explicit-virtual-functions]
| virtual ~SamplerNonPreciseBase() = default; | |
| ~SamplerNonPreciseBase() override = default; |
| } | ||
|
|
||
| protected: | ||
| Interp interp; |
There was a problem hiding this comment.
warning: member variable 'interp' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]
Interp interp;
^| }; | ||
|
|
||
| class SamplerPrecise { | ||
| class SamplerPreciseBase : public SamplerBase { |
There was a problem hiding this comment.
warning: class 'SamplerPreciseBase' defines a default destructor and a copy constructor but does not define a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
class SamplerPreciseBase : public SamplerBase {
^| : ReceiverBase(num_tracks) { | ||
| using InputType = ManyPerStreamline; | ||
| Receiver_ManyPerStreamline(const size_t num_tracks, const size_t num_metrics, const std::string &path) | ||
| : ReceiverBase(num_tracks, false, path), data(matrix_type::Zero(num_tracks, num_metrics)) {} |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
: ReceiverBase(num_tracks, false, path), data(matrix_type::Zero(num_tracks, num_metrics)) {}
^| Receiver_ManyPerStreamline(const size_t num_tracks, const size_t num_metrics, const std::string &path) | ||
| : ReceiverBase(num_tracks, false, path), data(matrix_type::Zero(num_tracks, num_metrics)) {} | ||
| Receiver_ManyPerStreamline(const Receiver_ManyPerStreamline &) = delete; | ||
| ~Receiver_ManyPerStreamline() { File::Matrix::save_matrix(data, path); } |
There was a problem hiding this comment.
warning: annotate this function with 'override' or (rarely) 'final' [cppcoreguidelines-explicit-virtual-functions]
| ~Receiver_ManyPerStreamline() { File::Matrix::save_matrix(data, path); } | |
| ~Receiver_ManyPerStreamline() override { File::Matrix::save_matrix(data, path); } |
| bool operator()(InputType &in) { | ||
| // TODO Chance that this will be prohibitively slow if count is not indicated in track file header | ||
| if (in.index >= size_t(data.rows())) | ||
| data.conservativeResizeLike(matrix_type::Zero(in.index + 1, data.cols())); |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
data.conservativeResizeLike(matrix_type::Zero(in.index + 1, data.cols()));
^| // TODO Chance that this will be prohibitively slow if count is not indicated in track file header | ||
| if (in.index >= size_t(data.rows())) | ||
| data.conservativeResizeLike(matrix_type::Zero(in.index + 1, data.cols())); | ||
| data.row(in.index) = in.values; |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'Index' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
data.row(in.index) = in.values;
^| matrix_type data; | ||
| }; | ||
|
|
||
| class Receiver_PerVertex : public ReceiverBase { |
There was a problem hiding this comment.
warning: class 'Receiver_PerVertex' defines a copy constructor but does not define a destructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
class Receiver_PerVertex : public ReceiverBase {
^|
Anyone with access to a Mac willing to help me look into the Add this at `cpp/cmd/tcksample.cpp:575: if (tck.get_index() == 112) {
std::cerr << "Troublesome streamline 112:\n";
std::cerr << "Intersections:\n";
for (const auto &i : intersections)
std::cerr << " " << i.transpose() << ": " << i.get_length() << "\n";
std::cerr << "Sampled data:\n";
for (const auto &i : data)
std::cerr << " " << i.length << ": " << i.value << "\n";
std::cerr << "Final result: " << out.value << "\n";
}Here's what my Linux box produces" |
Implemented for a specific project; listing here as draft for attribution to
3.1.0milestone so that it doesn't get forgotten.