PSD vs DFT: Why is this peak shifting?

3 ビュー (過去 30 日間)
Brandon  Madsen
Brandon Madsen 2017 年 6 月 8 日
編集済み: Brandon Madsen 2017 年 6 月 8 日
The following image depicts output from a spectral analysis of (1) an auditory stimulus and (2) the recorded neural response to that stimulus using scalp electrodes, averaged over a group of subjects. The "Baseline" spectrum is the average of the neural response during the time period before the evoking stimulus was presented. The x axis is frequency in Hz and the y axis is the DFT (left) or PSD (right) value respectively.
What I'm wondering is: why does the location of the peak sometimes change in the response when comparing DFT to PSD? Is something going wrong with my calculation or plotting, or does this make sense that this could happen?
Here are the relevant chunks of code I am using:
if true
%%SETTINGS
fs = 20000; % sampling rate (Hz)
stimMs = 120; % duration of stimulus (ms)
prestimMs = 40; % duration of prestimulus baseline recording period (ms)
f = 350:750; % vector of frequency values we are interested in analyzing (Hz)
nWins = 5; % number of desired analysis windows
overlapRatio = 0.5 % ratio of overlap between windows
%%DERIVE SOME MORE VARIABLES
spms = fs/1000; % samples per ms
wMs = floor(stimMs / (nWins + ...
overlapRatio - nWins * overlapRatio)); % analysis window duration (ms)
wSamps = wMs * smps; % # of samples per analysis window
overlapMs = wMs * overlapRatio; % duration of window overlap (ms)
prestimSamps = prestimMs * spms; % # of samples in prestim resp baseline
w = blackman(wSamps); % define shape of window
o = floor(overlapRatio * wSamps); % # of samples of overlap between windows
stimSamps = stimMs * spms; % # of samples making up the stimulus waveform
tStimOn = prestimSamps+1; % response index when stim turns on
tStimOff = tStimOn + stimSamps-1; % response index when stim turns off
%%GET THE DFT AND PSD VALUES
in1 = currResp(tStimOn:tStimOff); % grab part of resp where stim is on
in2 = currResp(tStimOn-wSamps:tStimOn-1); % grab the prestim baseline
[s1,~,~,p1] = spectrogram(in1,w,o,f,fs); % DFT and PSD of resp
[s2,~,~,p2] = spectrogram(in2,w,0,f,fs); % DFT and PSD of prestim baseline
[s3,~,~,p3] = spectrogram(stim,w,o,f,fs); % DFT and PSD of stim
%%PLOTS
for i=1:nWins
% plot DFT
y1 = abs(s1(:,i)); % response
y2 = abs(s2(:)); % baseline
y3 = abs(s3(:,i)); % stimulus
subplot(nWins,2,2*i-1);
plot(f,y1,f,y2,'-.',f,y3,'--');
xlim([f(1) f(end)]);
yMax=max(max(abs(s1)));
ylim([0 yMax]);
title([fName(1:end-4) ' Window ' num2str(i)],'Interpreter','none');
% plot PSD
y1 = p1(:,i); % response
y2 = p2(:); % baseline
y3 = p3(:,i); % stimulus
subplot(nWins,2,2*i);
plot(f,y1,f,y2,'-.',f,y3,'--');
xlim([f(1) f(end)]);
yMax=max(max(abs(p1)));
ylim([0 yMax]);
title([fName(1:end-7) ' PSD Window ' num2str(i)],'Interpreter','none');
% legend at the end
if i==nWins
lgd = legend('Response','Baseline','Stimulus','Location','none');
set(lgd,'Position',[0.4,0.4175,0.2,0.1]);
end
end
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeParametric Spectral Estimation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by