@@ -641,7 +641,7 @@ void FourChamberView::Meshing(){
641641 QString basename = " seg_final_smooth" ;
642642 QString segname = basename + " .nrrd" ;
643643 QString path = seg_dir + " /" + segname;
644- bool ask_to_load = true ;
644+
645645 if (!QFile::exists (path)) {
646646 // retrieve the path of the segmentation after user has selected it from the UI
647647 path = QFileDialog::getOpenFileName (NULL , " Open Segmentation file" , seg_dir.toStdString ().c_str (), QmitkIOUtil::GetFileOpenFilterString ());
@@ -1020,9 +1020,9 @@ void FourChamberView::SurfaceToVolume() {
10201020 std::unique_ptr<CemrgFourChamberCmd> fourch_cmd (new CemrgFourChamberCmd ());
10211021 fourch_cmd->SetCarpDirectory (carp_directory);
10221022 fourch_cmd->SetCarpless (carpless);
1023- for (unsigned int ix = 0 ; ix < atria.size (); ix++) {
1023+ for (auto ix = 0 ; ix < atria.size (); ix++) {
10241024 QString atr = atria.at (ix);
1025- for (unsigned int jx = 0 ; jx < suffix.size (); jx++) {
1025+ for (auto jx = 0 ; jx < suffix.size (); jx++) {
10261026 QString srcPath = uacFolder + " /" + atr + " /" + atr + suffix.at (jx);
10271027 QString dstPath = uacFolder + " /" + atr + " /" + atr + fibrsSheet + suffix.at (jx);
10281028 if (!cp (srcPath, dstPath)) return ;
@@ -1037,7 +1037,7 @@ void FourChamberView::SurfaceToVolume() {
10371037 if (!MeshtoolConvert (uacFolder, biatrPre + " _fibres_l" )) return ;
10381038
10391039 // === Mapping to four chamber mesh ===
1040- for (unsigned int jx = 0 ; jx < suffix.size (); jx++) {
1040+ for (auto jx = 0 ; jx < suffix.size (); jx++) {
10411041 QString srcPath = uacFolder + " /" + biatrPre + suffix.at (jx);
10421042 QString dstPath = uacFolder + " /" + biatrPre + fibrsSheet + suffix.at (jx);
10431043 if (!cp (srcPath, dstPath)) return ;
@@ -1077,7 +1077,7 @@ void FourChamberView::VentricularFibres(){
10771077 if (success_vfib_params) {
10781078 QStringList keys, values, types;
10791079 vfibres_parameters.KeysAndValues (keys, values, types);
1080- for (unsigned int ix = 0 ; ix < keys.size (); ix++) {
1080+ for (auto ix = 0 ; ix < keys.size (); ix++) {
10811081 std::cout << " [" << keys.at (ix).toStdString () << " ] " << values.at (ix).toStdString () << ' \n ' ;
10821082 }
10831083
@@ -1206,7 +1206,7 @@ void FourChamberView::Corrections(){
12061206
12071207 Inform (" Attention" , msg.c_str ());
12081208
1209- this ->GetSite ()->GetPage ()->ShowView (" org.mitk.views.multilabelsegmentation " );
1209+ this ->GetSite ()->GetPage ()->ShowView (" org.mitk.views.segmentation " );
12101210}
12111211
12121212void FourChamberView::SmoothSegmentation () {
@@ -1273,11 +1273,33 @@ void FourChamberView::CorrectionGetLabels() {
12731273 // find which labels need splitting
12741274 std::unique_ptr<CemrgMultilabelSegmentationUtils> multilabelUtils = std::unique_ptr<CemrgMultilabelSegmentationUtils>(new CemrgMultilabelSegmentationUtils ());
12751275 multilabelUtils->GetLabels (seg, labelsInSegmentation);
1276+
1277+ if (labelsInSegmentation.size () == 0 ) {
1278+ Warn (" Attention" , " No labels found in the segmentation" );
1279+ return ;
1280+ }
1281+
1282+ int maxLabel = *std::max_element (labelsInSegmentation.begin (), labelsInSegmentation.end ());
1283+ bool guessCnnLabels = labelsInSegmentation.size () == 10 && maxLabel == 10 ;
1284+ std::cout << " \t Guessing CNN labels: " << guessCnnLabels << ' \n ' ;
1285+ std::cout << " \t Labels in segmentation: " << labelsInSegmentation.size () << ' \n ' ;
1286+ std::cout << " \t Max label: " << maxLabel << ' \n ' ;
1287+
1288+ QStringList guessCnnLabelsList = {" BACKGROUND" , " LV_BP" , " LV_myo" , " RV_BP" , " LA_BP" , " RA_BP" , " Ao_BP" , " PArt_BP" , " " , " " , " LAA" };
1289+
12761290 foreach (int label, labelsInSegmentation) {
12771291 QString cbox_label = QString::number (label);
1278- m_Controls.combo_corrections_id ->addItem (QString::number (label));
1292+ if (guessCnnLabels) {
1293+ QString guessedLabel = guessCnnLabelsList.at (label);
1294+ if (!guessedLabel.isEmpty ()) {
1295+ cbox_label += " :" + guessedLabel;
1296+ segmentationLabels.SetLabelFromString (guessedLabel.toStdString (), label);
1297+ userLabels.SetLabelFromString (guessedLabel.toStdString (), label);
1298+ }
1299+ }
1300+ m_Controls.combo_corrections_id ->addItem (cbox_label);
12791301 }
1280-
1302+
12811303 bool segmentation_labels_loaded = CheckForExistingFile (Path (SDIR.SEG ), FourChamberView::LABELS_FILE);
12821304 if (segmentation_labels_loaded) {
12831305 int replySegLabels = Ask (" Segmentation labels found" , " Do you want to load the segmentation labels?" );
@@ -1437,22 +1459,22 @@ void FourChamberView::CorrectionIdLabels(int index) {
14371459 m_Controls.button_confirm_labels ->setEnabled (true );
14381460 }
14391461
1440- if (splitCurrentLabel) {
1462+ if (splitCurrentLabel) { // Label needs to be split
14411463 if (labelsToSplit.size () == 0 ) {
14421464 Inform (" Attention" , " Keep selecting labels to split until you are done.\n Then use Confirm button" );
14431465 }
14441466
14451467 labelsToSplit.push_back (label);
14461468 m_Controls.combo_corrections_id ->removeItem (index);
14471469
1448- } else if (deleteCurrentLabel) {
1470+ } else if (deleteCurrentLabel) { // Label needs to be deleted
14491471 m_Controls.combo_corrections_id ->removeItem (index);
14501472 multilabelUtils->RemoveLabel ((mitk::Image::Pointer) mlseg, label);
14511473 mitk::IOUtil::Save (mlseg, StdStringPath (SDIR.SEG + " /seg_corrected.nrrd" ));
14521474
14531475 CemrgCommonUtils::UpdateFromStorage (mlseg, nodes[0 ]->GetName (), this ->GetDataStorage ());
14541476
1455- } else {
1477+ } else { // Label can be ID'd appropriately
14561478 QString itemText = QString::number (label);
14571479 itemText += (pickedLabelName.isEmpty ()) ? " " : " : " + pickedLabelName;
14581480 m_Controls.combo_corrections_id ->setItemText (index, itemText);
@@ -2397,6 +2419,7 @@ bool FourChamberView::UserSelectMeshtools3DParameters(QString pre_input_path){
23972419 return userAccepted;
23982420}
23992421bool FourChamberView::UserSelectIdentifyLabels (int index, unsigned int label, QColor qc) {
2422+ MITK_INFO << " UserSelectIdentifyLabels" + std::to_string (index) + " " + std::to_string (label) + " " + std::to_string (qc.rgb ());
24002423 QDialog *inputs = new QDialog (0 , 0 );
24012424 bool userInputAccepted = false ;
24022425 m_IdLabels.setupUi (inputs);
0 commit comments