Skip to content

Commit

Permalink
bloodfest2024
Browse files Browse the repository at this point in the history
  • Loading branch information
Proulx-S committed Sep 4, 2024
1 parent adcdbe6 commit 6336613
Show file tree
Hide file tree
Showing 12 changed files with 1,942 additions and 246 deletions.
22 changes: 11 additions & 11 deletions addFreq.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function addFreq(H,onsets,ondurs,freqFlag)
function h = addFreq(H,onsets,ondurs,freqFlag)
if ~exist('ondurs','var'); ondurs = []; end
if ~exist('freqFlag','var'); freqFlag = []; end
if isempty(freqFlag); freqFlag = 0; end
Expand All @@ -11,28 +11,28 @@ function addFreq(H,onsets,ondurs,freqFlag)

fStim = 1/mean(diff(onsets));
if any(contains(H.Title.String,{'spectrogram' 'coherogram'}))
yline(fStim,'Color','r','linestyle','--')
h = yline(fStim,'Color','r','linestyle','--');
xLim = xlim;
text(xLim(2),fStim,'fStim','HorizontalAlignment','right','VerticalAlignment','top','Color','r')
elseif any(contains(H.Title.String,{'spectrum'}))
xline(fStim,'Color','r','linestyle','--')
h = xline(fStim,'Color','r','linestyle','--');
yLim = ylim;
text(fStim,yLim(2),'fStim','HorizontalAlignment','left','VerticalAlignment','top','Color','r')
end
if freqFlag && ~isempty(ondurs) && length(unique(ondurs))==1
fOn = 1/ondurs(1);
if any(contains(H.Title.String,{'spectrogram' 'coherogram'}))
yline(fOn,'Color','g','linestyle',':')
h = yline(fOn,'Color','g','linestyle',':');
text(xLim(2),fOn,'fOn','HorizontalAlignment','right','VerticalAlignment','top','Color','g')
if freqFlag>1
yline(fOn/2,'Color','g','linestyle',':')
h = yline(fOn/2,'Color','g','linestyle',':');
text(xLim(2),fOn/2,'fOn/2','HorizontalAlignment','right','VerticalAlignment','top','Color','g')
end
elseif any(contains(H.Title.String,{'spectrum'}))
xline(fOn,'Color','g','linestyle',':')
h = xline(fOn,'Color','g','linestyle',':');
text(fOn,yLim(2),'fOn','HorizontalAlignment','left','VerticalAlignment','top','Color','g')
if freqFlag>1
xline(fOn/2,'Color','g','linestyle',':')
h = xline(fOn/2,'Color','g','linestyle',':');
text(fOn/2,yLim(2),'fOn/2','HorizontalAlignment','left','VerticalAlignment','top','Color','g')
end
end
Expand All @@ -43,14 +43,14 @@ function addFreq(H,onsets,ondurs,freqFlag)
offdurList = onsets(2:end) - offsetList(1:end-1);
fOff = 1/mean(offdurList);
if any(contains(H.Title.String,{'spectrogram' 'coherogram'}))
yline(fOff,'Color','b','linestyle',':')
h = yline(fOff,'Color','b','linestyle',':');
text(xLim(2),fOff,'fOff','HorizontalAlignment','right','VerticalAlignment','top','Color','b')
yline(fOff,'Color','b','linestyle',':')
h = yline(fOff,'Color','b','linestyle',':');
text(xLim(2),fOff/2,'fOff/2','HorizontalAlignment','right','VerticalAlignment','top','Color','b')
elseif any(contains(H.Title.String,{'spectrum'}))
xline(fOff,'Color','b','linestyle',':')
h = xline(fOff,'Color','b','linestyle',':');
text(fOff,yLim(2),'fOff','HorizontalAlignment','left','VerticalAlignment','top','Color','b')
xline(fOff/2,'Color','b','linestyle',':')
h = xline(fOff/2,'Color','b','linestyle',':');
text(fOff/2,yLim(2),'fOff/2','HorizontalAlignment','left','VerticalAlignment','top','Color','b')
end
end
Expand Down
6 changes: 3 additions & 3 deletions addW.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function addW(H,gram)
function h = addW(H,gram)
if isempty(H)
H = gca;
else
Expand All @@ -13,15 +13,15 @@ function addW(H,gram)
x = mean(xlim); x = x.*[1 1];
xx = x + [-1 1].*W;
y = ylim; y = y(1).*[1 1];
line(xx,y,'Color','m','linewidth',3)
h = line(xx,y,'Color','m','linewidth',3);
elseif contains(H.Title.String,'spectrogram') || contains(H.Title.String,'coherogram')
im = findobj(H.Children,'type','image');
x = im.XData(1) - mean(diff(im.XData))/2;
x = x .* [1 1];
y = im.YData(end) + mean(diff(im.YData))/2;
y = y .* [1 1];
yy = y - [0 2].*W;
line(x,yy,'color','m','linewidth',3);
h = line(x,yy,'color','m','linewidth',3);
else
dbstack; error('code that')
end
222 changes: 124 additions & 98 deletions fsCommand2.m
Original file line number Diff line number Diff line change
Expand Up @@ -240,104 +240,130 @@





%% PSD individual ses (cross-run average)
for rc = 1:length(runCondStimList)
stimCondLabel = runCondStimList{rc};
if ~isfield(runCond,runCondStimList{rc}); continue; end
volPsd = cat(1,runCond.(stimCondLabel).volTsSes.volPsd);


ses = [volPsd.psd]; ses = {ses.fspec}'; [~,ses] = fileparts(fileparts(ses)); ses = cellstr(ses); for i = 1:size(ses,1); ses{i} = strsplit(ses{i},'_'); ses{i} = ses{i}{contains(ses{i},'ses-')}; end
run = [volPsd.psd]; run = {run.fspec}'; [~,run] = fileparts(fileparts(run)); run = cellstr(run); for i = 1:size(run,1); run{i} = strsplit(run{i},'_'); run{i} = run{i}{contains(run{i},'run-')}; end

fList = [volPsd.psd];
fList = {fList.fspec};
% fBaseList = [volResp.base];
% fBaseList = {fBaseList.fspec};
for f = 1:length(fList)
label = strjoin({...
replace(runCondStimList{rc},'_','-')...
ses{f}...
run{f}...
'psd'...
},'_');
opt = {...
['name=' label]...
'visible=0'...
'colormap=turbo'};
cmd{end+1} = [strjoin([fList(f) opt],':') ' \'];

% label = strjoin({...
% replace(runCondStimList{rc},'_','-')...
% ses{f}...
% run{f}...
% 'base'...
% },'_');
% opt = {...
% ['name=' label]...
% 'visible=0'};
% cmd{end+1} = [strjoin([fBaseList(f) opt],':') ' \'];
end
clear volPsd
end



%% COH individual ses (cross-run average)
for rc = 1:length(runCondStimList)
stimCondLabel = runCondStimList{rc};
if ~isfield(runCond,runCondStimList{rc}); continue; end
volPsd = cat(1,runCond.(stimCondLabel).volTsSes.volPsd);


ses = [volPsd.svd]; ses = [ses.fspec]'; ses = {ses.spSVmag}'; [~,ses] = fileparts(fileparts(ses)); ses = cellstr(ses); for i = 1:size(ses,1); ses{i} = strsplit(ses{i},'_'); ses{i} = ses{i}{contains(ses{i},'ses-')}; end
run = [volPsd.svd]; run = [run.fspec]'; run = {run.spSVmag}'; [~,run] = fileparts(fileparts(run)); run = cellstr(run); for i = 1:size(run,1); run{i} = strsplit(run{i},'_'); run{i} = run{i}{contains(run{i},'run-')}; end

fList = [volPsd.svd];
fList = [fList.fspec];
fListMag = {fList.spSVmag}';
fListPhase = {fList.spSVphase}';
% fBaseList = [volResp.base];
% fBaseList = {fBaseList.fspec};
for f = 1:length(fList)
label = strjoin({...
replace(runCondStimList{rc},'_','-')...
ses{f}...
run{f}...
'cohMag'...
},'_');
opt = {...
['name=' label]...
'visible=0'...
'colormap=turbo'};
cmd{end+1} = [strjoin([fListMag(f) opt],':') ' \'];

label = strjoin({...
replace(runCondStimList{rc},'_','-')...
ses{f}...
run{f}...
'cohPhase'},'_');
opt = {...
['name=' label]...
'visible=0'...
'colormap=turbo'};
cmd{end+1} = [strjoin([fListPhase(f) opt],':') ' \'];

% label = strjoin({...
% replace(runCondStimList{rc},'_','-')...
% ses{f}...
% run{f}...
% 'base'...
% },'_');
% opt = {...
% ['name=' label]...
% 'visible=0'};
% cmd{end+1} = [strjoin([fBaseList(f) opt],':') ' \'];
end
clear volPsd
end
warning('PSD and COH is broken')

% %% PSD individual ses (cross-run average)
% for rc = 1:length(runCondStimList)
% stimCondLabel = runCondStimList{rc};
% if ~isfield(runCond,runCondStimList{rc}); continue; end
% volPsd = cat(1,runCond.(stimCondLabel).volTsSes.volPsd);
%
% if isMRI(volPsd)
% fList = volPsd;
%
% ses = volPsd;
% run = volPsd;
% else
% fList = [volPsd.psd];
%
% ses = [volPsd.psd];
% run = [volPsd.psd];
% end
% fList = {fList.fspec};
%
% ses = {ses.fspec}'; [~,ses] = fileparts(fileparts(ses)); ses = cellstr(ses); for i = 1:size(ses,1); ses{i} = strsplit(ses{i},'_'); ses{i} = ses{i}{contains(ses{i},'ses-')}; end
% run = {run.fspec}'; [~,run] = fileparts(fileparts(run)); run = cellstr(run); for i = 1:size(run,1); run{i} = strsplit(run{i},'_'); run{i} = run{i}{contains(run{i},'run-')}; end
%
% % fBaseList = [volResp.base];
% % fBaseList = {fBaseList.fspec};
% for f = 1:length(fList)
% label = strjoin({...
% replace(runCondStimList{rc},'_','-')...
% ses{f}...
% run{f}...
% 'psd'...
% },'_');
% opt = {...
% ['name=' label]...
% 'visible=0'...
% 'colormap=turbo'};
% cmd{end+1} = [strjoin([fList(f) opt],':') ' \'];
%
% % label = strjoin({...
% % replace(runCondStimList{rc},'_','-')...
% % ses{f}...
% % run{f}...
% % 'base'...
% % },'_');
% % opt = {...
% % ['name=' label]...
% % 'visible=0'};
% % cmd{end+1} = [strjoin([fBaseList(f) opt],':') ' \'];
% end
% clear volPsd
% end
%
%
%
% %% COH individual ses (cross-run average)
% for rc = 1:length(runCondStimList)
% stimCondLabel = runCondStimList{rc};
% if ~isfield(runCond,runCondStimList{rc}); continue; end
% volPsd = cat(1,runCond.(stimCondLabel).volTsSes.volPsd);
%
% if isMRI(volPsd)
% fList = volPsd;
%
% ses = volPsd;
% run = volPsd;
% else
% fList = [volPsd.svd];
%
% ses = [volPsd.svd];
% run = [volPsd.svd];
% end
% fList = {fList.fspec};
%
% ses = {ses.fspec}'; [~,ses] = fileparts(fileparts(ses)); ses = cellstr(ses); for i = 1:size(ses,1); ses{i} = strsplit(ses{i},'_'); ses{i} = ses{i}{contains(ses{i},'ses-')}; end
% run = {run.fspec}'; [~,run] = fileparts(fileparts(run)); run = cellstr(run); for i = 1:size(run,1); run{i} = strsplit(run{i},'_'); run{i} = run{i}{contains(run{i},'run-')}; end
%
%
% % ses = [volPsd.svd]; ses = [ses.fspec]'; ses = {ses.spSVmag}'; [~,ses] = fileparts(fileparts(ses)); ses = cellstr(ses); for i = 1:size(ses,1); ses{i} = strsplit(ses{i},'_'); ses{i} = ses{i}{contains(ses{i},'ses-')}; end
% % run = [volPsd.svd]; run = [run.fspec]'; run = {run.spSVmag}'; [~,run] = fileparts(fileparts(run)); run = cellstr(run); for i = 1:size(run,1); run{i} = strsplit(run{i},'_'); run{i} = run{i}{contains(run{i},'run-')}; end
% %
% % fList = [volPsd.svd];
% % fList = [fList.fspec];
% fListMag = {fList.spSVmag}';
% fListPhase = {fList.spSVphase}';
% % fBaseList = [volResp.base];
% % fBaseList = {fBaseList.fspec};
% for f = 1:length(fList)
% label = strjoin({...
% replace(runCondStimList{rc},'_','-')...
% ses{f}...
% run{f}...
% 'cohMag'...
% },'_');
% opt = {...
% ['name=' label]...
% 'visible=0'...
% 'colormap=turbo'};
% cmd{end+1} = [strjoin([fListMag(f) opt],':') ' \'];
%
% label = strjoin({...
% replace(runCondStimList{rc},'_','-')...
% ses{f}...
% run{f}...
% 'cohPhase'},'_');
% opt = {...
% ['name=' label]...
% 'visible=0'...
% 'colormap=turbo'};
% cmd{end+1} = [strjoin([fListPhase(f) opt],':') ' \'];
%
% % label = strjoin({...
% % replace(runCondStimList{rc},'_','-')...
% % ses{f}...
% % run{f}...
% % 'base'...
% % },'_');
% % opt = {...
% % ['name=' label]...
% % 'visible=0'};
% % cmd{end+1} = [strjoin([fBaseList(f) opt],':') ' \'];
% end
% clear volPsd
% end



Expand Down
Loading

0 comments on commit 6336613

Please sign in to comment.