diff --git a/src/common/daraBlockCreation/getAscanBlock.cpp b/src/common/daraBlockCreation/getAscanBlock.cpp new file mode 100644 index 0000000..2f239f9 --- /dev/null +++ b/src/common/daraBlockCreation/getAscanBlock.cpp @@ -0,0 +1,102 @@ +#include "getAscanBlock.h" + +#include "Function.h" +#include "Matrix.h" +#include "Parser.h" +#include "Data/OneTasAScanData.h" +#include "Data/AScanData.h" +#include "Data/TasElementIndex.h" +#include "Data/ElementIndex.h" +#include "Data/GeometryIndex.h" +#include "Data/ElectricIndex.h" +#include "Data/MetaData.h" +#include "ShotList/ShotList.h" +#include + +using namespace Recon; +using namespace Aurora; + +namespace +{ + std::vector findTasIndex(TasIndicesPointer aTasIndices, int aTasNum) + { + std::vector result; + for(int i=0; igetMetaData().getSampleNumber(); + double* ascanBlockData = new double[ascanBlockSize]; + double* mpBlockData = new double[numScans]; + double* slBlockData = new double[numScans]; + double* snBlockData = new double[numScans]; + double* rlBlockData = new double[numScans]; + double* rnBlockData = new double[numScans]; + double* gainBlockData = new double[numScans]; + result.ascanBlock = Matrix::fromRawData(ascanBlockData, aParser->getMetaData().getSampleNumber(), numScans); + result.mpBlock = Matrix::fromRawData(mpBlockData, 1, numScans); + result.slBlock = Matrix::fromRawData(slBlockData, 1, numScans); + result.snBlock = Matrix::fromRawData(snBlockData, 1, numScans); + result.rlBlock = Matrix::fromRawData(rlBlockData, 1, numScans); + result.rnBlock = Matrix::fromRawData(rnBlockData, 1, numScans); + result.gainBlock = Matrix::fromRawData(gainBlockData, 1, numScans); + OneTasAScanData oenTasData = aParser->getOneTasAscanDataOfMotorPosition(1); + auto tasIndices = aParser->getMetaData().getTasIndices(); + auto receiverIndices = aParser->getMetaData().getReceiverIndices(); + for(int mpIndex=0; mpIndexgetOneTasAscanDataOfMotorPosition(aSl[slIndex]); + for(int snIndex=0; snIndexsearchAscanDataFromOneTasAscanDataOfMP(oenTasData, ElementIndex(GeometryIndex(aSn[snIndex])), TasElementIndex(aRl[rlIndex], ElementIndex(GeometryIndex(receiverIndices.get()[rElementIndex[rnIndex]]))), mp); + std::copy(ascan.get() ,ascan.get() + ascan.getAscanDataLength(), ascanBlockData); + ascanBlockData += ascan.getAscanDataLength(); + + mpBlockData[numScansIndex] = aMp[mpIndex]; + slBlockData[numScansIndex] = aSl[slIndex]; + snBlockData[numScansIndex] = aSn[snIndex]; + rlBlockData[numScansIndex] = aRl[rlIndex]; + rnBlockData[numScansIndex] = receiverIndices.get()[rElementIndex[rnIndex]]; + gainBlockData[numScansIndex] = ascan.getAmplification()[0]; + ++numScansIndex; + } + } + } + } + } + + // 改分支不会进,暂不实现 todo + // % initialized and calculated numbers agree?, otherwise reduce block sizes + // if num ~= numScans + // warning([mfilename, ':MissingSenderReceiverInfos'],'Not all defined data available.') + // writeReconstructionLog('Not all defined sender/receiver available', 3); + // usedDataIdxs = 1:num; + // [slBlock, snBlock, rlBlock, rnBlock, mpBlock, gainBlock] = removeDataFromArrays(usedDataIdxs, slBlock, snBlock, rlBlock, rnBlock, mpBlock, gainBlock); + // AscanBlock = AscanBlock(:,usedDataIdxs); + // end + + + return result; +} \ No newline at end of file diff --git a/src/common/daraBlockCreation/getAscanBlock.h b/src/common/daraBlockCreation/getAscanBlock.h new file mode 100644 index 0000000..8787d9b --- /dev/null +++ b/src/common/daraBlockCreation/getAscanBlock.h @@ -0,0 +1,25 @@ +#ifndef GET_ASCAN_BLOCK_H +#define GET_ASCAN_BLOCK_H + +#include "Matrix.h" +#include "src/common/getMeasurementMetaData.h" + +class Parser; + +namespace Recon +{ + struct AscanBlock + { + Aurora::Matrix ascanBlock; + Aurora::Matrix mpBlock; + Aurora::Matrix slBlock; + Aurora::Matrix snBlock; + Aurora::Matrix rlBlock; + Aurora::Matrix rnBlock; + Aurora::Matrix gainBlock; + }; + AscanBlock getAscanBlock(Parser* aParser, const Aurora::Matrix& mp, const Aurora::Matrix& aSL, const Aurora::Matrix& aSn, + const Aurora::Matrix& aRl, const Aurora::Matrix& aRn); +} + +#endif \ No newline at end of file diff --git a/test/Common_Test.cpp b/test/Common_Test.cpp index e9fdd70..3cde6aa 100644 --- a/test/Common_Test.cpp +++ b/test/Common_Test.cpp @@ -5,6 +5,9 @@ #include "common/common.h" #include "common/convertfp16tofloat.h" #include "common/getGeometryInfo.h" +#include "common/daraBlockCreation/getAscanBlock.h" + +#include "Parser.h" #include "MatlabReader.h" inline double fourDecimalRound(double src){ @@ -219,3 +222,68 @@ TEST_F(Common_Test, getGeometryInfo) { Aurora::Matrix maxRN = m.read("maxRN"); EXPECT_DOUBLE_EQ(geom.maxRN, maxRN[0]); } + +TEST_F(Common_Test, getAscanBlock) { + MatlabReader m("/home/sun/testData/getAscanBlock.mat"); + std::string dataPath = "/home/AScans_Data/volunteer_20230328/20230328T123237/"; + Parser parser(dataPath); + auto ascanBlock = m.read("AscanBlock"); + auto result = Recon::getAscanBlock(&parser, Aurora::Matrix::fromRawData(new double[1]{1}, 1), Aurora::Matrix::fromRawData(new double[1]{1}, 1), + 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), + Aurora::Matrix::fromRawData(new double[1]{1}, 1), + 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)); + for(int i=0; i