source: misclib/spectrsum.m @ 64

Last change on this file since 64 was 45, checked in by tjniskan, 11 years ago
  • Changed a small thing in license notices

M an2_export_gui.m
M an2_cellsprintf.m
M an2_getfilefilter.m
M an2_calc_wait.m
M an2_smiswrite.m
M misclib/spectrsum.m
M misclib/shiftind.m
M misclib/nifti4dto3d.m
M misclib/nifti3dto4d.m
M misclib/dcm_info.m
M misclib/addicon.m
M misclib/makelcmraw.m
M an2_check_file_exist.m
M an2_iseven.m
M an2_cellwrite.m
M an2_wbar.m
M an2_rot3d.m
M an2_readfdf.m
M an2_revision.m
M an2_viewprocpar.m
M an2_checkcthdr.m
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
M an2_smisread.m
M an2_resviewer.m
M an2_maptool.m
M aedes.m
M an2_helpabout.m
M an2_res2table.m
M an2_copy_roi.m
M plugins/save_roi_as_mask.m
M plugins/write_difference_images.m
M plugins/plot_profile.m
M plugins/calculate_t2_map.m
M plugins/calculate_t1r_map.m
M plugins/view_kspace.m
M plugins/copy_data_to_workspace.m
M plugins/take_snapshot.m
M an2_inputdlg.m
M an2_roi_copy_gui.m
M an2_readctdata.m
M an2_readfid.m
M an2_readfidprefs.m
M an2_readtab.m
M an2_check_updates.m
M an2_killfigs.m
M an2_roi_stats.m
M an2_saveres.m
M an2_rotateflip.m
M an2_juigetfiles.m
M an2_gui_defaults.m
M an2_editstack.m
M an2_errordump.m
M an2_update.m
M an2_write_nifti.m

File size: 2.5 KB
Line 
1function 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
28if nargin==0
29  DATA = an2_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;
37elseif nargin==1
38  DATA.KSPACE = DATA.KSPACE(4:end,:);
39  DATA_out = DATA;
40  fpath = DATA.HDR.fpath;
41else
42  DATA.KSPACE = DATA.KSPACE(4:end,:);
43  DATA_out = DATA;
44end
45
46
47%% Get data around the coline? peak
48PeakLimits = [1035 1060];
49
50data = abs(fftshift(fft(linebroad(DATA.KSPACE,0.6672,1)),1));
51%data = abs(fftshift(fft(DATA.KSPACE),1));
52data = data(PeakLimits(1):PeakLimits(2),:);
53
54[mx,Ind] = max(data);
55
56% Order using average index
57TrueInd = Ind(1);
58tmp=[];
59cols = lines(16);
60% Shift spectra
61for 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
68end
69DATA_out.tmp = DATA_out.KSPACE;
70DATA_out.KSPACE=sum(DATA_out.KSPACE,2);
71DATA.tmp = DATA.KSPACE;
72DATA.KSPACE = sum(DATA.KSPACE,2);
73
74
75%% Plot shifted and unshifted sums
76fh=figure('units','normal','position',[0.15 0.4 0.7 0.4]);
77h=subplot(1,3,1);
78plot(abs(fftshift(fft(DATA.KSPACE))),'b')
79hold on
80plot(abs(fftshift(fft(DATA_out.KSPACE))),'r')
81hold off
82
83h=subplot(1,3,2);
84%tmp=abs(fftshift(fft(linebroad(DATA.KSPACE,0.6672,5))));
85tmp=abs(fftshift(fft(DATA.tmp),1));
86plot(tmp(PeakLimits(1):PeakLimits(2),:))
87h=subplot(1,3,3);
88%tmp=abs(fftshift(fft(linebroad(DATA_out.KSPACE,0.6672,5))));
89tmp=abs(fftshift(fft(DATA_out.tmp),1));
90plot(tmp(PeakLimits(1):PeakLimits(2),:))
91pause
92
93%% Accept/reject
94resp = questdlg('Accept or reject?','Accept or reject?',...
95                'Accept','Reject','Cancel','Accept');
96if strcmpi(resp,'Accept')
97  %makelcmraw(DATA_out,fpath)
98elseif strcmpi(resp,'Reject')
99  %makelcmraw(DATA,fpath)
100end
101if ishandle(fh)
102  close(fh)
103end
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008