From b931d9e852da1205084885dab6fdfbd0c72cfca6 Mon Sep 17 00:00:00 2001 From: volker-baecker Date: Wed, 11 Dec 2024 18:58:16 +0100 Subject: [PATCH] make it work with the input images from the czi plugin which technially have 4 dimensions --- src/napari_bigfish/_widget.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/napari_bigfish/_widget.py b/src/napari_bigfish/_widget.py index 1d37cdc..383f53c 100644 --- a/src/napari_bigfish/_widget.py +++ b/src/napari_bigfish/_widget.py @@ -603,9 +603,19 @@ def addDetectedSpots(self, data): def detectSpots(self): - self.model.setData(self.data) - self.model.detectSpots(tuple(self.scale)) + data = self.data + if len(data.shape) > 3: + data = np.squeeze(data) + if np.amax(data) > 1: + data = data / np.amax(data) + scale = self.scale + if len(scale) > 3: + scale = scale[1:len(scale)] + self.model.setData(data) + self.model.detectSpots(tuple(scale)) result = self.model.getSpots() + if len(result.shape) < len(data.shape): + return np.hstack((np.zeros((len(result), 1), dtype=result.dtype), result)) return result