Signal | Science @ Science @ MentDB Weak
Signal processing
• Digital signal processing: convolution, correlation, windows, spectra, peaks, smoothing and filters.
• The signals are JSON arrays of numbers sampled at a regular interval; fs is the sampling frequency in Hz.
• The conventions and the default values are the ones of NumPy and SciPy (scipy.signal): the results can be compared with Python.
• The signals are JSON arrays of numbers sampled at a regular interval; fs is the sampling frequency in Hz.
• The conventions and the default values are the ones of NumPy and SciPy (scipy.signal): the results can be compared with Python.
dsp convolve <json_x> <json_h>dsp convolve <json_x> <json_h> <mode>dsp correlate <json_x> <json_y>dsp correlate <json_x> <json_y> <mode>dsp autocorr <json_x>dsp autocorr <json_x> <nlags>dsp window <name> <n>dsp spectrum <json_x> <fs>dsp periodogram <json_x> <fs>dsp welch <json_x> <fs> <nperseg>dsp peaks <json_x>dsp peaks <json_x> <json_options>dsp moving_average <json_x> <w>dsp savgol <json_x> <window_length> <polyorder>dsp detrend <json_x>dsp detrend <json_x> <type>dsp filter <json_x> <fs> <type> <cutoff> <order>
dsp convolve <json_x> <json_h>
Description
Linear convolution of two arrays (mode full: n+m-1 values), as numpy.convolve. Direct computation for the small arrays, FFT for the big ones.
Linear convolution of two arrays (mode full: n+m-1 values), as numpy.convolve. Direct computation for the small arrays, FFT for the big ones.
Parameters
json_x: The signal (JSON array of numbers) - String - required
json_h: The kernel - String - required
json_x: The signal (JSON array of numbers) - String - required
json_h: The kernel - String - required
Examples (4)
admin
dsp convolve "[1, 2, 3]" "[0, 1, 0.5]"
mentdb
[0,1,2.5,4,1.5]
Moving sum of 2 points
admin
dsp convolve "[1, 2, 3, 4]" "[1, 1]"
mentdb
[1,3,5,7,4]
Product of two polynomials (1 + 2x)(3 + x)
admin
dsp convolve "[1, 2]" "[3, 1]"
mentdb
[3,7,2]
Impulse: the filter itself
admin
dsp convolve "[1, 0, 0]" "[0.25, 0.5, 0.25]"
mentdb
[0.25,0.5,0.25,0,0]
dsp convolve <json_x> <json_h> <mode>
Description
Linear convolution with a mode: full (n+m-1 values), same (size of the biggest array, centered), valid (only where the arrays fully overlap), as numpy.convolve.
Linear convolution with a mode: full (n+m-1 values), same (size of the biggest array, centered), valid (only where the arrays fully overlap), as numpy.convolve.
Parameters
json_x: The signal (JSON array of numbers) - String - required
json_h: The kernel - String - required
mode: full, same or valid - String - required
json_x: The signal (JSON array of numbers) - String - required
json_h: The kernel - String - required
mode: full, same or valid - String - required
Examples (5)
admin
dsp convolve "[1, 2, 3, 4, 5]" "[1, 1, 1]" "valid"
mentdb
[6,9,12]
Same size as the signal
admin
dsp convolve "[1, 2, 3, 4, 5]" "[1, 1, 1]" "same"
mentdb
[3,6,9,12,9]
Full mode (the default)
admin
dsp convolve "[1, 2, 3, 4, 5]" "[1, 1, 1]" "full"
mentdb
[1,3,6,9,12,9,5]
Smoothing with a triangular kernel
admin
dsp convolve "[0, 0, 4, 0, 0, 2, 0]" "[0.25, 0.5, 0.25]" "same"
mentdb
[0,1,2,1,0.5,1,0.5]
Unknown mode: error
admin
dsp convolve "[1, 2]" "[1]" "foo"
mentdb
Sorry, an error appears (unknown mode 'foo' (full, same, valid)).
dsp correlate <json_x> <json_y>
Description
Cross-correlation c[k] = sum x[n+k]*y[n] (mode full: lags from -(len(y)-1) to len(x)-1), as scipy.signal.correlate. The lag of the maximum gives the delay between two signals.
Cross-correlation c[k] = sum x[n+k]*y[n] (mode full: lags from -(len(y)-1) to len(x)-1), as scipy.signal.correlate. The lag of the maximum gives the delay between two signals.
Parameters
json_x: The signal (JSON array of numbers) - String - required
json_y: The second signal - String - required
json_x: The signal (JSON array of numbers) - String - required
json_y: The second signal - String - required
Examples (3)
admin
dsp correlate "[1, 2, 3]" "[0, 1, 0.5]"
mentdb
[0.5,2,3.5,3,0]
Delay between two signals
admin
dsp correlate "[0, 0, 1, 2, 1, 0]" "[1, 2, 1]"
mentdb
[0,0,1,4,6,4,1,0]
Find a pattern in a signal: the maximum gives the position
admin
dsp correlate "[0, 1, 0, 0, 2, 4, 2, 0]" "[1, 2, 1]"
mentdb
[0,1,2,1,2,8,12,8,2,0]
dsp correlate <json_x> <json_y> <mode>
Description
Cross-correlation with a mode: full, same (size of the first array, centered), valid, as scipy.signal.correlate.
Cross-correlation with a mode: full, same (size of the first array, centered), valid, as scipy.signal.correlate.
Parameters
json_x: The signal (JSON array of numbers) - String - required
json_y: The second signal - String - required
mode: full, same or valid - String - required
json_x: The signal (JSON array of numbers) - String - required
json_y: The second signal - String - required
mode: full, same or valid - String - required
Examples (3)
admin
dsp correlate "[1, 2, 3, 4, 5]" "[1, 0, -1]" "same"
mentdb
[-2,-2,-2,-2,4]
Valid mode: only the full overlaps
admin
dsp correlate "[1, 2, 3, 4, 5]" "[1, 0, -1]" "valid"
mentdb
[-2,-2,-2]
Full mode
admin
dsp correlate "[1, 2, 3]" "[1, 1]" "full"
mentdb
[1,3,5,3]
dsp autocorr <json_x>
Description
Autocorrelation function r[k] for the lags 0 to n-1 (normalized: r[0] = 1, mean removed), as statsmodels acf. A periodic signal gives peaks at the multiples of its period.
Autocorrelation function r[k] for the lags 0 to n-1 (normalized: r[0] = 1, mean removed), as statsmodels acf. A periodic signal gives peaks at the multiples of its period.
Parameters
json_x: The signal (JSON array of numbers) - String - required
json_x: The signal (JSON array of numbers) - String - required
Examples (4)
admin
dsp autocorr "[1, 3, 2, 5, 4, 6]"
mentdb
[1,0.1,0.34285714285714286,-0.44285714285714284,-0.14285714285714285,-0.35714285714285715]
Periodic signal
admin
dsp autocorr "[0, 0.951, 0.588, -0.588, -0.951, 0, 0.951, 0.588, -0.588, -0.951]"
mentdb
[1,0.3090169540333321,-0.6281577337028904,-0.5853676973471077,0.15450847701666606,0.5,0.15450847701666606,-0.2236492566862244,-0.18085922033044166,0]
Alternating signal: the sign changes at each lag
admin
dsp autocorr "[1, 2, 1, 2, 1, 2]"
mentdb
[1,-0.8333333333333334,0.6666666666666666,-0.5,0.3333333333333333,-0.16666666666666666]
Random noise: close to 0 except at lag 0
admin
dsp autocorr "[0.5, -1.2, 0.3, 0.8, -0.4, 1.1, -0.9, 0.2]"
mentdb
[1,-0.5708874458874459,0.09415584415584419,0.0827922077922078,-0.354978354978355,0.3674242424242425,-0.1331168831168831,0.014610389610389612]
dsp autocorr <json_x> <nlags>
Description
Autocorrelation function for the lags 0 to nlags.
Autocorrelation function for the lags 0 to nlags.
Parameters
json_x: The signal (JSON array of numbers) - String - required
nlags: The last lag - Number - required
json_x: The signal (JSON array of numbers) - String - required
nlags: The last lag - Number - required
Examples (3)
admin
dsp autocorr "[1, 3, 2, 5, 4, 6, 5, 8, 7, 9]" 3
mentdb
[1,0.45,0.5,-0.03333333333333333]
Sine with a period of 5 samples: a new maximum at lag 5
admin
dsp autocorr "[0, 0.951, 0.588, -0.588, -0.951, 0, 0.951, 0.588, -0.588, -0.951]" 6
mentdb
[1,0.3090169540333321,-0.6281577337028904,-0.5853676973471077,0.15450847701666606,0.5,0.15450847701666606]
Lag 1 only
admin
dsp autocorr "[1, 3, 2, 5, 4, 6]" 1
mentdb
[1,0.1]
dsp window <name> <n>
Description
Window of n points (symmetric, as numpy.hanning, numpy.hamming...): boxcar, hann, hamming, blackman, bartlett, flattop. Multiply a signal by a window before a spectrum to reduce the leakage.
Window of n points (symmetric, as numpy.hanning, numpy.hamming...): boxcar, hann, hamming, blackman, bartlett, flattop. Multiply a signal by a window before a spectrum to reduce the leakage.
Parameters
name: boxcar, hann, hamming, blackman, bartlett or flattop - String - required
n: The number of points - Number - required
name: boxcar, hann, hamming, blackman, bartlett or flattop - String - required
n: The number of points - Number - required
Examples (7)
admin
dsp window "hann" 5
mentdb
[0,0.49999999999999994,1,0.5000000000000001,0]
Hamming window
admin
dsp window "hamming" 5
mentdb
[0.08000000000000002,0.54,1,0.5400000000000001,0.08000000000000002]
Blackman window
admin
dsp window "blackman" 5
mentdb
[-1.3877787807814457E-17,0.3399999999999999,0.9999999999999999,0.3400000000000001,-1.3877787807814457E-17]
Bartlett (triangular)
admin
dsp window "bartlett" 5
mentdb
[0,0.5,1,0.5,0]
Flat top (amplitude measures)
admin
dsp window "flattop" 5
mentdb
[-4.210510000000013E-4,-0.05473684000000003,1.000000003,-0.05473683999999998,-4.210510000000013E-4]
Rectangular (no window)
admin
dsp window "boxcar" 4
mentdb
[1,1,1,1]
Unknown window: error
admin
dsp window "foo" 5
mentdb
Sorry, an error appears (unknown window 'foo' (boxcar, hann, hamming, blackman, bartlett, flattop)).
dsp spectrum <json_x> <fs>
Description
One-sided amplitude spectrum of a real signal: a sine of amplitude A at the frequency f gives A at f.
Exact discrete Fourier transform of the n values (any n, no zero padding): frequencies k*fs/n for k = 0 to n/2.
Returns {f, amplitude, phase (radians)}.
One-sided amplitude spectrum of a real signal: a sine of amplitude A at the frequency f gives A at f.
Exact discrete Fourier transform of the n values (any n, no zero padding): frequencies k*fs/n for k = 0 to n/2.
Returns {f, amplitude, phase (radians)}.
Parameters
json_x: The signal (JSON array of numbers) - String - required
fs: The sampling frequency (Hz) - Number - required
json_x: The signal (JSON array of numbers) - String - required
fs: The sampling frequency (Hz) - Number - required
Examples (4)
admin
dsp spectrum "[0, 1.0607, 0.5, 1.0607, 0, -1.0607, -0.5, -1.0607, 0, 1.0607, 0.5, 1.0607, 0, -1.0607, -0.5, -1.0607]" 8
mentdb
{"f": [0,0.5,1,1.5,2,2.5,3,3.5,4], "amplitude": [0,0,1.000028162804571,0,0,0,0.5000281628045709,0,0], "phase": [0,0,-1.5707963267948966,0,0,0,-1.570796326794897,0,0]}
Sine of 2 Hz sampled at 10 Hz
admin
dsp spectrum "[0, 0.951, 0.588, -0.588, -0.951, 0, 0.951, 0.588, -0.588, -0.951]" 10
mentdb
{"f": [0,1,2,3,4,5], "amplitude": [4.742874840267547E-17,1.8552687127769032E-16,1.0000579802757321,1.953222381142193E-16,1.8996532112663283E-4,4.6007864835756186E-17], "phase": [-2.782821983319221,2.1480195828229656,-1.5707963267948966,-3.095865835156779,1.5707963267949914,-1.281413005760718]}
Constant signal: everything at 0 Hz
admin
dsp spectrum "[2, 2, 2, 2]" 4
mentdb
{"f": [0,1,2], "amplitude": [2,0,0], "phase": [0,0,0]}
Sum of two sines of 1 Hz and 2 Hz
admin
dsp spectrum "[0, 1.707, 1, -0.293, 0, 0.293, -1, -1.707]" 8
mentdb
{"f": [0,1,2,3,4], "amplitude": [0,0.9999244942988892,1,7.55057011108673E-5,0], "phase": [0,-1.5707963267948966,-1.5707963267948963,1.5707963267938316,0]}
dsp periodogram <json_x> <fs>
Description
Power spectral density (one-sided, density in unit^2/Hz), as scipy.signal.periodogram: mean removed, no window.
Returns {f, psd}.
Power spectral density (one-sided, density in unit^2/Hz), as scipy.signal.periodogram: mean removed, no window.
Returns {f, psd}.
Parameters
json_x: The signal (JSON array of numbers) - String - required
fs: The sampling frequency (Hz) - Number - required
json_x: The signal (JSON array of numbers) - String - required
fs: The sampling frequency (Hz) - Number - required
Examples (3)
admin
dsp periodogram "[1, 2, 1, 0, 1, 2, 1, 0]" 4
mentdb
{"f": [0,0.5,1,1.5,2], "psd": [0,0,1,0,0]}
Sine of 2 Hz sampled at 10 Hz
admin
dsp periodogram "[0, 0.951, 0.588, -0.588, -0.951, 0, 0.951, 0.588, -0.588, -0.951]" 10
mentdb
{"f": [0,1,2,3,4,5], "psd": [2.2494861750442914E-33,1.7210109983044337E-32,0.5000579819565882,1.9075388350973887E-32,1.8043411615372368E-8,2.11672362674521E-33]}
Periodogram of a noisy signal
admin
dsp periodogram "[0.5, -1.2, 0.3, 0.8, -0.4, 1.1, -0.9, 0.2]" 8
mentdb
{"f": [0,1,2,3,4], "psd": [0,0.04137209171765961,0.053125,0.45237790828234037,0.030625000000000006]}
dsp welch <json_x> <fs> <nperseg>
Description
Power spectral density by the Welch method, as scipy.signal.welch: segments of nperseg values, hann window, 50% overlap, mean removed in each segment, mean of the segments. Less noisy than the periodogram.
Returns {f, psd, segments}.
Power spectral density by the Welch method, as scipy.signal.welch: segments of nperseg values, hann window, 50% overlap, mean removed in each segment, mean of the segments. Less noisy than the periodogram.
Returns {f, psd, segments}.
Parameters
json_x: The signal (JSON array of numbers) - String - required
fs: The sampling frequency (Hz) - Number - required
nperseg: The number of values per segment - Number - required
json_x: The signal (JSON array of numbers) - String - required
fs: The sampling frequency (Hz) - Number - required
nperseg: The number of values per segment - Number - required
Examples (3)
admin
dsp welch "[1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 1, 0]" 4 8
mentdb
{"f": [0,0.5,1,1.5,2], "psd": [0,0.16666666666666666,0.6666666666666666,0.16666666666666666,0], "segments": 3}
Sine of 1 Hz sampled at 10 Hz, segments of 10
admin
dsp welch "[0, 0.588, 0.951, 0.951, 0.588, 0, -0.588, -0.951, -0.951, -0.588, 0, 0.588, 0.951, 0.951, 0.588, 0, -0.588, -0.951, -0.951, -0.588]" 10 10
mentdb
{"f": [0,1,2,3,4,5], "psd": [3.0404014055393164E-33,0.3333719879710588,0.08337466272256133,1.2028941076908978E-8,3.0072352692446657E-9,2.988362781710737E-33], "segments": 3}
Segment larger than the signal: one segment (the whole signal)
admin
dsp welch "[1, 2, 3]" 4 8
mentdb
{"f": [0,1.3333333333333333], "psd": [0.12500000000000006,0.25000000000000006], "segments": 1}
dsp peaks <json_x>
Description
Find the peaks (local maxima, the middle of a plateau) as scipy.signal.find_peaks.
Returns {indices, values, prominences}: the prominence is the height of the peak above the highest of its two bases.
Find the peaks (local maxima, the middle of a plateau) as scipy.signal.find_peaks.
Returns {indices, values, prominences}: the prominence is the height of the peak above the highest of its two bases.
Parameters
json_x: The signal (JSON array of numbers) - String - required
json_x: The signal (JSON array of numbers) - String - required
Examples (5)
admin
dsp peaks "[0, 2, 1, 3, 1, 2.5, 0, 1, 0]"
mentdb
{"indices": [1,3,5,7], "values": [2,3,2.5,1], "prominences": [1,3,1.5,1]}
Peaks of a noisy signal
admin
dsp peaks "[1, 3, 2, 4, 1, 5, 2, 2, 6, 1]"
mentdb
{"indices": [1,3,5,8], "values": [3,4,5,6], "prominences": [1,3,3,5]}
Plateau: the middle
admin
dsp peaks "[0, 1, 2, 2, 2, 1, 0]"
mentdb
{"indices": [3], "values": [2], "prominences": [2]}
No peak in a monotone signal
admin
dsp peaks "[1, 2, 3, 4]"
mentdb
{"indices": [], "values": [], "prominences": []}
All the local maxima, even the small ones
admin
dsp peaks "[0, 0.1, 1.2, 0.2, 0, 0.1, 0, 0.1, 1.1, 0.1, 0, 0.2, 0, 0.1, 1.3, 0.2]"
mentdb
{"indices": [2,5,8,11,14], "values": [1.2,0.1,1.1,0.2,1.3], "prominences": [1.2,0.1,1.1,0.2,1.1]}
dsp peaks <json_x> <json_options>
Description
Find the peaks with conditions (JSON object, all optional), as scipy.signal.find_peaks:
- height: minimum value
- distance: minimum number of samples between two peaks (the highest peaks are kept)
- prominence: minimum prominence
Find the peaks with conditions (JSON object, all optional), as scipy.signal.find_peaks:
- height: minimum value
- distance: minimum number of samples between two peaks (the highest peaks are kept)
- prominence: minimum prominence
Parameters
json_x: The signal (JSON array of numbers) - String - required
json_options: {"height": h, "distance": d, "prominence": p} - String - required
json_x: The signal (JSON array of numbers) - String - required
json_options: {"height": h, "distance": d, "prominence": p} - String - required
Examples (4)
admin
dsp peaks "[0, 2, 1, 3, 1, 2.5, 0, 1, 0]" "{\"height\": 1.5, \"distance\": 3}"
mentdb
{"indices": [3], "values": [3], "prominences": [3]}
Only the prominent peaks
admin
dsp peaks "[0, 0.1, 1.2, 0.2, 0, 0.1, 0, 0.1, 1.1, 0.1, 0, 0.2, 0, 0.1, 1.3, 0.2]" "{\"prominence\": 0.5}"
mentdb
{"indices": [2,8,14], "values": [1.2,1.1,1.3], "prominences": [1.2,1.1,1.1]}
Minimum height
admin
dsp peaks "[1, 3, 2, 4, 1, 5, 2, 2, 6, 1]" "{\"height\": 4}"
mentdb
{"indices": [3,5,8], "values": [4,5,6], "prominences": [3,3,5]}
Minimum distance between peaks
admin
dsp peaks "[1, 3, 2, 4, 1, 5, 2, 2, 6, 1]" "{\"distance\": 4}"
mentdb
{"indices": [3,8], "values": [4,6], "prominences": [3,5]}
dsp moving_average <json_x> <w>
Description
Moving average on w values (mode valid: n-w+1 values, the value i is the mean of x[i] to x[i+w-1]).
Moving average on w values (mode valid: n-w+1 values, the value i is the mean of x[i] to x[i+w-1]).
Parameters
json_x: The signal (JSON array of numbers) - String - required
w: The window size - Number - required
json_x: The signal (JSON array of numbers) - String - required
w: The window size - Number - required
Examples (4)
admin
dsp moving_average "[1, 2, 3, 4, 10, 6]" 3
mentdb
[2,3,5.666666666666667,6.666666666666667]
Smoothing over 5 points
admin
dsp moving_average "[2, 4, 3, 6, 5, 8, 7, 10, 9]" 5
mentdb
[4,5.2,5.8,7.2,7.8]
Window of 1: the signal
admin
dsp moving_average "[1, 2, 3]" 1
mentdb
[1,2,3]
Smoothing of noisy measures
admin
dsp moving_average "[10.2, 9.8, 10.5, 9.9, 10.1, 10.4, 9.7]" 3
mentdb
[10.166666666666666,10.066666666666668,10.166666666666666,10.133333333333333,10.066666666666665]
dsp savgol <json_x> <window_length> <polyorder>
Description
Savitzky-Golay smoothing, as scipy.signal.savgol_filter (mode interp): each value is replaced by the value of the polynomial fitted on the window around it. Smooths the noise and keeps the shape of the peaks better than a moving average.
Savitzky-Golay smoothing, as scipy.signal.savgol_filter (mode interp): each value is replaced by the value of the polynomial fitted on the window around it. Smooths the noise and keeps the shape of the peaks better than a moving average.
Parameters
json_x: The signal (JSON array of numbers) - String - required
window_length: The window length (odd) - Number - required
polyorder: The order of the polynomial (less than the window length) - Number - required
json_x: The signal (JSON array of numbers) - String - required
window_length: The window length (odd) - Number - required
polyorder: The order of the polynomial (less than the window length) - Number - required
Examples (5)
admin
dsp savgol "[2, 4, 3, 6, 5, 8, 7, 10, 9]" 5 2
mentdb
[2.1142857142857143,3.342857142857143,4.285714285714286,4.628571428571431,6.371428571428571,6.62857142857143,8.371428571428572,9.085714285714285,9.228571428571428]
Smoothing that keeps the peaks
admin
dsp savgol "[1, 2, 4, 8, 4, 2, 1, 2, 1]" 5 3
mentdb
[1.1571428571428466,1.3714285714285757,4.942857142857143,6.2857142857142865,4.942857142857143,1.8285714285714298,1.428571428571429,1.7142857142857095,1.0714285714285676]
Keeps a parabola exactly (order 2)
admin
dsp savgol "[0, 1, 4, 9, 16, 25, 36]" 5 2
mentdb
[-6.581115618108337E-16,1.0000000000000002,4.000000000000002,9.000000000000004,16.000000000000004,25,36]
Smoothing of a noisy peak
admin
dsp savgol "[0.1, 0.3, 0.2, 0.9, 1.6, 2.1, 1.5, 1.0, 0.2, 0.3, 0.1]" 5 2
mentdb
[0.15714285714285695,0.13142857142857137,0.3628571428571431,0.8485714285714288,1.6600000000000001,1.9200000000000002,1.637142857142857,0.8628571428571431,0.4057142857142858,0.16285714285714237,0.13428571428571345]
Even window: error
admin
dsp savgol "[1, 2, 3, 4, 5, 6]" 4 2
mentdb
Sorry, an error appears (the window length must be odd).
dsp detrend <json_x>
Description
Remove the linear trend (least squares line), as scipy.signal.detrend.
Remove the linear trend (least squares line), as scipy.signal.detrend.
Parameters
json_x: The signal (JSON array of numbers) - String - required
json_x: The signal (JSON array of numbers) - String - required
Examples (4)
admin
dsp detrend "[1, 2.2, 2.9, 4.1, 5]"
mentdb
[-0.05999999999999983,0.15000000000000036,-0.14000000000000012,0.07000000000000028,-0.019999999999999574]
Remove a linear drift
admin
dsp detrend "[0.1, 1.2, 1.9, 3.1, 4.0, 5.2]"
mentdb
[0.023809523809524197,0.12095238095238092,-0.18190476190476224,0.015238095238094829,-0.08761904761904837,0.10952380952380825]
A straight line becomes 0
admin
dsp detrend "[1, 2, 3, 4]"
mentdb
[-4.440892098500626E-16,0,0,4.440892098500626E-16]
Remove a drift from a sensor
admin
dsp detrend "[0, 1.1, 0.2, 1.3, 0.4, 1.5, 0.6]"
mentdb
[-0.4285714285714285,0.5714285714285716,-0.42857142857142855,0.5714285714285715,-0.4285714285714285,0.5714285714285715,-0.4285714285714285]
dsp detrend <json_x> <type>
Description
Remove the trend: linear (least squares line) or constant (mean), as scipy.signal.detrend.
Remove the trend: linear (least squares line) or constant (mean), as scipy.signal.detrend.
Parameters
json_x: The signal (JSON array of numbers) - String - required
type: linear or constant - String - required
json_x: The signal (JSON array of numbers) - String - required
type: linear or constant - String - required
Examples (3)
admin
dsp detrend "[1, 2.2, 2.9, 4.1, 5]" "constant"
mentdb
[-2.04,-0.8399999999999999,-0.14000000000000012,1.0599999999999996,1.96]
Linear (the default)
admin
dsp detrend "[1, 2.2, 2.9, 4.1, 5]" "linear"
mentdb
[-0.05999999999999983,0.15000000000000036,-0.14000000000000012,0.07000000000000028,-0.019999999999999574]
Constant: remove the mean
admin
dsp detrend "[10, 12, 11, 13]" "constant"
mentdb
[-1.5,0.5,-0.5,1.5]
dsp filter <json_x> <fs> <type> <cutoff> <order>
Description
Butterworth filter without phase shift (forward and backward), as scipy.signal.butter + scipy.signal.filtfilt (padding odd).
- type: lowpass, highpass (cutoff: a frequency in Hz), bandpass, bandstop (cutoff: "[low, high]")
- the cutoff frequencies must be below fs/2 (Nyquist)
- order 1 to 10 (the effective order is doubled by the forward-backward filtering)
Butterworth filter without phase shift (forward and backward), as scipy.signal.butter + scipy.signal.filtfilt (padding odd).
- type: lowpass, highpass (cutoff: a frequency in Hz), bandpass, bandstop (cutoff: "[low, high]")
- the cutoff frequencies must be below fs/2 (Nyquist)
- order 1 to 10 (the effective order is doubled by the forward-backward filtering)
Parameters
json_x: The signal (JSON array of numbers) - String - required
fs: The sampling frequency (Hz) - Number - required
type: lowpass, highpass, bandpass or bandstop - String - required
cutoff: The cutoff frequency (Hz) or [low, high] - String - required
order: The order of the filter (1 to 10) - Number - required
json_x: The signal (JSON array of numbers) - String - required
fs: The sampling frequency (Hz) - Number - required
type: lowpass, highpass, bandpass or bandstop - String - required
cutoff: The cutoff frequency (Hz) or [low, high] - String - required
order: The order of the filter (1 to 10) - Number - required
Examples (5)
admin
dsp filter "[0, 1.0607, 0.5, 1.0607, 0, -1.0607, -0.5, -1.0607, 0, 1.0607, 0.5, 1.0607, 0, -1.0607, -0.5, -1.0607]" 8 "lowpass" 2 2
mentdb
[-1.3462326241470146E-5,0.697036533277046,0.9571374563393378,0.6970042532872518,-1.1275709785596444E-5,-0.696962053000557,-0.9570698020806241,-0.69733193528391,-3.6991180647036326E-4,0.6988536647040171,0.959289272919446,0.6863099470598071,-0.012565725710205783,-0.6346133470628598,-0.883894918658211,-1.0607298646826482]
High-pass filter: keeps the 2 Hz sine, removes the offset of 1
admin
dsp filter "[1, 1.951, 1.588, 0.412, 0.049, 1, 1.951, 1.588, 0.412, 0.049]" 10 "highpass" 0.5 2
mentdb
[-0.03988401794025298,0.931387324966643,0.6039863498107468,-0.5157271874000008,-0.7991922818418904,0.2588416854207784,1.3510592025507757,1.167368235216259,0.20435983916485934,0.07509202665678849]
Band-pass between 1.5 and 2.5 Hz
admin
dsp filter "[0, 1.0607, 0.5, 1.0607, 0, -1.0607, -0.5, -1.0607, 0, 1.0607, 0.5, 1.0607, 0, -1.0607, -0.5, -1.0607]" 8 "bandpass" "[1.5, 2.5]" 2
mentdb
[0.001060074785809004,0.036130734774016154,0.008496960452136994,0.025910593883864436,0.008386042285966577,-0.02972738633250585,-0.018331800828019214,-0.020104267239520232,-0.014286822786016092,-9.883450014580332E-4,0.06655612292939293,0.08922638724731279,-0.10453041317523352,-0.10369348333760424,0.12427387910982077,8.507399330917459E-4]
Band-stop around 2 Hz
admin
dsp filter "[0, 1.0607, 0.5, 1.0607, 0, -1.0607, -0.5, -1.0607, 0, 1.0607, 0.5, 1.0607, 0, -1.0607, -0.5, -1.0607]" 8 "bandstop" "[1.5, 2.5]" 2
mentdb
[-0.001130946726046994,1.0244372793668777,0.4915791168428236,1.03501631837094,-0.008388605549900369,-1.0312184608666062,-0.48188918105162737,-1.0405811086383807,0.014919543720290945,1.062384523335179,0.4323172176566519,0.9694606507036329,0.10581892441918667,-0.953401535202933,-0.6245383610208952,-1.065708281130079]
Cutoff above fs/2: error
admin
dsp filter "[1, 2, 3, 4, 5, 6, 7, 8]" 8 "lowpass" 5 2
mentdb
Sorry, an error appears (the cutoff frequency must be between 0 and fs/2 (Nyquist: 4)).
