Page MenuHomePhabricator

TotalSegmentator: Modify as per new Segmentation changes
Closed, ResolvedPublic

Description

TotalSegmentator code needs update to work with the latest segmentation tool api changes.

Revisions and Commits

rMITK MITK
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision

Event Timeline

a178n triaged this task as High priority.May 3 2023, 2:49 PM
a178n created this task.

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.

a178n added a revision: Restricted Differential Revision.May 3 2023, 6:19 PM

Deleted branch from rMITK MITK: feature/T29558-totalseg-update.