Transmission detection fix and refactor.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "Function3D.h"
|
||||
#include "Matrix.h"
|
||||
|
||||
#include "config/config.h"
|
||||
#include "calculateBankDetectAndHilbertTransformation.hpp"
|
||||
|
||||
using namespace Aurora;
|
||||
@@ -235,7 +236,6 @@ namespace Recon {
|
||||
return result;
|
||||
}
|
||||
|
||||
//TODO:未测
|
||||
DetectResult detectTofAndAtt(
|
||||
const Aurora::Matrix &AscanBlock, const Aurora::Matrix &AscanRefBlock,
|
||||
const Aurora::Matrix &distBlock, const Aurora::Matrix &distRefBlock,
|
||||
@@ -260,7 +260,6 @@ namespace Recon {
|
||||
return result;
|
||||
}
|
||||
|
||||
//TODO:未测
|
||||
DetectResult detectTofAndAttMex(
|
||||
const Aurora::Matrix &AscanBlock, const Aurora::Matrix &AscanRefBlock,
|
||||
const Aurora::Matrix &distBlock, const Aurora::Matrix &distRefBlock,
|
||||
@@ -334,8 +333,8 @@ namespace Recon {
|
||||
delete [] resEnvelopeRef;
|
||||
}
|
||||
auto resDetect =Matrix::New(resDetectD,1,N);
|
||||
auto resEnvelope =Matrix::New(resEnvelopeD,N,M);
|
||||
auto resEnvelopeRef =Matrix::New(resEnvelopeRefD,N,M);
|
||||
auto resEnvelope =Matrix::New(resEnvelopeD,M,N);
|
||||
auto resEnvelopeRef =Matrix::New(resEnvelopeRefD,M,N);
|
||||
//floor(size(AscanBlock, 1)*inits.resampleFactor / 2 - 1),
|
||||
int end_1 = std::floor(_AscanBlock.getDimSize(0)*resampleFactor/2-1);
|
||||
//-ceil(size(AscanBlock, 1)*inits.resampleFactor / 2)
|
||||
@@ -349,7 +348,7 @@ namespace Recon {
|
||||
auto resDetectLags = zeros(_AscanBlock.getDimSize(1),1);
|
||||
for (size_t i = 0; i < _AscanBlock.getDimSize(1); i++)
|
||||
{
|
||||
resDetectLags[i] = lags2[(int)resDetect[i]+1];
|
||||
resDetectLags[i] = lags2[(int)resDetect[i]];
|
||||
}
|
||||
delete [] lags2;
|
||||
resDetectLags =resDetectLags/resampleFactor;
|
||||
@@ -378,32 +377,32 @@ namespace Recon {
|
||||
return result;
|
||||
}
|
||||
|
||||
DetectResult transmissionDetection(const Aurora::Matrix &AscanBlock, const Aurora::Matrix &AscanRefBlock,
|
||||
const Aurora::Matrix &distBlock, const Aurora::Matrix &distRefBlock,
|
||||
const Aurora::Matrix &sosWaterBlock,
|
||||
const Aurora::Matrix &sosWaterRefBlock,int version, int resampleFactor,int nthreads, double expectedSOSWater,
|
||||
int useTimeWindowing, int aScanReconstructionFrequency,int detectionWindowATT,
|
||||
double offsetElectronic, int detectionWindowSOS, double minSpeedOfSound,
|
||||
double maxSpeedOfSound, bool gaussWindow){
|
||||
switch (version) {
|
||||
DetectResult transmissionDetection(const Aurora::Matrix &AscanBlock,
|
||||
const Aurora::Matrix &AscanRefBlock,
|
||||
const Aurora::Matrix &distBlock,
|
||||
const Aurora::Matrix &distRefBlock,
|
||||
const Aurora::Matrix &sosWaterBlock,
|
||||
const Aurora::Matrix &sosWaterRefBlock,
|
||||
double expectedSOSWater) {
|
||||
switch (Recon::transParams::version) {
|
||||
case 1: {
|
||||
return detectTofAndAttMex(
|
||||
AscanBlock, AscanRefBlock, distBlock, distRefBlock,
|
||||
sosWaterBlock, sosWaterRefBlock, resampleFactor, nthreads,
|
||||
expectedSOSWater, useTimeWindowing,
|
||||
aScanReconstructionFrequency, detectionWindowATT,
|
||||
offsetElectronic, detectionWindowSOS, minSpeedOfSound,
|
||||
maxSpeedOfSound, gaussWindow);
|
||||
sosWaterBlock, sosWaterRefBlock, Recon::transParams::resampleFactor, Recon::transParams::nThreads,
|
||||
expectedSOSWater, Recon::transParams::useTimeWindowing,
|
||||
Recon::transParams::aScanReconstructionFrequency, Recon::transParams::detectionWindowATT,
|
||||
Recon::transParams::offsetElectronic, Recon::transParams::detectionWindowSOS, Recon::transParams::minSpeedOfSound,
|
||||
Recon::transParams::maxSpeedOfSound, Recon::transParams::gaussWindow);
|
||||
}
|
||||
case 2:
|
||||
default:
|
||||
return detectTofAndAtt(
|
||||
AscanBlock, AscanRefBlock, distBlock, distRefBlock,
|
||||
sosWaterBlock, sosWaterRefBlock, resampleFactor, nthreads,
|
||||
expectedSOSWater, useTimeWindowing,
|
||||
aScanReconstructionFrequency, detectionWindowATT,
|
||||
offsetElectronic, detectionWindowSOS, minSpeedOfSound,
|
||||
maxSpeedOfSound, gaussWindow);
|
||||
sosWaterBlock, sosWaterRefBlock, Recon::transParams::resampleFactor, Recon::transParams::nThreads,
|
||||
expectedSOSWater, Recon::transParams::useTimeWindowing,
|
||||
Recon::transParams::aScanReconstructionFrequency, Recon::transParams::detectionWindowATT,
|
||||
Recon::transParams::offsetElectronic, Recon::transParams::detectionWindowSOS, Recon::transParams::minSpeedOfSound,
|
||||
Recon::transParams::maxSpeedOfSound, Recon::transParams::gaussWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,11 +77,7 @@ DetectResult
|
||||
transmissionDetection(
|
||||
const Aurora::Matrix &AscanBlock, const Aurora::Matrix &AscanRefBlock,
|
||||
const Aurora::Matrix &distBlock, const Aurora::Matrix &distRefBlock,
|
||||
const Aurora::Matrix &sosWaterBlock, const Aurora::Matrix &sosWaterRefBlock,
|
||||
int version, int resampleFactor, int nthreads, double expectedSOSWater,
|
||||
int useTimeWindowing, int aScanReconstructionFrequency,
|
||||
int detectionWindowATT, double offsetElectronic, int detectionWindowSOS,
|
||||
double minSpeedOfSound, double maxSpeedOfSound, bool gaussWindow);
|
||||
const Aurora::Matrix &sosWaterBlock, const Aurora::Matrix &sosWaterRefBlock, double expectedSOSWater);
|
||||
|
||||
} // namespace Recon
|
||||
|
||||
|
||||
@@ -60,11 +60,56 @@ TEST_F(Detection_Test, detectTofAndAttMex) {
|
||||
Recon::transParams::minSpeedOfSound,
|
||||
Recon::transParams::maxSpeedOfSound, Recon::transParams::gaussWindow);
|
||||
|
||||
MatlabReader m2("/home/krad/TestData/tofResult.mat");
|
||||
|
||||
auto tof = m2.read("tof");
|
||||
MatlabReader m2("/home/krad/TestData/sosResult.mat");
|
||||
auto sosvalue = m2.read("sosValue");
|
||||
EXPECT_EQ(tof.getDataSize(), result.tof.getDataSize());
|
||||
ASSERT_EQ(sosvalue.getDataSize(), result.tof.getDataSize());
|
||||
ASSERT_EQ(sosvalue.getDataSize(), result.sosValue.getDataSize());
|
||||
ASSERT_EQ(sosvalue.getDataSize(), result.att.getDataSize());
|
||||
#pragma omp parallel for
|
||||
for (size_t i = 0; i < result.tof.getDataSize(); i++)
|
||||
{
|
||||
EXPECT_DOUBLE_AE(0,result.tof[i])<<",index:"<<i;
|
||||
EXPECT_DOUBLE_AE(sosvalue[i],result.sosValue[i])<<",index:"<<i;
|
||||
EXPECT_TRUE(std::isnan(result.att[i]))<<",index:"<<i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST_F(Detection_Test, detectTofAndAtt) {
|
||||
|
||||
MatlabReader m("/home/krad/TestData/getBlockOfTransmissionData.mat");
|
||||
|
||||
auto AscanBlock = m.read("AscanBlock");
|
||||
auto AscanRefBlock = m.read("AscanRefBlock");
|
||||
auto distBlock = m.read("dists");
|
||||
auto distBlockRef = m.read("distRefBlock");
|
||||
auto sosWaterBlock = m.read("waterTempBlock");
|
||||
auto sosWaterRefBlock = m.read("waterTempRefBlock");
|
||||
double expectedSOSWater = 1.511948131508464e+03;
|
||||
|
||||
auto result = Recon::detectTofAndAtt(
|
||||
AscanBlock, AscanRefBlock, distBlock, distBlockRef, sosWaterBlock,
|
||||
sosWaterRefBlock, Recon::transParams::resampleFactor,
|
||||
Recon::transParams::nThreads, expectedSOSWater,
|
||||
Recon::transParams::useTimeWindowing,
|
||||
Recon::transParams::aScanReconstructionFrequency,
|
||||
Recon::transParams::offsetElectronic,Recon::transParams::detectionWindowATT,
|
||||
Recon::transParams::detectionWindowSOS,
|
||||
Recon::transParams::minSpeedOfSound,
|
||||
Recon::transParams::maxSpeedOfSound, Recon::transParams::gaussWindow);
|
||||
|
||||
MatlabReader m2("/home/krad/TestData/sosResult.mat");
|
||||
auto sosvalue = m2.read("sosValue");
|
||||
ASSERT_EQ(sosvalue.getDataSize(), result.tof.getDataSize());
|
||||
ASSERT_EQ(sosvalue.getDataSize(), result.sosValue.getDataSize());
|
||||
ASSERT_EQ(sosvalue.getDataSize(), result.att.getDataSize());
|
||||
#pragma omp parallel for
|
||||
for (size_t i = 0; i < result.tof.getDataSize(); i++)
|
||||
{
|
||||
EXPECT_DOUBLE_AE(0,result.tof[i])<<",index:"<<i;
|
||||
EXPECT_DOUBLE_AE(sosvalue[i],result.sosValue[i])<<",index:"<<i;
|
||||
EXPECT_TRUE(std::isnan(result.att[i]))<<",index:"<<i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -172,10 +217,10 @@ TEST_F(Detection_Test, detectTofVectorized) {
|
||||
|
||||
auto tof = m2.read("tof");
|
||||
auto sosvalue = m2.read("sosValue");
|
||||
EXPECT_EQ(tof.getDataSize(), result.getDataSize());
|
||||
EXPECT_EQ(tof.getDataSize(), result.tof.getDataSize());
|
||||
#pragma omp parallel for
|
||||
for (size_t i = 0; i < tof.getDataSize(); i++)
|
||||
{
|
||||
EXPECT_DOUBLE_AE(tof[i],result[i])<<",index:"<<i;
|
||||
EXPECT_DOUBLE_AE(tof[i],result.tof[i])<<",index:"<<i;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user