Changed the code to continue the analysis if the correlation is invalid, set it to NaN