Why is Scipy implementation of Hilbert() function different from Matlab implementation of the function? I am trying to fit Hilbert envelop to a high frequency ultrasonic signal of frequency 250 KHZ and sampling rate 12000000. Raw signal looks like below: .

I used hilbert() function from scipy.signal package in python this is what it looks like .

The python code looks like below

from scipy.signal import hilbert
import numpy as np
 def Hilbert(self,i=0):
    analytical_signal = hilbert(self.sensor["s"+str(i)])
    amplitude_envelope = np.abs(analytical_signal)
    return amplitude_envelope


The Matlab implementation looks like this 

Matlab code is as follows:

figure;
plot(abs(hilbert(signal)),'r');
hold on; 
plot(signal,'b');


The line data is as follows Signal.
I am wondering which one is correct?
It works fine for me:

from scipy.signal import hilbert
import numpy as np
from matplotlib.pyplot import plot

sensor = np.loadtxt('signal.txt')
plot(sensor)

analytical_signal = hilbert(sensor)
plot(analytical_signal.real)
plot(analytical_signal.imag)

amplitude_envelope = np.abs(analytical_signal)
plot(amplitude_envelope)






What are you doing differently?  Maybe you're throwing away the imaginary part of analytical_signal somehow?