From 7088602b5912ffa0e274512d8089816c8425113c Mon Sep 17 00:00:00 2001 From: sunwen Date: Fri, 19 May 2023 10:28:22 +0800 Subject: [PATCH] Update geometry info , measrementInfo for startReconstruction. --- src/common/estimatePulseLength.cpp | 22 +++++ src/common/estimatePulseLength.h | 17 ++++ src/common/getGeometryInfo.cpp | 4 +- src/common/getGeometryInfo.h | 2 +- src/common/getMeasurementMetaData.cpp | 2 + src/common/getMeasurementMetaData.h | 3 + src/config/config.h | 31 ++++--- .../preprocessData/estimateOffset.cpp | 93 +++++++++++++++++++ .../preprocessData/estimateOffset.h | 11 +++ 9 files changed, 168 insertions(+), 17 deletions(-) create mode 100644 src/common/estimatePulseLength.cpp create mode 100644 src/common/estimatePulseLength.h create mode 100644 src/reflectionReconstruction/preprocessData/estimateOffset.cpp create mode 100644 src/reflectionReconstruction/preprocessData/estimateOffset.h diff --git a/src/common/estimatePulseLength.cpp b/src/common/estimatePulseLength.cpp new file mode 100644 index 0000000..9307c41 --- /dev/null +++ b/src/common/estimatePulseLength.cpp @@ -0,0 +1,22 @@ +#include "estimatePulseLength.h" +#include "Function1D.h" +#include "Function2D.h" +#include +#include + +using namespace Aurora; + +double Recon::estimatePulseLength(const CeEstimatePulseLength& aCe, double aSampleFreq) +{ + Matrix value1 = abs(hilbert(aCe.ce)); + double value2 = 0.05 * max(abs(hilbert(aCe.ce)),All)[0]; + std::vector t; + for(size_t i=0; i value2) + { + t.push_back(i); + } + } + return (t[t.size()-1] - t[0]) / aCe.ce_sf * aSampleFreq; +} \ No newline at end of file diff --git a/src/common/estimatePulseLength.h b/src/common/estimatePulseLength.h new file mode 100644 index 0000000..804af85 --- /dev/null +++ b/src/common/estimatePulseLength.h @@ -0,0 +1,17 @@ +#ifndef ESTIMATE_PULSE_LENGTH_H +#define ESTIMATE_PULSE_LENGTH_H + +#include "Matrix.h" + +namespace Recon +{ + struct CeEstimatePulseLength + { + Aurora::Matrix ce; + double ce_sf; + }; + + double estimatePulseLength(const CeEstimatePulseLength& aCe, double aSampleFreq); +} + +#endif \ No newline at end of file diff --git a/src/common/getGeometryInfo.cpp b/src/common/getGeometryInfo.cpp index d3c23dd..1e0ebe7 100644 --- a/src/common/getGeometryInfo.cpp +++ b/src/common/getGeometryInfo.cpp @@ -192,13 +192,13 @@ void getApertureBoundingBox(GeometryInfo& aOutput) } } -GeometryInfo Recon::getGeometryInfo(const Matrix& aMotorPos, const Matrix& aTransformationMatricesRef, +GeometryInfo Recon::getGeometryInfo(const Matrix& aMotorPos, const Matrix& aTransformationMatrices, const Matrix aRlList, const Matrix aRnList, const Matrix aSlList, const Matrix aSnList) { GeometryInfo result; result.headTable = Recon::HEAD_TABLE; result.sensChar = loadSensitivity(); - transformGeometry(aMotorPos, aTransformationMatricesRef, aRlList, aRnList, aSlList, aSnList, result); + transformGeometry(aMotorPos, aTransformationMatrices, aRlList, aRnList, aSlList, aSnList, result); getApertureBoundingBox(result); result.maxSL = emitterPositions.size(); result.maxSN = emitterPositions[0].getDimSize(0); diff --git a/src/common/getGeometryInfo.h b/src/common/getGeometryInfo.h index 655b94e..9e96651 100644 --- a/src/common/getGeometryInfo.h +++ b/src/common/getGeometryInfo.h @@ -26,7 +26,7 @@ namespace Recon std::vector receiverPositions; }; - GeometryInfo getGeometryInfo(const Aurora::Matrix& aMotorPos, const Aurora::Matrix& aTransformationMatricesRef, + GeometryInfo getGeometryInfo(const Aurora::Matrix& aMotorPos, const Aurora::Matrix& aTransformationMatrices, const Aurora::Matrix aRlList, const Aurora::Matrix aRnList, const Aurora::Matrix aSlList, const Aurora::Matrix aSnList); } diff --git a/src/common/getMeasurementMetaData.cpp b/src/common/getMeasurementMetaData.cpp index 7cf2709..14eb13a 100644 --- a/src/common/getMeasurementMetaData.cpp +++ b/src/common/getMeasurementMetaData.cpp @@ -53,6 +53,8 @@ MeasurementInfo Recon::loadMeasurementInfos(Parser* aParser) result.Wavelength = 3; result.expectedAScanLength = result.numberSamples; result.rootMeasUniqueID = metaData.getMeasurementID(); + result.dacDelay = metaData.getDacDelay(); + result.filterByPass = metaData.getFilterByPass(); if(result.Bandpassundersampling) { result.expectedAScanLength = reflectParams::aScanReconstructionFrequency / result.sampleRate * result.expectedAScanLength; diff --git a/src/common/getMeasurementMetaData.h b/src/common/getMeasurementMetaData.h index 6633fa3..18369c9 100644 --- a/src/common/getMeasurementMetaData.h +++ b/src/common/getMeasurementMetaData.h @@ -20,6 +20,9 @@ namespace Recon int Wavelength; unsigned int expectedAScanLength; std::string rootMeasUniqueID; + double dacDelay; + double filterByPass; + Aurora::Matrix matchedFilter; }; struct CEInfo diff --git a/src/config/config.h b/src/config/config.h index 94914d6..dd5c9d4 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -10,25 +10,25 @@ namespace Recon { //reconParams.measurementInfo.ce static bool useCEMeasured = true; - static int removeOutliersFromCEMeasured = 1; + static bool removeOutliersFromCEMeasured = true; static double offsetFilterEnabled = 6.9e-6; static double offsetFilterDisabled = 1.2e-6; //reconParams.measurementInfo.temp static bool useTASTempComp = true; static bool correctTASTemp = 1; - static //reconParams.hardwareSelection - int gpuSelectionList[8] = {0,1,2,3,4,5,6,7}; - static //reconParams.dataInfo - int expectedAScanDataLength = 4000; + //reconParams.hardwareSelection + static Aurora::Matrix gpuSelectionList = Aurora::Matrix::fromRawData(new double[8]{0,1,2,3,4,5,6,7},8); + //reconParams.dataInfo + static int expectedAScanDataLength = 4000; } namespace reflectParams { //reflectParams.dataSelection - static double senderTasList[128]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128};//1~128 - static double senderElementList[18]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};//1~18 - static double receiverTasList[128]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128};//1~128 - static double receiverElementList[18]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};//1~18 + static Aurora::Matrix senderTasList = Aurora::Matrix::fromRawData(new double[128]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128},128);//1~128 + static Aurora::Matrix senderElementList = Aurora::Matrix::fromRawData(new double[18]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18},18);//1~18 + static Aurora::Matrix receiverTasList = Aurora::Matrix::fromRawData(new double[128]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128},128);//1~128 + static Aurora::Matrix receiverElementList = Aurora::Matrix::fromRawData(new double[18]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18},18);//1~18 static Aurora::Matrix motorPos = Aurora::Matrix::fromRawData(new double[2]{1,2}, 2); static int constricReflectionAngles = 1; static int angleLowerLimit = 45; @@ -64,7 +64,7 @@ namespace Recon static int suppressSameHead = 1; static int suppressSameHeadLength = 1500; static int useCorrelation = 1; - static int matchedFilterCeAScan = 1; + static bool matchedFilterCeAScan = true; static int windowLength = 10; static int numThreads = 30; static int expectedUSSpeedRange[2] = {1420,1600}; @@ -89,15 +89,16 @@ namespace Recon namespace transParams { + static Aurora::Matrix gpuSelectionList; //transParams.dataSelection static int verbose = 1; static int saveRecon = 1; static int saveDebugInfomation = 1; //transParams.dataSelection - static double senderTasList[128]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128};//1~128 - static double senderElementList[18]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};//1~18 - static double receiverTasList[128]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128};//1~128 - static double receiverElementList[18]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};//1~18 + static Aurora::Matrix senderTasList = Aurora::Matrix::fromRawData(new double[128]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128},128);//1~128 + static Aurora::Matrix senderElementList = Aurora::Matrix::fromRawData(new double[18]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18},18);//1~18 + static Aurora::Matrix receiverTasList = Aurora::Matrix::fromRawData(new double[128]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128},128);//1~128 + static Aurora::Matrix receiverElementList = Aurora::Matrix::fromRawData(new double[18]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18},18);//1~18 static Aurora::Matrix motorPos = Aurora::Matrix::fromRawData(new double[2]{1,2}, 2); static int filterSensitivity = 1; static double sensFilter = 0.3; @@ -134,6 +135,8 @@ namespace Recon static int maxSpeedOfSound = 1550; static int detectionWindowSOS = 1; static int detectionWindowATT = 50; + static double pulseLengthSamples = 0; + static double pulseLengthRefSamples = 0; //transParams.rayTracing static int bentReconstruction = 0; static int bresenham = 1; diff --git a/src/reflectionReconstruction/preprocessData/estimateOffset.cpp b/src/reflectionReconstruction/preprocessData/estimateOffset.cpp new file mode 100644 index 0000000..2f4935c --- /dev/null +++ b/src/reflectionReconstruction/preprocessData/estimateOffset.cpp @@ -0,0 +1,93 @@ +#include "estimateOffset.h" +#include "../../common/ceMatchedFilterHandling.h" +#include "Function.h" +#include "Function1D.h" +#include "Function2D.h" +#include "Matrix.h" +#include "src/config/config.h" +#include + +using namespace Recon; +using namespace Aurora; + +double Recon::estimateOffset(const MeasurementInfo aExpInfo, const CEInfo& aCe, const Aurora::Matrix& aMatchedFilter) +{ + double offset = 0; + Matrix ce = aCe.ceRef; + double ceOffSet = aCe.ceRefOffSet; + Matrix ceMeasured; + if(aCe.measuredCEAvailable) + { + if(aCe.measuredCEUsed) + { + ceMeasured = real(ifft(aMatchedFilter)); + } + else + { + ceMeasured = real(ifft(reviseMatchedFilter(aCe.ce, true))); + } + } + + offset = offset + reflectParams::offsetElectronic; + if(!aCe.measuredCEUsed) + { + if(aCe.measuredCEAvailable && aCe.ceAvailable) + { + size_t column = ceMeasured.getDimSize(1); + size_t ceRows = ce.getDimSize(0); + double* offsetCEMeasuredData = Aurora::malloc(column); + for(int i=0; i