How can I do a Fourier series expansion of a wave-scan from an EDF file in MATLAB?

6 vues (au cours des 30 derniers jours)
Sergio
Sergio le 8 Fév 2024
Hi, I have an EDF file that I obtained from an organization, and this EDF is showing a set of waves, which can be simplified to just one at a time.
I am interested in doing a Fourier analysis of some of these single plots. Can this be done somehow? That is , for instance, pick one graph, convert it to single points at each maximum and minimum, and then generate a piecewise constant function. From then, the piecewise constant function will be input to any form of analysis.
Any ideas appreciated.
Thanks

Réponses (1)

Ayush Modi
Ayush Modi le 21 Fév 2024
Hi Sergio,
I understand you want to read EDF file and extract some of the individual signals from it. Afterwards, you want to perform fourier analysis on these signals. Here is an example how you can achieve this:
  • Step 1: Read the EDF file using "edfread" function
[record, hdr] = edfread('example.edf');
  • Step 2: Isolate the Desired signal
signal = record(1, :);
signal = signal.ECG{1}; % ECG is the signal in the example file
  • Step 3: Simplify the signal by finding the maxima and minima. You can achieve this using "findpeaks" function.
[pks_max, locs_max] = findpeaks(signal);
% Find minima
[pks_min, locs_min] = findpeaks(-signal);
pks_min = -pks_min; % Invert to get actual minima values
% Combine maxima and minima and sort them by location
combined_pks = [pks_max, pks_min];
combined_locs = [locs_max, locs_min];
[sorted_locs, sortIdx] = sort(combined_locs);
sorted_pks = combined_pks(sortIdx);
  • Step 4: Construct a Piecewise Constant Function by creating a new time series where the value of the function is constant between each pair of adjacent maxima and minima
% Initialize the piecewise constant function with zeros
piecewise_const = zeros(size(signal));
% Assign values between peaks
for i = 1:length(sorted_locs)-1
piecewise_const(sorted_locs(i):sorted_locs(i+1)) = sorted_pks(i);
end
  • Step 5: Perform Fourier Analysis using "fft" function
fft_result = fft(piecewise_const);
Please refer to the following MathWorks documentation for more information on:
Hope this helps!

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by