# Determining window sizes of varying length sub-sequences of time series data for outlier/discord detection

I'm working on some outlier detection methods for seasonal time series data. Basically I want to automate discord detection, i.e. suppose the time series could be split into multiple windows such that in general the shape of the data in each window is similar, as with the ECG data below.

If each window is length $n$ then I can use PAA, SAX or some other method. However, with variable window lengths I'm thinking of combining those methods with Dynamic Time Warping (DTW).

Is there a way to automatically detect the size of each window?