Skip to content

Commit

Permalink
restore fft method in matlab (#432)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Parfenov <a1994ndrey@gmail.com>
  • Loading branch information
Andrey1994 authored Apr 27, 2022
1 parent 87b28b0 commit ecb7fb4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/run_matlab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ jobs:
uses: matlab-actions/run-command@v1
with:
command: addpath('matlab-package/brainflow'),addpath('matlab-package/brainflow/examples'),addpath('matlab-package/brainflow/inc'),addpath('matlab-package/brainflow/lib'),SignalFiltering
- name: Run Transforms Test
uses: matlab-actions/run-command@v1
with:
command: addpath('matlab-package/brainflow'),addpath('matlab-package/brainflow/examples'),addpath('matlab-package/brainflow/inc'),addpath('matlab-package/brainflow/lib'),Transforms
16 changes: 16 additions & 0 deletions matlab-package/brainflow/DataFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,22 @@ function disable_data_logger()
stddev = output.Value;
end

function fft_data = perform_fft(data, window)
% perform fft
task_name = 'perform_fft';
n = size(data, 2);
if(bitand(n, n - 1) ~= 0)
error('For FFT shape must be power of 2!');
end
temp_input = libpointer('doublePtr', data);
lib_name = DataFilter.load_lib();
temp_re = libpointer('doublePtr', zeros(1, int32(n / 2 + 1)));
temp_im = libpointer('doublePtr', zeros(1, int32(n / 2 + 1)));
exit_code = calllib(lib_name, task_name, temp_input, n, window, temp_re, temp_im);
DataFilter.check_ec(exit_code, task_name);
fft_data = complex(temp_re.Value, temp_im.Value);
end

function data = perform_ifft(fft_data)
% perform inverse fft
task_name = 'perform_ifft';
Expand Down

0 comments on commit ecb7fb4

Please sign in to comment.