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