extract_regions function

Extract regions from a scan