diff --git a/src/common/DICOMExporter.cpp b/src/common/DICOMExporter.cpp index a884ef5..f608dc7 100644 --- a/src/common/DICOMExporter.cpp +++ b/src/common/DICOMExporter.cpp @@ -184,7 +184,7 @@ namespace Recon endPoint[2]*(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->putAndInsertUint16(DCM_Rows, Rows); dataset->putAndInsertUint16(DCM_Columns, Cols); @@ -229,11 +229,11 @@ namespace Recon { dataset->putAndInsertString(DCM_AccessionNumber, to_string(i).data()); dataset->putAndInsertString(DCM_InstanceNumber, to_string(i).data()); - string pos = to_string(originPosition[0] ) + "\\" + - to_string(originPosition[1]- i * spacing[2]) + "\\" + - to_string(originPosition[2]); + string pos = to_string(originPosition[1] ) + "\\" + + to_string(originPosition[2]+ i * spacing[2]) + "\\" + + to_string(originPosition[0]); 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()); // set SOPInstanceUID diff --git a/src/config/config.cpp b/src/config/config.cpp index be71b83..dd89991 100644 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -393,23 +393,23 @@ namespace Recon nlohmann::json dataSelection = params.at("dataSelection"); if(dataSelection.contains("senderTasList")) { - reflectParams::senderTasList = readToMatrix(dataSelection.at("senderTasList"), false); + transParams::senderTasList = readToMatrix(dataSelection.at("senderTasList"), false); } if(dataSelection.contains("receiverTasList")) { - reflectParams::receiverTasList = readToMatrix(dataSelection.at("receiverTasList"), false); + transParams::receiverTasList = readToMatrix(dataSelection.at("receiverTasList"), false); } if(dataSelection.contains("senderElementList")) { - reflectParams::senderElementList = readToMatrix(dataSelection.at("senderElementList"), false); + transParams::senderElementList = readToMatrix(dataSelection.at("senderElementList"), false); } if(dataSelection.contains("receiverElementList")) { - reflectParams::receiverElementList = readToMatrix(dataSelection.at("receiverElementList"), false); + transParams::receiverElementList = readToMatrix(dataSelection.at("receiverElementList"), false); } if(dataSelection.contains("motorPos")) { - reflectParams::motorPos = readToMatrix(dataSelection.at("motorPos"), false); + transParams::motorPos = readToMatrix(dataSelection.at("motorPos"), false); } if(dataSelection.contains("filterSensitivity")) { diff --git a/src/log/notify.cpp b/src/log/notify.cpp index 62a5029..7731520 100644 --- a/src/log/notify.cpp +++ b/src/log/notify.cpp @@ -11,7 +11,7 @@ bool notifyStart(const std::string& aReconID ){ std::string str = "{\"ReconID\": \""+ReconID+"\"}"; std::unordered_map headers; 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; } @@ -19,14 +19,14 @@ bool notifyFinish(){ std::string str = "{\"ReconID\": \""+ReconID+"\"}"; std::unordered_map headers; 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(); return resp->httpCode() == 200; } bool notifyProgress( int percent){ 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::unordered_map headers; headers["Content-Type"] = "application/json"; diff --git a/src/main.cxx b/src/main.cxx index 52fc52e..9a391d7 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -1,6 +1,8 @@ #include "Parser.h" +#include "Parser.h" #include "config/config.h" #include "log/notify.h" +#include "log/notify.h" #include #define EIGEN_USE_MKL_ALL @@ -15,51 +17,65 @@ int main(int argc, char *argv[]) { - int argNum = 4; + int argNum = 5; std::vector args(argNum); - args[0] = "/home/sun/20230418T141000/"; - args[1] = "/home/sun/20230418T145123/"; - args[2] = Recon::DEFAULT_OUTPUT_PATH; - args[3] = Recon::DEFAULT_CONFIG_PATH; + args[0] = ""; + args[1] = ""; + args[2] = ""; + args[3] = Recon::DEFAULT_OUTPUT_PATH; + args[4] = Recon::DEFAULT_CONFIG_PATH; argc = argc <= argNum? argc-1 : argNum; for (int i = 0; i < argc; i++) { args[i] = argv[i+1]; } - if(args[0].empty()) { - RECON_INFO("No reconstruction data."); - return 0; + printf("No recon id."); + return -1; } - std::string configPath = Recon::fixPathSlash(args[3]); - Recon::initalizeConfig(configPath); - if( args[1].empty() && Recon::transParams::runTransmissionReco) + std::string ReconID = args[0]; + if(args[1].empty()) { - RECON_INFO("Running transmission reconstruction, but no refrence data."); - return 0; + printf("No reconstruction data."); + 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; - if(Recon::endsWithMat(outPutPath)) - { - directoryPath = Recon::getPath(outPutPath); - } - else - { - outPutPath = Recon::fixPathSlash(outPutPath) + Recon::DEFAULT_OUTPUT_FILENAME; - } + auto defaultLogger = getLogger("Main",outPutPath.data()); + spdlog::set_default_logger(defaultLogger); + + outPutPath = Recon::fixPathSlash(outPutPath); + if(!Recon::isDirectory(directoryPath)) { RECON_INFO("Output directory is not valid."); - return 0; + return -4; } - std::string dataPath = Recon::fixPathSlash(args[0]); - std::string dataRefPath = Recon::fixPathSlash(args[1]); + std::string dataPath = Recon::fixPathSlash(args[1]); + std::string dataRefPath = Recon::fixPathSlash(args[2]); RECON_INFO("start"); - Recon::startReconstructions(dataPath, dataRefPath, outPutPath); - SPDLOG_INFO("finish"); - return 0; + Recon::notifyStart(ReconID); + int exitcode = Recon::startReconstructions(dataPath, dataRefPath, outPutPath); + if (exitcode == 0) + { + RECON_INFO("finish"); + if (!Recon::notifyFinish()) { + RECON_ERROR("Notify Finish failed!"); + return -100; + } + return exitcode; + } + else{ + return exitcode; + } }