Skip to content

Commit

Permalink
added a warning if apparently no channel region could be identified
Browse files Browse the repository at this point in the history
  • Loading branch information
csachs committed Apr 6, 2018
1 parent 1141bb1 commit e5097d3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions molyso/mm/channel_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"""
from __future__ import division, unicode_literals, print_function

import warnings

import numpy as np

from ..debugging import DebugPlot
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit e5097d3

Please sign in to comment.