TotalSegmentator code needs update to work with the latest segmentation tool api changes.
Description
Revisions and Commits
rMITK MITK | |||
Restricted Differential Revision | rMITKc077678de943 Code refactoring changes | ||
Restricted Differential Revision | rMITK6f28314e8196 Change Preview button icon | ||
Restricted Differential Revision | rMITKc1e1bcea88f9 code refactoring changes | ||
Restricted Differential Revision | rMITK4dc5c732f928 TotalSegmentator code updates |
Status | Assigned | Task | ||
---|---|---|---|---|
Resolved | kislinsk | T29191 [SEG] New segmentation tool candidates | ||
Resolved | floca | T29437 [SEG] Add TotalSegmentator | ||
Resolved | a178n | T29558 TotalSegmentator: Modify as per new Segmentation changes |
Event Timeline
Hi @floca
The code in UpdatePrepare function for TotalSegmentator has a problem. Not a bug. The labelSet that you modify for the preview preemptively contains all possible labels, not just the ones that are predicted.
void mitk::TotalSegmentatorTool::UpdatePrepare() { Superclass::UpdatePrepare(); auto preview = this->GetPreviewSegmentation(); auto labelset = preview->GetLabelSet(preview->GetActiveLayer()); labelset->RemoveAllLabels(); if (m_LabelMapTotal.empty()) { this->ParseLabelNames(this->GetLabelMapPath()); } auto labelMap = m_LabelMapTotal; const bool isSubTask = (this->GetSubTask() != DEFAULT_TOTAL_TASK); if (isSubTask) { std::vector<std::string> files = SUBTASKS_MAP.at(this->GetSubTask()); labelMap.clear(); mitk::Label::PixelType labelId = 1; for (auto const& file : files) { std::string labelName = file.substr(0, file.find('.')); labelMap[labelId] = labelName; labelId++; } } auto lookupTable = mitk::LookupTable::New(); lookupTable->SetType(mitk::LookupTable::LookupTableType::MULTILABEL); for (auto const& [key, val] : labelMap) { Label::Pointer label = Label::New(key, val); std::array<double, 3> lookupTableColor; lookupTable->GetColor(key, lookupTableColor.data()); Color color; color.SetRed(lookupTableColor[0]); color.SetGreen(lookupTableColor[1]); color.SetBlue(lookupTableColor[2]); label->SetColor(color); labelset->AddLabel(label, false); } }
So, once the segmentation operation is completed and labels are shown in the List widget, all the possible labels are listed out for Confirmation instead of just what was really predicted. This is undesirable.
I think we should only show what label was predicted. For that, I believe, the labelset of the preview segmentation should be set only after its predicted, inside the DoUpdatePreview.
Basically, the lookup table and color setting done should be done lazily & not in UpdatePrepare method.
You should do a compbination (to keep the 4D support).
UpdatePrepare clears the labels.
In DoUpdatePreview you add all labels that very found with the update and ar not already in the preview.