Add getTransmissionData unit test.
This commit is contained in:
253
test/GetTransmissionData_Test.cpp
Normal file
253
test/GetTransmissionData_Test.cpp
Normal file
@@ -0,0 +1,253 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <limits>
|
||||
|
||||
#include "Function.h"
|
||||
#include "Function1D.h"
|
||||
#include "Function2D.h"
|
||||
#include "MatlabReader.h"
|
||||
#include "Matrix.h"
|
||||
#include "Parser.h"
|
||||
#include "Data/MetaData.h"
|
||||
|
||||
#include "src/config/config.h"
|
||||
#include "src/common/ceMatchedFilterHandling.h"
|
||||
#include "src/common/getMeasurementMetaData.h"
|
||||
#include "src/common/getGeometryInfo.h"
|
||||
#include "src/reflectionReconstruction/preprocessData/estimateOffset.h"
|
||||
#include "src/common/estimatePulseLength.h"
|
||||
#include "src/transmissionReconstruction/detection/getTransmissionData.h"
|
||||
|
||||
using namespace Aurora;
|
||||
using namespace Recon;
|
||||
|
||||
|
||||
inline double fourDecimalRound(double src) {
|
||||
return round(src*10000.0)/10000.0;
|
||||
}
|
||||
|
||||
#define EXPECT_DOUBLE_AE(valueA,valueB)\
|
||||
EXPECT_DOUBLE_EQ(fourDecimalRound(valueA),fourDecimalRound(valueB))
|
||||
|
||||
class GetTransmissionData_Test : public ::testing::Test {
|
||||
protected:
|
||||
static void SetUpReconstructionTester() {
|
||||
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
}
|
||||
|
||||
void SetUp() {
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(GetTransmissionData_Test, getTransmissionData) {
|
||||
// std::string dataPath = "/home/AScans_Data/ADW_TAS_Issue/20230512T135108/";
|
||||
// std::string refPath = "/home/AScans_Data/ADW_TAS_Issue/20230512T141626/";
|
||||
// std::string outputPath;
|
||||
// Parser dataParser(dataPath);
|
||||
// Parser refParser(refPath);
|
||||
// std::string rootMeasUniqueID = dataParser.getMetaData().getMeasurementID();
|
||||
// std::string rootRefUniqueID = refParser.getMetaData().getMeasurementID();
|
||||
|
||||
// //init total used receiver/emitter/motorPos
|
||||
// Matrix motorPosTotal, slList, snList, rlList, rnList;
|
||||
// motorPosTotal = auroraUnion(reflectParams::motorPos, transParams::motorPos);
|
||||
// slList = auroraUnion(reflectParams::senderTasList, transParams::senderTasList);
|
||||
// snList = auroraUnion(reflectParams::senderElementList, transParams::senderElementList);
|
||||
// rlList = auroraUnion(reflectParams::receiverTasList, transParams::receiverTasList);
|
||||
// rnList = auroraUnion(reflectParams::receiverElementList, transParams::receiverElementList);
|
||||
|
||||
|
||||
// //getMeasurementMetaData
|
||||
// double maxNumTAS = Aurora::max(auroraUnion(slList, rlList)).getData()[0];
|
||||
// MeasurementInfo expInfo = loadMeasurementInfos(&dataParser);
|
||||
// TempInfo temp = getTemperatureInfo(&dataParser, maxNumTAS);
|
||||
// CEInfo ce = getCEInfo(&dataParser, expInfo);
|
||||
// TransFormInfo transformationInfo = getTransformationMatrix(&dataParser, motorPosTotal);
|
||||
// Matrix transformationMatrices = transformationInfo.rotationMatrix;
|
||||
// Matrix motorPosAvailable = transformationInfo.motorPos;
|
||||
|
||||
// Matrix motorPosAvailableRef;
|
||||
// MeasurementInfo expInfoRef;
|
||||
// TempInfo tempRef;
|
||||
// CEInfo ceRef;
|
||||
// Matrix transformationMatricesRef;
|
||||
// expInfoRef = loadMeasurementInfos(&refParser);
|
||||
// tempRef = getTemperatureInfo(&refParser, maxNumTAS);
|
||||
// ceRef = getCEInfo(&refParser, expInfoRef);
|
||||
// transformationInfo = getTransformationMatrix(&refParser, motorPosTotal);
|
||||
// transformationMatricesRef = transformationInfo.rotationMatrix;
|
||||
// motorPosAvailableRef = transformationInfo.motorPos;
|
||||
// if(transformationMatricesRef.isNull())
|
||||
// {
|
||||
// Matrix motorPos1 = Matrix::fromRawData(new double[1] {1}, 1);
|
||||
// transformationMatricesRef = getTransformationMatrix(&refParser, motorPos1).rotationMatrix;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Matrix mpRef_inter = intersect(motorPosAvailableRef, transParams::motorPos);
|
||||
// //extractMatchingReferenceMotorPosition
|
||||
// for(int i=0; i<motorPosAvailable.getDimSize(0); ++i)
|
||||
// {
|
||||
// if (sum(mpRef_inter == motorPosAvailable.getData()[i],FunctionDirection::All).getData()[0] == 0)
|
||||
// {
|
||||
// motorPosAvailableRef.getData()[i] = max(mpRef_inter).getData()[0];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Matrix isEqual = (ce.ceRef == ceRef.ceRef);
|
||||
|
||||
// if(!ce.ce.isNull() && !ceRef.ce.isNull())
|
||||
// {
|
||||
// isEqual = (ce.ce == ceRef.ce);
|
||||
// }
|
||||
// GeometryInfo geom = getGeometryInfo(motorPosAvailable, transformationMatrices, rlList, rnList, slList, snList);
|
||||
// PreComputes preComputes;
|
||||
// preComputes.matchedFilter = createMatchedFilter(ce.ce, ce.measuredCEUsed, reflectParams::findDefects, reconParams::removeOutliersFromCEMeasured, expInfo.Hardware);
|
||||
|
||||
// if(expInfo.sampleRate != reflectParams::aScanReconstructionFrequency)
|
||||
// {
|
||||
// reflectParams::expectedAScanDataLength = ceil(expInfo.numberSamples * ((double)reflectParams::aScanReconstructionFrequency / expInfo.sampleRate));
|
||||
// }
|
||||
|
||||
// preComputes.matchedFilterRef = createMatchedFilter(ceRef.ce, ceRef.measuredCEUsed, reflectParams::findDefects, reconParams::removeOutliersFromCEMeasured, expInfo.Hardware);
|
||||
|
||||
// preComputes.timeInterval = (double)1 / reflectParams::aScanReconstructionFrequency;
|
||||
// preComputes.measuredCEUsed = ce.measuredCEUsed;
|
||||
// preComputes.measuredCE_TASIndices = ce.tasIndices;
|
||||
// preComputes.measuredCE_receiverIndices = ce.receiverIndices;
|
||||
// preComputes.offset = estimateOffset(expInfo, ce, preComputes.matchedFilter);
|
||||
|
||||
// expInfo.matchedFilter = preComputes.matchedFilter;
|
||||
// expInfoRef.matchedFilter = preComputes.matchedFilterRef;
|
||||
|
||||
// CeEstimatePulseLength ceEstimatePulseLength;
|
||||
// CeEstimatePulseLength ceEstimatePulseLengthRef;
|
||||
// if(ce.measuredCEUsed)
|
||||
// {
|
||||
// ceEstimatePulseLength.ce = mean(ce.ce, FunctionDirection::Row);
|
||||
// ceEstimatePulseLengthRef.ce = mean(ce.ce, FunctionDirection::Row);
|
||||
// ceEstimatePulseLength.ce_sf = reflectParams::aScanReconstructionFrequency;
|
||||
// ceEstimatePulseLengthRef.ce_sf = reflectParams::aScanReconstructionFrequency;
|
||||
// }
|
||||
|
||||
// transParams::pulseLengthSamples = estimatePulseLength(ceEstimatePulseLength, reflectParams::aScanReconstructionFrequency);
|
||||
// transParams::pulseLengthRefSamples = estimatePulseLength(ceEstimatePulseLengthRef, reflectParams::aScanReconstructionFrequency);
|
||||
|
||||
// Matrix iMp;
|
||||
// Matrix mp_inter = intersect(motorPosAvailable, transParams::motorPos, iMp);
|
||||
// double* mpRef_interData = Aurora::malloc(iMp.getDataSize());
|
||||
// for(int i=0; i<iMp.getDataSize(); ++i)
|
||||
// {
|
||||
// mpRef_interData[i] = motorPosAvailableRef[iMp[i] - 1];
|
||||
// }
|
||||
// Matrix mpRef_inter = Matrix::New(mpRef_interData, iMp.getDataSize());
|
||||
// Matrix slList_inter = intersect(slList, transParams::senderTasList);
|
||||
// Matrix snList_inter = intersect(snList, transParams::senderElementList);
|
||||
// Matrix rlList_inter = intersect(rlList, transParams::receiverTasList);
|
||||
// Matrix rnList_inter = intersect(rnList, transParams::receiverElementList);
|
||||
|
||||
// transParams::aScanReconstructionFrequency = reflectParams::aScanReconstructionFrequency;
|
||||
// transParams::gpuSelectionList = reconParams::gpuSelectionList;
|
||||
|
||||
// GeometryInfo geomRef = getGeometryInfo(motorPosAvailableRef, transformationMatricesRef, rlList, rnList, slList, snList);
|
||||
// auto result = getTransmissionData(mp_inter, mpRef_inter, slList_inter, snList_inter, rlList_inter, rnList_inter, temp, tempRef, geom, geomRef, expInfo, expInfoRef, preComputes, &dataParser, &refParser);
|
||||
|
||||
// MatlabReader m("/home/sun/testData/getTransmissionData.mat");
|
||||
// auto mp = m.read("mp");
|
||||
// auto attDataTotal = m.read("attDataTotal");
|
||||
// auto findDefect = m.read("findDefect");
|
||||
// auto numPossibleScans = m.read("numPossibleScans");
|
||||
// auto numValidScans = m.read("numValidScans");
|
||||
// auto receiverList = m.read("receiverList");
|
||||
// auto rl = m.read("rl");
|
||||
// auto rn = m.read("rn");
|
||||
// auto senderList = m.read("senderList");
|
||||
// auto sl = m.read("sl");
|
||||
// auto sn = m.read("sn");
|
||||
// auto tofDataTotal = m.read("tofDataTotal");
|
||||
// auto waterTempList = m.read("waterTempList");
|
||||
|
||||
// EXPECT_DOUBLE_EQ(mp.getDataSize(),result.dataInfo.mp.getDataSize());
|
||||
// for(int i=0; i<mp.getDataSize(); ++i)
|
||||
// {
|
||||
// EXPECT_DOUBLE_AE(mp[i],result.dataInfo.mp[i]) << " mp: "<<i;
|
||||
// }
|
||||
|
||||
// EXPECT_DOUBLE_EQ(attDataTotal.getDataSize(),result.attDataTotal.getDataSize());
|
||||
// for(int i=0; i<attDataTotal.getDataSize(); ++i)
|
||||
// {
|
||||
// //有偏差
|
||||
// EXPECT_DOUBLE_AE(attDataTotal[i],result.attDataTotal[i]) << " attDataTotal: "<<i;
|
||||
// }
|
||||
|
||||
// EXPECT_DOUBLE_EQ(findDefect.getDataSize(),result.dataInfo.findDefect.getDataSize());
|
||||
// for(int i=0; i<findDefect.getDataSize(); ++i)
|
||||
// {
|
||||
// EXPECT_DOUBLE_AE(findDefect[i],result.dataInfo.findDefect[i]) << " findDefect: "<<i;
|
||||
// }
|
||||
|
||||
// for(int i=0; i<numPossibleScans.getDataSize(); ++i)
|
||||
// {
|
||||
// EXPECT_DOUBLE_AE(numPossibleScans[i],result.dataInfo.numPossibleScans) << " numPossibleScans: "<<i;
|
||||
// }
|
||||
|
||||
// EXPECT_DOUBLE_EQ(numValidScans.getDataSize(),result.dataInfo.numValidScans.getDataSize());
|
||||
// for(int i=0; i<numValidScans.getDataSize(); ++i)
|
||||
// {
|
||||
// EXPECT_DOUBLE_AE(numValidScans[i],result.dataInfo.numValidScans[i]) << " numValidScans: "<<i;
|
||||
// }
|
||||
|
||||
// EXPECT_DOUBLE_EQ(receiverList.getDataSize(),result.receiverList.getDataSize());
|
||||
// for(int i=0; i<receiverList.getDataSize(); ++i)
|
||||
// {
|
||||
// EXPECT_DOUBLE_AE(receiverList[i],result.receiverList[i]) << " receiverList: "<<i;
|
||||
// }
|
||||
|
||||
// EXPECT_DOUBLE_EQ(rl.getDataSize(),result.dataInfo.rl.getDataSize());
|
||||
// for(int i=0; i<rl.getDataSize(); ++i)
|
||||
// {
|
||||
// EXPECT_DOUBLE_AE(rl[i],result.dataInfo.rl[i]) << " rl: "<<i;
|
||||
// }
|
||||
|
||||
// EXPECT_DOUBLE_EQ(rn.getDataSize(),result.dataInfo.rn.getDataSize());
|
||||
// for(int i=0; i<rn.getDataSize(); ++i)
|
||||
// {
|
||||
// EXPECT_DOUBLE_AE(rn[i],result.dataInfo.rn[i]) << " rn: "<<i;
|
||||
// }
|
||||
|
||||
// EXPECT_DOUBLE_EQ(sl.getDataSize(),result.dataInfo.sl.getDataSize());
|
||||
// for(int i=0; i<sl.getDataSize(); ++i)
|
||||
// {
|
||||
// EXPECT_DOUBLE_AE(sl[i],result.dataInfo.sl[i]) << " sl: "<<i;
|
||||
// }
|
||||
|
||||
// EXPECT_DOUBLE_EQ(sn.getDataSize(),result.dataInfo.sn.getDataSize());
|
||||
// for(int i=0; i<sn.getDataSize(); ++i)
|
||||
// {
|
||||
// EXPECT_DOUBLE_AE(sn[i],result.dataInfo.sn[i]) << " sn: "<<i;
|
||||
// }
|
||||
|
||||
// EXPECT_DOUBLE_EQ(senderList.getDataSize(),result.senderList.getDataSize());
|
||||
// for(int i=0; i<senderList.getDataSize(); ++i)
|
||||
// {
|
||||
// EXPECT_DOUBLE_AE(senderList[i],result.senderList[i]) << " senderList: "<<i;
|
||||
// }
|
||||
|
||||
// EXPECT_DOUBLE_EQ(waterTempList.getDataSize(),result.waterTempList.getDataSize());
|
||||
// for(int i=0; i<waterTempList.getDataSize(); ++i)
|
||||
// {
|
||||
// EXPECT_DOUBLE_AE(waterTempList[i],result.waterTempList[i]) << " waterTempList: "<<i;
|
||||
// }
|
||||
|
||||
// EXPECT_DOUBLE_EQ(tofDataTotal.getDataSize(),result.tofDataTotal.getDataSize());
|
||||
// for(int i=0; i<tofDataTotal.getDataSize(); ++i)
|
||||
// {
|
||||
// EXPECT_DOUBLE_AE(tofDataTotal[i],result.tofDataTotal[i]) << " tofDataTotal: "<<i;
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user