diff --git a/src/CalcStats.py b/src/CalcStats.py
index cb513e299e83995b8c4106cddac3b022b0ce0eee..05c42898b0a0a7f93b881a85300d7ea966667413 100755
--- a/src/CalcStats.py
+++ b/src/CalcStats.py
@@ -811,8 +811,12 @@ class DeviceObj:
 						# calculate the correlation, numpy indexes start from 1 
 						self.corr[t_idx] = np.corrcoef(sensor_array,target_array)[0,1]
 						# low pass filter correlation
-						self.old_lp_filter_corr[t_idx] = self.lp_filter_corr[t_idx];
-						self.lp_filter_corr[t_idx] = lp_filter * np.absolute(self.corr[t_idx]) + (1 - lp_filter) * self.old_lp_filter_corr[t_idx]
+						# if data is 0/inf/NaN keep the previous value in order to avoid corrupting the filtered value
+						if (self.corr[t_idx] == 0) or np.isnan(self.corr[t_idx]) or np.isinf(self.corr[t_idx])
+							self.lp_filter_corr[t_idx] = self.old_lp_filter_corr[t_idx]
+						else	
+							self.old_lp_filter_corr[t_idx] = self.lp_filter_corr[t_idx];
+							self.lp_filter_corr[t_idx] = lp_filter * np.absolute(self.corr[t_idx]) + (1 - lp_filter) * self.old_lp_filter_corr[t_idx]
 
 						# correlation calculated with the bottom half of sensor values
 						self.corr_low[t_idx] = np.corrcoef(sensor_array_sort[1:int(self.valid_samples/2)],target_array_sort[1:int(self.valid_samples/2)])[0,1]