How to merge many time-frequency scalograms into a single image?

5 次查看(过去 30 天)
Hello. I am working on EEG signals using Bonn University data. My data has 500*4097 size and I want to create a single image representing scalogram of the entire data. I wrote a code to create scalogram for each data (500) but can not find a way to merge all these 500 data into one image. Here is my code for creating scalogram for one data:
function TF(f0,F1_Data,t)
sig=F1_Data(152,:);
fb=cwtfilterbank('SignalLength',numel(sig),'SamplingFrequency',f0,'VoicesPerOctave',12);
[cfs,frq]=wt(fb,sig);
figure
pcolor(t,frq,abs(cfs))
shading interp
axis tight
title("Scalogram")
xlabel("Time (s)")
ylabel("Frequency (Hz)")
end

回答(1 个)

Aastha
Aastha 2024-10-7
Hi Hossein,
As I understand, you want to combine the scalograms of each data point from your 500x4097 dataset into a single image.
Kindly refer to the following steps to combine the scalograms of each data point into a single image:
1. Compute the scalograms for each data point in the dataset and store them. You can use the "TF" function that you have defined to compute the scalograms using the MATLAB code below:
scalogram = cell(500,1);
for idx = 1:500
    data_point = eeg_data(idx,:);
    [cfs, frq] = TF(f0, data_point);
    scalogram_curr_data.cfs = cfs;
    scalogram_curr_data.frq = frq;
    scalogram{idx} = scalogram_curr_data;
end
You may refer to the documentation link of “cell” for any further information.
2. The “TF” function computes the continuous wavelet transform (CWT) for each data point using the “wt” function in MATLAB.
function [cfs, frq] = TF(f0, sig)
    fb = cwtfilterbank('SignalLength', numel(sig), ...
                       'SamplingFrequency', f0, 'VoicesPerOctave', 12);
    [cfs, frq] = wt(fb, sig);
end
The “cfs” matrix returned by the “wt” function is a 2D matrix where each row represents a scale, and the columns have the same length as the input signal. The “frq” array corresponds to the frequency values for each scale.
For any further information on “wt” function, you may refer to the link of MathWorks documentation mentioned below:
3. To combine the scalograms for the entire dataset into a single image, you can choose a specific scale and plot the scalograms for each data point using the MATLAB code given below:
% Choose a scale between 1 and size(cfs,1)
scale = 1;
frq = zeros(size(eeg_data,1),1);
cfs = zeros(size(eeg_data,1),size(eeg_data,2));
for idx = 1:size(eeg_data,1)
    frq(idx) = scalogram{idx}.frq(idx);
    cfs(idx,:) = scalogram{idx}.cfs(idx,:);
end
Kindly refer to the following documentation link of “zeros” function for any further information:
I hope this is helpful!

类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by