-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug fix: in getJ2.m, matrices were not reshape right when containing …
…multiple trials refactor: plotSpec.m and plotSpecGram.m now replace the various plotPsd....m and plotCoh....m
- Loading branch information
Showing
8 changed files
with
475 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
function [ax,F] = plotSpec(volPsd,metricLabel,H,tWin) | ||
if ~exist('H','var'); H = []; end | ||
if isempty(H); H = figure('WindowStyle','docked'); end | ||
|
||
if isfield(volPsd,'dsgn') && isfield(volPsd.dsgn,'f0'); f0 = volPsd.dsgn.f0; else; f0 = []; end | ||
|
||
if ~exist('tWin','var'); tWin = []; end | ||
if ~exist('metricLabel','var'); metricLabel = []; end | ||
if isempty(metricLabel); metricLabel = 'psd'; end % 'psd' 'coh' | ||
|
||
|
||
switch class(H) | ||
case 'matlab.graphics.layout.TiledChartLayout' | ||
F = H.Parent; | ||
case 'matlab.ui.Figure' | ||
F = H; | ||
otherwise | ||
end | ||
|
||
figure(F); | ||
ax = {}; | ||
ax{end+1} = nexttile; | ||
|
||
|
||
%% Select approrpiate data | ||
switch metricLabel | ||
case 'psd' | ||
mt = volPsd.psd; | ||
vec = mt.PSD; | ||
label = 'spatially averaged spectrum'; | ||
case 'coh' | ||
mt = volPsd.svd; | ||
vec = mt.COH; | ||
label = 'coherence spectrum'; | ||
otherwise | ||
dbstack; error('code trhat') | ||
end | ||
|
||
|
||
|
||
|
||
%%% average across space | ||
vec = squeeze(mean(vec,6)); | ||
f = squeeze(mt.f); | ||
% f = squeeze(volPsd.f); | ||
% psd = squeeze(mean(volPsd.vec,2)); | ||
plot(f,vec,'k') | ||
grid on | ||
axis tight | ||
xlabel('f (Hz)') | ||
switch metricLabel | ||
case 'psd' | ||
ylabel('psd') | ||
ax{end}.YScale = 'log'; | ||
case 'coh' | ||
ylabel('coherence') | ||
otherwise | ||
dbstack; error('code trhat') | ||
end | ||
|
||
|
||
K = mt.K; | ||
T = mt.T; | ||
[TW,W] = K2W(T,K,0); | ||
|
||
paramStr = ['(K=' num2str(K) '; 2W=' num2str(W*2,'%0.4f') 'Hz; T=' num2str(T,'%0.2f') 'sec); TW=' num2str(TW)]; | ||
title(['spatially averaged spectrum ' paramStr]) | ||
|
||
yLim = vec(f>0.01); | ||
yLim = [min(yLim) max(yLim)]; | ||
ylim(yLim) | ||
xlim([0 f(end)]) | ||
|
||
addW([],volPsd.psd) | ||
|
||
|
||
|
||
if isfield(volPsd,'psdTrialGram') && ~isempty(volPsd.psdTrialGram) | ||
addFreq([],volPsd.psdTrialGram.onsetList,volPsd.psdTrialGram.durList) | ||
end | ||
|
||
if ~isempty(f0) | ||
xline(f0,'--b') | ||
end | ||
|
||
if isfield(volPsd,'psdTrialGramMD') && ~isempty(volPsd.psdTrialGramMD) && ~isempty(tWin) | ||
dbstack; error('double-check that'); | ||
t = volPsd.psdTrialGramMD.t(1,1,1,1,1,1,:,1); | ||
f = volPsd.psdTrialGramMD.f(1,1,1,1,:,1,1,1); | ||
if tWin==inf | ||
psd = mean(mean(volPsd.psdTrialGramMD.vec.psdPC(:,:,:,:,:,:,:,:),6),7); | ||
else | ||
[~,wInd] = min(abs(t-tWin)); | ||
psd = mean(volPsd.psdTrialGramMD.vec.psdPC(:,:,:,:,:,:,wInd,:),6); | ||
end | ||
plot(squeeze(f),squeeze(psd),'--k') | ||
end | ||
|
||
|
||
ax = [ax{:}]; | ||
|
||
|
||
|
||
|
Oops, something went wrong.