source: misclib/makelcmraw.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: 2.6 KB
Line 
1function ok = makelcmraw(DATA,outdir,outname)
2% MAKELCMRAW - Write data in LCModel RAW file format
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%% Default RAW file name and path
29FilePath = [pwd,filesep];
30FileName = 'out.RAW';
31
32%% Parse input arguments
33if nargin==0
34  %% Ask for a file
35  [DATA,msg] = aedes_readfid('','return',3);
36  if isempty(DATA)
37    error(msg)
38    return
39  end
40elseif nargin==2
41  FilePath = outdir;
42  if ~(FilePath(end)==filesep)
43    FilePath = [FilePath,filesep];
44  end
45elseif nargin==3
46  FilePath = outdir;
47  if ~(FilePath(end)==filesep)
48    FilePath = [FilePath,filesep];
49  end
50  FileName = outname;
51  [fp,fn,fe]=fileparts(FileName);
52  FileName = [fn,'.RAW'];
53end
54
55%% Get default RAW file name
56if any(nargin==[0 1 2])
57  try
58    fpath=DATA.HDR.fpath;
59    ind = find(fpath==filesep);
60    if ind(end)==length(fpath)
61      tmp=fpath(ind(end-1)+1:end-1);
62    else
63      tmp=fpath(ind(end)+1:end);
64    end
65    FileName = [tmp(1:end-4),'.RAW'];
66  catch
67    % Failed, issue a warning and use out.RAW instead
68    warning('Could not determine filename. Using "out.RAW"')
69    FilePath = [pwd,filesep];
70    FileName = 'out.RAW';
71  end
72end
73
74
75%% Open file for writing
76fid = fopen([FilePath,FileName],'w');
77if fid<0
78  error('Could not open file "%s" for writing',FileName)
79end
80
81%% Write SEQPAR
82fprintf(fid,' $SEQPAR\n');
83fprintf(fid,' hzpppm=%3.3f\n',DATA.PROCPAR.sfrq);
84fprintf(fid,' echot=%4.1f\n',DATA.PROCPAR.te*1000);
85fprintf(fid,' seq=''%s''\n','STEAM');
86fprintf(fid,' $END\n');
87
88%% Write NMID
89fprintf(fid,' $NMID\n');
90fprintf(fid,' id=''%s''\n',FileName(1:min(length(FileName),20)));
91fprintf(fid,' fmtdat=''(2e14.5)''\n');
92fprintf(fid,' tramp=1.\n');
93fprintf(fid,' volume=1.\n');
94fprintf(fid,' $END\n');
95
96%% Write data
97real_data = real(DATA.KSPACE);
98real_data = real_data(:);
99imag_data = imag(DATA.KSPACE);
100imag_data = imag_data(:);
101tmp=strrep(strrep(strrep(sprintf('   %1.5e   %1.5e\n',[real_data ...
102                    imag_data]'),'e+0','e+'),'e-0','e-'),' -','-');
103%fprintf(fid,'  %1.5e  %1.5e\n',[real_data imag_data]');
104fprintf(fid,'%s',tmp);
105
106
107%% Close file
108fclose(fid);
Note: See TracBrowser for help on using the repository browser.

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