added functions to calculate mean phase difference between neighbours