I'm recording EEG where one channel's voltage pulses (lo-hi-lo) signify when experimental events of interest occurred (but with no additional information on what type of events). I use a custom peak detection (Matlab) script to detect these.
I also have log files with detailed information on each event. I match these sources of information by turning them into simple signals (zeros on every sample of no interest, ones for events) and smooth them using a moving average. I then cross-correlate the two signals, and use the lag with maximum cross-correlation value for alignment.
Works reasonably well, but towards the edges of the signal I notice considerable drift and markers end up further and further from where they need to be. Probably the result of different ways of time-keeping.
What seems to be needed is a way to compress/extend one signal with respect to the other until there's an optimal fit. But before going down that rabbit hole I suspect someone must have dealt with this kind of issue before and might know of some existing solution?