From 408c9dadccc7bda0c8cbd8e0c81eda4ce49d04da Mon Sep 17 00:00:00 2001
From: Constantin Pape <constantin.pape@iwr.uni-heidelberg.de>
Date: Thu, 13 Jun 2019 13:16:32 +0200
Subject: [PATCH] Skip invalid labels in morphology computation instead of
 placeholder features

---
 scripts/extension/attributes/morphology.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/scripts/extension/attributes/morphology.py b/scripts/extension/attributes/morphology.py
index d38be4f..635a72c 100644
--- a/scripts/extension/attributes/morphology.py
+++ b/scripts/extension/attributes/morphology.py
@@ -198,7 +198,6 @@ def intensity_row_features(raw, mask):
 def morphology_features_for_label_range(table, ds, ds_raw,
                                         scale_factor_seg, scale_factor_raw,
                                         label_begin, label_end):
-    n_features = 4 if ds_raw is None else 6
     label_range = np.logical_and(table['label_id'] >= label_begin, table['label_id'] < label_end)
     sub_table = table.loc[label_range, :]
     stats = []
@@ -213,8 +212,7 @@ def morphology_features_for_label_range(table, ds, ds_raw,
         # foreground in the mask
         seg_mask = seg == label_id
         if seg_mask.sum() == 0:
-            result = [float(label_id)] + [0.] * n_features
-            stats.append(result)
+            # if the seg mask is empty, we simply skip this label-id
             continue
 
         # compute the morphology features from the segmentation mask
-- 
GitLab