Prototype Optimization for Temporarily and Spatially Distorted Time Series