Skip to content

Commit

Permalink
Fixel::Matrix: Neaten by using typedefs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lestropie committed Jul 18, 2023
1 parent ab8bf84 commit cdc1c3b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/fixel/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ namespace MR
if (App::overwrite_files) {
File::remove (path);
} else {
throw Exception ("Cannot create fixel-fixel connectivity matrix \"" + path + "\": Already exists as file");
throw Exception ("Cannot create fixel-fixel connectivity matrix directory \"" + path + "\": Already exists as file");
}
}
} else {
Expand All @@ -322,7 +322,7 @@ namespace MR

index_type num_connections = 0;
{
ProgressBar progress ("Computing number of fixel-fixel connections in matrix", matrix.size());
ProgressBar progress ("Computing number of supra-threshold fixel-fixel connections", matrix.size());

for (size_t fixel_index = 0; fixel_index != matrix.size(); ++fixel_index) {
const connectivity_value_type normalisation_factor = matrix[fixel_index].norm_factor();
Expand Down
25 changes: 13 additions & 12 deletions src/fixel/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,18 @@ namespace MR
using BaseType::operator<;
using ValueType = connectivity_value_type;
InitElementWeighted() :
sum_weights (connectivity_value_type(0)) { }
sum_weights (ValueType(0)) { }
InitElementWeighted (const fixel_index_type fixel_index) = delete;
InitElementWeighted (const fixel_index_type fixel_index, const MappedTrack& all_data) :
BaseType (fixel_index),
sum_weights (all_data.get_weight()) { }
InitElementWeighted (const InitElementWeighted&) = default;
FORCE_INLINE fixel_index_type index() const { return BaseType::index(); }
FORCE_INLINE InitElementWeighted& operator+= (const connectivity_value_type increment) { sum_weights += increment; return *this; }
FORCE_INLINE InitElementWeighted& operator+= (const ValueType increment) { sum_weights += increment; return *this; }
FORCE_INLINE InitElementWeighted& operator= (const InitElementWeighted& that) { BaseType::operator= (that); sum_weights = that.sum_weights; return *this; }
FORCE_INLINE ValueType value() const { return sum_weights; }
private:
connectivity_value_type sum_weights;
ValueType sum_weights;
};


Expand Down Expand Up @@ -192,7 +192,7 @@ namespace MR
FORCE_INLINE void normalise (const ValueType norm_factor) { connectivity_value *= norm_factor; }
private:
fixel_index_type fixel_index;
connectivity_value_type connectivity_value;
ValueType connectivity_value;
};


Expand All @@ -205,24 +205,25 @@ namespace MR
public:
using ElementType = NormElement;
using BaseType = vector<NormElement>;
using ValueType = connectivity_value_type;
NormFixel() :
norm_multiplier (connectivity_value_type (1)) { }
norm_multiplier (ValueType (1)) { }
NormFixel (const BaseType& i) :
BaseType (i),
norm_multiplier (connectivity_value_type (1)) { }
norm_multiplier (ValueType (1)) { }
NormFixel (BaseType&& i) :
BaseType (std::move (i)),
norm_multiplier (connectivity_value_type (1)) { }
norm_multiplier (ValueType (1)) { }
void normalise() {
norm_multiplier = connectivity_value_type (0);
norm_multiplier = ValueType (0);
for (const auto& c : *this)
norm_multiplier += c.value();
norm_multiplier = norm_multiplier ? (connectivity_value_type (1) / norm_multiplier) : connectivity_value_type(0);
norm_multiplier = norm_multiplier ? (ValueType (1) / norm_multiplier) : ValueType(0);
}
void normalise (const connectivity_value_type sum) {
norm_multiplier = sum ? (connectivity_value_type(1) / sum) : connectivity_value_type(0);
void normalise (const ValueType sum) {
norm_multiplier = sum ? (ValueType(1) / sum) : ValueType(0);
}
connectivity_value_type norm_multiplier;
ValueType norm_multiplier;
};


Expand Down

0 comments on commit cdc1c3b

Please sign in to comment.