필터 지우기
필터 지우기

contourf lower edge effects, how to fix and how does contourf work

조회 수: 1 (최근 30일)
Joanne Hall
Joanne Hall 2022년 10월 12일
댓글: Star Strider 2022년 10월 15일
Dear Matlab,
Using CONTOURF() to plot phase-amplitude coupling with an EEG signal, there appears what I call 'an edge effect' at the bottom of the plot (whereby the largest activity is always colored at the bottom of the plot) SEE ATTACHED IMAGE. I would like to capture the entire range of the 'hottest color blods' so I tried changing the y-axis range. BUT If I change the y-axis to range, no metter what - The 'hottest' colors always end up at the bottom of the plot. So I don't know how contourf() works then. Can you please help me? Thanks very much in advance!
Attached is sample data and pasted code below...
The variable that I change below to adjust/change the y-axis range is:
power_frex = linspace(15,60,45);
(and the resulting plot always has a blob at the bottom)
ATTACHED ARE EXAMPLE PLOTS FROM CHANGING THE Y-AXIS RANGE VIA THE 'power_frex' variable.
%% signal parameters
load signal
srate = 250;
lowerfreq = 6;
upperfreq = 40; % Hz
%%% Compute PAC
phase_frex = linspace(1,10,15);
power_frex = linspace(15,60,45);
pac = zeros(length(power_frex),length(phase_frex));
for lowfi=1:length(phase_frex)
% get phase time series
phasets = exp(1i*angle(hilbert(filterFGx(signal,srate,phase_frex(lowfi),1))));
% loop over amplitude frequencies
for hifi=1:length(power_frex)
% get power time series
powts = abs(hilbert(filterFGx(signal,srate,power_frex(hifi),lowerfreq*2))).^2;
% PAC
pac(hifi,lowfi) = abs(mean( powts.*phasets ));
end
end
%%% visualize
figure(4), clf
contourf(phase_frex,power_frex,pac,40,'linecolor','none')
xlabel('Phase freq. (Hz)')
ylabel('Ampl. freq. (Hz)')
Joanne

채택된 답변

Star Strider
Star Strider 2022년 10월 12일
We’re missing the filter function you’re using, so not able to run your code. However the pspectrum 'spectrogram' plot demonstrates that the pwer is concentrated at the lower frequencies (as expected). I’m not certain how you’re limiting the plots you’re creating, however setting the appropriate axis limits rather than restricting the values plotted may produce the result you want.
Try something like this —
LD = load(websave('TESTsignal','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1153968/TESTsignal.mat'));
signal = LD.signal;
srate = 250;
lowerfreq = 6;
upperfreq = 40; % Hz
%%% Compute PAC
phase_frex = linspace(1,10,15);
power_frex = linspace(15,60,45);
% figure
[p,f,t] = pspectrum(signal, srate, 'spectrogram');
figure
surfc(t,f,10*log10(p), 'EdgeColor','none')
colormap(turbo)
hcb = colorbar;
hcb.Label.String = 'Power (dB)';
zlim([-50 max(zlim)])
xlabel('Time')
ylabel('Frequency')
zlabel('Power (dB)')
title('Frequency: 0 - 125 Hz')
figure
surfc(t,f,10*log10(p), 'EdgeColor','none')
colormap(turbo)
hcb = colorbar;
hcb.Label.String = 'Power (dB)';
ylim([50 max(ylim)])
zlim([-50 max(zlim)])
xlabel('Time')
ylabel('Frequency')
zlabel('Power (dB)')
title('Frequency: 50 - 125 Hz')
.
  댓글 수: 4

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by