# Patching data by identifying and copying repeating pattern

I have a dataset sampled with a specific pattern (timestamps). The very first repetition of the pattern is damaged, meaning that the values are nonsense. To exemplify, my data looks like this:

``````data = [garbage | pattern | pattern + t | pattern +2*t | ... | pattern + n*t];
``````

Where garbage and pattern could be, for example:

``````garbage = [1 10000 3 10000 1 10000 3 10000]
pattern = [6 7 8 9 6 7 8 9]
``````

And if t = 5...

``````pattern + t = [11 12 13 14 11 12 13 14]
``````

What I want to do is to reconstruct `garbage` so that `garbage = pattern -t`, basically patching my dataset. If I knew the size of the pattern, my problem would be straightforward. However, how can I solve the problem without knowing it?

And is there actually a way of solving the problem without having to find the pattern at all? Hints and insights are very welcome.

EDIT:
For clarification:
The data consists of timestamps of MRI images. Each "pattern" refers to the set of timestamps of 2D slices within a 3D volume, and I acquire multiple volumes. Not knowing the pattern means I don't always know the number of slices. What I call garbage refers to the set of damaged timestamps of the very first volume. The reason I'm patching the timestamps is to correlate it with other data sampled with correct timestamps.

• Why is there "garbage" in your dataset? Commented Feb 18, 2016 at 23:41
• problem with the software responsible for storing the timestamps. Doesn't happen with all datasets. The thing is I'm observing a bunch of physiological data, and don't want the timestamps messed up. Commented Feb 18, 2016 at 23:59
• Data is a collection of sets? Your explanation is not very clear. Could you show a real input data set and the desired output data set as an example? How do you make the distinction between garbage and good data? Commented Feb 19, 2016 at 0:22