-
I would like to handle an exception in an automated phenotyping system when no objects have been found. It is not clear to me what would find_objects return in that case that I could use for verification that there are no contours detected. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @Tronheim, great question. There are at least two approaches, depending on what works best for you. When Alternatively, I think a somewhat more robust approach is to check later in the workflow. This is because When you run |
Beta Was this translation helpful? Give feedback.
Hi @Tronheim, great question. There are at least two approaches, depending on what works best for you.
When
pcv.find_objects
does not find any contours, it returns an empty list (contours is otherwise a list of contours) andNone
(hierarchy). So you could check the length of the contours list, set up a conditional on whether contours is True/False (not empty/empty), etc.Alternatively, I think a somewhat more robust approach is to check later in the workflow. This is because
pcv.find_objects
may find contours that end up getting filtered out bypcv.roi_objects
later. Or in other words,find_objects
is only empty when no contours are found (no background) butroi_objects
is empty when no p…