Fix notify and DICOMExportor bug.

This commit is contained in:
kradchen
2023-11-21 14:03:52 +08:00
parent b070c3d5a8
commit 34d7086b47
4 changed files with 57 additions and 41 deletions

View File

@@ -184,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);
@@ -229,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

View File

@@ -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"))
{ {

View File

@@ -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";

View File

@@ -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;
}
} }