torch_ecg
torch_ecg copied to clipboard
MinMaxNormalization Not Resulting in Expected 0-1 Range
I tested MinMaxNormalize with the following code:
from torch_ecg._preprocessors import MinMaxNormalize
minmax = MinMaxNormalize()
sig = raw_sig[:, 0] # lead1, shape: (5000,)
sig_minmax, fs_minmax = minmax(sig, fs=500)
# plot
plt.figure(figsize=(20, 10))
plt.subplot(211)
plt.plot(sig)
plt.subplot(212)
plt.plot(sig_minmax)
plt.show()
To my surprise, the results from MinMaxNormalize weren't as expected within the 0-1 range. Instead, all values turned out to be 0 (In the above figure you can see the second curve). I would like to understand why this happened.
For further verification, I tested using the code below:
sig = raw_sig[:, 0] # lead1, shape: (5000,)
# use the min-max normalization to normalize the signal to [0, 1]
sig_minmax = (sig - np.min(sig)) / (np.max(sig) - np.min(sig))
# plot
plt.figure(figsize=(20, 10))
plt.subplot(211)
plt.plot(sig)
plt.subplot(212)
plt.plot(sig_minmax)
plt.show()
I found that my own code was effective and could correctly normalize the signal values to the [0, 1] range.
I hope to receive your feedback and clarification on this matter. Thank you!