forked from cjohnevans/GANNET-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MRSplotprepostalign.m
executable file
·44 lines (35 loc) · 1.62 KB
/
MRSplotprepostalign.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function MRSplotprepostalign(MRS_struct, specno)
%function MRSplotprepostalign(MRS_struct, specno)
% Plots pre and post alignment spectra in MRSLoadPfiles
% 110214: Scale spectra by the peak _height_ of water
% Plot multiple spectra as a stack - baselines offset
% by mean height of GABA
%numspec = length(MRS_struct.gabaspec(:,1));
numspec = 2;
SpectraToPlot = [MRS_struct.gabaspec(specno,:); MRS_struct.gabanoalign(specno,:)];
% Find Water amplitude max, across all Pfiles
waterheight = abs(max(MRS_struct.waterspec(specno,:),[],2));
waterheight = repmat(waterheight, [2 1]);
heightrescale = repmat((1./waterheight), [1 length(MRS_struct.gabaspec(1,:))]);
SpectraToPlot = SpectraToPlot .* heightrescale;
% Estimate baseline from between Glx and GABA
specbaseline = mean(real(SpectraToPlot(1,17250:17650)),2);
% averaged gaba height across all scans - to estimate stack spacing
gabaheight = abs(max(SpectraToPlot(1,17250:18000),[],2));
gabaheight = mean(gabaheight);
plotstackoffset = [ 0 : (numspec-1) ]';
plotstackoffset = plotstackoffset * gabaheight;
plotstackoffset = plotstackoffset - specbaseline;
SpectraToPlot = SpectraToPlot + ...
repmat(plotstackoffset, [ 1 length(MRS_struct.gabaspec(1,:))]);
%figure(99)
plot(MRS_struct.freq, real(SpectraToPlot));
%legendtxt = regexprep(MRS_struct.pfile{specno}, '_','-');
legendtxt = {'post', 'pre'};
legend(legendtxt)
set(gca,'XDir','reverse');
oldaxis = axis;
% yaxis max = top spec baseline + 2*meangabaheight
yaxismax = (numspec + 2) *gabaheight; % top spec + 2* height of gaba
yaxismin = - 2* gabaheight; % extend 2* gaba heights below zero
axis([0 5 yaxismin yaxismax])