MCPcopy Create free account
hub / github.com/MITK/MITK / FilterSuggestions

Method FilterSuggestions

Modules/Multilabel/src/mitkLabelSuggestionHelper.cpp:310–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308 }
309
310 LabelSuggestionHelper::ConstLabelVectorType LabelSuggestionHelper::FilterSuggestions(
311 const ConstLabelVectorType &suggestions,
312 const MultiLabelSegmentation *segmentation,
313 const std::optional<std::string_view> labelName)
314 {
315 if (segmentation == nullptr)
316 return suggestions;
317
318 LabelSuggestionHelper::ConstLabelVectorType filtered;
319
320 for (const auto &suggestion : suggestions)
321 {
322 auto maxInstance = GetMaxInstanceOccurrenceOfLabel(suggestion, GetSuggestionPreferences().suggestionOnce);
323
324 auto currentCount = segmentation->GetLabelValuesByName(suggestion->GetName()).size();
325
326 if ((labelName.has_value() && labelName.value() == suggestion->GetName()) || //label is excluded from filtering
327 !maxInstance.has_value() || //no limit is defined
328 maxInstance.value() > currentCount) //limit is not reached
329 filtered.push_back(suggestion);
330 }
331
332 return filtered;
333 }
334
335 LabelSuggestionHelper::Preferences LabelSuggestionHelper::GetSuggestionPreferences()
336 {

Callers

nothing calls this directly

Calls 5

GetLabelValuesByNameMethod · 0.80
sizeMethod · 0.45
GetNameMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected