-
Notifications
You must be signed in to change notification settings - Fork 16
/
MRSplotpostalign.m
executable file
·44 lines (38 loc) · 1.65 KB
/
MRSplotpostalign.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 MRSplotpostalign(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,:)];
%Water scaling is touhg if we have no water scans! Comment out
% % 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);
z=abs(MRS_struct.freq-3.6);
Glx_right=find(min(z)==z);
z=abs(MRS_struct.freq-3.3);
GABA_left=find(min(z)==z);
z=abs(MRS_struct.freq-2.8);
GABA_right=find(min(z)==z);
specbaseline = mean(real(SpectraToPlot(1,Glx_right:GABA_left)),2);
% averaged gaba height across all scans - to estimate stack spacing
gabaheight = abs(max(SpectraToPlot(1,Glx_right:GABA_right),[],2));
gabaheight = mean(gabaheight);
%figure(99)
plot(MRS_struct.freq, real(SpectraToPlot));
%legendtxt = regexprep(MRS_struct.pfile{specno}, '_','-');
legendtxt = {'no align'};
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])