Skip to content

Commit df81a53

Browse files
committed
added time logs for afib - v1.5
1 parent 0c4f026 commit df81a53

1 file changed

Lines changed: 52 additions & 2 deletions

File tree

CemrgApp/Plugins/kcl.cemrgapp.atrialfibres/src/internal/AtrialFibresView.cpp

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ PURPOSE. See the above copyright notices for more information.
3434

3535
//Qmitk
3636
#include <mitkImage.h>
37+
#include <mitkLog.h>
38+
3739
#include <QmitkIOUtil.h>
3840
#include <mitkProgressBar.h>
3941
#include <mitkIDataStorageService.h>
@@ -91,6 +93,7 @@ PURPOSE. See the above copyright notices for more information.
9193
#include <QFileDialog>
9294
#include <QInputDialog>
9395
#include <QDirIterator>
96+
#include <QDate>
9497

9598
//CemrgAppModule
9699
#include <CemrgCommonUtils.h>
@@ -390,6 +393,7 @@ void AtrialFibresView::AnalysisChoice(){
390393

391394
// Automatic pipeline
392395
void AtrialFibresView::AutomaticAnalysis(){
396+
MITK_INFO << "TIMELOG|AutomaticAnalysis| Start";
393397
QString prodPath = directory + "/";
394398
if(cnnPath.isEmpty()){
395399
if(uiSelector_imgauto_skipCemrgNet){
@@ -488,9 +492,11 @@ void AtrialFibresView::AutomaticAnalysis(){
488492
msg += "+ Click Step5: Clip PVs and MV (this step will set the correct labels)";
489493
QMessageBox::information(NULL, "Automatic Labelling complete", msg.c_str());
490494
}
495+
MITK_INFO << "TIMELOG|AutomaticAnalysis| End";
491496
}
492497

493498
void AtrialFibresView::MeshPreprocessing(){
499+
MITK_INFO << "TIMELOG|MeshPreprocessing| Start";
494500
MITK_INFO << "[MeshPreprocessing] ";
495501
if (!RequestProjectDirectoryFromUser()) return; // if the path was chosen incorrectly -> returns.
496502
if (!LoadSurfaceChecks()) return;
@@ -685,6 +691,7 @@ void AtrialFibresView::IdentifyPV(){
685691
}
686692

687693
void AtrialFibresView::CreateLabelledMesh(){
694+
MITK_INFO << "TIMELOG|CreateLabelledMesh| Start";
688695
if (!RequestProjectDirectoryFromUser()) return; // if the path was chosen incorrectly -> returns.
689696

690697
if(!analysisOnLge){
@@ -734,6 +741,7 @@ void AtrialFibresView::CreateLabelledMesh(){
734741
std::string meshName = tagName.toStdString() + "-Mesh";
735742
CemrgCommonUtils::AddToStorage(surface, meshName, this->GetDataStorage());
736743
}
744+
MITK_INFO << "TIMELOG|CreateLabelledMesh| End";
737745
}
738746

739747
void AtrialFibresView::ClipperMV(){
@@ -870,6 +878,8 @@ void AtrialFibresView::ClipMV(){
870878

871879

872880
void AtrialFibresView::ClipperPV(){
881+
MITK_INFO << "TIMELOG|MeshPreprocessing| End";
882+
MITK_INFO << "TIMELOG|ClipperPV| Start";
873883
if (!RequestProjectDirectoryFromUser()) return; // if the path was chosen incorrectly -> returns.#
874884
if (!LoadSurfaceChecks()) return; // Surface was not loaded and user could not find file.
875885

@@ -931,6 +941,7 @@ void AtrialFibresView::ClipperPV(){
931941

932942
// Labelled Mesh to UAC
933943
void AtrialFibresView::SelectLandmarks(){
944+
MITK_INFO << "TIMELOG|SelectLandmarks| Start";
934945
MITK_INFO << "[MeshPreprocessing] ";
935946
if (!RequestProjectDirectoryFromUser()) return; // if the path was chosen incorrectly -> returns.
936947
if (!LoadSurfaceChecks()) return;
@@ -969,6 +980,8 @@ void AtrialFibresView::CleanMeshQuality(){
969980
}
970981

971982
void AtrialFibresView::MeshingOptions(){
983+
MITK_INFO << "TIMELOG|SelectLandmarks| End";
984+
MITK_INFO << "TIMELOG|MeshImprovement| Start";
972985
if (!RequestProjectDirectoryFromUser()) return;
973986

974987
QMessageBox::information(NULL, "Open Mesh File", "Open the mesh file (vtk ONLY)");
@@ -1053,6 +1066,7 @@ void AtrialFibresView::MeshingOptions(){
10531066
}
10541067

10551068
MITK_INFO << "[MeshingOptions] finished";
1069+
MITK_INFO << "TIMELOG|MeshImprovement| End";
10561070
}
10571071
}
10581072

@@ -1072,6 +1086,7 @@ bool AtrialFibresView::UserSelectUacMesh(){
10721086

10731087

10741088
void AtrialFibresView::UacCalculation(){
1089+
MITK_INFO << "TIMELOG|UacCalculationSetup| Start";
10751090
if (!RequestProjectDirectoryFromUser()) return; // if the path was chosen incorrectly -> returns.
10761091
if(!UserSelectUacMesh()) return;
10771092

@@ -1108,9 +1123,11 @@ void AtrialFibresView::UacCalculation(){
11081123
m_Controls.button_0_1_uacRough->setVisible(true);
11091124
m_Controls.button_0_2_uacRefined->setVisible(true);
11101125
}
1126+
MITK_INFO << "TIMELOG|UacCalculationSetup| End";
11111127
}
11121128

11131129
void AtrialFibresView::UacCalculationRough(){
1130+
MITK_INFO << "TIMELOG|UacCalculation_Stage1| Start";
11141131
if (!RequestProjectDirectoryFromUser()) return; // if the path was chosen incorrectly -> returns.
11151132
if (!UserSelectUacMesh()) return;
11161133

@@ -1161,15 +1178,21 @@ void AtrialFibresView::UacCalculationRough(){
11611178

11621179
fibreAtlas << ("_" + uac_type + "_" + uac_surftype);
11631180
cmd->SetDockerImageUac();
1181+
MITK_INFO << "TIMELOG|UacCalculation_Stage1| UAC 1 start";
11641182
uacOutput = cmd->DockerUniversalAtrialCoordinates(directory, uaccmd, fibreAtlas, uacMeshName, uiLabels, path2landmarks);
1183+
MITK_INFO << "TIMELOG|UacCalculation_Stage1| UAC 1 end";
11651184

11661185
outputFiles << "LSbc1.vtx" << "LSbc2.vtx";
11671186
outputFiles << "PAbc1.vtx" << "PAbc2.vtx";
11681187

1169-
if (!IsUacOutputCorrect(directory, outputFiles)) return;
1188+
if (!IsUacOutputCorrect(directory, outputFiles)){
1189+
MITK_INFO << "TIMELOG|UacCalculation_Stage1| End (FAIL)";
1190+
return;
1191+
}
11701192

11711193
MITK_INFO << "Create Laplace Solve files for LR and PA SOLVES";
11721194
QString lr_par, pa_par;
1195+
MITK_INFO << "TIMELOG|UacCalculation_Stage1| openCARP start";
11731196
lr_par = CemrgCommonUtils::OpenCarpParamFileGenerator(directory, "carpf_laplace_LS.par", uacMeshName, "LSbc1", "LSbc2");
11741197
pa_par = CemrgCommonUtils::OpenCarpParamFileGenerator(directory, "carpf_laplace_PA.par", uacMeshName, "PAbc1", "PAbc2");
11751198

@@ -1178,16 +1201,19 @@ void AtrialFibresView::UacCalculationRough(){
11781201
QString lrLapSolve, paLapSolve;
11791202
lrLapSolve = cmd->OpenCarpDocker(directory, lr_par, "LR_UAC_N2");
11801203
paLapSolve = cmd->OpenCarpDocker(directory, pa_par, "PA_UAC_N2");
1204+
MITK_INFO << "TIMELOG|UacCalculation_Stage1| openCARP end";
11811205

11821206
bool uacOutputSuccess = IsUacOutputCorrect(directory, outputFiles);
11831207
MITK_ERROR(!uacOutputSuccess) << ("Problem with " + uaccmd).toStdString();
11841208
std::string msg = "UAC Calculation - Stage 1 ";
11851209
msg += (uacOutputSuccess) ? "successful" : "failed";
11861210
QMessageBox::information(NULL, "Attention", msg.c_str());
1211+
MITK_INFO << "TIMELOG|UacCalculation_Stage1| End";
11871212
}
11881213
}
11891214

11901215
void AtrialFibresView::UacCalculationRefined(){
1216+
MITK_INFO << "TIMELOG|UacCalculation_Stage2| Start";
11911217
if (!RequestProjectDirectoryFromUser()) return; // if the path was chosen incorrectly -> returns.
11921218
if (!UserSelectUacMesh()) return;
11931219

@@ -1240,16 +1266,22 @@ void AtrialFibresView::UacCalculationRefined(){
12401266
outputFiles << "AnteriorMesh.elem" << "PosteriorMesh.elem";
12411267
outputFiles << "Ant_Strength_Test_PA1.vtx" << "Ant_Strength_Test_LS1.vtx";
12421268
outputFiles << "Post_Strength_Test_PA1.vtx" << "Post_Strength_Test_LS1.vtx";
1269+
MITK_INFO << "TIMELOG|UacCalculation_Stage2| UAC 2.1 - Start";
12431270
cmd->SetDockerImageUac();
12441271
uacOutput = cmd->DockerUniversalAtrialCoordinates(directory, uaccmd, fibreAtlas, uacMeshName, uiLabels, path2landmarks);
1272+
MITK_INFO << "TIMELOG|UacCalculation_Stage2| UAC 2.1 - End";
12451273

1246-
if (!IsUacOutputCorrect(directory, outputFiles)) return;
1274+
if (!IsUacOutputCorrect(directory, outputFiles)){
1275+
MITK_INFO << "TIMELOG|UacCalculation_Stage2| End (FAILED)";
1276+
return;
1277+
}
12471278

12481279
QString lrp_par, udp_par, lra_par, uda_par;
12491280
QString carpf_lr, carpf_ud;
12501281
carpf_lr = "carpf_laplace_single_LR";
12511282
carpf_ud = "carpf_laplace_single_UD";
12521283

1284+
MITK_INFO << "TIMELOG|UacCalculation_Stage2| openCARP - Start";
12531285
lrp_par = CemrgCommonUtils::OpenCarpParamFileGenerator(directory, carpf_lr+"_P.par", "PosteriorMesh", "", "Post_Strength_Test_LS1");
12541286
udp_par = CemrgCommonUtils::OpenCarpParamFileGenerator(directory, carpf_ud+"_P.par", "PosteriorMesh", "", "Post_Strength_Test_PA1");
12551287
lra_par = CemrgCommonUtils::OpenCarpParamFileGenerator(directory, carpf_lr+"_A.par", "AnteriorMesh", "", "Ant_Strength_Test_LS1");
@@ -1262,6 +1294,7 @@ void AtrialFibresView::UacCalculationRefined(){
12621294
udpLapSolve = cmd->OpenCarpDocker(directory, udp_par, "UD_Post_UAC");
12631295
lraLapSolve = cmd->OpenCarpDocker(directory, lra_par, "LR_Ant_UAC");
12641296
udaLapSolve = cmd->OpenCarpDocker(directory, uda_par, "UD_Ant_UAC");
1297+
MITK_INFO << "TIMELOG|UacCalculation_Stage2| openCARP - End";
12651298

12661299
uaccmd = "UAC_2B_" + uac_type;
12671300
uaccmd += (!uiUac_meshtype_labelled) ? "_noPV" : "";
@@ -1270,19 +1303,23 @@ void AtrialFibresView::UacCalculationRefined(){
12701303
outputFiles << "Labelled_Coords_2D_Rescaling_v3_C.vtk";
12711304
outputFiles << "Labelled_Coords_2D_Rescaling_v3_C.elem";
12721305
outputFiles << "Labelled_Coords_2D_Rescaling_v3_C.pts";
1306+
MITK_INFO << "TIMELOG|UacCalculation_Stage2| UAC 2.2 - Start";
12731307
cmd->SetDockerImageUac();
12741308
uacOutput = cmd->DockerUniversalAtrialCoordinates(directory, uaccmd, fibreAtlas, uacMeshName, uiLabels, "");
1309+
MITK_INFO << "TIMELOG|UacCalculation_Stage2| UAC 2.2 - End";
12751310

12761311
bool uacOutputSuccess = IsUacOutputCorrect(directory, outputFiles);
12771312
MITK_ERROR(!uacOutputSuccess) << ("Problem with " + uaccmd).toStdString();
12781313
std::string msg = "UAC Calculation - Stage 2 ";
12791314
msg += (uacOutputSuccess) ? "successful" : "failed";
12801315
QMessageBox::information(NULL, "Attention", msg.c_str());
12811316

1317+
MITK_INFO << "TIMELOG|UacCalculation_Stage2| End";
12821318
}
12831319
}
12841320

12851321
void AtrialFibresView::UacFibreMapping(){
1322+
MITK_INFO << "TIMELOG|UacFibreMapping| Start";
12861323
if (!RequestProjectDirectoryFromUser()) return; // if the path was chosen incorrectly -> returns.
12871324
if (!UserSelectUacMesh()) return;
12881325

@@ -1387,9 +1424,11 @@ void AtrialFibresView::UacFibreMapping(){
13871424

13881425
MITK_INFO(count==clearFiles.size()) << "All aux Files cleared successfully";
13891426
}
1427+
MITK_INFO << "TIMELOG|UacFibreMapping| End";
13901428
}
13911429

13921430
void AtrialFibresView::UacCalculationVerifyLabels(){
1431+
MITK_INFO << "TIMELOG|VerifyLabels| Start";
13931432
if (!RequestProjectDirectoryFromUser()) return; // if the path was chosen incorrectly -> returns.
13941433
if(!GetUserEditLabelsInputs()){
13951434
MITK_INFO << "labels not checked. Stopping";
@@ -1437,6 +1476,7 @@ void AtrialFibresView::UacCalculationVerifyLabels(){
14371476
QMessageBox::information(NULL, title.c_str(), msg.c_str());
14381477
MITK_INFO << msg;
14391478
}
1479+
MITK_INFO << "TIMELOG|VerifyLabels| End";
14401480
}
14411481

14421482
bool AtrialFibresView::IsUacOutputCorrect(QString dir, QStringList filenames){
@@ -1662,10 +1702,20 @@ bool AtrialFibresView::RequestProjectDirectoryFromUser() {
16621702
succesfulAssignment = false;
16631703
}//_if
16641704

1705+
if (succesfulAssignment){
1706+
QString now = QDate::currentDate().toString(Qt::ISODate);
1707+
QString logfilename = directory + "/afib_log" + now + ".log";
1708+
std::string logfname_str = logfilename.toStdString();
1709+
1710+
mitk::LoggingBackend::SetLogFile(logfname_str.c_str());
1711+
MITK_INFO << ("Changed logfile location to: " + logfilename).toStdString();
1712+
}
1713+
16651714
} else {
16661715
MITK_INFO << ("Project directory already set: " + directory).toStdString();
16671716
}//_if
16681717

1718+
16691719
return succesfulAssignment;
16701720
}
16711721

0 commit comments

Comments
 (0)