1 | function spectrsum(DATA,fpath) |
---|
2 | % SPECTRSUM - |
---|
3 | % |
---|
4 | % |
---|
5 | % Synopsis: |
---|
6 | % |
---|
7 | % Description: |
---|
8 | % |
---|
9 | % Examples: |
---|
10 | % |
---|
11 | % See also: |
---|
12 | % |
---|
13 | |
---|
14 | % Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi> |
---|
15 | % |
---|
16 | % Department of Physics, Department of Neurobiology |
---|
17 | % University of Kuopio, FINLAND |
---|
18 | % |
---|
19 | % This program may be used under the terms of the GNU General Public |
---|
20 | % License version 2.0 as published by the Free Software Foundation |
---|
21 | % and appearing in the file LICENSE.TXT included in the packaging of |
---|
22 | % this program. |
---|
23 | % |
---|
24 | % This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
---|
25 | % WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
---|
26 | |
---|
27 | |
---|
28 | if nargin==0 |
---|
29 | DATA = aedes_readfid('','return',3); |
---|
30 | if isempty(DATA) |
---|
31 | % Canceled |
---|
32 | return |
---|
33 | end |
---|
34 | DATA.KSPACE = DATA.KSPACE(4:end,:); |
---|
35 | DATA_out = DATA; |
---|
36 | fpath = DATA.HDR.fpath; |
---|
37 | elseif nargin==1 |
---|
38 | DATA.KSPACE = DATA.KSPACE(4:end,:); |
---|
39 | DATA_out = DATA; |
---|
40 | fpath = DATA.HDR.fpath; |
---|
41 | else |
---|
42 | DATA.KSPACE = DATA.KSPACE(4:end,:); |
---|
43 | DATA_out = DATA; |
---|
44 | end |
---|
45 | |
---|
46 | |
---|
47 | %% Get data around the coline? peak |
---|
48 | PeakLimits = [1035 1060]; |
---|
49 | |
---|
50 | data = abs(fftshift(fft(linebroad(DATA.KSPACE,0.6672,1)),1)); |
---|
51 | %data = abs(fftshift(fft(DATA.KSPACE),1)); |
---|
52 | data = data(PeakLimits(1):PeakLimits(2),:); |
---|
53 | |
---|
54 | [mx,Ind] = max(data); |
---|
55 | |
---|
56 | % Order using average index |
---|
57 | TrueInd = Ind(1); |
---|
58 | tmp=[]; |
---|
59 | cols = lines(16); |
---|
60 | % Shift spectra |
---|
61 | for ii=1:length(Ind) |
---|
62 | shift = -(Ind(ii)-TrueInd); |
---|
63 | if shift~=0 |
---|
64 | freqdom = fftshift(fft(DATA.KSPACE(:,ii))); |
---|
65 | freqdom = freqdom(shiftind(length(freqdom),shift)); |
---|
66 | DATA_out.KSPACE(:,ii) = ifft(ifftshift(freqdom)); |
---|
67 | end |
---|
68 | end |
---|
69 | DATA_out.tmp = DATA_out.KSPACE; |
---|
70 | DATA_out.KSPACE=sum(DATA_out.KSPACE,2); |
---|
71 | DATA.tmp = DATA.KSPACE; |
---|
72 | DATA.KSPACE = sum(DATA.KSPACE,2); |
---|
73 | |
---|
74 | |
---|
75 | %% Plot shifted and unshifted sums |
---|
76 | fh=figure('units','normal','position',[0.15 0.4 0.7 0.4]); |
---|
77 | h=subplot(1,3,1); |
---|
78 | plot(abs(fftshift(fft(DATA.KSPACE))),'b') |
---|
79 | hold on |
---|
80 | plot(abs(fftshift(fft(DATA_out.KSPACE))),'r') |
---|
81 | hold off |
---|
82 | |
---|
83 | h=subplot(1,3,2); |
---|
84 | %tmp=abs(fftshift(fft(linebroad(DATA.KSPACE,0.6672,5)))); |
---|
85 | tmp=abs(fftshift(fft(DATA.tmp),1)); |
---|
86 | plot(tmp(PeakLimits(1):PeakLimits(2),:)) |
---|
87 | h=subplot(1,3,3); |
---|
88 | %tmp=abs(fftshift(fft(linebroad(DATA_out.KSPACE,0.6672,5)))); |
---|
89 | tmp=abs(fftshift(fft(DATA_out.tmp),1)); |
---|
90 | plot(tmp(PeakLimits(1):PeakLimits(2),:)) |
---|
91 | pause |
---|
92 | |
---|
93 | %% Accept/reject |
---|
94 | resp = questdlg('Accept or reject?','Accept or reject?',... |
---|
95 | 'Accept','Reject','Cancel','Accept'); |
---|
96 | if strcmpi(resp,'Accept') |
---|
97 | %makelcmraw(DATA_out,fpath) |
---|
98 | elseif strcmpi(resp,'Reject') |
---|
99 | %makelcmraw(DATA,fpath) |
---|
100 | end |
---|
101 | if ishandle(fh) |
---|
102 | close(fh) |
---|
103 | end |
---|