Adaptive data-driven motion detection and optimized correction for brain PET