v2.0.0
Loading...
Searching...
No Matches
sts_source_metrics.cpp
Go to the documentation of this file.
1//=============================================================================================================
34
35//=============================================================================================================
36// INCLUDES
37//=============================================================================================================
38
39#include "sts_source_metrics.h"
40
41//=============================================================================================================
42// STL INCLUDES
43//=============================================================================================================
44
45#include <cmath>
46
47//=============================================================================================================
48// USED NAMESPACES
49//=============================================================================================================
50
51using namespace STSLIB;
52using namespace Eigen;
53
54//=============================================================================================================
55// DEFINE MEMBER METHODS
56//=============================================================================================================
57
59 const Vector3d& truePos,
60 const Vector3d& estimatedPos)
61{
62 return (truePos - estimatedPos).norm();
63}
64
65//=============================================================================================================
66
68 const VectorXd& sourceAmplitudes,
69 const MatrixXd& sourcePositions,
70 int peakIndex)
71{
72 int nSources = sourceAmplitudes.size();
73 Vector3d peakPos = sourcePositions.row(peakIndex);
74
75 double weightedSum = 0.0;
76 double totalWeight = 0.0;
77
78 for (int k = 0; k < nSources; ++k) {
79 double absAmp = std::abs(sourceAmplitudes(k));
80 double dist = (sourcePositions.row(k).transpose() - peakPos).norm();
81 weightedSum += dist * absAmp;
82 totalWeight += absAmp;
83 }
84
85 if (totalWeight < 1e-10) {
86 return 0.0;
87 }
88
89 return weightedSum / totalWeight;
90}
91
92//=============================================================================================================
93
94int StatsSourceMetrics::findPeakIndex(const VectorXd& sourceAmplitudes)
95{
96 int peakIdx = 0;
97 sourceAmplitudes.cwiseAbs().maxCoeff(&peakIdx);
98 return peakIdx;
99}
StatsSourceMetrics class declaration.
Statistical testing (t-tests, F-tests, cluster permutation, multiple comparison correction).
static double peakLocalizationError(const Eigen::Vector3d &truePos, const Eigen::Vector3d &estimatedPos)
static double spatialDispersion(const Eigen::VectorXd &sourceAmplitudes, const Eigen::MatrixXd &sourcePositions, int peakIndex)
static int findPeakIndex(const Eigen::VectorXd &sourceAmplitudes)