Update reconstructArt and unittest.
Fix buildMatrix bug.
This commit is contained in:
@@ -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 <algorithm>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
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<<msg<<std::endl;
|
||||
// }
|
||||
}
|
||||
std::vector<int> potentialMapDataDims = {1,1,1};
|
||||
for(size_t i=0; i<dims.getDataSize(); ++i)
|
||||
{
|
||||
potentialMapDataDims[i] = dims[i];
|
||||
}
|
||||
Matrix potentialMap = (zeros(potentialMapDataDims[0], potentialMapDataDims[1], potentialMapDataDims[2]) + 1) * SOS_IN_WATER;
|
||||
|
||||
Matrix b;
|
||||
if(!data.isNull())
|
||||
{
|
||||
b = data;
|
||||
b.forceReshape(b.getDataSize(), 1, 1);
|
||||
for(size_t i=0; i<b.getDataSize(); ++i)
|
||||
{
|
||||
std::cerr<<msg<<std::endl;
|
||||
if(b[i] != b[i] || b[i] == INFINITY)
|
||||
{
|
||||
b[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(bentRecon)
|
||||
{
|
||||
bentRecon = false;
|
||||
numIter = 1;
|
||||
std::cout<<"No SOS data. Attenuation reconstruction is carried out without bent ray calculations."<<std::endl;
|
||||
}
|
||||
|
||||
Matrix bAtt;
|
||||
if(!dataAtt.isNull())
|
||||
{
|
||||
bAtt = dataAtt;
|
||||
bAtt.forceReshape(bAtt.getDataSize(), 1, 1);
|
||||
for(size_t i=0; i<bAtt.getDataSize(); ++i)
|
||||
{
|
||||
if(bAtt[i] != bAtt[i] || bAtt[i] == INFINITY)
|
||||
{
|
||||
bAtt[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Matrix> allHitMaps;
|
||||
if(transParams::saveDebugInfomation)
|
||||
{
|
||||
for(int i=0; i<numIter; ++i)
|
||||
{
|
||||
allHitMaps.push_back(Matrix());
|
||||
}
|
||||
}
|
||||
|
||||
transParams::nonNeg = false;
|
||||
BuildMatrixResult buildMatrixR;
|
||||
for(int iter=1; iter<=numIter; ++iter)
|
||||
{
|
||||
buildMatrixR = buildMatrix(senderList, receiverList, res, dims, bentRecon && (iter!=1), potentialMap);
|
||||
if(!data.isNull() && bentRecon && iter != numIter)
|
||||
{
|
||||
//与默认配置bentRecon不符,暂不实现
|
||||
// % reconstruction
|
||||
// if(iter == 1)
|
||||
// solverOutput = solveParameterIterator(M, b, dims, parameters, 0); % straight ray with all mus and betas
|
||||
// else
|
||||
// solverOutput = solveParameterIterator(M, b, dims, parameters, 1);
|
||||
// end
|
||||
// f1 = slownessToSOS(solverOutput{1}, SOS_IN_WATER);
|
||||
|
||||
// if iter == 1
|
||||
// outAll.straightRay = cellfun(@slownessToSOS, solverOutput, repmat({SOS_IN_WATER}, size(solverOutput)), 'UniformOutput', false);
|
||||
// else
|
||||
// outAll.bentRay{iter-1} = f1;
|
||||
// end
|
||||
// % look if exit criterion reached
|
||||
// if exitBent(f1, potentialMap, parameters, iter-1)
|
||||
// break;
|
||||
// end
|
||||
|
||||
// potentialMap = f1;
|
||||
}
|
||||
else if(bentRecon && iter == numIter)
|
||||
{
|
||||
printf("Maximum of %d iterations for bent ray reconstruction reached. Exiting the loop.\n",iter);
|
||||
}
|
||||
|
||||
if(transParams::saveDebugInfomation && !buildMatrixR.hitmap.isNull())
|
||||
{
|
||||
allHitMaps.push_back(buildMatrixR.hitmap);
|
||||
}
|
||||
|
||||
if(!data.isNull())
|
||||
{
|
||||
result.outSOS = solveParameterIterator(buildMatrixR.M, b, dims, false, transParams::nonNeg)[0][0];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Recon
|
||||
Reference in New Issue
Block a user