Slice-by-slice prospective hardware motion correction in EPI and simultaneous multislice sequences