The new matching algorithm is still greedy but with a twist. For each EMA meal (lapse or planned) it looks for the closest wrist detection. If that wrist detection has not been previously paired then it is matched. If it has been previously paired, then the distance between the previous pair compared to the new pair is examined. If the new pair is closer together than the previous pair, then the previous pair is unmatched and the new pair is matched. Whichever pair gets matched, the other EMA meal is left unmatched. EMA3.csv used for match-ema-wrist EMA4.csv used for match-ema-diet