From e5097d3632306c3a4bf5e2fb05071a4e11b245fb Mon Sep 17 00:00:00 2001 From: Christian Sachs Date: Fri, 6 Apr 2018 13:42:36 +0200 Subject: [PATCH] added a warning if apparently no channel region could be identified --- molyso/mm/channel_detection.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/molyso/mm/channel_detection.py b/molyso/mm/channel_detection.py index 547f24e..bae0233 100644 --- a/molyso/mm/channel_detection.py +++ b/molyso/mm/channel_detection.py @@ -4,6 +4,8 @@ """ from __future__ import division, unicode_literals, print_function +import warnings + import numpy as np from ..debugging import DebugPlot @@ -397,6 +399,13 @@ def horizontal_mean_frequency(img_frag, clean_around=None, clean_width=0.0): # print(collector) int_collector = collector.astype(np.int32) + if (int_collector == 0).all(): + warnings.warn( + "Apparently no channel region was detectable. If the images are flipped, try filename?rotate=<90|270>", + RuntimeWarning + ) + return 0, len(int_collector) + bins = np.bincount(int_collector) winner = np.argmax(bins[1:]) + 1