From 35be41282a39e6ab80ded6bcbee9ee35556a42b8 Mon Sep 17 00:00:00 2001
From: Jan Grewe <jan.grewe@g-node.org>
Date: Mon, 24 Feb 2025 11:45:24 +0100
Subject: [PATCH] [trackingdata] scores returns None, if no detections in range

---
 fixtracks/utils/trackingdata.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fixtracks/utils/trackingdata.py b/fixtracks/utils/trackingdata.py
index cf13de0..0ae80f6 100644
--- a/fixtracks/utils/trackingdata.py
+++ b/fixtracks/utils/trackingdata.py
@@ -169,11 +169,11 @@ class TrackingData(QObject):
         numpy.ndarray
             A NumPy array of type float32 containing the keypoint scores of the shape (N, M) 
             with N the number of detections and M the number of keypoints.
-        """ 
+        """
         if selection:
             if len(self._indices) < 1:
                 logging.info("TrackingData.scores returns empty array, not detections in range!")
-                return np.ndarray([])
+                return None
             return np.stack(self._data["keypoint_score"][self._indices]).astype(np.float32)
         return np.stack(self._data["keypoint_score"]).astype(np.float32)
 
@@ -195,6 +195,8 @@ class TrackingData(QObject):
         A NumPy array of shape (N, 2) containing the center of gravity for each detection.
         """
         scores = self.keypointScores(selection)
+        if scores is None:
+            return None
         scores[scores < threshold] = 0.0
         scores[:, np.setdiff1d(np.arange(scores.shape[1]), nodes)] = 0.0
         weighted_coords = self.coordinates(selection=selection) * scores[:, :, np.newaxis]