From a34a69eed764fab58d0a2b6cce500fcc2376a432 Mon Sep 17 00:00:00 2001 From: matthias-k Date: Sat, 27 Jan 2024 12:47:05 +0100 Subject: [PATCH] Don't compute saliency maps in NSS if there are no fixations on the image (#48) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matthias Kümmmerer --- pysaliency/saliency_map_models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pysaliency/saliency_map_models.py b/pysaliency/saliency_map_models.py index 23bebb9..eac0d1b 100644 --- a/pysaliency/saliency_map_models.py +++ b/pysaliency/saliency_map_models.py @@ -640,8 +640,10 @@ def CC(self, stimuli, other, verbose=False): def NSSs(self, stimuli, fixations, verbose=False): values = np.empty(len(fixations.x)) for n, s in enumerate(tqdm(stimuli, disable=not verbose)): - smap = self.saliency_map(s).copy() inds = fixations.n == n + if not inds.sum(): + continue + smap = self.saliency_map(s).copy() values[inds] = NSS(smap, fixations.x_int[inds], fixations.y_int[inds]) return values