source: plugins/view_kspace.m @ 214

Last change on this file since 214 was 80, checked in by tjniskan, 10 years ago
  • Changed the historical "an2_" prefix to "aedes_" in all files. NOTE:

Any script or function relying to Aedes functions will be broken
because of this. Just do a search/replace from "an2_" to "aedes_" in
your files and all should be well...

  • Changed the name of an2_readtab.m to a more informative

aedes_readphasetable.m

File size: 3.3 KB
Line 
1function view_kspace(DATA,ROI,AddInfo)
2% VIEW_KSPACE - Aedes plugin for viewing k-space of vnmr files
3%   
4%
5% Synopsis:
6%
7% Description:
8%
9% Examples:
10%
11% See also:
12%
13
14% This function is a part of Aedes - A graphical tool for analyzing
15% medical images
16%
17% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
18%
19% Department of Physics, Department of Neurobiology
20% University of Kuopio, FINLAND
21%
22% This program may be used under the terms of the GNU General Public
23% License version 2.0 as published by the Free Software Foundation
24% and appearing in the file LICENSE.TXT included in the packaging of
25% this program.
26%
27% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
30
31
32%% Check that the current file is vnmr data
33isVnmr = false;
34if AddInfo.isDataMixed
35  currentSlice = AddInfo.CurrentSlice;
36else
37  currentSlice = 1;
38end
39if isfield(DATA{currentSlice},'DataFormat') && ...
40    strcmpi(DATA{currentSlice}.DataFormat,'vnmr')
41  isVnmr = true;
42elseif isfield(DATA{currentSlice},'HDR') && ...
43    strcmpi(DATA{currentSlice}.HDR.fname,'fid')
44  isVnmr = true;
45end
46if ~isVnmr
47  hh=errordlg('The current file does not contain Varian VNMR data!',...
48              'Error','modal');
49  return
50end
51
52%% Check if the DATA structure already contains k-space. Otherwise the
53%% k-space data has to be read.
54if ~isfield(DATA{currentSlice},'KSPACE') || ...
55    isempty(DATA{currentSlice}.KSPACE)
56 
57  % Get file name and path
58  if isfield(DATA{currentSlice},'HDR') && ...
59      isfield(DATA{currentSlice}.HDR,'fname') && ...
60      isfield(DATA{currentSlice}.HDR,'fpath')
61   
62    fname = DATA{currentSlice}.HDR.fname;
63    fpath = DATA{currentSlice}.HDR.fpath;
64  else
65    hh=errordlg('The current file does not contain Varian VNMR data!',...
66                'Error','modal');
67    return
68  end
69 
70  resp=questdlg({'The k-space data has to be read from the file',...
71                sprintf('"%s"',[fpath,fname]),'',...
72                'Do you want to continue?'},...
73                'Read k-space from file?','OK','Abort','OK');
74  if strcmpi(resp,'Abort')
75    return
76  end
77 
78  %% Check if file exists
79  if exist([fpath,fname],'file')~=2
80    hh=errordlg({'Cannot read file',...
81                ['"',fpath,fname,'"'],'',...
82                'The file does not exist!'},...
83                'File does not exist!','modal');
84    return
85  end
86 
87  %% Read K-space
88  [tmp,msg]=aedes_readfid([fpath,fname],'return',2,...
89    'FastRead','on','OrientImages','on');
90  if isempty(tmp)
91    if iscell(msg)
92      hh==errordlg({'Error while reading file.',...
93                    '',msg{:}},'Error reading file',...
94                   'modal');
95      return
96    else
97      hh==errordlg({'Error while reading file.',...
98                    '',msg},'Error reading file',...
99                   'modal');
100      return
101    end
102  end
103  DATA_NEW = tmp;
104  DATA_NEW.FTDATA = abs(DATA_NEW.KSPACE);
105  DATA_NEW.FTDATA(:,:,:,2) = real(DATA_NEW.KSPACE);
106  DATA_NEW.FTDATA(:,:,:,3) = imag(DATA_NEW.KSPACE);
107  DATA_NEW.KSPACE = [];
108else
109  DATA_NEW = DATA{currentSlice};
110  DATA_NEW.FTDATA = abs(DATA_NEW.KSPACE);
111  DATA_NEW.FTDATA(:,:,:,2) = real(DATA_NEW.KSPACE);
112  DATA_NEW.FTDATA(:,:,:,3) = imag(DATA_NEW.KSPACE);
113  DATA_NEW.KSPACE=[];
114end
115
116%% Open the new DATA-structure in a new Aedes window
117aedes(DATA_NEW)
118
Note: See TracBrowser for help on using the repository browser.

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