#66: Stop execution if Pearson correlation is negative

This commit is contained in:
Benjamin Loison
2024-05-15 20:15:20 +02:00
parent 60a9dfe89c
commit f719ff767a
3 changed files with 10 additions and 6 deletions

View File

@@ -43,8 +43,12 @@ class Distance(Enum)
def getEndUserName(self):
return self.name.replace('_', '').title()
def getPearsonCorrelation(firstImage, secondImage):
return abs(scipy.stats.pearsonr(firstImage.flatten(), secondImage.flatten()).statistic - 1)
def getPearsonCorrelationDistance(firstImage, secondImage):
pearsonCorrelation = scipy.stats.pearsonr(firstImage.flatten(), secondImage.flatten()).statistic
if pearsonCorrelation < 0:
print('Negative Pearson correlation, investigate further!')
exit(1)
return abs(pearsonCorrelation - 1)
# Source: https://stackoverflow.com/a/43346070
def getGaussianKernel(size, sigma):