How to solve a data length error in the function "filtfilt"?
Show older comments
Hello,
I tried to code a Butterworth filter 4th order by using designfilt and then used the function filtfilt to apply it on my 3-dimensional EEG data.
But I'm getting an error, that the Data length must be larger than 12 samples, even though the length is larger...
I think I must be missing something. Can somebody help me?
So the size of the EEG data is "8x5121x30 double" and is called "ssvep0Hz". The passband is set between 5Hz and 20Hz. The sample_rate in this case is 512.
- This is the code I programmed:
function [filtered_signal] = myfilter(n,f1,f2,ssvepdat,samp_rate)
d = designfilt('bandpassiir', 'FilterOrder', 2*n, 'HalfPowerFrequency1', f1, 'HalfPowerFrequency2', f2, 'DesignMethod', 'butter', 'SampleRate', samp_rate);
filtered_signal = filtfilt(d,ssvepdat);
end
- And then implemented in the script it looks like that:
filtered_ssvep0Hz = myfilter(2,5,20,ssvep0Hz, sample_rate);
Thank you in advance.
Accepted Answer
More Answers (1)
Mathieu NOE
on 7 Jan 2021
0 votes
hello Lea
your issue is related to the size of the input data
filtfilt works only on "vertical" vectors so the first dimension must be the time
you have to find a way to put the data in 5121x8x30 or 5121x30x8 format
Categories
Find more on Digital Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!