Compare commits
4 Commits
dev-sunwen
...
Change-dou
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34d7086b47 | ||
|
|
b070c3d5a8 | ||
|
|
356691ee6f | ||
|
|
d028a604a4 |
@@ -130,11 +130,12 @@ namespace Recon
|
|||||||
}
|
}
|
||||||
exportDCM(path, reflectParams::imageStartpoint.getData(),
|
exportDCM(path, reflectParams::imageStartpoint.getData(),
|
||||||
reflectParams::imageEndpoint.getData(), XYZ, aMatrix.getData(), type);
|
reflectParams::imageEndpoint.getData(), XYZ, aMatrix.getData(), type);
|
||||||
|
RECON_INFO("Save DICOM to Path:{0}, type:{1}==================>",path,(int)type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DICOMExporter::exportDCM(string path, float * startPoint, float* endPoint, int* imageXYZ,float* data, int type)
|
void DICOMExporter::exportDCM(string path, float * startPoint, float* endPoint, int* imageXYZ,float* data, int type)
|
||||||
{
|
{
|
||||||
long Rows = imageXYZ[0], Cols = imageXYZ[1] ,Slices = imageXYZ[2];
|
long Rows = imageXYZ[1], Cols = imageXYZ[0] ,Slices = imageXYZ[2];
|
||||||
DcmFileFormat dcmFile;
|
DcmFileFormat dcmFile;
|
||||||
DcmDataset* dataset = dcmFile.getDataset();
|
DcmDataset* dataset = dcmFile.getDataset();
|
||||||
DcmMetaInfo* metaInfo = dcmFile.getMetaInfo();
|
DcmMetaInfo* metaInfo = dcmFile.getMetaInfo();
|
||||||
@@ -157,7 +158,7 @@ namespace Recon
|
|||||||
"InstName":mPatientData.getInstituationName().data());
|
"InstName":mPatientData.getInstituationName().data());
|
||||||
dataset->putAndInsertString(DCM_InstitutionAddress, mPatientData.getInstituationAddress().empty()?
|
dataset->putAndInsertString(DCM_InstitutionAddress, mPatientData.getInstituationAddress().empty()?
|
||||||
"default addr":mPatientData.getInstituationAddress().data());
|
"default addr":mPatientData.getInstituationAddress().data());
|
||||||
dataset->putAndInsertString(DCM_ReferringPhysicianName,mPatientData.getOperatorName().empty()?
|
dataset->putAndInsertString(DCM_ReferringPhysicianName,mPatientData.getReferringPhysicianName().empty()?
|
||||||
"ReferringPhysician": mPatientData.getOperatorName().data());
|
"ReferringPhysician": mPatientData.getOperatorName().data());
|
||||||
dataset->putAndInsertString(DCM_PatientName, mPatientData.getPatientName().empty()?
|
dataset->putAndInsertString(DCM_PatientName, mPatientData.getPatientName().empty()?
|
||||||
"TestPatient":mPatientData.getPatientName().data());
|
"TestPatient":mPatientData.getPatientName().data());
|
||||||
@@ -183,7 +184,7 @@ namespace Recon
|
|||||||
endPoint[2]*(float)1000.0,
|
endPoint[2]*(float)1000.0,
|
||||||
endPoint[0]*(float)1000.0,
|
endPoint[0]*(float)1000.0,
|
||||||
};
|
};
|
||||||
float originLocation =endPoint[1]*1000.0;
|
float originLocation =-endPoint[2]*1000.0;
|
||||||
dataset->putAndInsertString(DCM_SliceThickness, to_string(spacing[2]).data());
|
dataset->putAndInsertString(DCM_SliceThickness, to_string(spacing[2]).data());
|
||||||
dataset->putAndInsertUint16(DCM_Rows, Rows);
|
dataset->putAndInsertUint16(DCM_Rows, Rows);
|
||||||
dataset->putAndInsertUint16(DCM_Columns, Cols);
|
dataset->putAndInsertUint16(DCM_Columns, Cols);
|
||||||
@@ -228,11 +229,11 @@ namespace Recon
|
|||||||
{
|
{
|
||||||
dataset->putAndInsertString(DCM_AccessionNumber, to_string(i).data());
|
dataset->putAndInsertString(DCM_AccessionNumber, to_string(i).data());
|
||||||
dataset->putAndInsertString(DCM_InstanceNumber, to_string(i).data());
|
dataset->putAndInsertString(DCM_InstanceNumber, to_string(i).data());
|
||||||
string pos = to_string(originPosition[0] ) + "\\" +
|
string pos = to_string(originPosition[1] ) + "\\" +
|
||||||
to_string(originPosition[1]- i * spacing[2]) + "\\" +
|
to_string(originPosition[2]+ i * spacing[2]) + "\\" +
|
||||||
to_string(originPosition[2]);
|
to_string(originPosition[0]);
|
||||||
dataset->putAndInsertString(DCM_ImagePositionPatient, pos.data());
|
dataset->putAndInsertString(DCM_ImagePositionPatient, pos.data());
|
||||||
string loc = to_string(originLocation - i * spacing[2]);
|
string loc = to_string(originLocation + i * spacing[2]);
|
||||||
dataset->putAndInsertString(DCM_SliceLocation, loc.data());
|
dataset->putAndInsertString(DCM_SliceLocation, loc.data());
|
||||||
|
|
||||||
// set SOPInstanceUID
|
// set SOPInstanceUID
|
||||||
|
|||||||
@@ -393,23 +393,23 @@ namespace Recon
|
|||||||
nlohmann::json dataSelection = params.at("dataSelection");
|
nlohmann::json dataSelection = params.at("dataSelection");
|
||||||
if(dataSelection.contains("senderTasList"))
|
if(dataSelection.contains("senderTasList"))
|
||||||
{
|
{
|
||||||
reflectParams::senderTasList = readToMatrix(dataSelection.at("senderTasList"), false);
|
transParams::senderTasList = readToMatrix(dataSelection.at("senderTasList"), false);
|
||||||
}
|
}
|
||||||
if(dataSelection.contains("receiverTasList"))
|
if(dataSelection.contains("receiverTasList"))
|
||||||
{
|
{
|
||||||
reflectParams::receiverTasList = readToMatrix(dataSelection.at("receiverTasList"), false);
|
transParams::receiverTasList = readToMatrix(dataSelection.at("receiverTasList"), false);
|
||||||
}
|
}
|
||||||
if(dataSelection.contains("senderElementList"))
|
if(dataSelection.contains("senderElementList"))
|
||||||
{
|
{
|
||||||
reflectParams::senderElementList = readToMatrix(dataSelection.at("senderElementList"), false);
|
transParams::senderElementList = readToMatrix(dataSelection.at("senderElementList"), false);
|
||||||
}
|
}
|
||||||
if(dataSelection.contains("receiverElementList"))
|
if(dataSelection.contains("receiverElementList"))
|
||||||
{
|
{
|
||||||
reflectParams::receiverElementList = readToMatrix(dataSelection.at("receiverElementList"), false);
|
transParams::receiverElementList = readToMatrix(dataSelection.at("receiverElementList"), false);
|
||||||
}
|
}
|
||||||
if(dataSelection.contains("motorPos"))
|
if(dataSelection.contains("motorPos"))
|
||||||
{
|
{
|
||||||
reflectParams::motorPos = readToMatrix(dataSelection.at("motorPos"), false);
|
transParams::motorPos = readToMatrix(dataSelection.at("motorPos"), false);
|
||||||
}
|
}
|
||||||
if(dataSelection.contains("filterSensitivity"))
|
if(dataSelection.contains("filterSensitivity"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ bool notifyStart(const std::string& aReconID ){
|
|||||||
std::string str = "{\"ReconID\": \""+ReconID+"\"}";
|
std::string str = "{\"ReconID\": \""+ReconID+"\"}";
|
||||||
std::unordered_map<std::string, std::string> headers;
|
std::unordered_map<std::string, std::string> headers;
|
||||||
headers["Content-Type"] = "application/json";
|
headers["Content-Type"] = "application/json";
|
||||||
auto resp = req.post("https://127.0.0.1:5002/Task/Start/",str,headers);
|
auto resp = req.post("https://localhost:5002/Task/Start/",str,headers);
|
||||||
return resp->httpCode() == 200;
|
return resp->httpCode() == 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,14 +19,14 @@ bool notifyFinish(){
|
|||||||
std::string str = "{\"ReconID\": \""+ReconID+"\"}";
|
std::string str = "{\"ReconID\": \""+ReconID+"\"}";
|
||||||
std::unordered_map<std::string, std::string> headers;
|
std::unordered_map<std::string, std::string> headers;
|
||||||
headers["Content-Type"] = "application/json";
|
headers["Content-Type"] = "application/json";
|
||||||
auto resp = req.post("https://127.0.0.1:5002/Task/Finish/",str,headers);
|
auto resp = req.post("https://localhost:5002/Task/Finish/",str,headers);
|
||||||
Req::Request::Dispose();
|
Req::Request::Dispose();
|
||||||
return resp->httpCode() == 200;
|
return resp->httpCode() == 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool notifyProgress( int percent){
|
bool notifyProgress( int percent){
|
||||||
char buffer[2048] = {0};
|
char buffer[2048] = {0};
|
||||||
sprintf(buffer, "https://192.168.1.15:5003/Task/Notify/%d/", percent);
|
sprintf(buffer, "https://localhost:5002/Task/Notify/%d/", percent);
|
||||||
std::string str = "{\"ReconID\": \""+ReconID+"\"}";
|
std::string str = "{\"ReconID\": \""+ReconID+"\"}";
|
||||||
std::unordered_map<std::string, std::string> headers;
|
std::unordered_map<std::string, std::string> headers;
|
||||||
headers["Content-Type"] = "application/json";
|
headers["Content-Type"] = "application/json";
|
||||||
|
|||||||
72
src/main.cxx
72
src/main.cxx
@@ -1,6 +1,8 @@
|
|||||||
#include "Parser.h"
|
#include "Parser.h"
|
||||||
|
#include "Parser.h"
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
#include "log/notify.h"
|
#include "log/notify.h"
|
||||||
|
#include "log/notify.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#define EIGEN_USE_MKL_ALL
|
#define EIGEN_USE_MKL_ALL
|
||||||
|
|
||||||
@@ -15,51 +17,65 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int argNum = 4;
|
int argNum = 5;
|
||||||
std::vector<std::string> args(argNum);
|
std::vector<std::string> args(argNum);
|
||||||
args[0] = "/home/sun/20230418T141000/";
|
args[0] = "";
|
||||||
args[1] = "/home/sun/20230418T145123/";
|
args[1] = "";
|
||||||
args[2] = Recon::DEFAULT_OUTPUT_PATH;
|
args[2] = "";
|
||||||
args[3] = Recon::DEFAULT_CONFIG_PATH;
|
args[3] = Recon::DEFAULT_OUTPUT_PATH;
|
||||||
|
args[4] = Recon::DEFAULT_CONFIG_PATH;
|
||||||
argc = argc <= argNum? argc-1 : argNum;
|
argc = argc <= argNum? argc-1 : argNum;
|
||||||
for (int i = 0; i < argc; i++)
|
for (int i = 0; i < argc; i++)
|
||||||
{
|
{
|
||||||
args[i] = argv[i+1];
|
args[i] = argv[i+1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].empty())
|
if(args[0].empty())
|
||||||
{
|
{
|
||||||
RECON_INFO("No reconstruction data.");
|
printf("No recon id.");
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
std::string configPath = Recon::fixPathSlash(args[3]);
|
std::string ReconID = args[0];
|
||||||
Recon::initalizeConfig(configPath);
|
if(args[1].empty())
|
||||||
if( args[1].empty() && Recon::transParams::runTransmissionReco)
|
|
||||||
{
|
{
|
||||||
RECON_INFO("Running transmission reconstruction, but no refrence data.");
|
printf("No reconstruction data.");
|
||||||
return 0;
|
return -2;
|
||||||
|
}
|
||||||
|
std::string configPath = Recon::fixPathSlash(args[4]);
|
||||||
|
Recon::initalizeConfig(configPath);
|
||||||
|
if( args[2].empty() && Recon::transParams::runTransmissionReco)
|
||||||
|
{
|
||||||
|
printf("Running transmission reconstruction, but no refrence data.");
|
||||||
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string outPutPath = args[2];
|
std::string outPutPath = args[3];
|
||||||
std::string directoryPath = outPutPath;
|
std::string directoryPath = outPutPath;
|
||||||
if(Recon::endsWithMat(outPutPath))
|
auto defaultLogger = getLogger("Main",outPutPath.data());
|
||||||
{
|
spdlog::set_default_logger(defaultLogger);
|
||||||
directoryPath = Recon::getPath(outPutPath);
|
|
||||||
}
|
outPutPath = Recon::fixPathSlash(outPutPath);
|
||||||
else
|
|
||||||
{
|
|
||||||
outPutPath = Recon::fixPathSlash(outPutPath) + Recon::DEFAULT_OUTPUT_FILENAME;
|
|
||||||
}
|
|
||||||
if(!Recon::isDirectory(directoryPath))
|
if(!Recon::isDirectory(directoryPath))
|
||||||
{
|
{
|
||||||
RECON_INFO("Output directory is not valid.");
|
RECON_INFO("Output directory is not valid.");
|
||||||
return 0;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dataPath = Recon::fixPathSlash(args[0]);
|
std::string dataPath = Recon::fixPathSlash(args[1]);
|
||||||
std::string dataRefPath = Recon::fixPathSlash(args[1]);
|
std::string dataRefPath = Recon::fixPathSlash(args[2]);
|
||||||
RECON_INFO("start");
|
RECON_INFO("start");
|
||||||
Recon::startReconstructions(dataPath, dataRefPath, outPutPath);
|
Recon::notifyStart(ReconID);
|
||||||
SPDLOG_INFO("finish");
|
int exitcode = Recon::startReconstructions(dataPath, dataRefPath, outPutPath);
|
||||||
return 0;
|
if (exitcode == 0)
|
||||||
|
{
|
||||||
|
RECON_INFO("finish");
|
||||||
|
if (!Recon::notifyFinish()) {
|
||||||
|
RECON_ERROR("Notify Finish failed!");
|
||||||
|
return -100;
|
||||||
|
}
|
||||||
|
return exitcode;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return exitcode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,19 +222,23 @@ namespace Recon {
|
|||||||
{
|
{
|
||||||
allHitMaps.push_back(buildMatrixR.hitmap);
|
allHitMaps.push_back(buildMatrixR.hitmap);
|
||||||
}
|
}
|
||||||
|
#pragma omp parallel for num_threads(2)
|
||||||
if(!data.isNull())
|
for (int i =0; i<2; i++){
|
||||||
{
|
if (i ==0){
|
||||||
Matrix sosValue = solveParameterIterator(buildMatrixR.M, b, dims, false, transParams::nonNeg)[0][0];
|
if(!data.isNull())
|
||||||
result.outSOS = slownessToSOS(sosValue, SOS_IN_WATER) ;
|
{
|
||||||
|
Matrix sosValue = solveParameterIterator(buildMatrixR.M, b, dims, false, transParams::nonNeg)[0][0];
|
||||||
|
result.outSOS = slownessToSOS(sosValue, SOS_IN_WATER) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(!dataAtt.isNull())
|
||||||
|
{
|
||||||
|
Matrix attValue = solveParameterIterator(buildMatrixR.M, bAtt, dims, false, transParams::nonNeg,1)[0][0];
|
||||||
|
result.outATT = attValue/100 ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!dataAtt.isNull())
|
|
||||||
{
|
|
||||||
Matrix attValue = solveParameterIterator(buildMatrixR.M, bAtt, dims, false, transParams::nonNeg)[0][0];
|
|
||||||
result.outATT = attValue/100 ;
|
|
||||||
}
|
|
||||||
Recon::notifyProgress(10 + 10 * (iter/numIter));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace Recon
|
|||||||
float TVAL3Beta;
|
float TVAL3Beta;
|
||||||
float TVAL3Beta0;
|
float TVAL3Beta0;
|
||||||
bool nonNeg = false;
|
bool nonNeg = false;
|
||||||
|
int deviceIndex ;
|
||||||
};
|
};
|
||||||
|
|
||||||
Aurora::Matrix solve( Aurora::Sparse& M, Aurora::Matrix& b, const Aurora::Matrix& dims, int niter, TVAL3SolverOptions solverOptions){
|
Aurora::Matrix solve( Aurora::Sparse& M, Aurora::Matrix& b, const Aurora::Matrix& dims, int niter, TVAL3SolverOptions solverOptions){
|
||||||
@@ -39,7 +40,7 @@ namespace Recon
|
|||||||
opt.mu = solverOptions.TVAL3MU;
|
opt.mu = solverOptions.TVAL3MU;
|
||||||
opt.beta = solverOptions.TVAL3Beta;
|
opt.beta = solverOptions.TVAL3Beta;
|
||||||
opt.beta0 = solverOptions.TVAL3Beta0;
|
opt.beta0 = solverOptions.TVAL3Beta0;
|
||||||
int device = (int)solverOptions.gpuSelectionList[0];
|
int device = (int)solverOptions.gpuSelectionList[solverOptions.deviceIndex];
|
||||||
return callTval3(M, b, dims, device, opt);
|
return callTval3(M, b, dims, device, opt);
|
||||||
}
|
}
|
||||||
//SART
|
//SART
|
||||||
@@ -50,7 +51,7 @@ namespace Recon
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::vector<Aurora::Matrix>> solveParameterIterator(Aurora::Sparse M, Aurora::Matrix &b,
|
std::vector<std::vector<Aurora::Matrix>> solveParameterIterator(Aurora::Sparse M, Aurora::Matrix &b,
|
||||||
const Aurora::Matrix &dims, bool oneIter, bool nonNeg)
|
const Aurora::Matrix &dims, bool oneIter, bool nonNeg, int index)
|
||||||
{
|
{
|
||||||
if (Recon::transParams::name == "TVAL3"){
|
if (Recon::transParams::name == "TVAL3"){
|
||||||
std::vector<std::vector<Aurora::Matrix>> result(Recon::transParams::muValues.getDataSize());
|
std::vector<std::vector<Aurora::Matrix>> result(Recon::transParams::muValues.getDataSize());
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
namespace Recon {
|
namespace Recon {
|
||||||
std::vector<std::vector<Aurora::Matrix>>
|
std::vector<std::vector<Aurora::Matrix>>
|
||||||
solveParameterIterator(Aurora::Sparse M, Aurora::Matrix &b,
|
solveParameterIterator(Aurora::Sparse M, Aurora::Matrix &b,
|
||||||
const Aurora::Matrix &dims, bool oneIter = true, bool nonNeg = false);
|
const Aurora::Matrix &dims, bool oneIter = true, bool nonNeg = false,int index=0);
|
||||||
} // namespace Recon
|
} // namespace Recon
|
||||||
|
|
||||||
#endif // __SOLVE_H__
|
#endif // __SOLVE_H__
|
||||||
Reference in New Issue
Block a user