some minor changes

- removed some redundant code from extract_hs_hist
- checked if valid_mat contains any elements (it crashes in
label_circles if it's empty)