From c61a0ce09eaeca432233d496c77547e7459e6158 Mon Sep 17 00:00:00 2001 From: sunwen Date: Thu, 1 Jun 2023 13:39:24 +0800 Subject: [PATCH] Update reconstructArt and unittest. Fix buildMatrix bug. --- .../buildMatrix/buildMatrix.cpp | 16 +-- .../reconstruction/reconstruction.cpp | 111 +++++++++++++++++- test/Reconstruction_Test.cpp | 45 +++++++ 3 files changed, 159 insertions(+), 13 deletions(-) diff --git a/src/transmissionReconstruction/reconstruction/buildMatrix/buildMatrix.cpp b/src/transmissionReconstruction/reconstruction/buildMatrix/buildMatrix.cpp index 9c32355..3a72f51 100644 --- a/src/transmissionReconstruction/reconstruction/buildMatrix/buildMatrix.cpp +++ b/src/transmissionReconstruction/reconstruction/buildMatrix/buildMatrix.cpp @@ -1,5 +1,6 @@ #include "buildMatrix.h" +#include #include #include #include @@ -34,12 +35,8 @@ namespace Recon TraceStraightRayResult result; auto path = transpose(b3dMexDouble(startPt, endPt)); result.pathLen = path.getDimSize(0); - uint *temp = new uint[path.getDataSize()]{0}; //uint32(path) - std::copy(path.getData(),path.getData()+path.getDataSize(),temp); - std::copy(temp,temp+path.getDataSize(),path.getData()); - delete [] temp; - result.path = path; + result.path = round(path); result.weighting = getPixelLengthApproximation(startPt, endPt, res, result.pathLen); return result; } @@ -304,19 +301,21 @@ namespace Recon dims.getDimSize(1) == 2 ? convertToLinearIndices(dims, path.block(1, 0, 1)) : convertToLinearIndices(dims, path); + linearIndices = linearIndices-1; + linearIndices.forceReshape(1, linearIndices.getDataSize(), 1); if (Recon::transParams::saveDebugInfomation){ for (size_t i = 0; i < linearIndices.getDataSize(); i++) { result.hitmap[linearIndices[i]]+=1; } } - printf("Progress: %f (%zu of %zu\r\n)",(double)rayCount*100/(double)nTotalRays,rayCount,nTotalRays); + printf("Progress: %f (%zu of %zu)\r\n",(double)rayCount*100/(double)nTotalRays,rayCount,nTotalRays); cnt = cnt + pathLenDisc; if (cnt < safesize) { - i.setBlockValue(1, coeffIndex, cnt, rayCount-1); - j.setBlock(1,coeffIndex,cnt,linearIndices); + i.setBlockValue(1, coeffIndex, cnt-1, rayCount-1); + j.setBlock(1,coeffIndex,cnt-1,linearIndices); if (weighting.isScalar()){ s.setBlockValue(1, coeffIndex, cnt,weighting.getScalar()); } @@ -343,6 +342,7 @@ namespace Recon } coeffIndex = cnt; } + result.M = Sparse(i.block(0,0,coeffIndex-1), j.block(0,0,coeffIndex-1),s.block(0,0,coeffIndex-1),rayCount,prod(dims).getScalar()); return result; } diff --git a/src/transmissionReconstruction/reconstruction/reconstruction.cpp b/src/transmissionReconstruction/reconstruction/reconstruction.cpp index 3b29813..3fbdb05 100644 --- a/src/transmissionReconstruction/reconstruction/reconstruction.cpp +++ b/src/transmissionReconstruction/reconstruction/reconstruction.cpp @@ -7,10 +7,13 @@ #include "config/config.h" #include "CudaEnvInit.h" +#include "transmissionReconstruction/reconstruction/buildMatrix/buildMatrix.h" +#include "src/transmissionReconstruction/reconstruction/solvingEquationSystem/solve.h" #include #include #include +#include using namespace Aurora; namespace Recon { Aurora::Matrix calculateMinimalMaximalTransducerPositions( @@ -115,19 +118,117 @@ namespace Recon { Aurora::Matrix &receiverList, Aurora::Matrix &res, double SOS_IN_WATER) { - auto nTotalRays = size(senderList, 2); + ArtResult result; + int nTotalRays = size(senderList, 2); int numIter = 1; - if (transParams::bentReconstruction) + bool bentRecon = transParams::bentReconstruction; + if (bentRecon) { - numIter =transParams::bentIter+1; + numIter =transParams::bentIter + 1; } for (size_t i = 0; i < transParams::gpuSelectionList.getDataSize(); i++) { std::string msg; - if (!resetGPUDevice((int)transParams::gpuSelectionList[i],msg)) + // if (!resetGPUDevice((int)transParams::gpuSelectionList[i],msg)) + // { + // std::cerr< potentialMapDataDims = {1,1,1}; + for(size_t i=0; i allHitMaps; + if(transParams::saveDebugInfomation) + { + for(int i=0; i